aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/aai/tasks/AAIUpdateTasksTest.java20
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java38
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java584
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java69
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json1
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json40
8 files changed, 383 insertions, 372 deletions
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
@@ -161,6 +161,26 @@ public class AAIUpdateTasksTest extends BaseTaskTest {
}
@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();
doNothing().when(aaiPnfResources).updateOrchestrationStatusPnf(pnf, OrchestrationStatus.ACTIVE);
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java
index 38c74eecc7..d7d6da209e 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java
@@ -149,6 +149,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest {
private void fillRequiredAppcExecutionFields() {
RequestContext context = new RequestContext();
context.setMsoRequestId("TEST-MSO-ID");
+ context.setRequestorId("testRequestorId");
execution.setVariable("aicIdentity", "AIC-TEST");
execution.setVariable("vmIdList", "VM-ID-LIST-TEST");
execution.setVariable("vserverIdList", "VSERVER-ID-LIST");
@@ -192,6 +193,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest {
"{\"request_parameters\":{\"host_ip_address\":\"10.10.10.10\"},\"configuration_parameters\":{\"name1\":\"value1\",\"name2\":\"value2\"}}");
context.setRequestParameters(requestParameters);
context.setMsoRequestId("TEST-MSO-ID");
+ context.setRequestorId("testRequestorId");
execution.setVariable("aicIdentity", "AIC-TEST");
execution.setVariable("vmIdList", "VM-ID-LIST-TEST");
execution.setVariable("vserverIdList", "VSERVER-ID-LIST");
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
index 1aa7640492..a7ee89f073 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionBBTasksTest.java
@@ -400,6 +400,42 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@Test
+ public void rollbackExecutionRollbackToCreatedWithFabricTest() {
+ execution.setVariable("isRollback", false);
+ execution.setVariable("handlingCode", "RollbackToCreated");
+ execution.setVariable("requestAction", EMPTY_STRING);
+ execution.setVariable("resourceName", EMPTY_STRING);
+ List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
+
+ BuildingBlock buildingBlock1 = new BuildingBlock().setBpmnFlowName("AssignVfModuleBB");
+ ExecuteBuildingBlock ebb1 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock1);
+ flowsToExecute.add(ebb1);
+
+ BuildingBlock buildingBlock2 = new BuildingBlock().setBpmnFlowName("CreateVfModuleBB");
+ ExecuteBuildingBlock ebb2 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock2);
+ flowsToExecute.add(ebb2);
+
+ BuildingBlock buildingBlock3 = new BuildingBlock().setBpmnFlowName("ActivateVfModuleBB");
+ ExecuteBuildingBlock ebb3 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock3);
+ flowsToExecute.add(ebb3);
+
+ BuildingBlock buildingBlock4 = new BuildingBlock().setBpmnFlowName("AddFabricConfigurationBB");
+ ExecuteBuildingBlock ebb4 = new ExecuteBuildingBlock().setBuildingBlock(buildingBlock4);
+ flowsToExecute.add(ebb4);
+
+ execution.setVariable("flowsToExecute", flowsToExecute);
+ execution.setVariable("gCurrentSequence", 4);
+
+ workflowActionBBTasks.rollbackExecutionPath(execution);
+ List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
+ assertEquals(0, execution.getVariable("gCurrentSequence"));
+ assertEquals(2, ebbs.size());
+ assertEquals("DeleteFabricConfigurationBB", ebbs.get(0).getBuildingBlock().getBpmnFlowName());
+ assertEquals("DeactivateVfModuleBB", ebbs.get(1).getBuildingBlock().getBpmnFlowName());
+
+ }
+
+ @Test
public void rollbackExecutionRollbackToCreatedTest() {
execution.setVariable("isRollback", false);
execution.setVariable("handlingCode", "RollbackToCreated");
@@ -642,7 +678,7 @@ public class WorkflowActionBBTasksTest extends BaseTaskTest {
}
@Test
- public void getConfigurationId() {
+ public void getConfigurationId() throws Exception {
org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
vnfc.setModelInvariantId("modelInvariantId");
vnfc.setVnfcName("testVnfcName");
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 8f104566a4..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
@@ -43,6 +43,7 @@ import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.when;
+import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -116,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
@@ -163,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();
@@ -188,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();
@@ -213,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");
@@ -235,87 +230,11 @@ public class WorkflowActionTest extends BaseTaskTest {
}
@Test
- public void selectExecutionListExceptionAlreadyBuiltTest() throws Exception {
- DelegateExecution delegateExecution = new DelegateExecutionFake();
- String gAction = "deleteInstance";
- String resource = "VfModule";
- delegateExecution.setVariable("mso-request-id", "00f704ca-c5e5-4f95-a72c-6889db7b0688");
- delegateExecution.setVariable("requestAction", gAction);
- String bpmnRequest =
- new String(Files.readAllBytes(Paths.get("src/test/resources/__files/VfModuleCreateWithFabric.json")));
- delegateExecution.setVariable("bpmnRequest", bpmnRequest);
- delegateExecution.setVariable("aLaCarte", true);
- delegateExecution.setVariable("apiVersion", "7");
- delegateExecution.setVariable("requestUri",
- "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
-
- NorthBoundRequest northBoundRequest = new NorthBoundRequest();
- List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
- "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
- northBoundRequest.setOrchestrationFlowList(orchFlows);
-
- when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
- true, "my-custom-cloud-owner")).thenReturn(northBoundRequest);
-
- doAnswer(invocation -> {
- DelegateExecutionFake execution = invocation.getArgument(0);
- execution.setVariable("WorkflowException", "exception");
- execution.setVariable("WorkflowExceptionErrorMessage", "errorMessage");
- throw new BpmnError("WorkflowException");
- }).when(exceptionUtil).buildAndThrowWorkflowException(delegateExecution, 7000,
- "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations");
-
-
- org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
- vnf.setVnfId("vnf0");
- vnf.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
-
- org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
- vfModule.setModelCustomizationId("modelCustomizationId");
- when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
-
- List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
- vnfcs.add(vnfc);
- doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
-
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
- org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
- configuration.setConfigurationId("configurationId");
- configuration.setModelCustomizationId("modelCustimizationId");
- configuration.setConfigurationName("testConfigurationName");
- configurations.add(configuration);
- org.onap.aai.domain.yang.Configuration configuration1 = new org.onap.aai.domain.yang.Configuration();
- configuration1.setConfigurationId("configurationId");
- configuration1.setModelCustomizationId("modelCustimizationId");
- configuration1.setConfigurationName("testConfigurationName");
- configurations.add(configuration1);
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any());
-
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(any());
-
- thrown.expect(BpmnError.class);
- SPY_workflowAction.selectExecutionList(delegateExecution);
- assertEquals(
- "Exception in getConfigBuildingBlock: Multiple relationships exist from VNFC testVnfcName to Configurations",
- delegateExecution.getVariable("WorkflowException"));
- }
-
- @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."))
@@ -334,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<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB",
"AssignVolumeGroupBB", "AssignVfModuleBB");
@@ -388,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<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "AssignNetworkBB", "AssignVnfBB",
"AssignVolumeGroupBB", "AssignVfModuleBB");
@@ -443,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<OrchestrationFlow> orchFlows =
createFlowList("CreateNetworkBB", "ActivateNetworkBB", "CreateVolumeGroupBB", "ActivateVolumeGroupBB",
@@ -467,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();
@@ -497,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<OrchestrationFlow> orchFlows = createFlowList("DeactivateServiceInstanceBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
@@ -529,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<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
@@ -561,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<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
@@ -597,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<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
@@ -692,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<OrchestrationFlow> orchFlows = createFlowList("AssignServiceInstanceBB", "CreateNetworkCollectionBB",
"AssignNetworkBB", "AssignVnfBB", "AssignVolumeGroupBB", "AssignVfModuleBB", "CreateNetworkBB",
@@ -774,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<OrchestrationFlow> 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();
@@ -797,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);
@@ -810,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);
@@ -819,24 +687,53 @@ public class WorkflowActionTest extends BaseTaskTest {
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) 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<OrchestrationFlow> 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<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) 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<OrchestrationFlow> orchFlows = createFlowList("UnassignVfModuleBB", "UnassignVolumeGroupBB",
"UnassignVnfBB", "UnassignNetworkBB", "UnassignServiceInstanceBB");
@@ -876,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<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
"DeactivateVolumeGroupBB", "DeleteVolumeGroupBB", "DeactivateVnfBB", "DeactivateNetworkBB",
@@ -925,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");
@@ -979,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");
@@ -1052,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<OrchestrationFlow> orchFlows = createFlowList("CreateNetworkCollectionBB", "AssignNetworkBB",
"CreateNetworkBB", "ActivateNetworkBB", "ActivateNetworkCollectionBB");
@@ -1089,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();
@@ -1124,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<OrchestrationFlow> orchFlows = createFlowList("AssignVfModuleBB", "CreateVfModuleBB", "ActivateVfModuleBB",
"AssignFabricConfigurationBB", "ActivateFabricConfigurationBB");
@@ -1151,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");
@@ -1210,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");
@@ -1236,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");
@@ -1261,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");
@@ -1294,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");
@@ -1327,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");
@@ -1368,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");
@@ -1409,16 +1238,11 @@ public class WorkflowActionTest extends BaseTaskTest {
vnfcs.add(vnfc);
doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(), any(), any());
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
configuration.setConfigurationId("configurationId");
configuration.setModelCustomizationId("modelCustimizationId");
configuration.setConfigurationName("testConfigurationName");
- configurations.add(configuration);
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any());
-
- doReturn("testVnfcName").when(SPY_workflowAction).getVnfcNameForConfiguration(any());
+ doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(any(), any(), any());
NorthBoundRequest northBoundRequest = new NorthBoundRequest();
northBoundRequest.setOrchestrationFlowList(replaceVfModuleWithFabricOrchFlows);
@@ -1436,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");
@@ -1476,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");
@@ -1513,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");
@@ -1549,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");
@@ -1591,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");
@@ -1634,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");
@@ -1669,18 +1463,13 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
anyObject());
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
configuration.setConfigurationId("configurationId");
configuration.setModelCustomizationId("modelCustimizationId");
configuration.setConfigurationName("testConfigurationName");
- configurations.add(configuration);
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
+ doReturn(configuration).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
anyObject());
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
-
SPY_workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB",
@@ -1692,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");
@@ -1738,22 +1526,92 @@ public class WorkflowActionTest extends BaseTaskTest {
}
@Test
- public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception {
+ public void getConfigBuildingBlocksTest() throws Exception {
String gAction = "deleteInstance";
- String resource = "VfModule";
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
+
+ WorkflowType resourceType = WorkflowType.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");
+ execution.setVariable("vnfId", "1234");
+ execution.setVariable("vfModuleId", "vfModuleId1234");
+ execution.setVariable("requestUri",
+ "v7/serviceInstances/f647e3ef-6d2e-4cd3-bff4-8df4634208de/vnfs/b80b16a5-f80d-4ffa-91c8-bd47c7438a3d/vfModules");
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+ RequestDetails requestDetails = sIRequest.getRequestDetails();
+ String requestAction = "deleteInstance";
+ String requestId = "9c944122-d161-4280-8594-48c06a9d96d5";
+ boolean aLaCarte = true;
+ String apiVersion = "7";
+ String vnfType = "vnfType";
+ String key = "00d15ebb-c80e-43c1-80f0-90c40dde70b0";
+ String resourceId = "d1d35800-783d-42d3-82f6-d654c5054a6e";
+ Resource resourceKey = new Resource(resourceType, key, aLaCarte);
+ WorkflowResourceIds workflowResourceIds = SPY_workflowAction.populateResourceIdsFromApiHandler(execution);
+
+ List<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
+ "UnassignVfModuleBB", "DeleteFabricConfigurationBB");
+
+ ConfigBuildingBlocksDataObject dataObj = new ConfigBuildingBlocksDataObject().setsIRequest(sIRequest)
+ .setOrchFlows(orchFlows).setRequestId(requestId).setResourceKey(resourceKey).setApiVersion(apiVersion)
+ .setResourceId(resourceId).setRequestAction(requestAction).setaLaCarte(aLaCarte).setVnfType(vnfType)
+ .setWorkflowResourceIds(workflowResourceIds).setRequestDetails(requestDetails).setExecution(execution);
+
+ org.onap.aai.domain.yang.GenericVnf vnf = new org.onap.aai.domain.yang.GenericVnf();
+ vnf.setVnfId("vnf0");
+ vnf.setModelCustomizationId("modelCustomizationId");
+ when(bbSetupUtils.getAAIGenericVnf(any())).thenReturn(vnf);
+
+ org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule();
+ vfModule.setModelCustomizationId("modelCustomizationId");
+
+ org.onap.aai.domain.yang.Configuration config1 = new org.onap.aai.domain.yang.Configuration();
+ config1.setConfigurationId("config1");
+ org.onap.aai.domain.yang.Configuration config2 = new org.onap.aai.domain.yang.Configuration();
+ config2.setConfigurationId("config2");
+
+ List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
+ org.onap.aai.domain.yang.Vnfc vnfc1 = new org.onap.aai.domain.yang.Vnfc();
+ vnfc1.setVnfcName("zauk53avetd02svm001");
+ org.onap.aai.domain.yang.Vnfc vnfc2 = new org.onap.aai.domain.yang.Vnfc();
+ vnfc2.setVnfcName("zauk53avetd02tvm001");
+ vnfcs.add(vnfc1);
+ vnfcs.add(vnfc2);
+
+ when(bbSetupUtils.getAAIVfModule(any(), any())).thenReturn(vfModule);
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(any(), any(),
+ eq(org.onap.aai.domain.yang.Vnfc.class), eq(AAIObjectType.VNFC));
+ doReturn(config1).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc1),
+ eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION));
+ doReturn(config2).when(SPY_workflowAction).getRelatedResourcesInVnfc(eq(vnfc2),
+ eq(org.onap.aai.domain.yang.Configuration.class), eq(AAIObjectType.CONFIGURATION));
+
+ List<ExecuteBuildingBlock> results = SPY_workflowAction.getConfigBuildingBlocks(dataObj);
+
+ assertFalse(results.isEmpty());
+ assertEquals(2, results.size());
+ assertEquals("config1", results.get(0).getWorkflowResourceIds().getConfigurationId());
+ assertEquals("config2", results.get(1).getWorkflowResourceIds().getConfigurationId());
+ assertEquals("zauk53avetd02svm001", results.get(0).getConfigurationResourceKeys().getVnfcName());
+ assertEquals("zauk53avetd02tvm001", results.get(1).getConfigurationResourceKeys().getVnfcName());
+ }
+
+ @Test
+ public void selectExecutionListALaCarteVfModuleNoFabricDeleteTest() throws Exception {
+ String gAction = "deleteInstance";
+ String resource = "VfModule";
+ 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<OrchestrationFlow> orchFlows = createFlowList("DeactivateVfModuleBB", "DeleteVfModuleBB",
- "UnassignVfModuleBB", "DeactivateFabricConfigurationBB", "UnassignFabricConfigurationBB");
+ "UnassignVfModuleBB", "DeleteFabricConfigurationBB");
northBoundRequest.setOrchestrationFlowList(orchFlows);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
@@ -1769,21 +1627,10 @@ public class WorkflowActionTest extends BaseTaskTest {
when(bbSetupUtils.getAAIVfModule(anyObject(), anyObject())).thenReturn(vfModule);
List<org.onap.aai.domain.yang.Vnfc> vnfcs = new ArrayList<org.onap.aai.domain.yang.Vnfc>();
- org.onap.aai.domain.yang.Vnfc vnfc = new org.onap.aai.domain.yang.Vnfc();
- vnfc.setModelInvariantId("modelInvariantId");
- vnfc.setVnfcName("testVnfcName");
- vnfcs.add(vnfc);
- doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
- anyObject());
- List<org.onap.aai.domain.yang.Configuration> configurations =
- new ArrayList<org.onap.aai.domain.yang.Configuration>();
- org.onap.aai.domain.yang.Configuration configuration = new org.onap.aai.domain.yang.Configuration();
- doReturn(configurations).when(SPY_workflowAction).getRelatedResourcesInVnfc(anyObject(), anyObject(),
+ doReturn(vnfcs).when(SPY_workflowAction).getRelatedResourcesInVfModule(anyObject(), anyObject(), anyObject(),
anyObject());
- doReturn("testName").when(SPY_workflowAction).getVnfcNameForConfiguration(anyObject());
-
SPY_workflowAction.selectExecutionList(execution);
List<ExecuteBuildingBlock> ebbs = (List<ExecuteBuildingBlock>) execution.getVariable("flowsToExecute");
assertEqualsBulkFlowName(ebbs, "DeactivateVfModuleBB", "DeleteVfModuleBB", "UnassignVfModuleBB");
@@ -1793,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();
@@ -1853,10 +1695,9 @@ public class WorkflowActionTest extends BaseTaskTest {
doReturn(configurationResultWrappers).when(SPY_workflowAction).getResultWrappersFromRelationships(anyObject(),
anyObject());
- List<org.onap.aai.domain.yang.Configuration> configurationsList = SPY_workflowAction.getRelatedResourcesInVnfc(
- vnfc, org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
- assertEquals(1, configurationsList.size());
- assertEquals("testConfigurationId", configurationsList.get(0).getConfigurationId());
+ org.onap.aai.domain.yang.Configuration configuration = SPY_workflowAction.getRelatedResourcesInVnfc(vnfc,
+ org.onap.aai.domain.yang.Configuration.class, AAIObjectType.CONFIGURATION);
+ assertEquals("testConfigurationId", configuration.getConfigurationId());
}
/**
@@ -3034,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<Resource> resourceCounter = new ArrayList<>();
@@ -3211,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/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
index 59cd53edd5..b8be045f97 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java
@@ -48,13 +48,18 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf;
import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoPnf;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@RunWith(MockitoJUnitRunner.Silent.class)
public class AAIPnfResourcesTest extends TestDataSetup {
+ public static final String TEST_VERSION = "testVersion";
private static final String PNF_NAME = "pnfTest";
+ public static final String TEST_CUSTOMIZATION_UUID = "testCustomizationUuid";
+ public static final String TEST_INVARIANT_UUID = "testInvariantUuid";
+ public static final String TEST_ROLE = "testRole";
private Pnf pnf;
private ServiceInstance serviceInstance;
@@ -110,42 +115,87 @@ public class AAIPnfResourcesTest extends TestDataSetup {
@Test
public void existingPnfInAaiWithInventoriedStatusCanBeUsed() throws Exception {
// given
+ Pnf pnfTest = createPnfWithDefaultName();
org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(OrchestrationStatus.INVENTORIED.toString());
when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class,
AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai));
// when
- testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME);
+ testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest);
+ verify(aaiResourcesClientMock, times(1)).update(any(), any());
}
@Test
public void existingPnfInAaiWithNullStatusCanBeUsed() throws Exception {
// given
+ Pnf pnfTest = createPnfWithDefaultName();
org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(null);
+ pnfTest.setRole("test");
when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class,
AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai));
// when
- testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME);
+ testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest);
+ verify(aaiResourcesClientMock, times(1)).update(any(), eq(pnfFromAai));
+ }
+
+ @Test
+ public void existingPnfInAaiIsUpdated() throws Exception {
+ // given
+ org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(null);
+ Pnf pnfTest = getPnfWithTestValues();
+ when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai));
+ // when
+ testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest);
+ verify(aaiResourcesClientMock, times(1)).update(any(), eq(pnfFromAai));
+ verifyPnfFromAai(pnfFromAai);
+ }
+
+ private void verifyPnfFromAai(org.onap.aai.domain.yang.Pnf pnf) {
+ assertEquals(OrchestrationStatus.INVENTORIED.toString(), pnf.getOrchestrationStatus());
+ assertEquals(TEST_ROLE, pnf.getNfRole());
+ assertEquals(TEST_CUSTOMIZATION_UUID, pnf.getModelCustomizationId());
+ assertEquals(TEST_INVARIANT_UUID, pnf.getModelInvariantId());
+ assertEquals(TEST_VERSION, pnf.getModelVersionId());
+ }
+
+ private Pnf getPnfWithTestValues() {
+ Pnf pnfTest = createPnfWithDefaultName();
+ ModelInfoPnf modelInfoPnf = getModelInfoPnf();
+ pnfTest.setModelInfoPnf(modelInfoPnf);
+ pnfTest.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
+ pnfTest.setRole(TEST_ROLE);
+ return pnfTest;
+ }
+
+ private ModelInfoPnf getModelInfoPnf() {
+ ModelInfoPnf modelInfoPnf = new ModelInfoPnf();
+ modelInfoPnf.setModelCustomizationUuid(TEST_CUSTOMIZATION_UUID);
+ modelInfoPnf.setModelInvariantUuid(TEST_INVARIANT_UUID);
+ modelInfoPnf.setModelUuid(TEST_VERSION);
+ return modelInfoPnf;
}
@Test
public void existingPnfInAaiWithEmptyStatusCanBeUsed() throws Exception {
// given
+ Pnf pnfTest = createPnfWithDefaultName();
org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(Strings.EMPTY);
when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class,
AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai));
// when
- testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME);
+ testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest);
}
@Test
public void existingPnfInAaiCanNotBeUsed() {
// given
+ Pnf pnfTest = createPnfWithDefaultName();
org.onap.aai.domain.yang.Pnf pnfFromAai = createPnf(OrchestrationStatus.ACTIVE.toString());
when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class,
AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai));
// when
try {
- testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME);
+ testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest);
} catch (Exception e) {
// then
assertThat(e.getMessage()).isEqualTo(String.format(
@@ -153,6 +203,7 @@ public class AAIPnfResourcesTest extends TestDataSetup {
+ "if status is not set or set as Inventoried",
PNF_NAME));
}
+ verify(aaiResourcesClientMock, times(0)).update(any(), any());
}
@Test
@@ -161,19 +212,21 @@ public class AAIPnfResourcesTest extends TestDataSetup {
final String relatedTo = "service-instance";
final String serviceInstanceId = "service-instance-id";
final String path = "src/test/resources/__files/BuildingBlocks/aaiPnf.json";
+ Pnf pnfTest = createPnfWithDefaultName();
org.onap.aai.domain.yang.Pnf pnfFromAai =
new ObjectMapper().readValue(new File(path), org.onap.aai.domain.yang.Pnf.class);
when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class,
AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai));
// when
try {
- testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME);
+ testedObject.checkIfPnfExistsInAaiAndCanBeUsed(pnfTest);
} catch (Exception e) {
// then
assertThat(e.getMessage()).isEqualTo(String.format(
"Pnf with name %s exist with orchestration status %s and is related to %s service with certain service-instance-id: %s",
PNF_NAME, OrchestrationStatus.ACTIVE, relatedTo, serviceInstanceId));
}
+ verify(aaiResourcesClientMock, times(0)).update(any(), any());
}
private org.onap.aai.domain.yang.Pnf createPnf(String orchestrationStatus) {
@@ -182,4 +235,10 @@ public class AAIPnfResourcesTest extends TestDataSetup {
pnfFromAai.setOrchestrationStatus(orchestrationStatus);
return pnfFromAai;
}
+
+ private Pnf createPnfWithDefaultName() {
+ Pnf pnfTest = new Pnf();
+ pnfTest.setPnfName(PNF_NAME);
+ return pnfTest;
+ }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json
index 957c603dc9..191e0ac40e 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json
@@ -2,6 +2,7 @@
"ApplicationControllerTaskRequest": {
"controllerType": "TEST-CONTROLLER-NAME",
"action": "Lock",
+ "requestorId": "testRequestorId",
"identityUrl": "IDENTITY-URL-TEST",
"applicationControllerVnf": {
"vnfId": "TEST-VNF-ID",
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json
index 040c680d1c..724f096a4e 100644
--- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json
@@ -2,6 +2,7 @@
"ApplicationControllerTaskRequest": {
"controllerType": "APPC",
"action": "ConfigModify",
+ "requestorId": "testRequestorId",
"identityUrl": "IDENTITY-URL-TEST",
"applicationControllerVnf": {
"vnfId": "TEST-VNF-ID",
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json
new file mode 100644
index 0000000000..ac047a9638
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/aaiVfModule.json
@@ -0,0 +1,40 @@
+{
+ "automated-assignment": false,
+ "heat-stack-id": "zauk53avetd02_base/5c7a8a55-edb8-458e-a7dc-2dbbc696682e",
+ "is-base-vf-module": true,
+ "model-customization-id": "521d5f9b-0b76-49d3-879e-fce8767f34eb",
+ "model-invariant-id": "f0ac6f78-543f-41ac-81c3-672a4d47001c",
+ "model-version-id": "215ea5bd-f0e0-4560-9f64-9a9716ff6178",
+ "module-index": 0,
+ "orchestration-status": "Active",
+ "relationship-list": {
+ "relationship": [
+ {
+ "related-link": "/aai/v20/network/vnfcs/vnfc/zauk53avetd02svm001",
+ "related-to": "vnfc",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "zauk53avetd02svm001"
+ }
+ ],
+ "relationship-label": "org.onap.relationships.inventory.Uses"
+ },
+ {
+ "related-link": "/aai/v20/network/vnfcs/vnfc/zauk53avetd02tvm001",
+ "related-to": "vnfc",
+ "relationship-data": [
+ {
+ "relationship-key": "vnfc.vnfc-name",
+ "relationship-value": "zauk53avetd02tvm001"
+ }
+ ],
+ "relationship-label": "org.onap.relationships.inventory.Uses"
+ }
+ ]
+ },
+ "resource-version": "1595304004908",
+ "selflink": "restconf/config/GENERIC-RESOURCE-API:services/service/16b9c65d-70c7-47f0-aa03-7cdb8dfb76be/service-data/vnfs/vnf/9cf22c37-4f39-4fa5-a942-b72efc8f6450/vnf-data/vf-modules/vf-module/2cf0ecd4-737c-4a46-9097-adc2f0088483/vf-module-data/vf-module-topology/",
+ "vf-module-id": "2cf0ecd4-737c-4a46-9097-adc2f0088483",
+ "vf-module-name": "zauk53avetd02_base"
+} \ No newline at end of file