@@ -88,19 +88,10 @@ public class GraphQlMessageHandlerTests {
88
88
@ Autowired
89
89
private UpdateRepository updateRepository ;
90
90
91
- @ Autowired
92
- private IdGenerator idGenerator ;
93
-
94
-
95
91
@ Test
96
92
@ SuppressWarnings ("unchecked" )
97
93
void testHandleMessageForQueryWithRequestInputProvided () {
98
94
99
- Locale locale = Locale .getDefault ();
100
- String executionId = this .idGenerator .generateId ().toString ();
101
- this .graphQlMessageHandler .setLocale (locale );
102
- this .graphQlMessageHandler .setExecutionId (executionId );
103
-
104
95
StepVerifier verifier = StepVerifier .create (
105
96
Flux .from (this .resultChannel )
106
97
.map (Message ::getPayload )
@@ -117,7 +108,7 @@ void testHandleMessageForQueryWithRequestInputProvided() {
117
108
118
109
this .inputChannel .send (
119
110
MessageBuilder
120
- .withPayload (new RequestInput ("{ testQuery { id } }" , null , Collections .emptyMap (), locale , executionId ))
111
+ .withPayload (new RequestInput ("{ testQuery { id } }" , null , Collections .emptyMap (), null , UUID . randomUUID (). toString () ))
121
112
.build ()
122
113
);
123
114
@@ -128,11 +119,14 @@ void testHandleMessageForQueryWithRequestInputProvided() {
128
119
@ SuppressWarnings ("unchecked" )
129
120
void testHandleMessageForQueryWithQueryProvided () {
130
121
131
- String executionId = this .idGenerator .generateId ().toString ();
132
- this .graphQlMessageHandler .setExecutionId (executionId );
133
-
134
122
String fakeQuery = "{ testQuery { id } }" ;
135
- this .graphQlMessageHandler .setQuery (fakeQuery );
123
+ this .graphQlMessageHandler .setOperation (fakeQuery );
124
+
125
+ Locale locale = Locale .getDefault ();
126
+ this .graphQlMessageHandler .setLocale (locale );
127
+
128
+ String executionId = UUID .randomUUID ().toString ();
129
+ this .graphQlMessageHandler .setExecutionId (executionId );
136
130
137
131
StepVerifier .create (
138
132
Mono .from ((Mono <RequestOutput >) this .graphQlMessageHandler .handleRequestMessage (MessageBuilder .withPayload (fakeQuery ).build ()))
@@ -151,9 +145,6 @@ void testHandleMessageForQueryWithQueryProvided() {
151
145
@ SuppressWarnings ("unchecked" )
152
146
void testHandleMessageForMutationWithRequestInputProvided () {
153
147
154
- String executionId = this .idGenerator .generateId ().toString ();
155
- this .graphQlMessageHandler .setExecutionId (executionId );
156
-
157
148
String fakeId = UUID .randomUUID ().toString ();
158
149
Update expected = new Update (fakeId );
159
150
@@ -176,7 +167,7 @@ void testHandleMessageForMutationWithRequestInputProvided() {
176
167
177
168
this .inputChannel .send (
178
169
MessageBuilder
179
- .withPayload (new RequestInput ("mutation { update(id: \" " + fakeId + "\" ) { id } }" , null , Collections .emptyMap (), null , executionId ))
170
+ .withPayload (new RequestInput ("mutation { update(id: \" " + fakeId + "\" ) { id } }" , null , Collections .emptyMap (), null , UUID . randomUUID (). toString () ))
180
171
.build ()
181
172
);
182
173
@@ -193,9 +184,6 @@ void testHandleMessageForMutationWithRequestInputProvided() {
193
184
@ SuppressWarnings ("unchecked" )
194
185
void testHandleMessageForSubscriptionWithRequestInputProvided () {
195
186
196
- String executionId = this .idGenerator .generateId ().toString ();
197
- this .graphQlMessageHandler .setExecutionId (executionId );
198
-
199
187
StepVerifier verifier = StepVerifier .create (
200
188
Flux .from (this .resultChannel )
201
189
.map (Message ::getPayload )
@@ -209,8 +197,8 @@ void testHandleMessageForSubscriptionWithRequestInputProvided() {
209
197
Map <String , Object > results = (Map <String , Object >) requestOutput .getData ();
210
198
assertThat (results ).containsKey ("results" );
211
199
212
- Map <String , Object > queryResult = (Map <String , Object >) results .get ("results" );
213
- assertThat (queryResult )
200
+ Map <String , Object > operationResult = (Map <String , Object >) results .get ("results" );
201
+ assertThat (operationResult )
214
202
.containsKey ("id" )
215
203
.containsValue ("test-data-01" );
216
204
@@ -221,35 +209,15 @@ void testHandleMessageForSubscriptionWithRequestInputProvided() {
221
209
222
210
this .inputChannel .send (
223
211
MessageBuilder
224
- .withPayload (new RequestInput ("subscription { results { id } }" , null , Collections .emptyMap (), null , executionId ))
212
+ .withPayload (new RequestInput ("subscription { results { id } }" , null , Collections .emptyMap (), null , UUID . randomUUID (). toString () ))
225
213
.build ()
226
214
);
227
215
228
216
verifier .verify (Duration .ofSeconds (10 ));
229
217
}
230
218
231
219
@ Test
232
- void testHandleMessageForQueryWithInvalidPayload () {
233
-
234
- this .inputChannel .send (
235
- MessageBuilder
236
- .withPayload (new Object ())
237
- .build ()
238
- );
239
-
240
- Message <?> errorMessage = errorChannel .receive (10_000 );
241
- assertThat (errorMessage ).isNotNull ()
242
- .isInstanceOf (ErrorMessage .class )
243
- .extracting (Message ::getPayload )
244
- .isInstanceOf (MessageHandlingException .class )
245
- .satisfies ((ex ) -> assertThat ((Exception ) ex )
246
- .hasMessageContaining (
247
- "'queryExpression' must not be null" ));
248
-
249
- }
250
-
251
- @ Test
252
- void testHandleMessageForMutationWithInvalidPayload () {
220
+ void testHandleMessageWithInvalidPayload () {
253
221
254
222
this .inputChannel .send (
255
223
MessageBuilder
@@ -264,27 +232,7 @@ void testHandleMessageForMutationWithInvalidPayload() {
264
232
.isInstanceOf (MessageHandlingException .class )
265
233
.satisfies ((ex ) -> assertThat ((Exception ) ex )
266
234
.hasMessageContaining (
267
- "'queryExpression' must not be null" ));
268
-
269
- }
270
-
271
- @ Test
272
- void testHandleMessageForSubscriptionWithInvalidPayload () {
273
-
274
- this .inputChannel .send (
275
- MessageBuilder
276
- .withPayload (new Object ())
277
- .build ()
278
- );
279
-
280
- Message <?> errorMessage = errorChannel .receive (10_000 );
281
- assertThat (errorMessage ).isNotNull ()
282
- .isInstanceOf (ErrorMessage .class )
283
- .extracting (Message ::getPayload )
284
- .isInstanceOf (MessageHandlingException .class )
285
- .satisfies ((ex ) -> assertThat ((Exception ) ex )
286
- .hasMessageContaining (
287
- "'queryExpression' must not be null" ));
235
+ "'operationExpression' must not be null" ));
288
236
289
237
}
290
238
@@ -356,12 +304,13 @@ GraphQlMessageHandler handler(GraphQlService graphQlService) {
356
304
return new GraphQlMessageHandler (graphQlService );
357
305
}
358
306
307
+ // @artem
359
308
@ Bean
360
309
IntegrationFlow graphqlQueryMessageHandlerFlow (GraphQlMessageHandler handler ) {
361
310
362
- return IntegrationFlows .from (MessageChannels .flux ("inputChannel" ))
311
+ return IntegrationFlows .from (MessageChannels .flux ("inputChannel" ). datatype ( Object . class , RequestInput . class ) )
363
312
.handle (handler )
364
- .channel (c -> c .flux ("resultChannel" ))
313
+ .channel (c -> c .flux ("resultChannel" ). datatype ( RequestOutput . class ) )
365
314
.get ();
366
315
}
367
316
@@ -403,12 +352,6 @@ AnnotatedControllerConfigurer annotatedDataFetcherConfigurer() {
403
352
return new AnnotatedControllerConfigurer ();
404
353
}
405
354
406
- @ Bean
407
- IdGenerator idGenerator () {
408
-
409
- return new AlternativeJdkIdGenerator ();
410
- }
411
-
412
355
}
413
356
414
357
static class QueryResult {
0 commit comments