API test ordering for mso vfModules requests 05/98405/2
authorSara Weiss <sara.weiss@intl.att.com>
Thu, 14 Nov 2019 12:23:16 +0000 (14:23 +0200)
committerSara Weiss <sara.weiss@intl.att.com>
Thu, 14 Nov 2019 12:48:15 +0000 (14:48 +0200)
Issue-ID: VID-253
Signed-off-by: Sara Weiss <sara.weiss@intl.att.com>
Change-Id: I9a8594eab3f8e4eacaf503c23f04d1db6b101f90

vid-automation/src/main/java/vid/automation/test/services/SimulatorApi.java
vid-automation/src/test/java/org/onap/vid/api/AsyncInstantiationALaCarteApiTest.java
vid-automation/src/test/resources/a-la-carte/redux-a-la-carte-no-testapi.json

index ff8f209..c8ac7ea 100644 (file)
@@ -56,17 +56,24 @@ public class SimulatorApi {
         public List<StringWrapper> values;
     }
 
+    public static class BodyWrapper {
+        public String value;
+    }
+
     public static class HttpRequest {
         public StringWrapper path;
+        public BodyWrapper body;
         public List<RecordedHeaders> headers;
     }
 
     public static class RecordedRequests {
         public String path;
+        public String body;
         public Map<String, List<String>> headers;
 
-        public RecordedRequests(String path, Map<String, List<String>> headers) {
+        public RecordedRequests(String path,  String body, Map<String, List<String>> headers) {
             this.path = path;
+            this.body = body;
             this.headers = headers;
         }
 
@@ -188,6 +195,7 @@ public class SimulatorApi {
         List<HttpRequest> rawRequests =  retrieveRecordedHttpRequests();
         return rawRequests.stream().map(request->new RecordedRequests(
             request.path.value,
+            request.body != null && request.body != null ?  request.body.value : "",
             request.headers.stream().collect(
                 Collectors.toMap(
                     x->x.name.value,
index 25b40ed..92d3f79 100644 (file)
@@ -1,12 +1,14 @@
 package org.onap.vid.api;
 
 import static java.util.Collections.emptyMap;
+import static java.util.stream.Collectors.toList;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.CoreMatchers.hasItems;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.allOf;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.containsInRelativeOrder;
 import static org.hamcrest.Matchers.matchesPattern;
 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
 import static org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset.DEFAULT_INSTANCE_ID;
@@ -18,12 +20,14 @@ import static vid.automation.test.services.SimulatorApi.retrieveRecordedRequests
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+
 import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
 import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset;
 import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId;
@@ -408,6 +412,23 @@ public class AsyncInstantiationALaCarteApiTest extends AsyncInstantiationBase {
         }
     }
 
+
+    @Test
+    public void deployServiceAfterDragAndDropVFModule__verifyOrderMsoCalls() {
+        final ImmutableMap<PresetMSOServiceInstanceGen2WithNames.Keys, String> names = ImmutableMap
+            .of(SERVICE_NAME, "serviceInstanceName");
+        String vnfRequestId = UUID.randomUUID().toString();
+        registerPresetsForRetryTest("none", names, vnfRequestId, false);
+
+        final List<String> uuids = createBulkOfInstances(false, 1, names,
+            CREATE_BULK_OF_ALACARTE_NO_TESTAPI_REQUEST_CYPRESS);
+
+        final String jobId = uuids.get(0);
+
+        assertServiceInfoSpecific2(jobId, JobStatus.COMPLETED, names.get(SERVICE_NAME));
+        assertMSOcalledWithOrder();
+    }
+
     @Test
     public void verifyMetricsLogInAsyncInstantiation() {
 
@@ -525,6 +546,24 @@ public class AsyncInstantiationALaCarteApiTest extends AsyncInstantiationBase {
         ));
     }
 
+
+    private void assertMSOcalledWithOrder() {
+
+        List<RecordedRequests> requests = retrieveRecordedRequests();
+
+        String path = "/mso/serviceInstantiation/v7/serviceInstances/.*/vnfs/.*/vfModules";
+        List<String> msoVFModulesRequests =
+            requests.stream().filter(x -> x.path.matches(path)).map(x -> x.body).collect(toList());
+
+        assertThat("request for vfNodule send with position order",
+            msoVFModulesRequests,
+            contains(
+                containsString("2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0"),
+                containsString("2017488PasqualeVpe..PASQUALE_vPFE_BV..module-2"),
+                containsString("2017488PasqualeVpe..PASQUALE_vRE_BV..module-1")
+            ));
+    }
+
     private ImmutableList<JobAuditStatus> vidAuditStatusesCompleted(String jobId) {
         return ImmutableList.of(
                 vidAuditStatus(jobId, "PENDING", false),
index a6c4dc1..dfdab76 100644 (file)
@@ -13,6 +13,7 @@
           "2017488_pasqualevpe0..2017488PasqualeVpe..PASQUALE_base_vPE_BV..module-0": {
             "instanceName": "mimazepubi",
             "lcpCloudRegionId": "hvf6",
+            "position": "2",
             "tenantId": "624eb554b0d147c19ff8885341760481",
             "rollbackOnFailure": "false",
             "sdncPreLoad": false,
@@ -37,6 +38,7 @@
             "instanceName": "puwesovabe",
             "volumeGroupName": "puwesovabe_vol",
             "lcpCloudRegionId": "AAIAIC25",
+            "position": "3",
             "legacyRegion": "my region",
             "tenantId": "092eb9e8e4b7412e8787dd091bc58e86",
             "rollbackOnFailure": "true",
@@ -68,6 +70,7 @@
             "instanceName": "bnmgtrx",
             "volumeGroupName": "",
             "lcpCloudRegionId": "hvf6",
+            "position": "1",
             "tenantId": "624eb554b0d147c19ff8885341760481",
             "rollbackOnFailure": "false",
             "sdncPreLoad": false,