summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
authorJozsef Csongvai <jozsef.csongvai@bell.ca>2020-11-24 14:44:01 -0500
committerJozsef Csongvai <jozsef.csongvai@bell.ca>2021-06-18 00:00:43 +0000
commit3c9bc7d08acb18d76af794bfe936fed7c917b284 (patch)
tree1a86cc0ba88633f061b2a56bf06766b81a619b18 /bpmn
parentabfaee8128ecc8bfb1fe7562631fb0d765b22d8c (diff)
Add VNF-Macro-Create and VNF-Macro-Delete
These macros enable creation and deletion of a vnf with vfmodules for an existing service instance using building blocks. Also: - No longer force alaCarte=true for these use cases - Fix broken vfModule sorting logic for baseFirst/baseLast - Minor refactoring replacing String literals with constants Issue-ID: SO-3635 Signed-off-by: Jozsef Csongvai <jozsef.csongvai@bell.ca> Change-Id: I16975f3561f2d978dede20679927ac3531def900
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java14
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java45
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java5
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java22
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java25
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java15
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java37
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java55
8 files changed, 124 insertions, 94 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 5cbadd6b75..83d1f5249f 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -1054,8 +1054,18 @@ public class BBInputSetup implements JavaDelegate {
if (requestDetails.getOwningEntity() != null)
owningEntity = mapperLayer.mapRequestOwningEntity(requestDetails.getOwningEntity());
- Service service =
- bbInputSetupUtils.getCatalogServiceByModelUUID(requestDetails.getModelInfo().getModelVersionId());
+ String modelVersionId = requestDetails.getModelInfo().getModelVersionId();
+
+ if (ModelType.vnf == requestDetails.getModelInfo().getModelType()) {
+ for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) {
+ if (ModelType.service == relatedInstanceList.getRelatedInstance().getModelInfo().getModelType()) {
+ modelVersionId = relatedInstanceList.getRelatedInstance().getModelInfo().getModelVersionId();
+ break;
+ }
+ }
+ }
+
+ Service service = bbInputSetupUtils.getCatalogServiceByModelUUID(modelVersionId);
if (service == null) {
service = bbInputSetupUtils.getCatalogServiceByModelVersionAndModelInvariantUUID(
requestDetails.getModelInfo().getModelVersion(),
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
index 2138f489ee..813dc04ecd 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilder.java
@@ -26,6 +26,7 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import java.util.Comparator;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ConfigurationResourceKeys;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
@@ -36,12 +37,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ACTIVATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONFIGURATION;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
@@ -94,15 +95,17 @@ public class ExecuteBuildingBlockBuilder {
true, false);
} else if (orchFlow.getFlowName().contains(VFMODULE) || (orchFlow.getFlowName().contains(CONTROLLER)
&& (VFMODULE).equalsIgnoreCase(orchFlow.getBpmnScope()))) {
- List<Resource> vfModuleResourcesSorted;
- if (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE)
- || requestAction.equals("activateInstance")) {
- vfModuleResourcesSorted = sortVfModulesByBaseFirst(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ Comparator<Resource> resourceComparator;
+ if (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE)
+ || requestAction.equals(ACTIVATE_INSTANCE)) {
+ resourceComparator = Resource.sortBaseFirst;
} else {
- vfModuleResourcesSorted = sortVfModulesByBaseLast(resourceList.stream()
- .filter(x -> WorkflowType.VFMODULE == x.getResourceType()).collect(Collectors.toList()));
+ resourceComparator = Resource.sortBaseLast;
}
+ List<Resource> vfModuleResourcesSorted =
+ resourceList.stream().filter(x -> WorkflowType.VFMODULE == x.getResourceType())
+ .sorted(resourceComparator).collect(Collectors.toList());
+
for (Resource resource : vfModuleResourcesSorted) {
flowsToExecute.add(buildExecuteBuildingBlock(orchFlow, requestId, resource, apiVersion, resourceId,
requestAction, false, vnfType, workflowResourceIds, requestDetails, false, null, null,
@@ -169,30 +172,6 @@ public class ExecuteBuildingBlockBuilder {
return executeBuildingBlock;
}
- protected List<Resource> sortVfModulesByBaseFirst(List<Resource> vfModuleResources) {
- int count = 0;
- for (Resource resource : vfModuleResources) {
- if (resource.isBaseVfModule()) {
- Collections.swap(vfModuleResources, 0, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
-
- protected List<Resource> sortVfModulesByBaseLast(List<Resource> vfModuleResources) {
- int count = 0;
- for (Resource resource : vfModuleResources) {
- if (resource.isBaseVfModule()) {
- Collections.swap(vfModuleResources, vfModuleResources.size() - 1, count);
- break;
- }
- count++;
- }
- return vfModuleResources;
- }
-
private void addBuildingBlockToExecuteBBList(List<ExecuteBuildingBlock> flowsToExecute, List<Resource> resourceList,
WorkflowType workflowType, OrchestrationFlow orchFlow, String requestId, String apiVersion,
String resourceId, String requestAction, String vnfType, WorkflowResourceIds workflowResourceIds,
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
index 447f8994db..692d8bccdb 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/Resource.java
@@ -20,6 +20,8 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
+import java.util.Comparator;
+
public class Resource {
private String resourceId;
@@ -31,6 +33,9 @@ public class Resource {
private String vfModuleCustomizationId;
private String cvnfModuleCustomizationId;
+ public static final Comparator<Resource> sortBaseFirst = Comparator.comparingInt(x -> x.isBaseVfModule() ? 0 : 1);
+ public static final Comparator<Resource> sortBaseLast = Comparator.comparingInt(x -> x.isBaseVfModule() ? 1 : 0);
+
public Resource(WorkflowType resourceType, String resourceId, boolean generated) {
this.resourceId = resourceId;
this.resourceType = resourceType;
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 29206a6aa9..8a9289981d 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
@@ -26,13 +26,16 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CONTROLLER;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.RECREATE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.REPLACEINSTANCERETAINASSIGNMENTS;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.SERVICE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UPDATE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
import java.io.IOException;
import java.util.ArrayList;
@@ -279,14 +282,14 @@ public class WorkflowAction {
List<Resource> resourceList = new ArrayList<>();
List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
- if (resourceType == WorkflowType.SERVICE) {
+ if (resourceType == WorkflowType.SERVICE || isVNFCreateOrDelete(resourceType, requestAction)) {
resourceList = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution,
serviceInstanceId, resourceId, aaiResourceIds);
} else if (resourceType == WorkflowType.VNF && (REPLACEINSTANCE.equalsIgnoreCase(requestAction)
- || ("recreateInstance".equalsIgnoreCase(requestAction)))) {
+ || (RECREATE_INSTANCE.equalsIgnoreCase(requestAction)))) {
vnfEBBLoader.traverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
- } else if (resourceType == WorkflowType.VNF && "updateInstance".equalsIgnoreCase(requestAction)) {
+ } else if (resourceType == WorkflowType.VNF && UPDATE_INSTANCE.equalsIgnoreCase(requestAction)) {
vnfEBBLoader.customTraverseAAIVnf(execution, resourceList, workflowResourceIds.getServiceInstanceId(),
workflowResourceIds.getVnfId(), aaiResourceIds);
} else {
@@ -317,12 +320,12 @@ public class WorkflowAction {
}
// By default, enable homing at VNF level for CREATE_INSTANCE and ASSIGNINSTANCE
if (resourceType == WorkflowType.SERVICE
- && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGNINSTANCE))
+ && (requestAction.equals(CREATE_INSTANCE) || requestAction.equals(ASSIGN_INSTANCE))
&& resourceList.stream().anyMatch(x -> WorkflowType.VNF.equals(x.getResourceType()))) {
execution.setVariable(HOMING, true);
execution.setVariable("calledHoming", false);
}
- if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)
+ if (resourceType == WorkflowType.SERVICE && (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE)
|| requestAction.equalsIgnoreCase(CREATE_INSTANCE))) {
generateResourceIds(flowsToExecute, resourceList, serviceInstanceId);
} else {
@@ -331,6 +334,11 @@ public class WorkflowAction {
return flowsToExecute;
}
+ private boolean isVNFCreateOrDelete(WorkflowType resourceType, String requestAction) {
+ return resourceType == WorkflowType.VNF
+ && (CREATE_INSTANCE.equalsIgnoreCase(requestAction) || DELETE_INSTANCE.equalsIgnoreCase(requestAction));
+ }
+
private void setExecutionVariables(DelegateExecution execution, List<ExecuteBuildingBlock> flowsToExecute,
List<String> flowNames) {
execution.setVariable("flowNames", flowNames);
@@ -887,7 +895,7 @@ public class WorkflowAction {
protected boolean isRequestMacroServiceResume(boolean aLaCarte, WorkflowType resourceType, String requestAction,
String serviceInstanceId) {
return (!aLaCarte && resourceType == WorkflowType.SERVICE
- && (requestAction.equalsIgnoreCase(ASSIGNINSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))
+ && (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE) || requestAction.equalsIgnoreCase(CREATE_INSTANCE))
&& (serviceInstanceId != null && serviceInstanceId.trim().length() > 1)
&& (bbInputSetupUtils.getAAIServiceInstanceById(serviceInstanceId) != null));
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
index b2cc89545b..38ba0077e2 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionConstants.java
@@ -32,16 +32,23 @@ public final class WorkflowActionConstants {
throw new IllegalStateException("Utility class");
}
- public static final String USER_PARAM_SERVICE = "service";
+ public static final String ACTIVATE_INSTANCE = "activateInstance";
+ public static final String ASSIGN_INSTANCE = "assignInstance";
+ public static final String CONFIGURATION = "Configuration";
+ public static final String CONTROLLER = "Controller";
public static final String CREATE_INSTANCE = "createInstance";
+ public static final String DEACTIVATE_INSTANCE = "deactivateInstance";
+ public static final String DELETE_INSTANCE = "deleteInstance";
public static final String FABRIC_CONFIGURATION = "FabricConfiguration";
- public static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
- static final String SERVICE = "Service";
- static final String CONTROLLER = "Controller";
public static final String NETWORKCOLLECTION = "NetworkCollection";
- static final String CONFIGURATION = "Configuration";
- public static final String ASSIGNINSTANCE = "assignInstance";
- static final String REPLACEINSTANCE = "replaceInstance";
- static final String VOLUMEGROUP = "VolumeGroup";
- static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
+ public static final String RECREATE_INSTANCE = "recreateInstance";
+ public static final String REPLACEINSTANCE = "replaceInstance";
+ public static final String REPLACEINSTANCERETAINASSIGNMENTS = "replaceInstanceRetainAssignments";
+ public static final String SERVICE = "Service";
+ public static final String UNASSIGN_INSTANCE = "unassignInstance";
+ public static final String UPDATE_INSTANCE = "updateInstance";
+ public static final String USER_PARAM_SERVICE = "service";
+ public static final String VOLUMEGROUP = "VolumeGroup";
+ public static final String WORKFLOW_ACTION_ERROR_MESSAGE = "WorkflowActionErrorMessage";
+
}
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
index 068c287ee7..6d02594c68 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java
@@ -35,12 +35,16 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ACTIVATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DEACTIVATE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.DELETE_INSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.UNASSIGN_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.WORKFLOW_ACTION_ERROR_MESSAGE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.CREATE_INSTANCE;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.FABRIC_CONFIGURATION;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.NETWORKCOLLECTION;
import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.USER_PARAM_SERVICE;
-import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGNINSTANCE;
+import static org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionConstants.ASSIGN_INSTANCE;
@Component
@@ -77,7 +81,7 @@ public class ServiceEBBLoader {
boolean containsService = false;
List<Resource> resourceList = new ArrayList<>();
List<Map<String, Object>> userParams = sIRequest.getRequestDetails().getRequestParameters().getUserParams();
- if (requestAction.equalsIgnoreCase(ASSIGNINSTANCE)) {
+ if (requestAction.equalsIgnoreCase(ASSIGN_INSTANCE)) {
// SERVICE-MACRO-ASSIGN will always get user params with a
// service.
@@ -108,16 +112,15 @@ public class ServiceEBBLoader {
if (!foundRelated(resourceList)) {
traverseCatalogDbService(execution, sIRequest, resourceList, aaiResourceIds);
}
- } else if (("activateInstance".equalsIgnoreCase(requestAction)
- || "unassignInstance".equalsIgnoreCase(requestAction)
- || "deleteInstance".equalsIgnoreCase(requestAction)
+ } else if ((ACTIVATE_INSTANCE.equalsIgnoreCase(requestAction)
+ || UNASSIGN_INSTANCE.equalsIgnoreCase(requestAction) || DELETE_INSTANCE.equalsIgnoreCase(requestAction)
|| requestAction.equalsIgnoreCase("activate" + FABRIC_CONFIGURATION))) {
// SERVICE-MACRO-ACTIVATE, SERVICE-MACRO-UNASSIGN, and
// SERVICE-MACRO-DELETE
// Will never get user params with service, macro will have
// to query the SI in AAI to find related instances.
traverseAAIService(execution, resourceList, resourceId, aaiResourceIds);
- } else if ("deactivateInstance".equalsIgnoreCase(requestAction)) {
+ } else if (DEACTIVATE_INSTANCE.equalsIgnoreCase(requestAction)) {
resourceList.add(new Resource(WorkflowType.SERVICE, "", false));
}
return resourceList;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java
index fae2317c8d..cc3da9952a 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ExecuteBuildingBlockBuilderTest.java
@@ -41,43 +41,6 @@ public class ExecuteBuildingBlockBuilderTest {
final private ExecuteBuildingBlockBuilder executeBBBuilder = new ExecuteBuildingBlockBuilder();
@Test
- public void sortVfModulesByBaseFirstTest() {
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
- resource1.setBaseVfModule(false);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
- resource3.setBaseVfModule(true);
- resources.add(resource3);
-
- List<Resource> result = executeBBBuilder.sortVfModulesByBaseFirst(resources);
- assertEquals("333", result.get(0).getResourceId());
- assertEquals("222", result.get(1).getResourceId());
- assertEquals("111", result.get(2).getResourceId());
- }
-
- @Test
- public void sortVfModulesByBaseLastTest() {
- List<Resource> resources = new ArrayList<>();
- Resource resource1 = new Resource(WorkflowType.VFMODULE, "111", false);
- resource1.setBaseVfModule(true);
- resources.add(resource1);
- Resource resource2 = new Resource(WorkflowType.VFMODULE, "222", false);
- resource2.setBaseVfModule(false);
- resources.add(resource2);
- Resource resource3 = new Resource(WorkflowType.VFMODULE, "333", false);
- resource3.setBaseVfModule(false);
- resources.add(resource3);
- List<Resource> result = executeBBBuilder.sortVfModulesByBaseLast(resources);
- assertEquals("333", result.get(0).getResourceId());
- assertEquals("222", result.get(1).getResourceId());
- assertEquals("111", result.get(2).getResourceId());
- }
-
- @Test
public void verifyLackOfNullPointerExceptionForNullResource() {
ExecuteBuildingBlock result = null;
try {
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java
new file mode 100644
index 0000000000..5e3afa16ac
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Bell Canada. All rights reserved.
+ * ================================================================================
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.junit.Test;
+
+public class ResourceTest {
+
+ @Test
+ public void testBaseFirstComparator() {
+ Resource r1 = new Resource(null, "1", false);
+ Resource r2 = new Resource(null, "2", false);
+ r2.setBaseVfModule(true);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2).stream().sorted(Resource.sortBaseFirst).collect(Collectors.toList());
+
+ assertEquals("2", sorted.get(0).getResourceId());
+ }
+
+ @Test
+ public void testBaseLastComparator() {
+ Resource r1 = new Resource(null, "1", false);
+ Resource r2 = new Resource(null, "2", false);
+ r1.setBaseVfModule(true);
+
+ List<Resource> sorted =
+ Arrays.asList(r1, r2).stream().sorted(Resource.sortBaseLast).collect(Collectors.toList());
+
+ assertEquals("1", sorted.get(1).getResourceId());
+ }
+
+}