From 809dd1050faf1bb3687807be384940ccbb28ff22 Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Fri, 11 Oct 2019 00:26:05 +0300 Subject: Add ability to retrieve from simulator recorded requests and headers Issue-ID: VID-253 Signed-off-by: Eylon Malin Change-Id: Ie8dfe7216240a95d40c0d7ffdd5c69f6ddb643af --- .../vid/automation/test/services/SimulatorApi.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'vid-automation') diff --git a/vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java b/vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java index aae494f84..fd7033c6e 100644 --- a/vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java +++ b/vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java @@ -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 values; + } + public static class HttpRequest{ - public Path path; + public StringWrapper path; + public List 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 retrieveRecordedRequestsPathCounter() { - Response response = client.target(uri).path("retrieveRecordedRequests").request().get(); - List httpRequests = response.readEntity(new GenericType>(){}); + List httpRequests = retrieveRecordedRequests(); return httpRequests.stream().map(x->x.path.value).collect( Collectors.groupingBy(Function.identity(), Collectors.counting())); } + public static List retrieveRecordedRequests() { + Response response = client.target(uri).path("retrieveRecordedRequests").request().get(); + return response.readEntity(new GenericType>(){}); + } + private static void registerToSimulatorAndAssertSuccess(String name, Object content, RegistrationStrategy registrationStrategy) { if (registrationStrategy == RegistrationStrategy.CLEAR_THEN_SET) { clearRegistrations(); -- cgit 1.2.3-korg