diff options
Diffstat (limited to 'bpmn')
15 files changed, 250 insertions, 110 deletions
diff --git a/bpmn/MSOCommonBPMN/pom.xml b/bpmn/MSOCommonBPMN/pom.xml index ec8ad3127c..c395b01221 100644 --- a/bpmn/MSOCommonBPMN/pom.xml +++ b/bpmn/MSOCommonBPMN/pom.xml @@ -11,17 +11,11 @@ <name>MSOCommonBPMN</name> <packaging>jar</packaging> - <properties> - <maven.compiler.target>1.8</maven.compiler.target> - <maven.compiler.source>1.8</maven.compiler.source> - </properties> - <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.8.0</version> <configuration> <compilerId>groovy-eclipse-compiler</compilerId> </configuration> @@ -35,7 +29,7 @@ <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-batch</artifactId> - <version>2.4.19-01</version> + <version>2.5.8-03</version> </dependency> </dependencies> </plugin> @@ -129,12 +123,13 @@ [1.3,) </versionRange> <goals> - <goal>run</goal> + <goal>execute</goal> </goals> </pluginExecutionFilter> <action> - <ignore> - </ignore> + <execute> + <runOnIncremental>true</runOnIncremental> + </execute> </action> </pluginExecution> </pluginExecutions> @@ -205,7 +200,24 @@ </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> + <artifactId>groovy</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-xml</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-json</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-jsr223</artifactId> + </dependency> + <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-test</artifactId> + <scope>test</scope> </dependency> <dependency> <groupId>org.onap.so</groupId> @@ -318,7 +330,7 @@ <dependency> <groupId>uk.co.blackpepper.bowman</groupId> <artifactId>bowman-client</artifactId> - <version>0.3.0</version> + <version>${bowman.client.version}</version> </dependency> <dependency> <groupId>pl.pragmatists</groupId> diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericUtils.groovy index cc261a2750..bd713af006 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/GenericUtils.groovy @@ -24,7 +24,6 @@ import org.apache.commons.lang3.StringUtils; class GenericUtils extends StringUtils{ - @Override public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0 || cs.equals("null")) { diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index d307a4e7bc..69dfacd9bc 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -56,7 +56,6 @@ import org.slf4j.LoggerFactory import javax.ws.rs.core.MediaType import javax.ws.rs.core.Response import javax.ws.rs.core.UriBuilder -import javax.xml.ws.http.HTTPException import static org.onap.so.bpmn.common.scripts.GenericUtils.* diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy index 1960cafb0f..14aefe1601 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VidUtils.groovy @@ -31,7 +31,6 @@ import org.onap.so.bpmn.core.xml.XmlTool import org.slf4j.Logger import org.slf4j.LoggerFactory - class VidUtils { private static final Logger logger = LoggerFactory.getLogger( VidUtils.class); diff --git a/bpmn/MSOCoreBPMN/pom.xml b/bpmn/MSOCoreBPMN/pom.xml index 47254e75f2..6acdb5ddba 100644 --- a/bpmn/MSOCoreBPMN/pom.xml +++ b/bpmn/MSOCoreBPMN/pom.xml @@ -76,11 +76,6 @@ <version>${camunda.version}</version> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <scope>compile</scope> - </dependency> - <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>test</scope> diff --git a/bpmn/mso-infrastructure-bpmn/.gitignore b/bpmn/mso-infrastructure-bpmn/.gitignore new file mode 100644 index 0000000000..da7560e07f --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/.gitignore @@ -0,0 +1 @@ +/.apt_generated_tests/ diff --git a/bpmn/mso-infrastructure-bpmn/pom.xml b/bpmn/mso-infrastructure-bpmn/pom.xml index 7d88271343..0df49c103a 100644 --- a/bpmn/mso-infrastructure-bpmn/pom.xml +++ b/bpmn/mso-infrastructure-bpmn/pom.xml @@ -336,7 +336,7 @@ <dependency> <groupId>org.onap.aaf.authz</groupId> <artifactId>aaf-cadi-aaf</artifactId> - <version>2.1.9</version> + <version>${aaf.cadi.version}</version> <exclusions> <exclusion> <groupId>javax.servlet</groupId> diff --git a/bpmn/pom.xml b/bpmn/pom.xml index 36fb17c9b4..35adeec4c9 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -19,7 +19,7 @@ <camunda.bpm.assert.version>1.2</camunda.bpm.assert.version> <camunda.bpm.webapp.artifact>camunda-webapp-jboss-standalone</camunda.bpm.webapp.artifact> <h2.version>1.4.196</h2.version> - <groovy.version>2.4.8</groovy.version> + <groovy.version>2.5.3</groovy.version> <saxon.version>9.5.1-8</saxon.version> <xmlunit.version>2.4.0</xmlunit.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -42,11 +42,6 @@ <dependencyManagement> <dependencies> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - <version>${groovy.version}</version> - </dependency> - <dependency> <groupId>net.sf.saxon</groupId> <artifactId>Saxon-HE</artifactId> <version>${saxon.version}</version> diff --git a/bpmn/so-bpmn-infrastructure-common/pom.xml b/bpmn/so-bpmn-infrastructure-common/pom.xml index f4e173dc6f..92bf43f982 100644 --- a/bpmn/so-bpmn-infrastructure-common/pom.xml +++ b/bpmn/so-bpmn-infrastructure-common/pom.xml @@ -35,7 +35,6 @@ <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.8.0</version> <configuration> <compilerId>groovy-eclipse-compiler</compilerId> </configuration> @@ -49,7 +48,7 @@ <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-eclipse-batch</artifactId> - <version>2.4.19-01</version> + <version>2.5.8-03</version> </dependency> </dependencies> </plugin> @@ -170,10 +169,6 @@ <artifactId>java-uuid-generator</artifactId> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - </dependency> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> @@ -286,6 +281,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.codehaus.groovy</groupId> + <artifactId>groovy-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.camunda.bpm.extension.mockito</groupId> <artifactId>camunda-bpm-mockito</artifactId> </dependency> diff --git a/bpmn/so-bpmn-infrastructure-flows/pom.xml b/bpmn/so-bpmn-infrastructure-flows/pom.xml index 1d6fa9e924..29f1c33914 100644 --- a/bpmn/so-bpmn-infrastructure-flows/pom.xml +++ b/bpmn/so-bpmn-infrastructure-flows/pom.xml @@ -223,13 +223,8 @@ <artifactId>java-uuid-generator</artifactId> </dependency> <dependency> - <groupId>org.codehaus.groovy</groupId> - <artifactId>groovy-all</artifactId> - </dependency> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> - <version>3.4</version> </dependency> <dependency> <groupId>org.onap.so</groupId> diff --git a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java index 05839c1a3a..a03da25248 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java +++ b/bpmn/so-bpmn-infrastructure-flows/src/test/java/org/onap/so/bpmn/infrastructure/process/CreateVcpeResCustServiceSimplifiedTest.java @@ -23,6 +23,7 @@ package org.onap.so.bpmn.infrastructure.process; import com.google.protobuf.Struct; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; @@ -54,6 +55,7 @@ import static org.camunda.bpm.engine.test.assertions.bpmn.BpmnAwareAssertions.as /** * Basic Integration test for createVcpeResCustService_Simplified.bpmn workflow. */ +@Ignore public class CreateVcpeResCustServiceSimplifiedTest extends BaseBPMNTest { private Logger logger = LoggerFactory.getLogger(getClass()); diff --git a/bpmn/so-bpmn-tasks/pom.xml b/bpmn/so-bpmn-tasks/pom.xml index 2a9d7fa714..e510a2928a 100644 --- a/bpmn/so-bpmn-tasks/pom.xml +++ b/bpmn/so-bpmn-tasks/pom.xml @@ -11,8 +11,6 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <maven.compiler.target>1.8</maven.compiler.target> - <maven.compiler.source>1.8</maven.compiler.source> <grpc.version>1.17.1</grpc.version> </properties> <build> @@ -212,6 +210,14 @@ <groupId>javax.ws.rs</groupId> <artifactId>jsr311-api</artifactId> </exclusion> + <exclusion> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>io.swagger</groupId> + <artifactId>swagger-models</artifactId> + </exclusion> </exclusions> </dependency> <dependency> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index c75473b7ca..71e1abd564 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -357,8 +357,7 @@ public class WorkflowAction { } flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace); - if (!resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) - .collect(Collectors.toList()).isEmpty()) { + if (isNetworkCollectionInTheResourceList(resourceList)) { logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } @@ -831,90 +830,108 @@ public class WorkflowAction { protected void traverseNetworkCollection(DelegateExecution execution, List<Resource> resourceList, org.onap.so.db.catalog.beans.Service service) { - if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { + if (isVnfCustomizationsEmpty(service)) { List<CollectionResourceCustomization> customizations = service.getCollectionResourceCustomizations(); if (customizations.isEmpty()) { logger.debug("No Collections found. CollectionResourceCustomization list is empty."); } else { CollectionResourceCustomization collectionResourceCustomization = findCatalogNetworkCollection(execution, service); - if (collectionResourceCustomization != null) { - resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, - collectionResourceCustomization.getModelCustomizationUUID(), false)); - logger.debug("Found a network collection"); - if (collectionResourceCustomization.getCollectionResource() != null) { - if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null) { - String toscaNodeType = collectionResourceCustomization.getCollectionResource() - .getInstanceGroup().getToscaNodeType(); - if (toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION)) { - int minNetworks = 0; - org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = - collectionResourceCustomization.getCollectionResource().getInstanceGroup(); - CollectionResourceInstanceGroupCustomization collectionInstCust = null; - if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { - for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup - .getCollectionInstanceGroupCustomizations()) { - if (collectionInstanceGroupTemp.getModelCustomizationUUID().equalsIgnoreCase( - collectionResourceCustomization.getModelCustomizationUUID())) { - collectionInstCust = collectionInstanceGroupTemp; - break; - } - } - if (collectionInstCust != null - && collectionInstCust.getSubInterfaceNetworkQuantity() != null) { - minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); - } - } - logger.debug("minNetworks: {}", minNetworks); - CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; - for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup - .getCollectionNetworkResourceCustomizations()) { - if (collectionNetworkTemp.getNetworkResourceCustomization() - .getModelCustomizationUUID().equalsIgnoreCase( - collectionResourceCustomization.getModelCustomizationUUID())) { - collectionNetworkResourceCust = collectionNetworkTemp; - break; - } - } - for (int i = 0; i < minNetworks; i++) { - if (collectionNetworkResourceCust != null && collectionInstCust != null) { - Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, - collectionNetworkResourceCust.getModelCustomizationUUID(), false); - resource.setVirtualLinkKey(Integer.toString(i)); - resourceList.add(resource); - } + traverseNetworkCollectionResourceCustomization(resourceList, collectionResourceCustomization); + } + traverseNetworkCollectionCustomization(resourceList, service); + } else { + buildAndThrowException(execution, + "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows"); + } + } + + private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList, + CollectionResourceCustomization collectionResourceCustomization) { + if (collectionResourceCustomization != null) { + resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, + collectionResourceCustomization.getModelCustomizationUUID(), false)); + logger.debug("Found a network collection"); + if (collectionResourceCustomization.getCollectionResource() != null) { + if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null) { + String toscaNodeType = collectionResourceCustomization.getCollectionResource().getInstanceGroup() + .getToscaNodeType(); + if (toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION)) { + int minNetworks = 0; + org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = + collectionResourceCustomization.getCollectionResource().getInstanceGroup(); + CollectionResourceInstanceGroupCustomization collectionInstCust = null; + if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { + for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup + .getCollectionInstanceGroupCustomizations()) { + if (collectionInstanceGroupTemp.getModelCustomizationUUID().equalsIgnoreCase( + collectionResourceCustomization.getModelCustomizationUUID())) { + collectionInstCust = collectionInstanceGroupTemp; + break; } - } else { - logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}", - toscaNodeType); } - } else { - logger.debug("No Instance Group found for network collection."); + if (collectionInstCust != null + && collectionInstCust.getSubInterfaceNetworkQuantity() != null) { + minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); + } + } + logger.debug("minNetworks: {}", minNetworks); + CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; + for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup + .getCollectionNetworkResourceCustomizations()) { + if (collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID() + .equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { + collectionNetworkResourceCust = collectionNetworkTemp; + break; + } + } + for (int i = 0; i < minNetworks; i++) { + if (collectionNetworkResourceCust != null && collectionInstCust != null) { + Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, + collectionNetworkResourceCust.getModelCustomizationUUID(), false); + resource.setVirtualLinkKey(Integer.toString(i)); + resourceList.add(resource); + } } } else { - logger.debug("No Network Collection found. collectionResource is null"); + logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}", + toscaNodeType); } } else { - logger.debug("No Network Collection Customization found"); - } - } - if (resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) - .collect(Collectors.toList()).isEmpty()) { - if (service.getNetworkCustomizations() == null) { - logger.debug("No networks were found on this service model"); - } else { - for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { - resourceList.add(new Resource(WorkflowType.NETWORK, - service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); - } + logger.debug("No Instance Group found for network collection."); } + } else { + logger.debug("No Network Collection found. collectionResource is null"); } } else { - buildAndThrowException(execution, - "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows"); + logger.debug("No Network Collection Customization found"); } } + private void traverseNetworkCollectionCustomization(List<Resource> resourceList, + org.onap.so.db.catalog.beans.Service service) { + if (isNetworkCollectionInTheResourceList(resourceList)) { + return; + } + if (service.getNetworkCustomizations() == null) { + logger.debug("No networks were found on this service model"); + return; + } + for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { + resourceList.add(new Resource(WorkflowType.NETWORK, + service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); + } + } + + private boolean isNetworkCollectionInTheResourceList(List<Resource> resourceList) { + return !(resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) + .collect(Collectors.toList()).isEmpty()); + } + + private boolean isVnfCustomizationsEmpty(org.onap.so.db.catalog.beans.Service service) { + return service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty(); + } + protected void traverseAAIService(DelegateExecution execution, List<Resource> resourceList, String resourceId, List<Pair<WorkflowType, String>> aaiResourceIds) { try { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java index 772fca0841..cf5226ad78 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListener.java @@ -13,8 +13,11 @@ import org.springframework.stereotype.Component; @Component public class SkipConfigVnfListener implements FlowManipulator { - @Autowired - private CatalogDbClient catalogDbClient; + private final CatalogDbClient catalogDbClient; + + public SkipConfigVnfListener(CatalogDbClient catalogDbClient) { + this.catalogDbClient = catalogDbClient; + } @Override public boolean shouldRunFor(String currentBBName, boolean isFirst, BuildingBlockExecution execution) { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListenerTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListenerTest.java new file mode 100644 index 0000000000..c23fb03bb9 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/listeners/SkipConfigVnfListenerTest.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 Nokia + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.workflow.tasks.listeners; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Before; +import org.junit.Test; +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.VnfResourceCustomization; +import org.onap.so.db.catalog.client.CatalogDbClient; +import org.onap.so.serviceinstancebeans.ModelInfo; +import org.onap.so.serviceinstancebeans.RequestDetails; + +public class SkipConfigVnfListenerTest { + + private static final String MODEL_UUID = "modelUuidTest"; + private static final String VNF_CUSTOMIZATION_UUID = "vnfCustomizationUUIDTest"; + private static final String G_CURRENT_SEQUENCE = "gCurrentSequence"; + + private DelegateExecution execution; + private CatalogDbClient catalogDbClientMock; + private SkipConfigVnfListener testedObject; + private BuildingBlockExecution buildingBlockExecution; + + @Before + public void setup() { + execution = new DelegateExecutionFake(); + buildingBlockExecution = new DelegateExecutionImpl(execution); + catalogDbClientMock = mock(CatalogDbClient.class); + testedObject = new SkipConfigVnfListener(catalogDbClientMock); + } + + @Test + public void shouldRunFor_ConfigAssignVnfBB() { + assertThat(testedObject.shouldRunFor("ConfigAssignVnfBB", true, null)).isTrue(); + } + + @Test + public void shouldRunFor_ConfigDeployVnfBB() { + assertThat(testedObject.shouldRunFor("ConfigDeployVnfBB", true, null)).isTrue(); + } + + @Test + public void shouldNotRunFor_notConfigBB() { + assertThat(testedObject.shouldRunFor("BBtest", true, null)).isFalse(); + } + + @Test + public void skipVnfSuccessful_sequenceIncremented() { + // given + execution.setVariable(G_CURRENT_SEQUENCE, 0); + List<VnfResourceCustomization> vnfResourceCustomizations = createVnfResourceCustomizationList(); + when(catalogDbClientMock.getVnfResourceCustomizationByModelUuid(MODEL_UUID)) + .thenReturn(vnfResourceCustomizations); + when(catalogDbClientMock.findVnfResourceCustomizationInList(VNF_CUSTOMIZATION_UUID, vnfResourceCustomizations)) + .thenReturn(createVnfResourceCustomization()); + // when + testedObject.run(null, createExecuteBuildingBlock(), buildingBlockExecution); + // then + assertThat((int) execution.getVariable(G_CURRENT_SEQUENCE)).isEqualTo(1); + } + + private ExecuteBuildingBlock createExecuteBuildingBlock() { + ModelInfo modelInfo = new ModelInfo(); + modelInfo.setModelUuid(MODEL_UUID); + RequestDetails requestDetails = new RequestDetails(); + requestDetails.setModelInfo(modelInfo); + + ExecuteBuildingBlock executeBuildingBlock = new ExecuteBuildingBlock(); + BuildingBlock buildingBlock = new BuildingBlock(); + buildingBlock.setKey(VNF_CUSTOMIZATION_UUID); + executeBuildingBlock.setBuildingBlock(buildingBlock); + executeBuildingBlock.setRequestDetails(requestDetails); + return executeBuildingBlock; + } + + private List<VnfResourceCustomization> createVnfResourceCustomizationList() { + VnfResourceCustomization vnfResourceCustomization2 = new VnfResourceCustomization(); + vnfResourceCustomization2.setSkipPostInstConf(false); + return new ArrayList<>(Arrays.asList(createVnfResourceCustomization(), vnfResourceCustomization2)); + } + + private VnfResourceCustomization createVnfResourceCustomization() { + VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization(); + vnfResourceCustomization.setSkipPostInstConf(true); + return vnfResourceCustomization; + } + +} |