From c759aa4e6aaec556711522e6204a1b0af859d4c5 Mon Sep 17 00:00:00 2001 From: mharazin Date: Tue, 13 Oct 2020 16:21:59 +0200 Subject: Fix skipPostInstConf for PNF Issue-ID: SO-3271 Signed-off-by: Mateusz Harazin Change-Id: I550a6582da1c7dd9d000ee9c7cfe421a293b9e59 --- .../listeners/SkipCDSBuildingBlockListener.java | 14 ++++++- .../SkipCDSBuildingBlockListenerTest.java | 49 ++++++++++++++++++++++ .../db/catalog/beans/PnfResourceCustomization.java | 6 +-- .../org/onap/so/db/catalog/beans/BeansTest.java | 8 ++-- 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java index 682a0471ee..2119ced951 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipCDSBuildingBlockListener.java @@ -29,6 +29,7 @@ import org.onap.so.bpmn.common.BBConstants; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulator; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -48,6 +49,9 @@ public class SkipCDSBuildingBlockListener implements FlowManipulator { private Set vFModuleAction = new HashSet(Arrays.asList("VfModuleConfigAssign", "VfModuleConfigDeploy")); + private Set pnfActions = + new HashSet<>(Arrays.asList("config-assign", "config-deploy", "PnfConfigAssign", "PnfConfigDeploy")); + @Override public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { @@ -95,9 +99,17 @@ public class SkipCDSBuildingBlockListener implements FlowManipulator { boolean skipVfModule = vfc.isSkipPostInstConf(); currentSequenceSkipCheck(execution, skipVfModule); } - } + } else if (currentBB.getBuildingBlock().getBpmnScope().equalsIgnoreCase("PNF") + && containsIgnoreCaseAction(currentBB, pnfActions)) { + PnfResourceCustomization pnfResourceCustomization = + catalogDbClient.getPnfResourceCustomizationByModelCustomizationUUID(customizationUUID); + if (null != pnfResourceCustomization) { + boolean skipConfigPNF = pnfResourceCustomization.isSkipPostInstConf(); + currentSequenceSkipCheck(execution, skipConfigPNF); + } + } } private boolean containsIgnoreCaseAction(ExecuteBuildingBlock currentBB, Set actions) { 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 fb162f857b..fdf4d36c89 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 @@ -36,6 +36,7 @@ import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.db.catalog.beans.PnfResourceCustomization; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -47,9 +48,11 @@ 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 BBNAME = "ControllerExecutionBB"; private static final boolean ISFIRST = true; @@ -63,6 +66,7 @@ public class SkipCDSBuildingBlockListenerTest { 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(); @InjectMocks @@ -166,6 +170,44 @@ public class SkipCDSBuildingBlockListenerTest { } + @Test + public void testProcessForPNFToSkipCDSBB() { + // given + setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, 0); + pnfResourceCustomization = getPnfResourceCustomization(true); + + when(catalogDbClient + .getPnfResourceCustomizationByModelCustomizationUUID(executeBuildingBlock.getBuildingBlock().getKey())) + .thenReturn(pnfResourceCustomization); + + // when + skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); + + // then + actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + assertEquals(1, actual); + + } + + @Test + public void testProcessForPNFNotToSkipCDSBB() { + // given + setBuildingBlockAndCurrentSequence(PNF_SCOPE, PNFModule_TEST_ACTION, 0); + pnfResourceCustomization = getPnfResourceCustomization(false); + + when(catalogDbClient + .getPnfResourceCustomizationByModelCustomizationUUID(executeBuildingBlock.getBuildingBlock().getKey())) + .thenReturn(pnfResourceCustomization); + + // when + skipCDSBuildingBlockListener.run(flowsToExecute, executeBuildingBlock, buildingBlockExecution); + + // then + actual = buildingBlockExecution.getVariable(BBConstants.G_CURRENT_SEQUENCE); + assertEquals(0, actual); + + } + /** * setting scope action in buildingBlock and BB current sequence in BuildingBlockExecution * @@ -199,4 +241,11 @@ public class SkipCDSBuildingBlockListenerTest { return vfModuleCustomizations; } + private PnfResourceCustomization getPnfResourceCustomization(boolean setSkippost) { + PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization(); + pnfResourceCustomization.setModelCustomizationUUID(MODELCUSTOMIZATIONUUID); + pnfResourceCustomization.setSkipPostInstConf(setSkippost); + return pnfResourceCustomization; + } + } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java index d26ce84505..2e4623d25d 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/PnfResourceCustomization.java @@ -83,7 +83,7 @@ public class PnfResourceCustomization implements Serializable { private String blueprintVersion; @Column(name = "SKIP_POST_INSTANTIATION_CONFIGURATION") - private Boolean skipPostInstConf; + private boolean skipPostInstConf; @Column(name = "CONTROLLER_ACTOR") private String controllerActor; @@ -219,11 +219,11 @@ public class PnfResourceCustomization implements Serializable { this.blueprintVersion = blueprintVersion; } - public Boolean isSkipPostInstConf() { + public boolean isSkipPostInstConf() { return skipPostInstConf; } - public void setSkipPostInstConf(Boolean skipPostInstConf) { + public void setSkipPostInstConf(boolean skipPostInstConf) { this.skipPostInstConf = skipPostInstConf; } diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java index f710890883..b39a85fb92 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/beans/BeansTest.java @@ -67,10 +67,10 @@ public class BeansTest { } private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new NoPrimitivesRule()) - .with(new NoNestedClassRule()).with(new NoStaticExceptFinalRule()) - .with(new SerializableMustHaveSerialVersionUIDRule()).with(new HasToStringRule()) - .with(new EqualsAndHashCodeTester()).with(new NoPublicFieldsExceptStaticFinalRule()) + Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new NoNestedClassRule()) + .with(new NoStaticExceptFinalRule()).with(new SerializableMustHaveSerialVersionUIDRule()) + .with(new HasToStringRule()).with(new EqualsAndHashCodeTester()) + .with(new NoPublicFieldsExceptStaticFinalRule()) .with(new CustomSetterMustExistRule() .exclude(allOf(hasAnnotationPropertyWithValue(Column.class, "updatable", equalTo(false)), hasAnnotation(GeneratedValue.class)), hasAnnotation(Temporal.class))) -- cgit 1.2.3-korg