diff options
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java')
2 files changed, 55 insertions, 37 deletions
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()); + } + +} |