diff options
author | Mateusz Gołuchowski <mateusz.goluchowski@nokia.com> | 2020-11-05 15:47:23 +0100 |
---|---|---|
committer | Ikram Ikramullah <ikram@research.att.com> | 2020-11-27 15:14:17 +0000 |
commit | 164596ffc56c1f9a4418a2f3b8f3941896b124f7 (patch) | |
tree | 6b622ce09273cad1e73735f77dd650624a54e5f1 /vid-app-common/src/test/java | |
parent | 3e558222d300ff70ff490914cc2245cf2a59e72a (diff) |
Update VID SO API call generation - include PNF instanceName parameter in SO API call (macro)
Creation of functionality to prepare service with PNF request which call SO.
Issue-ID: VID-695
Signed-off-by: Mateusz Goluchowski <mateusz.goluchowski@nokia.com>
Change-Id: I5285ac2ab5e95665244ca18c6549249d9330b1ed
Diffstat (limited to 'vid-app-common/src/test/java')
6 files changed, 61 insertions, 34 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java index 85faaab28..6d9ae13de 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/job/command/ResourceCommandTest.java @@ -286,6 +286,7 @@ public class ResourceCommandTest { static ServiceInstantiation createService(List<Vnf> vnfs, List<Network> networks, List<InstanceGroup> vnfGroups) { return new ServiceInstantiation(mock(ModelInfo.class), null, null, null, null, null, null, null, null, null, null, null, null, null, null, convertToMap(vnfs), + convertToMap(null), convertToMap(networks), convertToMap(vnfGroups), null, diff --git a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java index ce94a7096..62108d5aa 100644 --- a/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/job/impl/AsyncInstantiationIntegrationTest.java @@ -213,7 +213,7 @@ public class AsyncInstantiationIntegrationTest extends AsyncInstantiationBaseTes private List<UUID> pushMacroBulk() { ServiceInstantiation serviceInstantiation = generateMockMacroServiceInstantiationPayload(false, createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true), - 3, true,PROJECT_NAME, true); + createPnfList(), 3, true,PROJECT_NAME, true); return asyncInstantiationBL.pushBulkJob(serviceInstantiation, USER_ID); } 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 81ba9578f..632552e75 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 @@ -81,6 +81,7 @@ public class InstantiationModelSerializationTest { emptyMap(), emptyMap(), emptyMap(), + emptyMap(), instanceParams, true, 1, 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 738af18cf..7ed3e6795 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 @@ -57,13 +57,10 @@ import org.onap.vid.model.Action; import org.onap.vid.model.ServiceInfo; import org.onap.vid.model.ServiceInfo.ServiceAction; import org.onap.vid.model.VidNotions; -import org.onap.vid.model.serviceInstantiation.InstanceGroup; -import org.onap.vid.model.serviceInstantiation.Network; -import org.onap.vid.model.serviceInstantiation.ServiceInstantiation; -import org.onap.vid.model.serviceInstantiation.VfModule; -import org.onap.vid.model.serviceInstantiation.Vnf; +import org.onap.vid.model.serviceInstantiation.*; import org.onap.vid.mso.RestObject; import org.onap.vid.mso.model.ModelInfo; +import org.onap.vid.mso.model.ServiceInstantiationRequestDetails; import org.onap.vid.mso.model.ServiceInstantiationRequestDetails.UserParamNameAndValue; import org.onap.vid.mso.rest.AsyncRequestStatus; import org.onap.vid.mso.rest.RequestStatus; @@ -190,22 +187,22 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests } - public ServiceInstantiation generateMockMacroServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure) { - return generateMockServiceInstantiationPayload(isPause, vnfs, Collections.EMPTY_MAP, Collections.EMPTY_MAP, bulkSize, isUserProvidedNaming, projectName, rollbackOnFailure, false, null, Action.Create, null); + public ServiceInstantiation generateMockMacroServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs, Map<String, Pnf> pnfs, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure) { + return generateMockServiceInstantiationPayload(isPause, vnfs, pnfs, Collections.EMPTY_MAP, Collections.EMPTY_MAP, bulkSize, isUserProvidedNaming, projectName, rollbackOnFailure, false, null, Action.Create, null); } public ServiceInstantiation generateMockALaCarteServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs, Map<String, Network> networks, Map<String, InstanceGroup> vnfGroups, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure, String testApi) { - return generateMockServiceInstantiationPayload(isPause, vnfs, networks, vnfGroups, bulkSize, isUserProvidedNaming, projectName, rollbackOnFailure, true, testApi, Action.Create, null); + return generateMockServiceInstantiationPayload(isPause, vnfs, null, networks, vnfGroups, bulkSize, isUserProvidedNaming, projectName, rollbackOnFailure, true, testApi, Action.Create, null); } public ServiceInstantiation generateMockAlaCarteServiceDeletionPayload(boolean isPause, Map<String, Vnf> vnfs, Map<String, Network> networks, Map<String, InstanceGroup> vnfGroups, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure, String testApi, String instanceId) { - return generateMockServiceInstantiationPayload(isPause, vnfs, networks, vnfGroups, bulkSize, isUserProvidedNaming, projectName, rollbackOnFailure, true, testApi, Action.Delete, instanceId); + return generateMockServiceInstantiationPayload(isPause, vnfs, null, networks, vnfGroups, bulkSize, isUserProvidedNaming, projectName, rollbackOnFailure, true, testApi, Action.Delete, instanceId); } - public ServiceInstantiation generateMockServiceDeletionPayload(boolean isPause, Map<String, Vnf> vnfs, Map<String, Network> networks, Map<String, InstanceGroup> vnfGroups, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure, String testApi, String instanceId) { - return generateMockServiceInstantiationPayload(isPause, vnfs, networks, vnfGroups, bulkSize, isUserProvidedNaming, projectName, rollbackOnFailure, false, testApi, Action.Delete, instanceId); + public ServiceInstantiation generateMockServiceDeletionPayload(boolean isPause, Map<String, Vnf> vnfs, Map<String, Pnf> pnfs, Map<String, Network> networks, Map<String, InstanceGroup> vnfGroups, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure, String testApi, String instanceId) { + return generateMockServiceInstantiationPayload(isPause, vnfs, pnfs, networks, vnfGroups, bulkSize, isUserProvidedNaming, projectName, rollbackOnFailure, false, testApi, Action.Delete, instanceId); } - private ServiceInstantiation generateMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs, Map<String, Network> networks, Map<String, InstanceGroup> vnfGroups, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure, boolean isAlacarte, String testApi, Action action, String instanceId) { + private ServiceInstantiation generateMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs, Map<String, Pnf> pnfs, Map<String, Network> networks, Map<String, InstanceGroup> vnfGroups, int bulkSize, boolean isUserProvidedNaming, String projectName, boolean rollbackOnFailure, boolean isAlacarte, String testApi, Action action, String instanceId) { ModelInfo modelInfo = createModelInfo(); List<Map<String,String>> instanceParams = createInstanceParams(); @@ -226,6 +223,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests AsyncInstantiationBusinessLogicTest.AIC_ZONE_ID, AsyncInstantiationBusinessLogicTest.AIC_ZONE_NAME, vnfs, + pnfs, networks, vnfGroups, null, @@ -304,6 +302,26 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests return createModelInfo("vnf", modelName, modelVersion, modelVersionId, modelInvariantId, modelCustomizationId, modelCustomizationName); } + protected ModelInfo createPnfModelInfo() { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelCustomizationName("modelCustomizationName"); + modelInfo.setModelCustomizationId("modelCustomizationId"); + modelInfo.setModelInvariantId("modelInvariantId"); + modelInfo.setModelVersionId("modelVersionId"); + modelInfo.setModelName("modelName"); + modelInfo.setModelType("pnf"); + modelInfo.setModelVersion("1.0"); + return modelInfo; + } + + protected Pnf createPnf() { + ModelInfo modelInfo = createPnfModelInfo(); + List<Map<String, String>> instanceParams = new ArrayList<>(); + + return new Pnf(modelInfo, "productFamilyId", "instanceName", null, "platformName", null, null, + null, instanceParams, "lineOfBusinessName", true,null, null, null, null, null, null); + } + private ModelInfo createNetworkModelInfo(boolean isAlacarte, String modelCustomizationId) { ModelInfo modelInfo = new ModelInfo(); @@ -373,6 +391,16 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests return vnfs; } + protected Map<String, Pnf> createPnfList() { + Map<String, Pnf> pnfs = new HashMap<>(); + Pnf pnf = createPnf(); + + pnfs.put(pnf.getModelInfo().getModelName(), pnf); + + + return pnfs; + } + protected void mockAaiClientAaiStatusOK() { when(aaiClient.isNodeTypeExistsByName(eq(AsyncInstantiationBusinessLogicImpl.NAME_FOR_CHECK_AAI_STATUS), any())).thenReturn(false); } @@ -387,8 +415,8 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests enableAddCloudOwnerOnMsoRequest(true); } - protected ServiceInstantiation generateMacroMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs) { - return generateMockMacroServiceInstantiationPayload(isPause, vnfs, 1, true, PROJECT_NAME, false); + protected ServiceInstantiation generateMacroMockServiceInstantiationPayload(boolean isPause, Map<String, Vnf> vnfs, Map<String, Pnf> pnfs) { + return generateMockMacroServiceInstantiationPayload(isPause, vnfs, pnfs,1, true, PROJECT_NAME, false); } protected ServiceInstantiation generatePre1806MacroTransportServiceInstantiationPayload(String tenantId, String lcpCloudRegionId) { @@ -397,7 +425,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests ServiceInstantiation serviceInstantiation = new ServiceInstantiation(createServiceModelInfo(), "038d99af-0427-42c2-9d15-971b99b9b489", "JULIO ERICKSON", "some_project_name", "some_subscriber_id", "some_subscriber_name", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb", null, "MOG", lcpCloudRegionId, null, tenantId, - null, null, null, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, instanceParams, false, 1, false, false, + null, null, null, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, Collections.EMPTY_MAP, instanceParams, false, 1, false, false, null, null, null, null, null, null, new VidNotions(InstantiationUI.TRANSPORT_SERVICE, ModelCategory.Transport, InstantiationUI.TRANSPORT_SERVICE, InstantiationType.Macro), "originalName" ); @@ -516,7 +544,7 @@ public class AsyncInstantiationBaseTest extends AbstractTestNGSpringContextTests "foo:002", instanceGroup2, "foo:003", instanceGroup3 ); - return generateMockServiceInstantiationPayload(false, emptyMap(), emptyMap(), groups, + return generateMockServiceInstantiationPayload(false, emptyMap(), emptyMap(), emptyMap(), groups, 1, true, PROJECT_NAME, false, true, "VNF_API", Action.None, "1234567890"); } diff --git a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java index 284efce45..5ff05a471 100644 --- a/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/services/AsyncInstantiationBusinessLogicTest.java @@ -409,7 +409,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT @Test(dataProvider = "pauseAndInstanceParams") public void createMacroServiceInstantiationMsoRequestUniqueName(Boolean isPause, HashMap<String, String> vfModuleInstanceParamsMap, List vnfInstanceParams) throws Exception { defineMocks(); - ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(isPause, createVnfList(vfModuleInstanceParamsMap, vnfInstanceParams, true), 2, true, PROJECT_NAME, false); + ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(isPause, createVnfList(vfModuleInstanceParamsMap, vnfInstanceParams, true), null, 2, true, PROJECT_NAME, false); final URL resource = this.getClass().getResource("/payload_jsons/bulk_service_request_unique_names.json"); when(jobAdapterMock.createServiceInstantiationJob(any(), any(), any(), any(), any(), anyString(), any())).thenAnswer(invocation -> { Object[] args = invocation.getArguments(); @@ -481,7 +481,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT final ServiceInstantiation request = generateMockMacroServiceInstantiationPayload( false, createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true), - bulkSize, isUserProvidedNaming, projectName, true + createPnfList(), bulkSize, isUserProvidedNaming, projectName, true ); // in "createServiceInstantiationJob()" we will probe the service, with the generated names @@ -618,7 +618,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT ServiceInstantiation macroPayload = generateMockMacroServiceInstantiationPayload( false, createVnfList(instanceParamsMapWithoutParams, ImmutableList.of(vnfInstanceParamsMapWithParamsToRemove, vnfInstanceParamsMapWithParamsToRemove), true), - 2, false,PROJECT_NAME, false); + createPnfList(), 2, false,PROJECT_NAME, false); ServiceInstantiation aLaCartePayload = generateALaCarteServiceInstantiationPayload(); return new Object[][]{ @@ -733,7 +733,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT @Test(dataProvider = "isPauseAndPropertyDataProvider") public void testServiceInstantiationPath_RequestPathIsAsExpected(boolean isPause, String expectedProperty) { - ServiceInstantiation serviceInstantiationPauseFlagTrue = generateMacroMockServiceInstantiationPayload(isPause, createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true)); + ServiceInstantiation serviceInstantiationPauseFlagTrue = generateMacroMockServiceInstantiationPayload(isPause, createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true), createPnfList()); String path = asyncInstantiationBL.getServiceInstantiationPath(serviceInstantiationPauseFlagTrue); Assert.assertEquals(path, SystemProperties.getProperty(expectedProperty)); } @@ -752,7 +752,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT final ServiceInstantiation request = generateMockMacroServiceInstantiationPayload( false, createVnfList(instanceParamsMapWithoutParams, Collections.EMPTY_LIST, true), - 100, true,PROJECT_NAME, true + createPnfList(), 100, true,PROJECT_NAME, true ); pushJobAndAssertDates(startTestDate, request); @@ -1013,7 +1013,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT @Test public void pushBulkJob_verifyMacroFlow_useMacroServiceInstantiationJobType(){ - final ServiceInstantiation request = generateMacroMockServiceInstantiationPayload(false, Collections.emptyMap()); + final ServiceInstantiation request = generateMacroMockServiceInstantiationPayload(false, Collections.emptyMap(), Collections.emptyMap()); // in "createServiceInstantiationJob()" we will probe the service, with the generated names configureMockitoWithMockedJob(); @@ -1064,7 +1064,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT public void whenLcpRegionNotEmpty_thenCloudRegionIdOfServiceIsLegacy() { String legacyCloudRegion = "legacyCloudRegion"; ServiceInstantiation service = new ServiceInstantiation(new ModelInfo(), null, null, null, null, null, null, - null, null, "anyCloudRegion", legacyCloudRegion, null, null, null, null, null, null, null, null, null, + null, null, "anyCloudRegion", legacyCloudRegion, null, null, null, null, null, null, null, null, null, null, false, 1,false, false, null, null, Action.Create.name(), UUID.randomUUID().toString(), null, null, null, "originalName"); assertThat(service.getLcpCloudRegionId(), equalTo(legacyCloudRegion)); } @@ -1087,7 +1087,7 @@ public class AsyncInstantiationBusinessLogicTest extends AsyncInstantiationBaseT @NotNull protected ServiceInstantiation createServiceWithIsALaCarteAndAction(boolean isALaCarte, Action action) { return new ServiceInstantiation(new ModelInfo(), null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, null, null, false, 1, false, isALaCarte, null, null, action.name(), UUID.randomUUID().toString(), null, null, null, "originalName"); } 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 ef2a6a5fb..1fc3879a4 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 @@ -137,7 +137,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest { @Test(dataProvider = "pauseAndInstanceParams", enabled = false) //Test is irrelevant with unique names feature public void createMacroServiceInstantiationMsoRequest(Boolean isPause, HashMap<String, String> vfModuleInstanceParamsMap, List vnfInstanceParams) throws Exception { - ServiceInstantiation serviceInstantiationPayload = generateMacroMockServiceInstantiationPayload(isPause, createVnfList(vfModuleInstanceParamsMap, vnfInstanceParams, true)); + ServiceInstantiation serviceInstantiationPayload = generateMacroMockServiceInstantiationPayload(isPause, createVnfList(vfModuleInstanceParamsMap, vnfInstanceParams, true), createPnfList()); final URL resource = this.getClass().getResource("/payload_jsons/bulk_macro_service_request.json"); RequestDetailsWrapper<ServiceInstantiationRequestDetails> result = msoRequestBuilder.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016"); @@ -166,9 +166,8 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest { private void createMacroServiceInfo_WithUserProvidedNamingFalse_ServiceInfoIsAsExpected(boolean withVfmodules, boolean disabledHoming) throws IOException { ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true, - createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, EMPTY_LIST, false), - 1, - false, PROJECT_NAME, true); + createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, EMPTY_LIST, false), null, + 1, false, PROJECT_NAME, true); URL resource; if (disabledHoming) { resource = this.getClass().getResource("/payload_jsons/bulk_service_no_homing.json"); @@ -258,7 +257,7 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest { } private ServiceInstantiation generateServiceDeletionPayload() { - return generateMockServiceDeletionPayload(false, EMPTY_MAP, EMPTY_MAP, EMPTY_MAP, 1, true, PROJECT_NAME, false, "VNF_API", "1234567890"); + return generateMockServiceDeletionPayload(false, EMPTY_MAP, EMPTY_MAP, EMPTY_MAP, EMPTY_MAP,1, true, PROJECT_NAME, false, "VNF_API", "1234567890"); } @DataProvider @@ -484,16 +483,14 @@ public class MsoRequestBuilderTest extends AsyncInstantiationBaseTest { public void checkIfNullProjectNameSentToMso() { ServiceInstantiation serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true, createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, EMPTY_LIST, false), - 1, - false, null, false); + createPnfList(), 1, false, null, false); RequestDetailsWrapper<ServiceInstantiationRequestDetails> result = msoRequestBuilder.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016"); JsonNode jsonNode = new ObjectMapper().valueToTree(result.requestDetails); Assert.assertTrue(jsonNode.get("project").isNull()); serviceInstantiationPayload = generateMockMacroServiceInstantiationPayload(true, createVnfList(vfModuleInstanceParamsMapWithParamsToRemove, EMPTY_LIST, false), - 1, - false, "not null", false); + createPnfList(), 1, false, "not null", false); result = msoRequestBuilder.generateMacroServiceInstantiationRequest(null, serviceInstantiationPayload, serviceInstantiationPayload.getInstanceName(), "az2016"); jsonNode = new ObjectMapper().valueToTree(result.requestDetails); Assert.assertTrue(jsonNode.get("project").get("projectName").asText().equalsIgnoreCase("not null")); |