Merge "Prepare for java 11"
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 ac33d7a..95f10c3 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
@@ -809,65 +809,7 @@
             } 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);
-                                    }
-                                }
-                            } else {
-                                logger.debug("Instance Group tosca node type does not contain NetworkCollection:  {}",
-                                        toscaNodeType);
-                            }
-                        } else {
-                            logger.debug("No Instance Group found for network collection.");
-                        }
-                    } else {
-                        logger.debug("No Network Collection found. collectionResource is null");
-                    }
-                } else {
-                    logger.debug("No Network Collection Customization found");
-                }
+                traverseNetworkCollectionResourceCustomization(resourceList, collectionResourceCustomization);
             }
             traverseNetworkCollectionCustomization(resourceList, service);
         } else {
@@ -876,6 +818,68 @@
         }
     }
 
+    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;
+                                }
+                            }
+                            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("Instance Group tosca node type does not contain NetworkCollection:  {}",
+                                toscaNodeType);
+                    }
+                } else {
+                    logger.debug("No Instance Group found for network collection.");
+                }
+            } else {
+                logger.debug("No Network Collection found. collectionResource is null");
+            }
+        } else {
+            logger.debug("No Network Collection Customization found");
+        }
+    }
+
     private void traverseNetworkCollectionCustomization(List<Resource> resourceList,
             org.onap.so.db.catalog.beans.Service service) {
         if (isNetworkCollectionInTheResourceList(resourceList)) {
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 772fca0..cf5226a 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 @@
 @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 0000000..c23fb03
--- /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;
+    }
+
+}