AAF tests presets should redirect to simulator by it's config 74/98274/3
authorIttay Stern <ittay.stern@att.com>
Tue, 12 Nov 2019 07:05:39 +0000 (09:05 +0200)
committerIttay Stern <ittay.stern@att.com>
Tue, 12 Nov 2019 08:53:21 +0000 (10:53 +0200)
Issue-ID: VID-701

Change-Id: Ie1d0c78ec15e127fc782978175df4f608587a94a
Signed-off-by: Ittay Stern <ittay.stern@att.com>
vid-automation/src/main/java/org/onap/simulator/presetGenerator/presets/aaf/AAFGetUrlServicePreset.java
vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java

index b3376e6..c391466 100644 (file)
@@ -2,6 +2,7 @@ package org.onap.simulator.presetGenerator.presets.aaf;
 
 import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
 import org.springframework.http.HttpMethod;
+import vid.automation.test.services.SimulatorApi;
 
 public class AAFGetUrlServicePreset extends BasePreset {
     @Override
@@ -11,7 +12,11 @@ public class AAFGetUrlServicePreset extends BasePreset {
 
     @Override
     public String getReqPath() {
-        return "/locate/com.att.aaf.service:2.0";
+        return "/locate/" + regexAafServerName() + ":2.0";
+    }
+
+    private String regexAafServerName() {
+        return "([a-z-]+\\.)*[a-z-]+";
     }
 
     @Override
@@ -21,6 +26,22 @@ public class AAFGetUrlServicePreset extends BasePreset {
 
     @Override
     public Object getResponseBody() {
-        return "{\"endpoint\":[{\"name\":\"com.att.aaf.service\",\"major\": 2,\"minor\": 0,\"patch\": 19,\"pkg\": 21,\"latitude\": 38.627346,\"longitude\": -90.19377,\"protocol\": \"http\",\"subprotocol\": [],\"hostname\": \"127.0.0.1\",\"port\": 1080}]}";
+        return ""
+            + "{"
+            + "  \"endpoint\": [{"
+            + "      \"name\": \"aaf-service\","
+            + "      \"major\": 2,"
+            + "      \"minor\": 0,"
+            + "      \"patch\": 19,"
+            + "      \"pkg\": 21,"
+            + "      \"latitude\": 38.627346,"
+            + "      \"longitude\": -90.19377,"
+            + "      \"protocol\": \"http\","
+            + "      \"subprotocol\": [],"
+            + "      \"port\": " + SimulatorApi.getSimulatedResponsesPort() + ","
+            + "      \"hostname\": \"" + SimulatorApi.getSimulatorHost() + "\""
+            + "    }"
+            + "  ]"
+            + "}"; 
     }
 }
index 6e15b7b..ff8f209 100644 (file)
@@ -82,7 +82,7 @@ public class SimulatorApi {
             ImmutableList.of(dropTestApiFieldFromString(), dropFieldCloudOwnerFromString());
 
     static {
-        String host = System.getProperty("SIM_HOST", System.getProperty("VID_HOST", "127.0.0.1"));
+        String host = getSimulatorHost();
         Integer port = Integer.valueOf(System.getProperty("SIM_PORT", System.getProperty("VID_PORT", "8080"))); //port for registration
         uri = new JerseyUriBuilder().host(host).port(port).scheme("http").path("vidSimulator").build();
         client = ClientBuilder.newClient();
@@ -94,10 +94,18 @@ public class SimulatorApi {
         jacksonJsonProvider.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
         client.register(jacksonJsonProvider);
 
-        Integer simulationPort = Integer.valueOf(System.getProperty("SIMULATION_PORT", "1080")); //port getting simulated responses
+        Integer simulationPort = getSimulatedResponsesPort();
         simulationUri = new JerseyUriBuilder().host(host).port(simulationPort).scheme("http").build();
     }
 
+    public static String getSimulatorHost() {
+        return System.getProperty("SIM_HOST", System.getProperty("VID_HOST", "127.0.0.1"));
+    }
+
+    public static Integer getSimulatedResponsesPort() {
+        return Integer.valueOf(System.getProperty("SIMULATION_PORT", "1080"));
+    }
+
     public static URI getSimulationUri() {
         return simulationUri;
     }