From 4180d54d46aebca6bba531241d01759615887e2c Mon Sep 17 00:00:00 2001 From: Mateusz Gołuchowski Date: Thu, 30 Jul 2020 15:33:03 +0200 Subject: Create DeactivatePnfBB and include it into Service-Macro-Delete flow. - created DeactivatePnfBB which changes orchestration status to inventoried when invoked - included BB into flow in R_MacroData script which initializes database - added support for mapping of service relations to PNFs - changed version of logging-analytics to 1.6.7 Issue-ID: SO-3111 Change-Id: I375db2014887f1f634adac31d4d1af3675f5911c Signed-off-by: Mateusz Goluchowski --- .../main/resources/db/migration/R__MacroData.sql | 22 +- .../servicedecomposition/tasks/BBInputSetup.java | 15 + .../tasks/BBInputSetupMapperLayer.java | 5 + .../tasks/BBInputSetupMapperLayerTest.java | 13 +- .../tasks/BBInputSetupTest.java | 24 ++ .../__files/ExecuteBuildingBlock/PnfExpected.json | 8 + .../__files/ExecuteBuildingBlock/aaiPnfInput.json | 38 ++ .../subprocess/BuildingBlock/DeactivatePnfBB.bpmn | 56 +++ .../infrastructure/aai/tasks/AAIUpdateTasks.java | 7 + .../workflow/tasks/WorkflowAction.java | 13 + .../aai/tasks/AAIUpdateTasksTest.java | 20 + .../workflow/tasks/WorkflowActionTest.java | 407 +++++++-------------- pom.xml | 6 +- 13 files changed, 351 insertions(+), 283 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfExpected.json create mode 100644 bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiPnfInput.json create mode 100644 bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivatePnfBB.bpmn diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index 9e81fbc024..91a0dbd1f0 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -84,16 +84,17 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('Service-Macro-Delete', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '4', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '5', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '6', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '7', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '8', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '9', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '10', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '11', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '12', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '13', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '14', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '15', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '6', 'DeactivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '7', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '8', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '9', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '10', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '11', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '12', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '13', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '14', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '15', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '16', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '1', 'AssignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '2', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '3', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), @@ -280,6 +281,7 @@ VALUES ('DeactivateVolumeGroupBB', 'VOLUME_GROUP', 'DEACTIVATE'), ('DeactivateVfModuleBB', 'VF_MODULE', 'DEACTIVATE'), ('DeactivateNetworkBB', 'NETWORK', 'DEACTIVATE'), +('DeactivatePnfBB', 'NO_VALIDATE', 'DEACTIVATE'), ('ChangeModelServiceInstanceBB', 'SERVICE', 'CHANGEMODEL'), diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 0cdf8a6e5d..e65e1a8471 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -62,6 +62,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys; @@ -1854,6 +1855,7 @@ public class BBInputSetup implements JavaDelegate { this.mapOwningEntity(relationships.getByType(AAIObjectType.OWNING_ENTITY), serviceInstance); this.mapL3Networks(relationships.getRelatedAAIUris(AAIObjectType.L3_NETWORK), serviceInstance.getNetworks()); this.mapGenericVnfs(relationships.getRelatedAAIUris(AAIObjectType.GENERIC_VNF), serviceInstance.getVnfs()); + this.mapPnfs(relationships.getRelatedAAIUris(AAIObjectType.PNF), serviceInstance.getPnfs()); this.mapCollection(relationships.getByType(AAIObjectType.COLLECTION), serviceInstance); this.mapConfigurations(relationships.getRelatedAAIUris(AAIObjectType.CONFIGURATION), serviceInstance.getConfigurations()); @@ -1905,6 +1907,19 @@ public class BBInputSetup implements JavaDelegate { return genericVnf; } + protected void mapPnfs(List list, List pnfs) { + for (AAIResourceUri aaiResourceUri : list) { + pnfs.add(this.mapPnf(aaiResourceUri)); + } + } + + protected Pnf mapPnf(AAIResourceUri aaiResourceUri) { + AAIResultWrapper aaiPnfWrapper = this.bbInputSetupUtils.getAAIResourceDepthOne(aaiResourceUri); + Optional aaiPnfWrapperOp = + aaiPnfWrapper.asBean(org.onap.aai.domain.yang.Pnf.class); + return aaiPnfWrapperOp.map(pnf -> this.mapperLayer.mapAAIPnfIntoPnf(pnf)).orElse(null); + } + protected List mapInstanceGroups(List instanceGroups) { List instanceGroupsList = new ArrayList<>(); for (AAIResultWrapper volumeGroupWrapper : instanceGroups) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 67d073d7b6..2bb383e4ec 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -52,6 +52,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet; import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.bbobjects.Vnfc; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBinding; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; @@ -323,6 +324,10 @@ public class BBInputSetupMapperLayer { return genericVnf; } + protected Pnf mapAAIPnfIntoPnf(org.onap.aai.domain.yang.Pnf aaiPnf) { + return modelMapper.map(aaiPnf, Pnf.class); + } + protected void mapAllLicensesIntoGenericVnf(org.onap.aai.domain.yang.GenericVnf aaiGenericVnf, GenericVnf genericVnf) { if (aaiGenericVnf.getLicenses() != null) { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 13d2b7d3d3..4755e58582 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -39,6 +39,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; @@ -75,7 +76,6 @@ import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; -import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfcCustomization; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.RequestDetails; @@ -421,6 +421,17 @@ public class BBInputSetupMapperLayerTest { assertThat(actual, sameBeanAs(expected)); } + @Test + public void testMapAAIPnfIntoPnf() throws IOException { + Pnf expected = mapper.readValue(new File(RESOURCE_PATH + "PnfExpected.json"), Pnf.class); + org.onap.aai.domain.yang.Pnf aaiPnf = + mapper.readValue(new File(RESOURCE_PATH + "aaiPnfInput.json"), org.onap.aai.domain.yang.Pnf.class); + + Pnf actual = bbInputSetupMapperLayer.mapAAIPnfIntoPnf(aaiPnf); + + assertThat(actual, sameBeanAs(expected)); + } + @Test public void testMapAAICollectionIntoCollection() throws JsonParseException, JsonMappingException, IOException { org.onap.aai.domain.yang.Collection aaiCollection = mapper diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java index 9e9c6f365f..dd79d2772f 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupTest.java @@ -69,6 +69,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; @@ -1814,6 +1815,29 @@ public class BBInputSetupTest { verify(SPY_bbInputSetup, times(1)).mapVolumeGroups(any()); } + @Test + public void testMapPnfs() throws JsonProcessingException { + org.onap.aai.domain.yang.Pnf expectedAAI = new org.onap.aai.domain.yang.Pnf(); + org.onap.aai.domain.yang.RelationshipList relationshipList = new org.onap.aai.domain.yang.RelationshipList(); + org.onap.aai.domain.yang.Relationship relationship = new org.onap.aai.domain.yang.Relationship(); + relationshipList.getRelationship().add(relationship); + expectedAAI.setRelationshipList(relationshipList); + + Pnf expected = new Pnf(); + AAIResourceUri aaiResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.PNF, "pnfId"); + AAIResultWrapper pnfWrapper = + new AAIResultWrapper(new AAICommonObjectMapperProvider().getMapper().writeValueAsString(expectedAAI)); + + doReturn(pnfWrapper).when(SPY_bbInputSetupUtils).getAAIResourceDepthOne(aaiResourceUri); + doReturn(expected).when(bbInputSetupMapperLayer).mapAAIPnfIntoPnf(isA(org.onap.aai.domain.yang.Pnf.class)); + + List pnfs = new ArrayList<>(); + + SPY_bbInputSetup.mapPnfs(Arrays.asList(aaiResourceUri), pnfs); + + assertEquals(expected, pnfs.get(0)); + } + @Test public void testMapVolumeGroups() throws JsonProcessingException { org.onap.aai.domain.yang.VolumeGroup expectedAAI = new org.onap.aai.domain.yang.VolumeGroup(); diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfExpected.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfExpected.json new file mode 100644 index 0000000000..460f72aa31 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/PnfExpected.json @@ -0,0 +1,8 @@ +{ + "pnf-id":"pnfId", + "pnf-name":"pnfName", + "nf-role":"gNB", + "orchestration-status":"INVENTORIED", + "cloud-region":null, + "model-info-pnf":null +} \ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiPnfInput.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiPnfInput.json new file mode 100644 index 0000000000..da0039c923 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiPnfInput.json @@ -0,0 +1,38 @@ +{ + "pnfName":"pnfName", + "pnfName2":null, + "selflink":null, + "pnfName2Source":null, + "pnfId":"pnfId", + "nfNamingCode":null, + "equipType":null, + "equipVendor":null, + "equipModel":null, + "managementOption":null, + "orchestrationStatus":"INVENTORIED", + "ipaddressV4Oam":null, + "swVersion":null, + "inMaint":null, + "frameId":null, + "serialNumber":null, + "ipaddressV4Loopback0":null, + "ipaddressV6Loopback0":null, + "ipaddressV4Aim":null, + "ipaddressV6Aim":null, + "ipaddressV6Oam":null, + "invStatus":null, + "resourceVersion":null, + "provStatus":null, + "nfRole":"gNB", + "adminStatus":null, + "operationalStatus":null, + "modelCustomizationId":null, + "modelInvariantId":null, + "modelVersionId":null, + "pnfIpv4Address":null, + "pnfIpv6Address":null, + "softwareVersions":null, + "relationshipList":null, + "lagInterfaces":null, + "vrfs":null +} \ No newline at end of file diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivatePnfBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivatePnfBB.bpmn new file mode 100644 index 0000000000..f01f81073b --- /dev/null +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/DeactivatePnfBB.bpmn @@ -0,0 +1,56 @@ + + + + + + + + + + + + SequenceFlow_0l6rtzy + + + SequenceFlow_1fu9o4x + SequenceFlow_0l6rtzy + + + SequenceFlow_1fu9o4x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java index cc630232c2..6c989093ab 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasks.java @@ -89,6 +89,13 @@ public class AAIUpdateTasks { updateOrchestrationStatusForPnf(execution, OrchestrationStatus.ASSIGNED); } + /** + * BPMN access method to update status of Pnf to Inventoried in AAI + */ + public void updateOrchestrationStatusInventoriedPnf(BuildingBlockExecution execution) { + updateOrchestrationStatusForPnf(execution, OrchestrationStatus.INVENTORIED); + } + /** * BPMN access method to update status of Pnf to Active in AAI */ diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 6f11882281..985114abcd 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -936,6 +936,7 @@ public class WorkflowAction { bbInputSetup.getExistingServiceInstance(serviceInstanceAAI); resourceList.add(new Resource(WorkflowType.SERVICE, serviceInstanceMSO.getServiceInstanceId(), false)); traverseServiceInstanceMSOVnfs(resourceList, aaiResourceIds, serviceInstanceMSO); + traverseServiceInstanceMSOPnfs(resourceList, aaiResourceIds, serviceInstanceMSO); if (serviceInstanceMSO.getNetworks() != null) { for (org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network network : serviceInstanceMSO .getNetworks()) { @@ -993,6 +994,18 @@ public class WorkflowAction { } } + private void traverseServiceInstanceMSOPnfs(List resourceList, + List> aaiResourceIds, + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO) { + if (serviceInstanceMSO.getPnfs() == null) { + return; + } + for (org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf : serviceInstanceMSO.getPnfs()) { + aaiResourceIds.add(new Pair<>(WorkflowType.PNF, pnf.getPnfId())); + resourceList.add(new Resource(WorkflowType.PNF, pnf.getPnfId(), false)); + } + } + private void traverseVnfModules(List resourceList, List> aaiResourceIds, org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf) { if (vnf.getVfModules() == null) { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java index a7dfe7f7a4..28d2abc792 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java @@ -160,6 +160,26 @@ public class AAIUpdateTasksTest extends BaseTaskTest { aaiUpdateTasks.updateOrchestrationStatusAssignedPnf(execution); } + @Test + public void updateOrchestrationStatusInventoriedPnfTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.INVENTORIED); + + aaiUpdateTasks.updateOrchestrationStatusInventoriedPnf(execution); + + verify(aaiPnfResources, times(1)).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.INVENTORIED); + } + + @Test + public void updateOrchestrationStatusInventoriedPnfExceptionTest() throws Exception { + Pnf pnf = preparePnfAndExtractForPnf(); + doThrow(RuntimeException.class).when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, + OrchestrationStatus.INVENTORIED); + + expectedException.expect(BpmnError.class); + aaiUpdateTasks.updateOrchestrationStatusInventoriedPnf(execution); + } + @Test public void updateOrchestrationStatusActivePnfTest() throws Exception { Pnf pnf = preparePnfAndExtractForPnf(); diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index e975f44426..407a844c4e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -117,6 +117,15 @@ import org.springframework.core.env.Environment; public class WorkflowActionTest extends BaseTaskTest { + private static final String MACRO_ACTIVATE_DELETE_UNASSIGN_JSON = "Macro/ServiceMacroActivateDeleteUnassign.json"; + private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json"; + private static final String MACRO_ASSIGN_NO_CLOUD_JSON = "Macro/ServiceMacroAssignNoCloud.json"; + private static final String VF_MODULE_CREATE_WITH_FABRIC_JSON = "VfModuleCreateWithFabric.json"; + private static final String VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON = + "VfModuleReplaceRebuildVolumeGroups.json"; + private static final String MACRO_CREATE_NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json"; + private static final String MACRO_VNF_MACRO_REPLACE_JSON = "Macro/VnfMacroReplace.json"; + @Mock protected Environment environment; @InjectMocks @@ -164,13 +173,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteNetworkCreateTest() throws Exception { String gAction = "createInstance"; String resource = "Network"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/networks/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -189,13 +193,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteNetworkDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "Network"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/networks/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -214,13 +213,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteServiceCreateTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/serviceInstances/123"); @@ -238,14 +232,9 @@ public class WorkflowActionTest extends BaseTaskTest { @Test public void selectExecutionListDuplicateNameExceptionTest() throws Exception { String gAction = "createInstance"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v6/serviceInstances"); - execution.setVariable("requestAction", gAction); doThrow(new DuplicateNameException( "serviceInstance with name (instanceName) and different version id (3c40d244-808e-42ca-b09a-256d83d19d0a) already exists. The name must be unique.")) @@ -264,16 +253,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroAssignTest() throws Exception { String gAction = "assignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB"); @@ -318,16 +301,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroAssignNoCloudTest() throws Exception { String gAction = "assignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssignNoCloud.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_NO_CLOUD_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB"); @@ -373,16 +350,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroActivateTest() throws Exception { String gAction = "activateInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/si0"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB", @@ -397,7 +368,6 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); vnf.setVnfId("vnf0"); - org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule2 = buildVfModule(); @@ -427,23 +397,16 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals("testVfModuleId2", ebbs.get(5).getWorkflowResourceIds().getVfModuleId()); assertEquals("vnf0", ebbs.get(6).getWorkflowResourceIds().getVnfId()); assertEquals("si0", ebbs.get(7).getWorkflowResourceIds().getServiceInstanceId()); - } @Test public void selectExecutionListServiceMacroDeactivateTest() throws Exception { String gAction = "deactivateInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("DeactivateServiceInstanceBB"); northBoundRequest.setOrchestrationFlowList(orchFlows); @@ -459,16 +422,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroEmptyServiceTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -491,16 +448,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateJustNetworkTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -527,16 +478,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateWithNetworkCollectionTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); northBoundRequest.setIsToplevelflow(true); List orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", @@ -622,16 +567,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroCreateWithUserParams() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB", "AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB", @@ -704,21 +643,16 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", - "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB", - "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", - "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB"); + "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", + "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", + "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", + "UnassignServiceInstanceBB"); northBoundRequest.setOrchestrationFlowList(orchFlows); ServiceInstance serviceInstanceAAI = new ServiceInstance(); @@ -727,7 +661,10 @@ public class WorkflowActionTest extends BaseTaskTest { new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance(); org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf vnf = new org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf(); + org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = + new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf(); vnf.setVnfId("vnfId123"); + pnf.setPnfId("pnfId123"); org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule vfModule = buildVfModule(); vnf.getVfModules().add(vfModule); @@ -740,6 +677,7 @@ public class WorkflowActionTest extends BaseTaskTest { vnf.getVolumeGroups().add(volumeGroup); serviceInstanceMSO.getVnfs().add(vnf); + serviceInstanceMSO.getPnfs().add(pnf); doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); @@ -749,24 +687,53 @@ public class WorkflowActionTest extends BaseTaskTest { List ebbs = (List) execution.getVariable("flowsToExecute"); assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeactivateVfModuleBB", "DeleteVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", - "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", "UnassignVolumeGroupBB", - "UnassignVnfBB", "UnassignServiceInstanceBB"); + "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignVfModuleBB", "UnassignVfModuleBB", + "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignServiceInstanceBB"); + } + + @Test + public void selectExecutionListServiceMacroDeleteWithPnfTest() throws Exception { + String gAction = "deleteInstance"; + String resource = "Service"; + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); + execution.setVariable("requestUri", "v6/serviceInstances/123"); + + NorthBoundRequest northBoundRequest = new NorthBoundRequest(); + List orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", + "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivatePnfBB", + "DeactivateNetworkBB", "DeleteNetworkBB", "DeleteNetworkCollectionBB", "DeactivateServiceInstanceBB", + "UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", + "UnassignServiceInstanceBB"); + northBoundRequest.setOrchestrationFlowList(orchFlows); + + ServiceInstance serviceInstanceAAI = new ServiceInstance(); + serviceInstanceAAI.setServiceInstanceId("aaisi123"); + org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstanceMSO = + new org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance(); + org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf pnf = + new org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf(); + pnf.setPnfId("pnfId123"); + + serviceInstanceMSO.getPnfs().add(pnf); + + doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123"); + doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI); + when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource, + false, "my-custom-cloud-owner")).thenReturn(northBoundRequest); + workflowAction.selectExecutionList(execution); + List ebbs = (List) execution.getVariable("flowsToExecute"); + assertEqualsBulkFlowName(ebbs, "DeactivatePnfBB", "DeactivateServiceInstanceBB", "UnassignServiceInstanceBB"); } @Test public void selectExecutionListServiceMacroUnassignTest() throws Exception { String gAction = "unassignInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("UnassignVfModuleBB", "UnassignVolumeGroupBB", "UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB"); @@ -806,16 +773,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListServiceMacroDeleteNetworkCollectionTest() throws Exception { String gAction = "deleteInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB", "DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB", @@ -855,13 +816,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListVnfMacroRecreateTest() throws Exception { String gAction = "recreateInstance"; String resource = "Vnf"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/recreate"); execution.setVariable("serviceInstanceId", "123"); execution.setVariable("vnfId", "1234"); @@ -909,13 +865,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListVnfMacroReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "Vnf"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/VnfMacroReplace.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_VNF_MACRO_REPLACE_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v7/serviceInstances/123/vnfs/1234/replace"); execution.setVariable("serviceInstanceId", "123"); execution.setVariable("vnfId", "1234"); @@ -982,16 +933,10 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListNetworkCollectionMacroCreate() throws Exception { String gAction = "createInstance"; String resource = "NetworkCollection"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_NETWORK_COLLECTION_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("CreateNetworkCollectionBB", "AssignNetworkBB", "CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB"); @@ -1019,13 +964,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListNetworkCollectionMacroDelete() throws Exception { String gAction = "deleteInstance"; String resource = "NetworkCollection"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/CreateNetworkCollection.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_CREATE_NETWORK_COLLECTION_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123/networkCollections/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -1054,17 +994,11 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoFabricCreateTest() throws Exception { String gAction = "createInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); - NorthBoundRequest northBoundRequest = new NorthBoundRequest(); List orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB", "AssignFabricConfigurationBB", "ActivateFabricConfigurationBB"); @@ -1081,13 +1015,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleFabricCreateTest() throws Exception { String gAction = "createInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); @@ -1140,13 +1069,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); @@ -1166,13 +1090,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); @@ -1191,13 +1110,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleVolumeGroupToNoVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1224,13 +1138,8 @@ public class WorkflowActionTest extends BaseTaskTest { throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1257,13 +1166,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1298,13 +1202,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleWithFabricKeepVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1361,13 +1260,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleKeepVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1401,13 +1295,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoVolumeGroupToVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1438,13 +1327,8 @@ public class WorkflowActionTest extends BaseTaskTest { throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1474,13 +1358,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceTest() throws Exception { String gAction = "replaceInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1516,13 +1395,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleRebuildVolumeGroupReplaceRetainAssignmentsTest() throws Exception { String gAction = "replaceInstanceRetainAssignments"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = new String( - Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleReplaceRebuildVolumeGroups.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_REPLACE_REBUILD_VOLUME_GROUPS_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules/1234"); execution.setVariable("vnfId", "b80b16a5-f80d-4ffa-91c8-bd47c7438a3d"); @@ -1559,13 +1433,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); @@ -1612,10 +1481,9 @@ public class WorkflowActionTest extends BaseTaskTest { String gAction = "deleteInstance"; ObjectMapper mapper = new ObjectMapper(); WorkflowType resourceType = WorkflowType.VFMODULE; + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); execution.setVariable("bpmnRequest", bpmnRequest); execution.setVariable("vnfId", "1234"); execution.setVariable("vfModuleId", "vfModuleId1234"); @@ -1736,13 +1604,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception { String gAction = "deleteInstance"; String resource = "VfModule"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", true); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(VF_MODULE_CREATE_WITH_FABRIC_JSON); + initExecution(gAction, bpmnRequest, true); execution.setVariable("requestUri", "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules"); @@ -1777,13 +1640,8 @@ public class WorkflowActionTest extends BaseTaskTest { public void selectExecutionListMacroResumeTest() throws Exception { String gAction = "createInstance"; String resource = "Service"; - execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); - execution.setVariable("requestAction", gAction); - String bpmnRequest = - new String(Files.readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroAssign.json"))); - execution.setVariable("bpmnRequest", bpmnRequest); - execution.setVariable("aLaCarte", false); - execution.setVariable("apiVersion", "7"); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON); + initExecution(gAction, bpmnRequest, false); execution.setVariable("requestUri", "v6/serviceInstances/123"); NorthBoundRequest northBoundRequest = new NorthBoundRequest(); @@ -3017,8 +2875,7 @@ public class WorkflowActionTest extends BaseTaskTest { doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a"); doReturn(collectionResourceCustomization).when(catalogDbClient) .getNetworkCollectionResourceCustomizationByID("123"); - String bpmnRequest = new String(Files - .readAllBytes(Paths.get("src/test/resources/__files/Macro/ServiceMacroActivateDeleteUnassign.json"))); + String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON); ObjectMapper mapper = new ObjectMapper(); ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class); List resourceCounter = new ArrayList<>(); @@ -3194,4 +3051,16 @@ public class WorkflowActionTest extends BaseTaskTest { assertEquals(ebbs.get(i).getBuildingBlock().getBpmnFlowName(), flowNames[i]); } } + + private void initExecution(String gAction, String bpmnRequest, boolean isAlaCarte) { + execution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688"); + execution.setVariable("requestAction", gAction); + execution.setVariable("bpmnRequest", bpmnRequest); + execution.setVariable("aLaCarte", isAlaCarte); + execution.setVariable("apiVersion", "7"); + } + + private String readBpmnRequestFromFile(String fileName) throws IOException { + return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + fileName))); + } } diff --git a/pom.xml b/pom.xml index 0243def0ab..a9466bdae0 100644 --- a/pom.xml +++ b/pom.xml @@ -870,17 +870,17 @@ org.onap.logging-analytics logging-slf4j - 1.6.7-SNAPSHOT + 1.6.7 org.onap.logging-analytics logging-filter-base - 1.6.7-SNAPSHOT + 1.6.7 org.onap.logging-analytics logging-filter-spring - 1.6.7-SNAPSHOT + 1.6.7 org.apache.httpcomponents -- cgit 1.2.3-korg