add some tolerance for instantiationUI in some SdcApiTests 82/98282/1
authorEylon Malin <eylon.malin@intl.att.com>
Tue, 12 Nov 2019 10:06:39 +0000 (12:06 +0200)
committerEylon Malin <eylon.malin@intl.att.com>
Tue, 12 Nov 2019 10:06:39 +0000 (12:06 +0200)
Issue-ID: VID-701
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Change-Id: I07b3dcad90644a36b8bf1b65c578f2e34f6b44b1

vid-automation/src/test/java/org/onap/vid/api/SdcApiTest.java

index 858b2f8..918c413 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.vid.api;
 import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
 import static net.javacrumbs.jsonunit.JsonMatchers.jsonStringEquals;
 import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
+import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
 import static org.hamcrest.core.IsNot.not;
@@ -129,7 +130,9 @@ public class SdcApiTest extends BaseApiTest {
         ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + MACRO_INSTANTIATION_TYPE_UUID), String.class);
         assertEquals(response.getStatusCode(), HttpStatus.OK);
         String emptyInstantiationTypeExpectedResponse = loadResourceAsString(EMPTY_INSTANTIATION_TYPE_EXPECTED_RESPONSE);
-        assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(turnOffInstantiationUI(emptyInstantiationTypeExpectedResponse))));
+        assertThat(response.getBody(), jsonEquals(emptyInstantiationTypeExpectedResponse)
+            .when(IGNORING_ARRAY_ORDER)
+            .whenIgnoringPaths("service.vidNotions.instantiationUI"));
     }
 
     @Test
@@ -149,7 +152,9 @@ public class SdcApiTest extends BaseApiTest {
         ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + MIN_MAX_INITIAL_UUID), String.class);
         assertEquals(response.getStatusCode(), HttpStatus.OK);
         String minMaxInitialExpectedResponse = loadResourceAsString("sdcApiTest/minMaxInitialExpectedResponse.json");
-        assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(turnOffInstantiationUI(minMaxInitialExpectedResponse))));
+        assertThat(response.getBody(), jsonEquals(minMaxInitialExpectedResponse)
+            .when(IGNORING_ARRAY_ORDER)
+            .whenIgnoringPaths("service.vidNotions.instantiationUI"));
     }
 
     @Test
@@ -163,12 +168,18 @@ public class SdcApiTest extends BaseApiTest {
 
     @Test
     @FeatureTogglingTest(Features.FLAG_1902_VNF_GROUPING)
-    public void getServiceModelWithServiceRoleGrouping(){
+    public void getServiceModelWithServiceRoleGrouping() throws Exception {
         registerToSimulatorWithPresets(GROUPING_SERVICE_ROLE_UUID, GROUPING_SERVICE_ROLE_INVARIANT_UUID, GROUPING_SERVICE_ROLE_FILE_PATH);
         ResponseEntity<String> response = restTemplate.getForEntity(buildUri(SDC_GET_SERVICE_MODEL + GROUPING_SERVICE_ROLE_UUID), String.class);
         assertEquals(response.getStatusCode(), HttpStatus.OK);
         String groupingServiceRoleExpectedResponse = loadResourceAsString(GROUPING_SERVICE_ROLE_EXPECTED_RESPONSE);
-        assertThat("The response is in the format of JSON", response.getBody(), is(jsonStringEquals(groupingServiceRoleExpectedResponse)));
+        assertThat(response.getBody(), jsonEquals(groupingServiceRoleExpectedResponse)
+            .when(IGNORING_ARRAY_ORDER)
+            .whenIgnoringPaths("service.vidNotions.instantiationUI"));
+
+        //assert that instantiationUI is not legacy
+        JsonNode instantiationUI = objectMapper.readValue(response.getBody(), JsonNode.class).get("service").get("vidNotions").get("instantiationUI");
+        assertThat(instantiationUI.asText(), not(equalTo("legacy")));
     }
 
     private void registerToSimulatorWithPresets(String uuid, String invariantUuid, String pathPath){
@@ -178,15 +189,6 @@ public class SdcApiTest extends BaseApiTest {
         registerExpectationFromPresets(presets, CLEAR_THEN_SET);
     }
 
-    private String turnOffInstantiationUI(String expectedJson) {
-        if (!Features.FLAG_5G_IN_NEW_INSTANTIATION_UI.isActive()) {
-            // replaces the instantiationUI field-value with "legacy", whatever it was
-            return expectedJson.replaceFirst("(\"instantiationUI\": *\")[^\"]*(\",)", "$1legacy$2");
-        } else {
-            return expectedJson;
-        }
-    }
-
     @Test
     public void withModelFromE2eWithToscaParserButNewFlow_requestModels_expectVnfRelatedVfModulesNotNull() {