summaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java1
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAI.java (renamed from bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java)2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java2
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java178
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java357
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java19
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAITest.java (renamed from bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java)3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateWithoutResources.json48
9 files changed, 428 insertions, 183 deletions
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 55a92b0b81..068c287ee7 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
@@ -12,7 +12,6 @@ import org.onap.aaiclient.client.aai.entities.Relationships;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
import org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException;
-import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java
index 210d5195e5..b271226414 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java
@@ -32,7 +32,6 @@ import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.aai.entities.Relationships;
import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
-import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAI.java
index 4140692b44..7f1eb0ef07 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAI.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.workflow.tasks;
+package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader;
import java.util.List;
import java.util.Optional;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
index ab83acaec2..78b9bf1ee6 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java
@@ -27,7 +27,7 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetworkBBUtils;
-import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.WorkflowActionExtractResourcesAAI;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
index 31f37f4ac3..10e6ed4895 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java
@@ -24,16 +24,13 @@
package org.onap.so.bpmn.infrastructure.workflow.tasks;
-import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.ArgumentMatchers.anyObject;
@@ -57,7 +54,6 @@ import java.util.UUID;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
-import org.javatuples.Pair;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
@@ -2064,180 +2060,6 @@ public class WorkflowActionTest extends BaseTaskTest {
}
}
- @Ignore
- @Test
- public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException, VrfBondingServiceException {
- execution.setVariable("testProcessKey", "testProcessKeyValue");
- Service service = new Service();
- List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
- NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
- networkCust.setModelCustomizationUUID("123");
- networkCustomizations.add(networkCust);
- service.setNetworkCustomizations(networkCustomizations);
- NetworkCollectionResourceCustomization collectionResourceCustomization =
- new NetworkCollectionResourceCustomization();
- collectionResourceCustomization.setModelCustomizationUUID("123");
- CollectionResource collectionResource = new CollectionResource();
- collectionResource.setToscaNodeType("NetworkCollection");
- InstanceGroup instanceGroup = new InstanceGroup();
- List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
- CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization =
- new CollectionResourceInstanceGroupCustomization();
- collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
- collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
- instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
- collectionResource.setInstanceGroup(instanceGroup);
- collectionResourceCustomization.setCollectionResource(collectionResource);;
- service.setModelUUID("abc");
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
- doReturn(service).when(catalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
- doReturn(collectionResourceCustomization).when(catalogDbClient)
- .getNetworkCollectionResourceCustomizationByID("123");
- String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
- ObjectMapper mapper = new ObjectMapper();
- ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
- List<Resource> resourceCounter = new ArrayList<>();
- thrown.expect(BpmnError.class);
- List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
- serviceEBBLoader.traverseCatalogDbService(execution, sIRequest, resourceCounter, aaiResourceIds);
- }
-
-
-
- @Test
- public void findCatalogNetworkCollectionTest() {
- Service service = new Service();
- NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization();
- networkCustomization.setModelCustomizationUUID("123");
- service.getCollectionResourceCustomizations().add(networkCustomization);
- doReturn(networkCustomization).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
- CollectionResourceCustomization customization =
- serviceEBBLoader.findCatalogNetworkCollection(execution, service);
- assertNotNull(customization);
- }
-
- @Test
- public void findCatalogNetworkCollectionEmptyTest() {
- Service service = new Service();
- NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization();
- networkCustomization.setModelCustomizationUUID("123");
- service.getCollectionResourceCustomizations().add(networkCustomization);
- CollectionResourceCustomization customization =
- serviceEBBLoader.findCatalogNetworkCollection(execution, service);
- assertNull(customization);
- }
-
- @Test
- public void findCatalogNetworkCollectionMoreThanOneTest() {
- Service service = new Service();
- NetworkCollectionResourceCustomization networkCustomization1 = new NetworkCollectionResourceCustomization();
- networkCustomization1.setModelCustomizationUUID("123");
- NetworkCollectionResourceCustomization networkCustomization2 = new NetworkCollectionResourceCustomization();
- networkCustomization2.setModelCustomizationUUID("321");
- service.getCollectionResourceCustomizations().add(networkCustomization1);
- service.getCollectionResourceCustomizations().add(networkCustomization2);
- doReturn(networkCustomization1).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
- doReturn(networkCustomization2).when(catalogDbClient).getNetworkCollectionResourceCustomizationByID("321");
- serviceEBBLoader.findCatalogNetworkCollection(execution, service);
- assertEquals("Found multiple Network Collections in the Service model, only one per Service is supported.",
- execution.getVariable("WorkflowActionErrorMessage"));
- }
-
-
- @Test
- public void traverseAAIServiceTest() {
- List<Resource> resourceCounter = new ArrayList<>();
- String resourceId = "si0";
- List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
-
- ServiceInstance serviceInstanceAAI = new ServiceInstance();
- serviceInstanceAAI.setServiceInstanceId(resourceId);
-
- org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance();
- setGenericVnf();
- setVfModule(true);
- setVolumeGroup();
- setL3Network();
- setCollection();
- setConfiguration();
-
- Configuration config = new Configuration();
- config.setConfigurationId("testConfigurationId2");
- serviceInstance.getConfigurations().add(config);
-
- Relationship relationship1 = new Relationship();
- relationship1.setRelatedTo("vnfc");
- RelationshipList relationshipList1 = new RelationshipList();
- relationshipList1.getRelationship().add(relationship1);
-
- Relationship relationship2 = new Relationship();
- relationship2.setRelatedTo("vpn-binding");
- RelationshipList relationshipList2 = new RelationshipList();
- relationshipList2.getRelationship().add(relationship2);
-
- org.onap.aai.domain.yang.Configuration aaiConfiguration1 = new org.onap.aai.domain.yang.Configuration();
- aaiConfiguration1.setConfigurationId("testConfigurationId");
- aaiConfiguration1.setRelationshipList(relationshipList1);
-
- org.onap.aai.domain.yang.Configuration aaiConfiguration2 = new org.onap.aai.domain.yang.Configuration();
- aaiConfiguration2.setConfigurationId("testConfigurationId2");
- aaiConfiguration2.setRelationshipList(relationshipList1);
-
- try {
- doReturn(serviceInstanceAAI).when(bbSetupUtils).getAAIServiceInstanceById(resourceId);
- doReturn(serviceInstance).when(bbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
- doReturn(Optional.of(aaiConfiguration1)).when(aaiConfigurationResources)
- .getConfiguration("testConfigurationId");
- doReturn(Optional.of(aaiConfiguration2)).when(aaiConfigurationResources)
- .getConfiguration("testConfigurationId2");
- serviceEBBLoader.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
- assertEquals(8, resourceCounter.size());
- assertTrue(resourceCounter.get(2).isBaseVfModule());
- assertThat(aaiResourceIds, sameBeanAs(getExpectedResourceIds()));
- } catch (Exception e) {
- fail("Unexpected exception was thrown.");
- }
- }
-
- @Test
- public void foundRelatedTest() {
- List<Resource> resourceList = new ArrayList<>();
- resourceList.add(new Resource(WorkflowType.PNF, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false));
-
- assertEquals(serviceEBBLoader.foundRelated(resourceList), true);
- }
-
- @Test
- public void containsWorkflowTypeTest() {
- List<Resource> resourceList = new ArrayList<>();
- resourceList.add(new Resource(WorkflowType.PNF, "resource id", false));
- resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false));
- resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false));
-
- assertEquals(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.PNF), true);
- assertEquals(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.VNF), true);
- assertEquals(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.NETWORK), true);
- assertEquals(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.NETWORKCOLLECTION), true);
- assertEquals(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.CONFIGURATION), false);
- }
-
- private List<Pair<WorkflowType, String>> getExpectedResourceIds() {
- List<Pair<WorkflowType, String>> resourceIds = new ArrayList<>();
- resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, "testVnfId1"));
- resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE, "testVfModuleId1"));
- resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, "testVolumeGroupId1"));
- resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORK, "testNetworkId1"));
- resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, "testId"));
- resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, "testConfigurationId"));
- resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, "testConfigurationId2"));
- return resourceIds;
- }
-
private List<OrchestrationFlow> createFlowList(String... flowNames) {
List<OrchestrationFlow> result = new ArrayList<>();
int sequenceNumber = 1;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
new file mode 100644
index 0000000000..a5ecf364a6
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoaderTest.java
@@ -0,0 +1,357 @@
+/*-
+ * ============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.ebb.loader;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake;
+import org.javatuples.Pair;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mock;
+import org.onap.aai.domain.yang.Relationship;
+import org.onap.aai.domain.yang.RelationshipList;
+import org.onap.aai.domain.yang.ServiceInstance;
+import org.onap.aaiclient.client.aai.entities.Relationships;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
+import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.AAIConfigurationResources;
+import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.CollectionResourceCustomization;
+import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.CollectionResource;
+import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
+import org.onap.so.db.catalog.beans.InstanceGroup;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.serviceinstancebeans.RelatedInstance;
+import org.onap.so.serviceinstancebeans.ServiceInstancesRequest;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyList;
+import static org.mockito.Mockito.anyString;
+
+public class ServiceEBBLoaderTest extends BaseTaskTest {
+
+ private static final String MACRO_ACTIVATE_DELETE_UNASSIGN_JSON = "Macro/ServiceMacroActivateDeleteUnassign.json";
+ private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json";
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Mock
+ protected Relationships relationships;
+
+ private DelegateExecution execution;
+ private ServiceEBBLoader serviceEBBLoader;
+ private UserParamsServiceTraversal mockUserParamsServiceTraversal;
+ private CatalogDbClient mockCatalogDbClient;
+ private VrfValidation mockVrfValidation;
+ private AAIConfigurationResources mockAaiConfigurationResources;
+ private WorkflowActionExtractResourcesAAI mockWorkflowActionExtractResourcesAAI;
+ private BBInputSetupUtils mockBbInputSetupUtils;
+ private BBInputSetup mockBbInputSetup;
+
+ @Before
+ public void before() throws Exception {
+ execution = new DelegateExecutionFake();
+ mockUserParamsServiceTraversal = mock(UserParamsServiceTraversal.class);
+ mockCatalogDbClient = mock(CatalogDbClient.class);
+ mockVrfValidation = mock(VrfValidation.class);
+ mockAaiConfigurationResources = mock(AAIConfigurationResources.class);
+ mockWorkflowActionExtractResourcesAAI = mock(WorkflowActionExtractResourcesAAI.class);
+ mockBbInputSetupUtils = mock(BBInputSetupUtils.class);
+ mockBbInputSetup = mock(BBInputSetup.class);
+ serviceEBBLoader = new ServiceEBBLoader(mockUserParamsServiceTraversal, mockCatalogDbClient, mockVrfValidation,
+ mockAaiConfigurationResources, mockWorkflowActionExtractResourcesAAI, mockBbInputSetupUtils,
+ mockBbInputSetup, mock(ExceptionBuilder.class));
+ }
+
+
+ @Test
+ public void getResourceListForServiceWithRequestActionAssignInstance()
+ throws IOException, VrfBondingServiceException {
+ String bpmnRequest = readBpmnRequestFromFile(MACRO_ASSIGN_JSON);
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+ String requestAction = "assignInstance";
+ String serviceInstanceId = "123";
+ String resourceId = "si0";
+ List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
+ doReturn(prepareListWithResources()).when(mockUserParamsServiceTraversal).getResourceListFromUserParams(any(),
+ anyList(), anyString(), anyString());
+ List<Resource> resources = serviceEBBLoader.getResourceListForService(sIRequest, requestAction, execution,
+ serviceInstanceId, resourceId, aaiResourceIds);
+ assertNotNull(resources);
+ assertEquals(resources.size(), 6);
+ }
+
+ @Test
+ public void findCatalogNetworkCollectionTest() {
+ Service service = new Service();
+ NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization();
+ networkCustomization.setModelCustomizationUUID("123");
+ service.getCollectionResourceCustomizations().add(networkCustomization);
+ doReturn(networkCustomization).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
+ CollectionResourceCustomization customization =
+ serviceEBBLoader.findCatalogNetworkCollection(execution, service);
+ assertNotNull(customization);
+ }
+
+ @Test
+ public void findCatalogNetworkCollectionEmptyTest() {
+ Service service = new Service();
+ NetworkCollectionResourceCustomization networkCustomization = new NetworkCollectionResourceCustomization();
+ networkCustomization.setModelCustomizationUUID("123");
+ service.getCollectionResourceCustomizations().add(networkCustomization);
+ CollectionResourceCustomization customization =
+ serviceEBBLoader.findCatalogNetworkCollection(execution, service);
+ assertNull(customization);
+ }
+
+ @Test
+ public void findCatalogNetworkCollectionMoreThanOneTest() {
+ Service service = new Service();
+ NetworkCollectionResourceCustomization networkCustomization1 = new NetworkCollectionResourceCustomization();
+ networkCustomization1.setModelCustomizationUUID("123");
+ NetworkCollectionResourceCustomization networkCustomization2 = new NetworkCollectionResourceCustomization();
+ networkCustomization2.setModelCustomizationUUID("321");
+ service.getCollectionResourceCustomizations().add(networkCustomization1);
+ service.getCollectionResourceCustomizations().add(networkCustomization2);
+ doReturn(networkCustomization1).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID("123");
+ doReturn(networkCustomization2).when(mockCatalogDbClient).getNetworkCollectionResourceCustomizationByID("321");
+ serviceEBBLoader.findCatalogNetworkCollection(execution, service);
+ assertEquals("Found multiple Network Collections in the Service model, only one per Service is supported.",
+ execution.getVariable("WorkflowActionErrorMessage"));
+ }
+
+ @Test
+ public void foundRelatedTest() {
+ List<Resource> resourceList = new ArrayList<>();
+ resourceList.add(new Resource(WorkflowType.PNF, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false));
+
+ assertTrue(serviceEBBLoader.foundRelated(resourceList));
+ }
+
+ @Test
+ public void containsWorkflowTypeTest() {
+ List<Resource> resourceList = new ArrayList<>();
+ resourceList.add(new Resource(WorkflowType.PNF, "resource id", false));
+ resourceList.add(new Resource(WorkflowType.VNF, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.NETWORK, "model customization id", false));
+ resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, "model customization id", false));
+
+ assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.PNF));
+ assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.VNF));
+ assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.NETWORK));
+ assertTrue(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.NETWORKCOLLECTION));
+ assertFalse(serviceEBBLoader.containsWorkflowType(resourceList, WorkflowType.CONFIGURATION));
+ }
+
+ @Test
+ public void traverseAAIServiceTest() {
+ List<Resource> resourceCounter = new ArrayList<>();
+ String resourceId = "si0";
+ List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
+
+ ServiceInstance serviceInstanceAAI = new ServiceInstance();
+ serviceInstanceAAI.setServiceInstanceId(resourceId);
+
+ org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance serviceInstance = setServiceInstance();
+ setGenericVnf();
+ setVfModule(true);
+ setVolumeGroup();
+ setL3Network();
+ setCollection();
+ setConfiguration();
+
+ Configuration config = new Configuration();
+ config.setConfigurationId("testConfigurationId2");
+ serviceInstance.getConfigurations().add(config);
+
+ Relationship relationship1 = new Relationship();
+ relationship1.setRelatedTo("vnfc");
+ RelationshipList relationshipList1 = new RelationshipList();
+ relationshipList1.getRelationship().add(relationship1);
+
+ Relationship relationship2 = new Relationship();
+ relationship2.setRelatedTo("vpn-binding");
+ RelationshipList relationshipList2 = new RelationshipList();
+ relationshipList2.getRelationship().add(relationship2);
+
+ org.onap.aai.domain.yang.Configuration aaiConfiguration1 = new org.onap.aai.domain.yang.Configuration();
+ aaiConfiguration1.setConfigurationId("testConfigurationId");
+ aaiConfiguration1.setRelationshipList(relationshipList1);
+
+ org.onap.aai.domain.yang.Configuration aaiConfiguration2 = new org.onap.aai.domain.yang.Configuration();
+ aaiConfiguration2.setConfigurationId("testConfigurationId2");
+ aaiConfiguration2.setRelationshipList(relationshipList1);
+
+ try {
+ doReturn(serviceInstanceAAI).when(mockBbInputSetupUtils).getAAIServiceInstanceById(resourceId);
+ doReturn(serviceInstance).when(mockBbInputSetup).getExistingServiceInstance(serviceInstanceAAI);
+ doReturn(Optional.of(aaiConfiguration1)).when(mockAaiConfigurationResources)
+ .getConfiguration("testConfigurationId");
+ doReturn(Optional.of(aaiConfiguration2)).when(mockAaiConfigurationResources)
+ .getConfiguration("testConfigurationId2");
+ serviceEBBLoader.traverseAAIService(execution, resourceCounter, resourceId, aaiResourceIds);
+ assertEquals(8, resourceCounter.size());
+ assertTrue(resourceCounter.get(2).isBaseVfModule());
+ assertThat(aaiResourceIds, sameBeanAs(getExpectedResourceIds()));
+ } catch (Exception e) {
+ fail("Unexpected exception was thrown.");
+ }
+ }
+
+ @Test
+ public void traverseVrfConfigurationTest() throws VrfBondingServiceException, JsonProcessingException {
+ List<Resource> resource = new ArrayList<>();
+ List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
+
+ Service service = new Service();
+ List<ConfigurationResourceCustomization> resourceCustomizations = new ArrayList<>();
+
+ ConfigurationResourceCustomization configuration = new ConfigurationResourceCustomization();
+ configuration.setModelCustomizationUUID("123");
+ resourceCustomizations.add(configuration);
+ service.setConfigurationCustomizations(resourceCustomizations);
+
+ Relationship relationship = new Relationship();
+ relationship.setRelatedTo("vpn-binding");
+
+ RelationshipList relationshipList = new RelationshipList();
+ relationshipList.getRelationship().add(relationship);
+
+ org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network();
+ aaiLocalNetwork.setNetworkId("localNetworkId");
+ aaiLocalNetwork.setRelationshipList(relationshipList);
+
+ RelatedInstance relatedVpnBinding = new RelatedInstance();
+ relatedVpnBinding.setInstanceId("vpnBindingInstanceId");
+ RelatedInstance relatedLocalNetwork = new RelatedInstance();
+ relatedLocalNetwork.setInstanceId("localNetworkInstanceId");
+
+
+ doReturn(aaiLocalNetwork).when(mockBbInputSetupUtils).getAAIL3Network("localNetworkInstanceId");
+
+ serviceEBBLoader.traverseVrfConfiguration(aaiResourceIds, resource, service, relatedVpnBinding,
+ relatedLocalNetwork);
+ assertEquals(resource.size(), 1);
+ assertEquals(aaiResourceIds.size(), 0);
+ }
+
+ private List<Pair<WorkflowType, String>> getExpectedResourceIds() {
+ List<Pair<WorkflowType, String>> resourceIds = new ArrayList<>();
+ resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VNF, "testVnfId1"));
+ resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VFMODULE, "testVfModuleId1"));
+ resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.VOLUMEGROUP, "testVolumeGroupId1"));
+ resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORK, "testNetworkId1"));
+ resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.NETWORKCOLLECTION, "testId"));
+ resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, "testConfigurationId"));
+ resourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, "testConfigurationId2"));
+ return resourceIds;
+ }
+
+ @Test
+ public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException, VrfBondingServiceException {
+ execution.setVariable("testProcessKey", "testProcessKeyValue");
+ Service service = new Service();
+ List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>();
+ NetworkResourceCustomization networkCust = new NetworkResourceCustomization();
+ networkCust.setModelCustomizationUUID("123");
+ networkCustomizations.add(networkCust);
+ service.setNetworkCustomizations(networkCustomizations);
+ NetworkCollectionResourceCustomization collectionResourceCustomization =
+ new NetworkCollectionResourceCustomization();
+ collectionResourceCustomization.setModelCustomizationUUID("123");
+ CollectionResource collectionResource = new CollectionResource();
+ collectionResource.setToscaNodeType("NetworkCollection");
+ InstanceGroup instanceGroup = new InstanceGroup();
+ List<CollectionResourceInstanceGroupCustomization> collectionInstanceGroupCustomizations = new ArrayList<>();
+ CollectionResourceInstanceGroupCustomization collectionInstanceGroupCustomization =
+ new CollectionResourceInstanceGroupCustomization();
+ collectionInstanceGroupCustomization.setSubInterfaceNetworkQuantity(3);
+ collectionInstanceGroupCustomizations.add(collectionInstanceGroupCustomization);
+ instanceGroup.setCollectionInstanceGroupCustomizations(collectionInstanceGroupCustomizations);
+ collectionResource.setInstanceGroup(instanceGroup);
+ collectionResourceCustomization.setCollectionResource(collectionResource);;
+ service.setModelUUID("abc");
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+ service.getCollectionResourceCustomizations().add(collectionResourceCustomization);
+
+
+ doReturn(service).when(mockCatalogDbClient).getServiceByID("3c40d244-808e-42ca-b09a-256d83d19d0a");
+ doReturn(collectionResourceCustomization).when(mockCatalogDbClient)
+ .getNetworkCollectionResourceCustomizationByID("123");
+ String bpmnRequest = readBpmnRequestFromFile(MACRO_ACTIVATE_DELETE_UNASSIGN_JSON);
+ ObjectMapper mapper = new ObjectMapper();
+ ServiceInstancesRequest sIRequest = mapper.readValue(bpmnRequest, ServiceInstancesRequest.class);
+
+ List<Resource> resource = new ArrayList<>();
+ List<Pair<WorkflowType, String>> aaiResourceIds = new ArrayList<>();
+
+ serviceEBBLoader.traverseCatalogDbService(execution, sIRequest, resource, aaiResourceIds);
+ assertEquals(resource.size(), 2);
+ }
+
+ private String readBpmnRequestFromFile(String fileName) throws IOException {
+ return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + fileName)));
+ }
+
+ private List<Resource> prepareListWithResources() {
+ List<Resource> resourceList = new ArrayList<>();
+ resourceList.add(new Resource(WorkflowType.SERVICE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false));
+ resourceList.add(new Resource(WorkflowType.VNF, "ab153b6e-c364-44c0-bef6-1f2982117f04", false));
+ resourceList.add(new Resource(WorkflowType.VOLUMEGROUP, "a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f", false));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "3c40d244-808e-42ca-b09a-256d83d19d0a", false));
+ resourceList.add(new Resource(WorkflowType.VFMODULE, "72d9d1cd-f46d-447a-abdb-451d6fb05fa8", false));
+ return resourceList;
+ }
+}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
index 75514b15d7..9f4bd97ac6 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/UserParamsServiceTraversalTest.java
@@ -61,6 +61,7 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest {
private static final String MACRO_ASSIGN_JSON = "Macro/ServiceMacroAssign.json";
private static final String MACRO_ASSIGN_PNF_JSON = "Macro/ServiceMacroAssignPnf.json";
private static final String NETWORK_COLLECTION_JSON = "Macro/CreateNetworkCollection.json";
+ private static final String MACRO_CREATE_WITHOUT_RESOURCES_JSON = "Macro/ServiceMacroCreateWithoutResources.json";
private static final String serviceInstanceId = "123";
private DelegateExecution execution;
private CatalogDbClient mockCatalogDbClient;
@@ -76,6 +77,24 @@ public class UserParamsServiceTraversalTest extends BaseTaskTest {
}
@Test
+ public void getResourceListFromUserParams() throws Exception {
+ initExecution(requestAction, readBpmnRequestFromFile(MACRO_CREATE_WITHOUT_RESOURCES_JSON), false);
+ Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient)
+ .getVfModuleCustomizationByModelCuztomizationUUID("a25e8e8c-58b8-4eec-810c-97dcc1f5cb7f");
+ Mockito.doReturn(getCvnfcCustomizations()).when(mockCatalogDbClient).getCvnfcCustomization(anyString(),
+ anyString(), anyString());
+
+ List<Resource> resourceListFromUserParams = userParamsServiceTraversal.getResourceListFromUserParams(execution,
+ getUserParams(), serviceInstanceId, requestAction);
+ List<WorkflowType> expected = List.of(WorkflowType.SERVICE);
+ List<WorkflowType> result =
+ resourceListFromUserParams.stream().map(Resource::getResourceType).collect(Collectors.toList());
+
+ assertEquals(1, resourceListFromUserParams.size());
+ assertThat(expected, is(result));
+ }
+
+ @Test
public void getResourceListFromUserParamsForVnfs() throws Exception {
initExecution(requestAction, readBpmnRequestFromFile(MACRO_ASSIGN_JSON), false);
Mockito.doReturn(getVfModuleCustomization()).when(mockCatalogDbClient)
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAITest.java
index 7ac245d0f4..ba55dd0365 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAITest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAITest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.so.bpmn.infrastructure.workflow.tasks;
+package org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -38,6 +38,7 @@ import org.onap.aaiclient.client.aai.entities.Relationships;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAISimpleUri;
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types;
+import org.onap.so.bpmn.infrastructure.workflow.tasks.ebb.loader.WorkflowActionExtractResourcesAAI;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateWithoutResources.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateWithoutResources.json
new file mode 100644
index 0000000000..579c924d9b
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/Macro/ServiceMacroCreateWithoutResources.json
@@ -0,0 +1,48 @@
+{
+ "requestDetails": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelInvariantId": "5d48acb5-097d-4982-aeb2-f4a3bd87d31b",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a",
+ "modelName": "Sample Service Model",
+ "modelVersion": "10.0"
+ },
+ "cloudConfiguration": {
+ "cloudOwner" : "my-custom-cloud-owner"
+ },
+ "owningEntity": {
+ "owningEntityId": "038d99af-0427-42c2-9d15-971b99b9b489",
+ "owningEntityName": "PACKET CORE"
+ },
+ "project": {
+ "projectName": "{some project name}"
+ },
+ "subscriberInfo": {
+ "globalSubscriberId": "{some subscriber id}"
+ },
+ "requestInfo": {
+ "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb",
+ "source": "VID",
+ "suppressRollback": true,
+ "requestorId": "xxxxxx",
+ "instanceName": "test"
+ },
+ "requestParameters": {
+ "subscriptionServiceType": "VMX",
+ "aLaCarte": false,
+ "userParams": [
+ {
+ "service": {
+ "modelInfo": {
+ "modelType": "service",
+ "modelName": "Sample Service Model",
+ "modelVersionId": "3c40d244-808e-42ca-b09a-256d83d19d0a"
+ },
+ "instanceParams": [],
+ "resources": {}
+ }
+ }
+ ]
+ }
+ }
+}