aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2021-11-30 10:14:13 -0500
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-12-21 18:05:42 -0500
commita05bbfe4b578439411c58c2587cb28161af7a426 (patch)
tree41e45b645bbdda7647494a68584de63b0540a64c /bpmn/so-bpmn-tasks/src/test
parentac72b81b53a366fbd6d38d4563d81dac26480f72 (diff)
Use resource list for SkipCDSBuildingBlockListener
The listener was using a customizationId from the requestPayload. Since the requestPayload is slightly different for VNF LCM requests, this logic was inconsistent and not working properly. By adding modelCustomizationId and modelVersionId to the Resource class, the SkipCDSBuildingBlockListener can leverage this to perform more reliable lookups for customization objects. This also enables SkipCDSBuildingBlockListener to run for delete requests. Previously this would have failed as the resourceKey is instance-id in the delete case and customization-id in for create. By using the explicit property of the resource object, there will be no confusion. Issue-ID: SO-3807 Change-Id: I0922e5e7373990d9b409651cb4365e11d5618558 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca>
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java30
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java4
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java11
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java182
4 files changed, 104 insertions, 123 deletions
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 52196aae49..a044944f29 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
@@ -409,6 +409,10 @@ public class WorkflowActionTest extends BaseTaskTest {
serviceInstanceMSO.getVnfs().add(vnf);
+ VfModule aaiVfModule = new VfModule();
+ aaiVfModule.setIsBaseVfModule(false);
+
+ doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any());
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("si0");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any());
@@ -932,6 +936,10 @@ public class WorkflowActionTest extends BaseTaskTest {
serviceInstanceMSO.getVnfs().add(vnf);
serviceInstanceMSO.getPnfs().add(pnf);
+ VfModule aaiVfModule = new VfModule();
+ aaiVfModule.setIsBaseVfModule(false);
+
+ doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any());
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any());
@@ -1013,6 +1021,10 @@ public class WorkflowActionTest extends BaseTaskTest {
serviceInstanceMSO.getVnfs().add(vnf);
+ VfModule aaiVfModule = new VfModule();
+ aaiVfModule.setIsBaseVfModule(false);
+
+ doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any());
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
doReturn(Mockito.mock(GenericVnf.class)).when(bbSetupUtils).getAAIGenericVnf(any());
@@ -1104,6 +1116,11 @@ public class WorkflowActionTest extends BaseTaskTest {
serviceInstanceMSO.getVnfs().add(vnf);
+ org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
+ aaiVfModule.setIsBaseVfModule(false);
+
+ doReturn(aaiVfModule).when(bbSetupUtils).getAAIVfModule(any(), any());
+ doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(bbSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
@@ -1151,21 +1168,26 @@ public class WorkflowActionTest extends BaseTaskTest {
vfModule2.setVfModuleId("vfModule2");
vnf.getVfModules().add(vfModule2);
serviceInstanceMSO.getVnfs().add(vnf);
- VfModule vfModuleAAI = new VfModule();
- vfModuleAAI.setVfModuleId("vfModule2");
+ VfModule vfModuleAAI1 = new VfModule();
+ vfModuleAAI1.setIsBaseVfModule(false);
+ VfModule vfModuleAAI2 = new VfModule();
+ vfModuleAAI2.setIsBaseVfModule(false);
+ vfModuleAAI2.setVfModuleId("vfModule2");
RelationshipList relationshipList = new RelationshipList();
Relationship relationship = new Relationship();
relationshipList.getRelationship().add(relationship);
- vfModuleAAI.setRelationshipList(relationshipList);
+ vfModuleAAI2.setRelationshipList(relationshipList);
Relationships relationships = new Relationships("abc");
Configuration config = new Configuration();
config.setConfigurationId("configId");
Optional<Configuration> configOp = Optional.of(config);
Optional<Relationships> relationshipsOp = Optional.of(relationships);
+ doReturn(new org.onap.aai.domain.yang.GenericVnf()).when(bbSetupUtils).getAAIGenericVnf(vnf.getVnfId());
doReturn(relationshipsOp).when(workflowActionUtils).extractRelationshipsVnfc(isA(Relationships.class));
doReturn(configOp).when(workflowActionUtils).extractRelationshipsConfiguration(isA(Relationships.class));
- doReturn(vfModuleAAI).when(bbSetupUtils).getAAIVfModule("1234", "vfModule2");
+ doReturn(vfModuleAAI1).when(bbSetupUtils).getAAIVfModule("1234", "vfModule1");
+ doReturn(vfModuleAAI2).when(bbSetupUtils).getAAIVfModule("1234", "vfModule2");
doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById("123");
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
when(catalogDbClient.getNorthBoundRequestByActionAndIsALaCarteAndRequestScopeAndCloudOwner(gAction, resource,
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
index 2725626c1a..76763e8ca8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
@@ -239,6 +239,9 @@ public class ServiceEBBLoaderTest extends BaseTaskTest {
aaiConfiguration2.setConfigurationId("testConfigurationId2");
aaiConfiguration2.setRelationshipList(relationshipList1);
+ org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
+ aaiVfModule.setIsBaseVfModule(true);
+
try {
doReturn(genericVnfAai).when(mockBbInputSetupUtils).getAAIGenericVnf(genericVnf.getVnfId());
doReturn(serviceInstanceAAI).when(mockBbInputSetupUtils).getAAIServiceInstanceById(resourceId);
@@ -247,6 +250,7 @@ public class ServiceEBBLoaderTest extends BaseTaskTest {
.getConfiguration("testConfigurationId");
doReturn(Optional.of(aaiConfiguration2)).when(mockAaiConfigurationResources)
.getConfiguration("testConfigurationId2");
+ doReturn(aaiVfModule).when(mockBbInputSetupUtils).getAAIVfModule(any(), any());
serviceEBBLoader.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
assertEquals(8, resourceCounter.size());
assertTrue(resourceCounter.get(2).isBaseVfModule());
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java
index 78a9628243..2775c6d7b9 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoaderTest.java
@@ -47,12 +47,14 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.only;
public class VnfEBBLoaderTest {
private String serviceId;
private String vnfId;
+ private String vfModuleId;
private BBInputSetupUtils bbInputSetupUtils;
private BBInputSetup bbInputSetup;
private WorkflowActionExtractResourcesAAI workflowActionUtils;
@@ -67,6 +69,7 @@ public class VnfEBBLoaderTest {
public void setup() {
serviceId = "service123";
vnfId = "vnf123";
+ vfModuleId = "vfModule123";
serviceInstanceAAI = mock(org.onap.aai.domain.yang.ServiceInstance.class);
serviceInstanceMSO = mock(ServiceInstance.class);
bbInputSetupUtils = mock(BBInputSetupUtils.class);
@@ -95,11 +98,19 @@ public class VnfEBBLoaderTest {
GenericVnf genericVnf = mock(GenericVnf.class);
doReturn(vnfId).when(genericVnf).getVnfId();
+ org.onap.aai.domain.yang.GenericVnf aaiVnf = mock(org.onap.aai.domain.yang.GenericVnf.class);
+ doReturn(aaiVnf).when(bbInputSetupUtils).getAAIGenericVnf(vnfId);
+
VfModule vfModule = mock(VfModule.class);
+ doReturn(vfModuleId).when(vfModule).getVfModuleId();
ModelInfoVfModule modelInfoVfModule = new ModelInfoVfModule();
modelInfoVfModule.setIsBaseBoolean(true);
doReturn(modelInfoVfModule).when(vfModule).getModelInfoVfModule();
+ org.onap.aai.domain.yang.VfModule aaiVfModule = new org.onap.aai.domain.yang.VfModule();
+ aaiVfModule.setIsBaseVfModule(true);
+ doReturn(aaiVfModule).when(bbInputSetupUtils).getAAIVfModule(vnfId, vfModuleId);
+
doReturn(serviceInstanceAAI).when(bbInputSetupUtils).getAAIServiceInstanceById(serviceId);
doReturn(serviceInstanceMSO).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
doReturn(List.of(genericVnf)).when(serviceInstanceMSO).getVnfs();
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java
index b23147e351..1fbee2dbc8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListenerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
+import java.util.UUID;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
import org.junit.Before;
import org.junit.Test;
@@ -34,6 +35,8 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.BBConstants;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.db.catalog.beans.PnfResourceCustomization;
@@ -41,7 +44,6 @@ 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.client.CatalogDbClient;
-import org.onap.so.serviceinstancebeans.ModelInfo;
import org.onap.so.serviceinstancebeans.RequestDetails;
@RunWith(MockitoJUnitRunner.Silent.class)
@@ -51,25 +53,24 @@ public class SkipCDSBuildingBlockListenerTest {
private static final String VNF_SCOPE = "VNF";
private static final String VF_SCOPE = "VFModule";
private static final String PNF_SCOPE = "pnf";
- private static final String TEST_MODELUUID = "123456789";
private static final String VNF_TEST_ACTION = "VnfConfigAssign";
private static final String VFModule_TEST_ACTION = "VfModuleConfigAssign";
private static final String PNFModule_TEST_ACTION = "config-assign";
- private static final String MODELCUSTOMIZATIONUUID = "123456789";
+ private static final String SERVICE_MODEL_VERSION_ID = UUID.randomUUID().toString();
+ private static final String VNF_MODEL_CUSTOMIZATION_ID = UUID.randomUUID().toString();
+ private static final String VF_MODULE_CUSTOMIZATION_ID = UUID.randomUUID().toString();
+ private static final String PNF_CUSTOMIZATION_ID = UUID.randomUUID().toString();
private static final String BBNAME = "ControllerExecutionBB";
private static final boolean ISFIRST = true;
- private int actual;
private List<ExecuteBuildingBlock> flowsToExecute = new ArrayList<>();
- private List<VnfResourceCustomization> vnfResourceCustomization;
- private List<VfModuleCustomization> vfModuleCustomization;
- private ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock();
+ private ExecuteBuildingBlock executeBuildingBlock;
private RequestDetails reqDetail = new RequestDetails();
private BuildingBlockExecution buildingBlockExecution = new DelegateExecutionImpl(new DelegateExecutionFake());
- private VnfResourceCustomization vnfCust = new VnfResourceCustomization();
- private VfModuleCustomization vfCust = new VfModuleCustomization();
- private PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
- private BuildingBlock buildingBlock = new BuildingBlock();
+ private VnfResourceCustomization vnfCust;
+ private VfModuleCustomization vfCust;
+ private PnfResourceCustomization pnfResourceCustomization;
+ private BuildingBlock buildingBlock;
@InjectMocks
private SkipCDSBuildingBlockListener skipCDSBuildingBlockListener;
@@ -78,10 +79,27 @@ public class SkipCDSBuildingBlockListenerTest {
@Before
public void before() {
- ModelInfo model = new ModelInfo();
- model.setModelUuid(TEST_MODELUUID);
- reqDetail.setModelInfo(model);
- executeBuildingBlock.setRequestDetails(reqDetail);
+ executeBuildingBlock = new ExecuteBuildingBlock();
+ buildingBlock = new BuildingBlock();
+
+ ArrayList<Resource> resources = new ArrayList<>();
+ Resource service = new Resource(WorkflowType.SERVICE, SERVICE_MODEL_VERSION_ID, false, null);
+ service.setModelVersionId(SERVICE_MODEL_VERSION_ID);
+ resources.add(service);
+ Resource vnf = new Resource(WorkflowType.VNF, VNF_MODEL_CUSTOMIZATION_ID, false, null);
+ vnf.setModelCustomizationId(VNF_MODEL_CUSTOMIZATION_ID);
+ resources.add(vnf);
+ Resource vfModule = new Resource(WorkflowType.VFMODULE, VF_MODULE_CUSTOMIZATION_ID, false, null);
+ vfModule.setModelCustomizationId(VF_MODULE_CUSTOMIZATION_ID);
+ resources.add(vfModule);
+ Resource pnf = new Resource(WorkflowType.PNF, PNF_CUSTOMIZATION_ID, false, null);
+ pnf.setModelCustomizationId(PNF_CUSTOMIZATION_ID);
+ resources.add(pnf);
+ buildingBlockExecution.setVariable("resources", resources);
+
+ vnfCust = new VnfResourceCustomization();
+ vfCust = new VfModuleCustomization();
+ pnfResourceCustomization = new PnfResourceCustomization();
}
@Test
@@ -93,133 +111,83 @@ public class SkipCDSBuildingBlockListenerTest {
@Test
public void testSkipCDSforService() {
- setBuildingBlockAndCurrentSequence(SERVICE_SCOPE, "service-config-assign", 0);
- Service service = new Service();
- when(catalogDbClient.getServiceByID(TEST_MODELUUID)).thenReturn(service);
+ setBuildingBlockAndCurrentSequence(SERVICE_SCOPE, "service-config-assign", SERVICE_MODEL_VERSION_ID, 0);
+ when(catalogDbClient.getServiceByID(SERVICE_MODEL_VERSION_ID)).thenReturn(new Service());
skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
- actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
- assertEquals(1, actual);
+ assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE));
}
@Test
public void testProcessForVNFToSkipCDSBB() {
- // given
- setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0);
- vnfResourceCustomization = getVnfResourceCustomizationList(true);
+ setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, VNF_MODEL_CUSTOMIZATION_ID, 0);
+ when(catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(VNF_MODEL_CUSTOMIZATION_ID))
+ .thenReturn(vnfCust);
- when(catalogDbClient.getVnfResourceCustomizationByModelUuid(
- executeBuildingBlock.getRequestDetails().getModelInfo().getModelUuid()))
- .thenReturn(vnfResourceCustomization);
- when(catalogDbClient.findVnfResourceCustomizationInList(executeBuildingBlock.getBuildingBlock().getKey(),
- vnfResourceCustomization)).thenReturn(vnfCust);
-
- // when
skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
- // then
- actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
- assertEquals(1, actual);
-
+ assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE));
}
@Test
public void testProcessForVNFNotToSkipCDSBB() {
- // given
- setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, 0);
- vnfResourceCustomization = getVnfResourceCustomizationList(false);
-
- when(catalogDbClient.getVnfResourceCustomizationByModelUuid(
- executeBuildingBlock.getRequestDetails().getModelInfo().getModelUuid()))
- .thenReturn(vnfResourceCustomization);
- when(catalogDbClient.findVnfResourceCustomizationInList(executeBuildingBlock.getBuildingBlock().getKey(),
- vnfResourceCustomization)).thenReturn(vnfCust);
+ setBuildingBlockAndCurrentSequence(VNF_SCOPE, VNF_TEST_ACTION, VNF_MODEL_CUSTOMIZATION_ID, 0);
+ vnfCust.setSkipPostInstConf(false);
+ when(catalogDbClient.getVnfResourceCustomizationByModelCustomizationUUID(VNF_MODEL_CUSTOMIZATION_ID))
+ .thenReturn(vnfCust);
- // when
skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
- // then
- actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
- assertEquals(0, actual);
-
+ assertEquals(0, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE));
}
@Test
public void testProcessForVFToSkipCDSBB() {
- // given
- setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, 0);
- vfModuleCustomization = getVfModuleCustomizationList(true);
-
- when(catalogDbClient
- .getVfModuleCustomizationByModelCuztomizationUUID(executeBuildingBlock.getBuildingBlock().getKey()))
- .thenReturn(vfCust);
+ setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, VF_MODULE_CUSTOMIZATION_ID, 0);
+ when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(VF_MODULE_CUSTOMIZATION_ID))
+ .thenReturn(vfCust);
- // when
skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
- // then
- actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
- assertEquals(1, actual);
-
+ assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE));
}
@Test
public void testProcessForVFNotToSkipCDSBB() {
- // given
- setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, 0);
- vfModuleCustomization = getVfModuleCustomizationList(false);
-
+ setBuildingBlockAndCurrentSequence(VF_SCOPE, VFModule_TEST_ACTION, VF_MODULE_CUSTOMIZATION_ID, 0);
+ vfCust.setSkipPostInstConf(false);
when(catalogDbClient
.getVfModuleCustomizationByModelCuztomizationUUID(executeBuildingBlock.getBuildingBlock().getKey()))
.thenReturn(vfCust);
- // when
skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
- // then
- actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
- assertEquals(0, actual);
-
+ assertEquals(0, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE));
}
@Test
public void testProcessForPNFToSkipCDSBB() {
- // given
- setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, 0);
- pnfResourceCustomization = getPnfResourceCustomization(true);
-
- when(catalogDbClient
- .getPnfResourceCustomizationByModelCustomizationUUID(executeBuildingBlock.getBuildingBlock().getKey()))
- .thenReturn(pnfResourceCustomization);
+ setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, PNF_CUSTOMIZATION_ID, 0);
+ when(catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(PNF_CUSTOMIZATION_ID))
+ .thenReturn(pnfResourceCustomization);
- // when
skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
- // then
- actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
- assertEquals(1, actual);
-
+ assertEquals(1, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE));
}
@Test
public void testProcessForPNFNotToSkipCDSBB() {
- // given
- setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, 0);
- pnfResourceCustomization = getPnfResourceCustomization(false);
-
- when(catalogDbClient
- .getPnfResourceCustomizationByModelCustomizationUUID(executeBuildingBlock.getBuildingBlock().getKey()))
- .thenReturn(pnfResourceCustomization);
+ setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, PNF_CUSTOMIZATION_ID, 0);
+ pnfResourceCustomization.setSkipPostInstConf(false);
+ when(catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(PNF_CUSTOMIZATION_ID))
+ .thenReturn(pnfResourceCustomization);
- // when
skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution);
- // then
- actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE);
- assertEquals(0, actual);
-
+ assertEquals(0, (int) buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE));
}
/**
@@ -229,37 +197,13 @@ public class SkipCDSBuildingBlockListenerTest {
* @param action
* @param squence
*/
- private void setBuildingBlockAndCurrentSequence(String scope, String action, int sequence) {
+ private void setBuildingBlockAndCurrentSequence(String scope, String action, String key, int sequence) {
buildingBlock.setBpmnScope(scope);
buildingBlock.setBpmnAction(action);
buildingBlock.setBpmnFlowName("ControllerExecutionBB");
- buildingBlock.setKey(MODELCUSTOMIZATIONUUID);
+ buildingBlock.setKey(key);
executeBuildingBlock.setBuildingBlock(buildingBlock);
buildingBlockExecution.setVariable(BBConstants.G_CURRENT_SEQUENCE, sequence);
-
- }
-
- private List<VnfResourceCustomization> getVnfResourceCustomizationList(boolean setSkippost) {
- List<VnfResourceCustomization> vnfResourceCustomizations = new ArrayList<>();
- vnfCust.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID);
- vnfCust.setSkipPostInstConf(setSkippost);
- vnfResourceCustomizations.add(vnfCust);
- return vnfResourceCustomizations;
- }
-
- private List<VfModuleCustomization> getVfModuleCustomizationList(boolean setSkippost) {
- List<VfModuleCustomization> vfModuleCustomizations = new ArrayList<>();
- vfCust.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID);
- vfCust.setSkipPostInstConf(setSkippost);
- vfModuleCustomizations.add(vfCust);
- return vfModuleCustomizations;
- }
-
- private PnfResourceCustomization getPnfResourceCustomization(boolean setSkippost) {
- PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
- pnfResourceCustomization.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID);
- pnfResourceCustomization.setSkipPostInstConf(setSkippost);
- return pnfResourceCustomization;
}
}