From 3c9bc7d08acb18d76af794bfe936fed7c917b284 Mon Sep 17 00:00:00 2001 From: Jozsef Csongvai Date: Tue, 24 Nov 2020 14:44:01 -0500 Subject: 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 Change-Id: I16975f3561f2d978dede20679927ac3531def900 --- .../tasks/ExecuteBuildingBlockBuilderTest.java | 37 --------------- .../workflow/tasks/ResourceTest.java | 55 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 37 deletions(-) create mode 100644 bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ResourceTest.java (limited to 'bpmn/so-bpmn-tasks/src/test/java/org/onap') 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 @@ -40,43 +40,6 @@ public class ExecuteBuildingBlockBuilderTest { final private ExecuteBuildingBlockBuilder executeBBBuilder = new ExecuteBuildingBlockBuilder(); - @Test - public void sortVfModulesByBaseFirstTest() { - List 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 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 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 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; 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 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 sorted = + Arrays.asList(r1, r2).stream().sorted(Resource.sortBaseLast).collect(Collectors.toList()); + + assertEquals("1", sorted.get(1).getResourceId()); + } + +} -- cgit 1.2.3-korg