Add ability to retrieve from simulator recorded requests and headers 04/96904/1
authorEylon Malin <eylon.malin@intl.att.com>
Thu, 10 Oct 2019 21:26:05 +0000 (00:26 +0300)
committerEylon Malin <eylon.malin@intl.att.com>
Thu, 10 Oct 2019 21:26:05 +0000 (00:26 +0300)
Issue-ID: VID-253
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Change-Id: Ie8dfe7216240a95d40c0d7ffdd5c69f6ddb643af

vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java

index aae494f..fd7033c 100644 (file)
@@ -46,12 +46,18 @@ public class SimulatorApi {
     com.fasterxml.jackson.databind.JsonMappingException: Can not find a (Map) Key deserializer for type
      [simple type, class org.mockserver.model.NottableString]
     */
-    public static class Path {
+    public static class StringWrapper {
         public String value;
     }
 
+    public static class RecordedHeaders {
+        public StringWrapper name;
+        public List<StringWrapper> values;
+    }
+
     public static class HttpRequest{
-        public Path path;
+        public StringWrapper path;
+        public List<RecordedHeaders> headers;
     }
 
     private static final URI uri; //uri for registration
@@ -146,12 +152,16 @@ public class SimulatorApi {
         The key of the map is a path, and the value is counter
      */
     public static Map<String, Long> retrieveRecordedRequestsPathCounter() {
-        Response response = client.target(uri).path("retrieveRecordedRequests").request().get();
-        List<HttpRequest> httpRequests =  response.readEntity(new GenericType<List<HttpRequest>>(){});
+        List<HttpRequest> httpRequests =  retrieveRecordedRequests();
         return httpRequests.stream().map(x->x.path.value).collect(
                 Collectors.groupingBy(Function.identity(), Collectors.counting()));
     }
 
+    public static List<HttpRequest> retrieveRecordedRequests() {
+        Response response = client.target(uri).path("retrieveRecordedRequests").request().get();
+        return response.readEntity(new GenericType<List<HttpRequest>>(){});
+    }
+
     private static void registerToSimulatorAndAssertSuccess(String name, Object content, RegistrationStrategy registrationStrategy) {
         if (registrationStrategy == RegistrationStrategy.CLEAR_THEN_SET) {
             clearRegistrations();