summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/test
diff options
context:
space:
mode:
authorEylon Malin <eylon.malin@intl.att.com>2020-01-08 16:03:08 +0200
committerIttay Stern <ittay.stern@att.com>2020-01-09 17:17:46 +0200
commit6b5dd86a3557e8eed2c4584f5d16df5654cbc57b (patch)
treef3978f5e3e92a5728f8bdb89146de38305b16fb7 /vid-app-common/src/test
parente8414b1fe839291418ead3a7e5a64bf382dc1121 (diff)
Fix the format of supplementary file and user params for aLaCarte requests
supplementary file shall be in format [{"name": "fieldName", "value" : "xyz"}] Also this is the format of each param in user params for aLaCarte requests and old macros Issue-ID: VID-743 Change-Id: I579298ce3f0b789a7a69e6af5a85bfbd50ae9fc0 Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Diffstat (limited to 'vid-app-common/src/test')
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java19
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java10
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java104
-rw-r--r--vid-app-common/src/test/java/org/onap/vid/services/UserParamsContainerTest.kt57
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json19
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json19
-rw-r--r--vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json19
8 files changed, 177 insertions, 80 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java b/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java
index b5d281622..b7ae76915 100644
--- a/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/model/serviceInstantiation/InstantiationModelSerializationTest.java
@@ -38,6 +38,7 @@ import static org.onap.vid.utils.KotlinUtilsKt.JACKSON_OBJECT_MAPPER;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.lang.reflect.InvocationTargetException;
+import java.util.List;
import java.util.Map;
import org.apache.commons.beanutils.PropertyUtils;
import org.onap.vid.model.VidNotions;
@@ -45,6 +46,7 @@ import org.onap.vid.model.VidNotions.InstantiationType;
import org.onap.vid.model.VidNotions.InstantiationUI;
import org.onap.vid.model.VidNotions.ModelCategory;
import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.UserParamNameAndValue;
import org.testng.annotations.Test;
public class InstantiationModelSerializationTest {
@@ -125,10 +127,10 @@ public class InstantiationModelSerializationTest {
@Test
public void serializeAndDeserializeVfModule() throws Exception {
- ImmutableMap<String, String> supplementaryParams = ImmutableMap.of(
- "uno", "1",
- "dos", "2",
- "tres", "3"
+ List<UserParamNameAndValue> supplementaryParams = ImmutableList.of(
+ new UserParamNameAndValue("uno", "1"),
+ new UserParamNameAndValue("dos", "2"),
+ new UserParamNameAndValue("tres", "3")
);
VfModule vfModule = new VfModule(
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java
index 29041839a..67d3d4a9a 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AAITreeNodeBuilderTest.java
@@ -50,7 +50,10 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.tuple.Pair;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
@@ -79,6 +82,7 @@ public class AAITreeNodeBuilderTest {
private ExecutorService executorService;
private Logging logging = new Logging();
+ private static final Logger logger = LogManager.getLogger(AAITreeNodeBuilderTest.class);
private static final ObjectMapper mapper = new ObjectMapper();
@@ -92,7 +96,9 @@ public class AAITreeNodeBuilderTest {
private void buildNodeAndAssert(JsonNode inputNode, AAITreeNode expectedNode, NodeType nodeType){
ConcurrentSkipListSet<AAITreeNode> nodesAccumulator = new ConcurrentSkipListSet<>(comparing(AAITreeNode::getUniqueNodeKey));
when(aaiClientMock.typedAaiRest(Unchecked.toURI("anyUrl"), JsonNode.class, null, HttpMethod.GET, false)).thenReturn(inputNode);
- AAITreeNode actualNode = aaiTreeNodeBuilder.buildNode(
+ AAITreeNode actualNode;
+ try {
+ actualNode = aaiTreeNodeBuilder.buildNode(
nodeType,
"anyUrl",
null,
@@ -100,7 +106,16 @@ public class AAITreeNodeBuilderTest {
nodesAccumulator,
executorService,
AAI_TREE_PATHS.getSubTree(new AAIServiceTree.AaiRelationship(nodeType))
- ).get(0);
+ ).get(0);
+ } catch (Throwable e) {
+ //print stack traces for more information in case of failure
+ System.out.println("Failed to build node by aaiTreeNodeBuilder");
+ ExceptionUtils.getThrowableList(e)
+ .stream()
+ .peek(it ->System.err.println(it.getLocalizedMessage()))
+ .forEach(Throwable::printStackTrace);
+ throw e;
+ }
assertThat(actualNode, jsonEquals(expectedNode).when(IGNORING_ARRAY_ORDER, IGNORING_EXTRA_FIELDS).whenIgnoringPaths("relationshipList","children[0].relationshipList"));
}
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
index b9535000a..83130fdd9 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBaseTest.java
@@ -22,7 +22,6 @@ package org.onap.vid.services;
import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;
-import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -65,6 +64,7 @@ import org.onap.vid.model.serviceInstantiation.VfModule;
import org.onap.vid.model.serviceInstantiation.Vnf;
import org.onap.vid.mso.RestObject;
import org.onap.vid.mso.model.ModelInfo;
+import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.UserParamNameAndValue;
import org.onap.vid.mso.rest.AsyncRequestStatus;
import org.onap.vid.mso.rest.RequestStatus;
import org.onap.vid.properties.Features;
@@ -250,7 +250,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
}
protected VfModule createVfModule(String modelName, String modelVersionId, String modelCustomizationId,
- List<Map<String, String>> instanceParams, Map<String, String> supplementaryParams, String instanceName, String volumeGroupInstanceName, boolean isAlacarte) {
+ List<Map<String, String>> instanceParams, List<UserParamNameAndValue> supplementaryParams, String instanceName, String volumeGroupInstanceName, boolean isAlacarte) {
ModelInfo vfModuleInfo = new ModelInfo();
vfModuleInfo.setModelType("vfModule");
vfModuleInfo.setModelName(modelName);
@@ -276,7 +276,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
}
protected VfModule createVfModuleForReplace(ModelInfo vfModuleModelInfo, String instanceName,
- String lcpCloudRegionId, String tenantId, Boolean retainAssignments, Boolean retainVolumeGroups, Map<String, String> supplementaryParams) {
+ String lcpCloudRegionId, String tenantId, Boolean retainAssignments, Boolean retainVolumeGroups, List<UserParamNameAndValue> supplementaryParams) {
return new VfModule( vfModuleModelInfo, instanceName, null, Action.Upgrade.name(), lcpCloudRegionId, null, tenantId,
null, supplementaryParams, true, null, null, UUID.randomUUID().toString(), null, null, retainAssignments, retainVolumeGroups, null);
}
@@ -349,9 +349,9 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests
Map<String, Map<String, VfModule>> vfModules = new HashMap<>();
List<Map<String, String>> instanceParams1 = ImmutableList.of((ImmutableMap.of("vmx_int_net_len", "24")));
- VfModule vfModule1 = createVfModule("201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0", VF_MODULE_0_MODEL_VERSION_ID, VF_MODULE_0_MODEL_CUSTOMIZATION_NAME, instanceParams1, new HashMap<>(), (isUserProvidedNaming ? "vmxnjr001_AVPN_base_vPE_BV_base" : null), null, isAlacarte);
+ VfModule vfModule1 = createVfModule("201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0", VF_MODULE_0_MODEL_VERSION_ID, VF_MODULE_0_MODEL_CUSTOMIZATION_NAME, instanceParams1, emptyList(), (isUserProvidedNaming ? "vmxnjr001_AVPN_base_vPE_BV_base" : null), null, isAlacarte);
List<Map<String, String>> instanceParams2 = ImmutableList.of(vfModuleInstanceParamsMap);
- VfModule vfModule2 = createVfModule("201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", VF_MODULE_1_MODEL_VERSION_ID, VF_MODULE_1_MODEL_CUSTOMIZATION_NAME, instanceParams2, new HashMap<>(), (isUserProvidedNaming ? "vmxnjr001_AVPN_base_vRE_BV_expansion": null), (isUserProvidedNaming ? "myVgName" : null), isAlacarte);
+ VfModule vfModule2 = createVfModule("201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", VF_MODULE_1_MODEL_VERSION_ID, VF_MODULE_1_MODEL_CUSTOMIZATION_NAME, instanceParams2, emptyList(), (isUserProvidedNaming ? "vmxnjr001_AVPN_base_vRE_BV_expansion": null), (isUserProvidedNaming ? "myVgName" : null), isAlacarte);
String vfModuleModelName = vfModule1.getModelInfo().getModelName();
vfModules.put(vfModuleModelName, new LinkedHashMap<>());
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
index efd9e2b27..dea9e092e 100644
--- a/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
+++ b/vid-app-common/src/test/java/org/onap/vid/services/MsoRequestBuilderTest.java
@@ -21,6 +21,10 @@
package org.onap.vid.services;
import static com.google.common.collect.Maps.newHashMap;
+import static java.util.Collections.EMPTY_LIST;
+import static java.util.Collections.EMPTY_MAP;
+import static java.util.Collections.emptyList;
+import static java.util.Collections.singletonList;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonNodeAbsent;
import static net.javacrumbs.jsonunit.JsonMatchers.jsonPartEquals;
@@ -41,7 +45,6 @@ import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -78,7 +81,7 @@ import org.onap.vid.mso.model.ModelInfo;
import org.onap.vid.mso.model.NetworkInstantiationRequestDetails;
import org.onap.vid.mso.model.ServiceDeletionRequestDetails;
import org.onap.vid.mso.model.ServiceInstantiationRequestDetails;
-import org.onap.vid.mso.model.UserParamMap;
+import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.UserParamNameAndValue;
import org.onap.vid.mso.model.VfModuleMacro;
import org.onap.vid.mso.model.VfModuleOrVolumeGroupRequestDetails;
import org.onap.vid.mso.model.VnfInstantiationRequestDetails;
@@ -163,7 +166,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
private void createMacroServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected(boolean withVfmodules, boolean disabledHoming) throws IOException {
ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true,
- createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
+ createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, EMPTY_LIST, false),
1,
false, PROJECT_NAME, true);
URL resource;
@@ -181,7 +184,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
msoRequestBuilder.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
String expected = IOUtils.toString(resource, "UTF-8");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
+ assertThat(result, jsonEquals(expected));
}
@Test
@@ -233,7 +236,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
}
private ServiceInstantiation generateALaCarteServiceDeletionPayload() {
- return generateMockAlaCarteServiceDeletionPayload(false, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, 1, true, PROJECT_NAME, false, "VNF_API", "1234567890");
+ return generateMockAlaCarteServiceDeletionPayload(false, EMPTY_MAP, EMPTY_MAP, EMPTY_MAP, 1, true, PROJECT_NAME, false, "VNF_API", "1234567890");
}
@Test
@@ -255,7 +258,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
}
private ServiceInstantiation generateServiceDeletionPayload() {
- return generateMockServiceDeletionPayload(false, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, 1, true, PROJECT_NAME, false, "VNF_API", "1234567890");
+ return generateMockServiceDeletionPayload(false, EMPTY_MAP, EMPTY_MAP, EMPTY_MAP, 1, true, PROJECT_NAME, false, "VNF_API", "1234567890");
}
@DataProvider
@@ -301,7 +304,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
public static Object[][] testBuildVnfInstanceParamsDataProvider(Method test) {
return new Object[][]{
{
- Collections.EMPTY_LIST,
+ EMPTY_LIST,
ImmutableList.of(
ImmutableList.of(ImmutableMap.of("k1", "v1", "k2", "v2")),
ImmutableList.of(ImmutableMap.of("k3", "v3", "k2", "v2"))
@@ -313,23 +316,23 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
ImmutableList.of(
ImmutableList.of(ImmutableMap.of("k1", "v1", "k2", "v2")),
ImmutableList.of(ImmutableMap.of("k3", "v3", "k2", "v2")),
- ImmutableList.of(Collections.EMPTY_MAP),
- Collections.singletonList(null)
+ ImmutableList.of(EMPTY_MAP),
+ singletonList(null)
),
ImmutableList.of(ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3", "j1", "w1"))
},
{
- Collections.EMPTY_LIST,
+ EMPTY_LIST,
Arrays.asList(null, null),
- Collections.EMPTY_LIST //mso is expect to empty list and not list with empty map
+ EMPTY_LIST //mso is expect to empty list and not list with empty map
},
{
- ImmutableList.of(Collections.EMPTY_MAP),
+ ImmutableList.of(EMPTY_MAP),
ImmutableList.of(
- ImmutableList.of(Collections.EMPTY_MAP),
- ImmutableList.of(Collections.EMPTY_MAP)
+ ImmutableList.of(EMPTY_MAP),
+ ImmutableList.of(EMPTY_MAP)
),
- Collections.EMPTY_LIST //mso is expect to empty list and not list with empty map
+ EMPTY_LIST //mso is expect to empty list and not list with empty map
}
};
}
@@ -360,8 +363,11 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
ModelInfo vnfModelInfo = createVnfModelInfo(true);
List<Map<String, String>> instanceParams = ImmutableList.of(ImmutableMap.of("vmx_int_net_len", "24",
"vre_a_volume_size_0", "120"));
- Map<String, String> supplementaryParams = ImmutableMap.of("vre_a_volume_size_0", "100",
- "availability_zone_0", "mtpocdv-kvm-az01");
+ List<UserParamNameAndValue> supplementaryParams = ImmutableList.of(
+ new UserParamNameAndValue("vre_a_volume_size_0", "100"),
+ new UserParamNameAndValue("availability_zone_0", "mtpocdv-kvm-az01")
+ );
+
VfModule vfModule = createVfModule("201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1", "56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
"72d9d1cd-f46d-447a-abdb-451d6fb05fa8", instanceParams, supplementaryParams,
(isUserProvidedNaming ? "vmxnjr001_AVPN_base_vRE_BV_expansion" : null), "myVgName", true);
@@ -378,26 +384,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
final RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> result = msoRequestBuilder.generateVfModuleInstantiationRequest(
vfModule, siModelInfo, serviceInstanceId,
vnfModelInfo, vnfInstanceId, volumeGroupInstanceId, "pa0916", "VNF_API");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @DataProvider
- public static Object[][] expectedAggregatedParams() {
- return new Object[][]{
- {ImmutableMap.of("a", "b", "c", "d"), ImmutableMap.of("e", "f", "g", "h"), ImmutableList.of(ImmutableMap.of("c", "d", "a", "b", "e", "f", "g", "h"))},
- {ImmutableMap.of("a", "b", "c", "g"), ImmutableMap.of("c", "d", "e", "f"), ImmutableList.of(ImmutableMap.of("a", "b", "c", "d", "e", "f"))},
- {ImmutableMap.of(), ImmutableMap.of("c", "d", "e", "f"), ImmutableList.of(ImmutableMap.of("c", "d", "e", "f"))},
- {ImmutableMap.of("a", "b", "c", "g"), ImmutableMap.of(), ImmutableList.of(ImmutableMap.of("a", "b", "c", "g"))},
- {ImmutableMap.of(), ImmutableMap.of(), ImmutableList.of()},
- {null, ImmutableMap.of(), ImmutableList.of()},
- {ImmutableMap.of(), null, ImmutableList.of()},
- };
- }
-
- @Test(dataProvider = "expectedAggregatedParams")
- public void testAggregateInstanceParamsAndSuppFile(Map<String, String> instanceParams, Map<String, String> suppParams, List<UserParamMap<String, String>> expected) {
- List<UserParamMap<String, String>> aggParams = msoRequestBuilder.aggregateAllInstanceParams(instanceParams, suppParams);
- assertThat("Aggregated params are not as expected", aggParams, equalTo(expected));
+ assertThat(result, jsonEquals(expected).when(IGNORING_ARRAY_ORDER));
}
@Test
@@ -406,8 +393,8 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
VfModule vfModule = createVfModule("201673MowAvpnVpeBvL..AVPN_vRE_BV..module-1",
"56e2b103-637c-4d1a-adc8-3a7f4a6c3240",
"72d9d1cd-f46d-447a-abdb-451d6fb05fa8",
- Collections.emptyList(),
- Collections.emptyMap(),
+ emptyList(),
+ emptyList(),
"vmxnjr001_AVPN_base_vRE_BV_expansion",
"myVgName",
true);
@@ -437,7 +424,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
@Test(dataProvider = "expectedNetworkRequestDetailsParameters")
public void createNetworkRequestDetails_detailsAreAsExpected(String networkName, String filePath) throws IOException {
- List<NetworkDetails> networkDetails = Collections.singletonList(new NetworkDetails(networkName, "ab153b6e-c364-44c0-bef6-1f2982117f04"));
+ List<NetworkDetails> networkDetails = singletonList(new NetworkDetails(networkName, "ab153b6e-c364-44c0-bef6-1f2982117f04"));
final List<Network> networksList = new ArrayList<>(createNetworkList(null, networkDetails, true).values());
ModelInfo siModelInfo = createServiceModelInfo();
String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
@@ -495,7 +482,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
@Test
public void checkIfNullProjectNameSentToMso() {
ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true,
- createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
+ createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, EMPTY_LIST, false),
1,
false, null, false);
RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
@@ -503,7 +490,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
JsonNode jsonNode = new ObjectMapper().valueToTree(result.requestDetails);
Assert.assertTrue(jsonNode.get("project").isNull());
serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true,
- createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
+ createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, EMPTY_LIST, false),
1,
false, "not null", false);
result = msoRequestBuilder.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
@@ -569,7 +556,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
" }" +
" }" +
"}";
- VfModule vfModuleDetails = createVfModule("201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0", VF_MODULE_0_MODEL_VERSION_ID, VF_MODULE_0_MODEL_CUSTOMIZATION_NAME, null, new HashMap<>(), "vmxnjr001_AVPN_base_vPE_BV_base", null, true);
+ VfModule vfModuleDetails = createVfModule("201673MowAvpnVpeBvL..AVPN_base_vPE_BV..module-0", VF_MODULE_0_MODEL_VERSION_ID, VF_MODULE_0_MODEL_CUSTOMIZATION_NAME, null, emptyList(), "vmxnjr001_AVPN_base_vPE_BV_base", null, true);
RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> result =
msoRequestBuilder.generateDeleteVfModuleRequest(vfModuleDetails, "az2018");
MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
@@ -636,16 +623,25 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
@Test
public void generateReplaceVfModuleRequest_whenThereAreSupplementaryParams_thenTheyAreAddToUserParams() {
- String expectedParams = "[{"
- + " \"vre_a_volume_size_0\" : \"100\","
- + " \"vmx_int_net_len\" : \"24\","
- + " \"availability_zone_0\": \"abc\""
- + " }]";
-
- Map<String, String> supplementaryParams = ImmutableMap.of(
- "vre_a_volume_size_0", "100",
- "vmx_int_net_len", "24",
- "availability_zone_0", "abc"
+ String expectedParams = "["
+ + " {"
+ + " \"name\": \"vre_a_volume_size_0\","
+ + " \"value\": \"100\""
+ + " },"
+ + " {"
+ + " \"name\": \"vmx_int_net_len\","
+ + " \"value\": \"24\""
+ + " },"
+ + " {"
+ + " \"name\": \"availability_zone_0\","
+ + " \"value\": \"abc\""
+ + " }"
+ + " ]";
+
+ List<UserParamNameAndValue> supplementaryParams = ImmutableList.of(
+ new UserParamNameAndValue( "vre_a_volume_size_0", "100"),
+ new UserParamNameAndValue("vmx_int_net_len", "24"),
+ new UserParamNameAndValue("availability_zone_0", "abc")
);
assertThat(generatedVfModuleReplaceRequest(null, null, supplementaryParams),
@@ -662,7 +658,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest {
}
private RequestDetailsWrapper<VfModuleOrVolumeGroupRequestDetails> generatedVfModuleReplaceRequest(
- Boolean retainAssignments, Boolean retainVolumeGroups, Map<String, String> supplementaryParams) {
+ Boolean retainAssignments, Boolean retainVolumeGroups, List<UserParamNameAndValue> supplementaryParams) {
when(featureManager.isActive(Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST)).thenReturn(true);
when(aaiClient.getCloudOwnerByCloudRegionId("regionOne")).thenReturn("irma-aic");
diff --git a/vid-app-common/src/test/java/org/onap/vid/services/UserParamsContainerTest.kt b/vid-app-common/src/test/java/org/onap/vid/services/UserParamsContainerTest.kt
new file mode 100644
index 000000000..511c4e5cb
--- /dev/null
+++ b/vid-app-common/src/test/java/org/onap/vid/services/UserParamsContainerTest.kt
@@ -0,0 +1,57 @@
+package org.onap.vid.services
+
+import org.hamcrest.CoreMatchers.equalTo
+import org.hamcrest.MatcherAssert
+import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.UserParamNameAndValue
+import org.testng.annotations.DataProvider
+import org.testng.annotations.Test
+
+class UserParamsContainerTest {
+
+ @DataProvider
+ fun userParamsDataProvider(): Array<Array<Any?>>? {
+ return arrayOf(
+ arrayOf<Any?>(
+ mapOf("a" to "b", "c" to "d"),
+ listOf(UserParamNameAndValue("e", "f"), UserParamNameAndValue("g", "h")),
+ mapOf("c" to "d", "a" to "b", "e" to "f", "g" to "h")
+ ),
+ arrayOf<Any?>(
+ mapOf("a" to "b", "c" to "g"),
+ listOf(UserParamNameAndValue("c", "d") , UserParamNameAndValue("e", "f")),
+ mapOf("c" to "d", "a" to "b", "e" to "f")
+ ),
+ arrayOf<Any?>(
+ emptyMap<String,String>(),
+ listOf(UserParamNameAndValue("c", "d"), UserParamNameAndValue("e", "f")),
+ mapOf("c" to "d", "e" to "f")
+ ),
+ arrayOf<Any?>(
+ mapOf("a" to "b", "c" to "d"),
+ emptyList<UserParamNameAndValue>(),
+ mapOf("a" to "b", "c" to "d")
+ ),
+ arrayOf<Any?>(
+ emptyMap<String,String>(),
+ emptyList<UserParamNameAndValue>(),
+ emptyMap<String,String>()
+ ),
+ arrayOf(
+ null,
+ emptyList<UserParamNameAndValue>(),
+ emptyMap<String,String>()
+ ),
+ arrayOf<Any?>(
+ emptyMap<String,String>(),
+ null,
+ emptyMap<String,String>()
+ )
+ )
+ }
+
+ @Test(dataProvider = "userParamsDataProvider")
+ fun testUserParamsConvertorCtor(instanceParams: Map<String, String>?, suppParams: List<UserParamNameAndValue>?, expected: Map<String, String>) {
+ val aggParams: Map<String, String> = UserParamsContainer(instanceParams, suppParams).params
+ MatcherAssert.assertThat("Aggregated params are not as expected", aggParams, equalTo(expected))
+ }
+} \ No newline at end of file
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json
index 1bce76097..84dcd730f 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request.json
@@ -59,11 +59,20 @@
],
"requestParameters": {
"usePreload": true,
- "userParams": [{
- "vre_a_volume_size_0" : "100",
- "vmx_int_net_len" : "24",
- "availability_zone_0": "mtpocdv-kvm-az01"
- }],
+ "userParams": [
+ {
+ "name": "vre_a_volume_size_0",
+ "value": "100"
+ },
+ {
+ "name": "vmx_int_net_len",
+ "value": "24"
+ },
+ {
+ "name": "availability_zone_0",
+ "value": "mtpocdv-kvm-az01"
+ }
+ ],
"testApi" : "VNF_API"
}
}
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json
index 1c0d2b981..026c16f7b 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_instance_name.json
@@ -49,11 +49,20 @@
],
"requestParameters": {
"usePreload": true,
- "userParams": [{
- "vre_a_volume_size_0" : "100",
- "vmx_int_net_len" : "24",
- "availability_zone_0": "mtpocdv-kvm-az01"
- }],
+ "userParams": [
+ {
+ "name": "vre_a_volume_size_0",
+ "value": "100"
+ },
+ {
+ "name": "vmx_int_net_len",
+ "value": "24"
+ },
+ {
+ "name": "availability_zone_0",
+ "value": "mtpocdv-kvm-az01"
+ }
+ ],
"testApi" : "VNF_API"
}
}
diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json
index 3581a475a..1d0b96eca 100644
--- a/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json
+++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule_instantiation_request_without_volume_group.json
@@ -50,11 +50,20 @@
],
"requestParameters": {
"usePreload": true,
- "userParams": [{
- "vre_a_volume_size_0" : "100",
- "vmx_int_net_len" : "24",
- "availability_zone_0": "mtpocdv-kvm-az01"
- }],
+ "userParams": [
+ {
+ "name": "vre_a_volume_size_0",
+ "value": "100"
+ },
+ {
+ "name": "vmx_int_net_len",
+ "value": "24"
+ },
+ {
+ "name": "availability_zone_0",
+ "value": "mtpocdv-kvm-az01"
+ }
+ ],
"testApi" : "VNF_API"
}
}