@@ -37,10 +37,14 @@ public class QueryAggregatedObjectsTestSteps extends FunctionalTestBase {
37
37
38
38
private static final Logger LOGGER = LoggerFactory .getLogger (QueryAggregatedObjectsTestSteps .class );
39
39
40
- private static final String AGGREGATED_OBJ_JSON_PATH = "src/test/resources/AggregatedDocument .json" ;
40
+ private static final String AGGREGATED_OBJ_JSON_PATH = "src/test/resources/AggregatedDocumentInternalCompositionLatest .json" ;
41
41
private static final String MISSED_NOTIFICATION_JSON_PATH = "src/test/resources/MissedNotification.json" ;
42
42
private static final String QUERY_1_FILE_NAME = "src/functionaltests/resources/queryAggregatedObject1.json" ;
43
43
private static final String QUERY_2_FILE_NAME = "src/functionaltests/resources/queryAggregatedObject2.json" ;
44
+ private static final String QUERY_3_FILE_NAME = "src/functionaltests/resources/queryAggregatedObject3.json" ;
45
+ private static final String QUERY_4_FILE_NAME = "src/functionaltests/resources/queryAggregatedObject4.json" ;
46
+ private static final String QUERY_5_FILE_NAME = "src/functionaltests/resources/queryAggregatedObject5.json" ;
47
+ private static final String QUERY_6_FILE_NAME = "src/functionaltests/resources/queryAggregatedObject6.json" ;
44
48
45
49
@ LocalServerPort
46
50
private int applicationPort ;
@@ -300,6 +304,86 @@ public void check_missed_notification_has_been_returned() throws Throwable {
300
304
expectedResponse , responseAsString );
301
305
}
302
306
307
+ @ And ("^Perform a query on created Aggregated object with filter$" )
308
+ public void perform_valid_query_and_filter_on_aggregated_object () throws Throwable {
309
+ final String expectedResponse = "[{\" 6acc3c87-75e0-4b6d-88f5-b1a5d4e62b43\" :\" \\ \" 33d05e6f-9bd9-4138-83b6-e20cc74680a3\\ \" \" }]" ;
310
+ final String entryPoint = "/query" ;
311
+
312
+ String query1 = FileUtils .readFileToString (new File (QUERY_3_FILE_NAME ), "UTF-8" );
313
+
314
+ List <String > queries = new ArrayList <>();
315
+ queries .add (query1 );
316
+
317
+ for (String query : queries ) {
318
+ LOGGER .debug ("Freestyle querying for the AggregatedObject with criteria: " + query );
319
+ HttpRequest postRequest = new HttpRequest (HttpMethod .POST );
320
+ response = postRequest .setPort (applicationPort )
321
+ .setHost (hostName )
322
+ .addHeader ("content-type" , "application/json" )
323
+ .addHeader ("Accept" , "application/json" )
324
+ .setEndpoint (entryPoint )
325
+ .setBody (query )
326
+ .performRequest ();
327
+
328
+ LOGGER .debug (
329
+ "Response of /query RestApi, Status Code: " + response .getStatusCodeValue () + "\n Response: " + response .getBody ().toString ());
330
+
331
+ String responseAsString = response .getBody ().toString ();
332
+ int reponseStatusCode = response .getStatusCodeValue ();
333
+
334
+ assertEquals (HttpStatus .OK .toString (), Integer .toString (reponseStatusCode ));
335
+ assertEquals ("Failed to compare actual response:\n " + responseAsString + "\n with expected response:\n " + expectedResponse ,
336
+ expectedResponse , responseAsString );
337
+ }
338
+ }
339
+
340
+ @ And ("^Perform a query and filter with part of path$" )
341
+ public void perform__query_and_filter_with_part_of_path () throws Throwable {
342
+ final String expectedResponse = "[{\" 6acc3c87-75e0-4b6d-88f5-b1a5d4e62b43\" :\" \\ \" [1481875921843, 1481875988767, 1481875921763, 1481875944272, 5005, 1481875891763, 2000]\\ \" \" }]" ;
343
+ final String expectedResponse2 = "[{\" 6acc3c87-75e0-4b6d-88f5-b1a5d4e62b43\" :\" \\ \" null\\ \" \" }]" ;
344
+ final String expectedResponse3 = "[{\" 6acc3c87-75e0-4b6d-88f5-b1a5d4e62b43\" :\" \\ \" [33d05e6f-9bd9-4138-83b6-e20cc74680a3, 33d05e6f-9bd9-4138-83b6-e20cc74681b5]\\ \" \" }]" ;
345
+ final String entryPoint = "/query" ;
346
+
347
+ List <String > expectedResponses = new ArrayList <String >();
348
+ expectedResponses .add (expectedResponse );
349
+ expectedResponses .add (expectedResponse2 );
350
+ expectedResponses .add (expectedResponse3 );
351
+
352
+ String query1 = FileUtils .readFileToString (new File (QUERY_4_FILE_NAME ), "UTF-8" );
353
+ String query2 = FileUtils .readFileToString (new File (QUERY_5_FILE_NAME ), "UTF-8" );
354
+ String query3 = FileUtils .readFileToString (new File (QUERY_6_FILE_NAME ), "UTF-8" );
355
+
356
+ List <String > queries = new ArrayList <>();
357
+ queries .add (query1 );
358
+ queries .add (query2 );
359
+ queries .add (query3 );
360
+
361
+ int pos = 0 ;
362
+ for (String query : queries ) {
363
+ LOGGER .debug ("Freestyle querying for the AggregatedObject with criteria: " + query );
364
+ HttpRequest postRequest = new HttpRequest (HttpMethod .POST );
365
+ response = postRequest .setPort (applicationPort )
366
+ .setHost (hostName )
367
+ .addHeader ("content-type" , "application/json" )
368
+ .addHeader ("Accept" , "application/json" )
369
+ .setEndpoint (entryPoint )
370
+ .setBody (query )
371
+ .performRequest ();
372
+
373
+ LOGGER .debug (
374
+ "Response of /query RestApi, Status Code: " + response .getStatusCodeValue () + "\n Response: " + response .getBody ().toString ());
375
+
376
+ String responseAsString = response .getBody ().toString ();
377
+ int reponseStatusCode = response .getStatusCodeValue ();
378
+
379
+ assertEquals (HttpStatus .OK .toString (), Integer .toString (reponseStatusCode ));
380
+ assertEquals ("Failed to compare actual response:\n " + responseAsString + "\n with expected response:\n " + expectedResponses .get (pos ),
381
+ expectedResponses .get (pos ), responseAsString );
382
+
383
+ pos ++;
384
+ }
385
+ }
386
+
303
387
/**
304
388
* Method that creates a document in MongoDb database.
305
389
*
0 commit comments