|
19 | 19 | import static org.assertj.core.api.Assertions.assertThat;
|
20 | 20 |
|
21 | 21 | import java.util.HashMap;
|
22 |
| -import java.util.UUID; |
23 | 22 |
|
24 | 23 | import javax.persistence.EntityManager;
|
25 | 24 |
|
@@ -57,10 +56,8 @@ public GraphQLSchemaBuilder graphQLSchemaBuilder(final EntityManager entityManag
|
57 | 56 |
|
58 | 57 | }
|
59 | 58 |
|
60 |
| - |
61 | 59 | @Autowired
|
62 | 60 | private GraphQLExecutor executor;
|
63 |
| - |
64 | 61 |
|
65 | 62 | @Test
|
66 | 63 | public void contextLoads() {
|
@@ -222,6 +219,115 @@ public void queryForElementCollection() {
|
222 | 219 | assertThat(result.toString()).isEqualTo(expected);
|
223 | 220 | }
|
224 | 221 |
|
| 222 | + @Test |
| 223 | + public void queryForEnumIn() { |
| 224 | + //given |
| 225 | + String query = "{ Books(where: {genre: {IN: PLAY}}) { select { id title, genre } }}"; |
| 226 | + |
| 227 | + String expected = "{Books={select=[" |
| 228 | + + "{id=5, title=The Cherry Orchard, genre=PLAY}, " |
| 229 | + + "{id=6, title=The Seagull, genre=PLAY}, " |
| 230 | + + "{id=7, title=Three Sisters, genre=PLAY}" |
| 231 | + + "]}}"; |
| 232 | + |
| 233 | + //when |
| 234 | + Object result = executor.execute(query).getData(); |
| 235 | + |
| 236 | + // then |
| 237 | + assertThat(result.toString()).isEqualTo(expected); |
| 238 | + } |
| 239 | + |
| 240 | + @Test |
| 241 | + public void queryForEnumInArray() { |
| 242 | + //given |
| 243 | + String query = "{ Books(where: {genre: {IN: [NOVEL, PLAY]}}) { select { id title, genre } }}"; |
| 244 | + |
| 245 | + String expected = "{Books={select=[" |
| 246 | + + "{id=2, title=War and Peace, genre=NOVEL}, " |
| 247 | + + "{id=3, title=Anna Karenina, genre=NOVEL}, " |
| 248 | + + "{id=5, title=The Cherry Orchard, genre=PLAY}, " |
| 249 | + + "{id=6, title=The Seagull, genre=PLAY}, " |
| 250 | + + "{id=7, title=Three Sisters, genre=PLAY}" |
| 251 | + + "]}}"; |
| 252 | + |
| 253 | + //when |
| 254 | + Object result = executor.execute(query).getData(); |
| 255 | + |
| 256 | + // then |
| 257 | + assertThat(result.toString()).isEqualTo(expected); |
| 258 | + } |
| 259 | + |
| 260 | + @Test |
| 261 | + public void queryForEnumNinArray() { |
| 262 | + //given |
| 263 | + String query = "{ Books(where: {genre: {NIN: [NOVEL]}}) { select { id title, genre } }}"; |
| 264 | + |
| 265 | + String expected = "{Books={select=[" |
| 266 | + + "{id=5, title=The Cherry Orchard, genre=PLAY}, " |
| 267 | + + "{id=6, title=The Seagull, genre=PLAY}, " |
| 268 | + + "{id=7, title=Three Sisters, genre=PLAY}" |
| 269 | + + "]}}"; |
| 270 | + |
| 271 | + //when |
| 272 | + Object result = executor.execute(query).getData(); |
| 273 | + |
| 274 | + // then |
| 275 | + assertThat(result.toString()).isEqualTo(expected); |
| 276 | + } |
| 277 | + |
| 278 | + @Test |
| 279 | + public void queryForEnumEq() { |
| 280 | + //given |
| 281 | + String query = "{ Books(where: {genre: {EQ: NOVEL}}) { select { id title, genre } }}"; |
| 282 | + |
| 283 | + String expected = "{Books={select=[" |
| 284 | + + "{id=2, title=War and Peace, genre=NOVEL}, " |
| 285 | + + "{id=3, title=Anna Karenina, genre=NOVEL}" |
| 286 | + + "]}}"; |
| 287 | + |
| 288 | + //when |
| 289 | + Object result = executor.execute(query).getData(); |
| 290 | + |
| 291 | + // then |
| 292 | + assertThat(result.toString()).isEqualTo(expected); |
| 293 | + } |
| 294 | + |
| 295 | + @Test |
| 296 | + public void queryForEnumNe() { |
| 297 | + //given |
| 298 | + String query = "{ Books(where: {genre: {NE: PLAY}}) { select { id title, genre } }}"; |
| 299 | + |
| 300 | + String expected = "{Books={select=[" |
| 301 | + + "{id=2, title=War and Peace, genre=NOVEL}, " |
| 302 | + + "{id=3, title=Anna Karenina, genre=NOVEL}" |
| 303 | + + "]}}"; |
| 304 | + |
| 305 | + //when |
| 306 | + Object result = executor.execute(query).getData(); |
| 307 | + |
| 308 | + // then |
| 309 | + assertThat(result.toString()).isEqualTo(expected); |
| 310 | + } |
| 311 | + |
| 312 | + @Test |
| 313 | + public void queryForEnumNin() { |
| 314 | + //given |
| 315 | + String query = "{ Books(where: {genre: {NIN: PLAY}}) { select { id title, genre } }}"; |
| 316 | + |
| 317 | + String expected = "{Books={select=[" |
| 318 | + + "{id=2, title=War and Peace, genre=NOVEL}, " |
| 319 | + + "{id=3, title=Anna Karenina, genre=NOVEL}" |
| 320 | + + "]}}"; |
| 321 | + |
| 322 | + //when |
| 323 | + Object result = executor.execute(query).getData(); |
| 324 | + |
| 325 | + // then |
| 326 | + assertThat(result.toString()).isEqualTo(expected); |
| 327 | + } |
| 328 | + |
| 329 | + |
| 330 | + |
225 | 331 | // https://github.com/introproventures/graphql-jpa-query/issues/30
|
226 | 332 | @Test
|
227 | 333 | public void queryForEntityWithMappedSuperclass() {
|
|
0 commit comments