- final List<Vnf> vnfList = new ArrayList<>(createVnfList(new HashMap<>(), null, isUserProvidedNaming, true).values());
- ModelInfo siModelInfo = createServiceModelInfo();
- String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
-
- //we validate that the asyncInstantiationBL call to getUniqueName by simulate that aai retrun that original
- //vnf name is used, and only next picked name is free.
- Mockito.reset(aaiClient);
- mockAaiClientAaiStatusOK();
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_NAME), eq(ResourceType.GENERIC_VNF))).thenReturn(true);
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_NAME+"_001"), eq(ResourceType.GENERIC_VNF))).thenReturn(false);
- enableAddCloudOwnerOnMsoRequest(isFlagAddCloudOwnerActive);
-
- String expected = IOUtils.toString(this.getClass().getResource(file), "UTF-8");
- final RequestDetailsWrapper<VnfInstantiationRequestDetails> result = asyncInstantiationBL.generateVnfInstantiationRequest(vnfList.get(0), siModelInfo, serviceInstanceId, "pa0916");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @DataProvider
- public static Object[][] createVnfParameters() {
- return new Object[][]{
- {true, true, "/payload_jsons/bulk_vnf_request.json"},
- {false, true, "/payload_jsons/bulk_vnf_request_without_cloud_owner.json"},
- {true, false, "/payload_jsons/bulk_vnf_request_without_instance_name.json"},
- };
- }
-
- @DataProvider
- public static Object[][] vfModuleRequestDetails(Method test) {
- return new Object[][]{
- {"cc3514e3-5a33-55df-13ab-12abad84e7cc", true, "/payload_jsons/vfmodule_instantiation_request.json"},
- {null, true, "/payload_jsons/vfmodule_instantiation_request_without_volume_group.json"},
- {null, false, "/payload_jsons/vfmodule_instantiation_request_without_instance_name.json"}
- };
- }
-
- @Test(dataProvider = "vfModuleRequestDetails")
- public void createVfModuleRequestDetails_detailsAreAsExpected(String volumeGroupInstanceId, boolean isUserProvidedNaming, String fileName) throws IOException {
-
- ModelInfo siModelInfo = createServiceModelInfo();
- 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");
- 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);
-
- String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
- String vnfInstanceId = "bb3514e3-5a33-55df-13ab-12abad84e7bb";
-
- Mockito.reset(aaiClient);
- mockAaiClientAaiStatusOK();
- enableAddCloudOwnerOnMsoRequest();
- when(aaiClient.isNodeTypeExistsByName(eq("vmxnjr001_AVPN_base_vRE_BV_expansion"), eq(ResourceType.VF_MODULE))).thenReturn(false);
-
- String expected = IOUtils.toString(this.getClass().getResource(fileName), "UTF-8");
- final RequestDetailsWrapper<VfModuleInstantiationRequestDetails> result = asyncInstantiationBL.generateVfModuleInstantiationRequest(
- vfModule, siModelInfo, serviceInstanceId,
- vnfModelInfo, vnfInstanceId, volumeGroupInstanceId, "pa0916");
- 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<VfModuleInstantiationRequestDetails.UserParamMap<String, String>> expected) {
- List<VfModuleInstantiationRequestDetails.UserParamMap<String, String>> aggParams = ((AsyncInstantiationBusinessLogicImpl)asyncInstantiationBL).aggregateAllInstanceParams(instanceParams, suppParams);
- assertThat("Aggregated params are not as expected", aggParams, equalTo(expected));
- }
-
- @DataProvider
- public static Object[][] expectedNetworkRequestDetailsParameters() {
- return new Object[][]{
- {true, "/payload_jsons/network_instantiation_request.json"},
- {false, "/payload_jsons/network_instantiation_request_without_instance_name.json"}
- };
- }
-
- @Test(dataProvider = "expectedNetworkRequestDetailsParameters")
- public void createNetworkRequestDetails_detailsAreAsExpected(boolean isUserProvidedNaming, String filePath) throws IOException {
-
- final List<Network> networksList = new ArrayList<>(createNetworkList(null, isUserProvidedNaming, true).values());
- ModelInfo siModelInfo = createServiceModelInfo();
- String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
-
- Mockito.reset(aaiClient);
- mockAaiClientAaiStatusOK();
- enableAddCloudOwnerOnMsoRequest();
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_NAME), eq(ResourceType.L3_NETWORK))).thenReturn(true);
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_NAME+"_001"), eq(ResourceType.L3_NETWORK))).thenReturn(false);
-
- String expected = IOUtils.toString(this.getClass().getResource(filePath), "UTF-8");
- final RequestDetailsWrapper<NetworkInstantiationRequestDetails> result = asyncInstantiationBL.generateNetworkInstantiationRequest(networksList.get(0), siModelInfo, serviceInstanceId, "pa0916");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @Test
- public void createInstanceGroupRequestDetails_detailsAreAsExpected() throws IOException {
-
- final InstanceGroup instanceGroup = createInstanceGroup(true, Action.Create);
- ModelInfo siModelInfo = createServiceModelInfo();
- String serviceInstanceId = "aa3514e3-5a33-55df-13ab-12abad84e7aa";
-
- Mockito.reset(aaiClient);
- mockAaiClientAaiStatusOK();
- enableAddCloudOwnerOnMsoRequest();
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_GROUP_NAME), eq(ResourceType.INSTANCE_GROUP))).thenReturn(true);
- when(aaiClient.isNodeTypeExistsByName(eq(VNF_GROUP_NAME+"_001"), eq(ResourceType.INSTANCE_GROUP))).thenReturn(false);
-
- String expected = IOUtils.toString(this.getClass().getResource("/payload_jsons/instance_group_instantiation_request.json"), "UTF-8");
- final RequestDetailsWrapper<InstanceGroupInstantiationRequestDetails> result = asyncInstantiationBL.generateInstanceGroupInstantiationRequest(instanceGroup, siModelInfo, serviceInstanceId, "az2018");
- MsoOperationalEnvironmentTest.assertThatExpectationIsLikeObject(expected, result);
- }
-
- @Test
- public void checkIfNullProjectNameSentToMso(){
- ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true,
- createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
- 1,
- false,null,false);
- RequestDetailsWrapper<ServiceInstantiationRequestDetails> result =
- asyncInstantiationBL.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
- JsonNode jsonNode = new ObjectMapper().valueToTree(result.requestDetails);
- Assert.assertTrue(jsonNode.get("project").isNull());
- serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true,
- createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, Collections.EMPTY_LIST, false),
- 1,
- false,"not null",false);
- result = asyncInstantiationBL.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016");
- jsonNode = new ObjectMapper().valueToTree(result.requestDetails);
- Assert.assertTrue(jsonNode.get("project").get("projectName").asText().equalsIgnoreCase("not null"));
-
-
-
- }