summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java35
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java56
2 files changed, 5 insertions, 86 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
index 06c65020f5..7c9e000a44 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetwork.java
@@ -21,10 +21,8 @@ package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
-import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
import org.onap.so.logger.MsoLogger;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,30 +33,9 @@ public class AssignNetwork {
private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,
AssignNetwork.class);
- @Autowired
- private ExceptionBuilder exceptionUtil;
+
@Autowired
private ExtractPojosForBB extractPojosForBB;
-
- /**
- * Check if there are collection(s)
- * @param execution
- * @return boolean
- */
- public boolean hasCollection(BuildingBlockExecution execution) {
- boolean hasCollection = false;
- try {
- ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID,
- execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
- if (serviceInstance.getCollection() != null){
- hasCollection = true;
- msoLogger.debug("there are collections to create");
- }
- } catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
- }
- return hasCollection;
- }
/**
* Check if network was found by name
@@ -80,14 +57,4 @@ public class AssignNetwork {
}
return networkFound;
}
-
- /**
- * BPMN access method. Return flag if BPMN flow should skip AAI interaction
- * @param execution
- * @return TRUE if network collection was NOT present OR network WAS found by name
- */
- public boolean skipNetworkCreationInAAI(BuildingBlockExecution execution) {
-
- return !hasCollection(execution) || networkFoundByName(execution);
- }
}
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
index a206140014..6e5bd314d8 100644
--- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/AssignNetworkTest.java
@@ -25,7 +25,6 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
-import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -36,80 +35,33 @@ public class AssignNetworkTest extends BaseTaskTest {
@Autowired
private AssignNetwork assignNetwork;
- private ServiceInstance serviceInstance;
private L3Network network;
@Before
public void before() {
- serviceInstance = setServiceInstance();
network = setL3Network();
}
@Test
- public void hasCollectionTest() throws Exception {
- setServiceInstance();
- //collection present by default base test setup
- boolean hasCollection = assignNetwork.hasCollection(execution);
- assertEquals(true, hasCollection);
-
- boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
- assertEquals(false, skip);
- }
-
- @Test
- public void hasNoCollectionTest() throws Exception {
- //clear collection
+ public void networkNotFoundTest() throws Exception {
+ //network status to PRECREATED - when it was NOT found by name
try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
- } catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
- }
- serviceInstance.setCollection(null);
- boolean hasCollection = assignNetwork.hasCollection(execution);
- assertEquals(false, hasCollection);
-
- boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
- assertEquals(true, skip);
- }
-
- @Test
- public void hasNoCollectionNoNetworkTest() throws Exception {
- //clear collection and updated network status to PRECREATED - when it was NOT found by name
- try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID,execution.getLookupMap().get(ResourceKey.NETWORK_ID));
} catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
}
- serviceInstance.setCollection(null);
+
network.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
- boolean hasCollection = assignNetwork.hasCollection(execution);
boolean networkFound = assignNetwork.networkFoundByName(execution);
- assertEquals(false, hasCollection);
assertEquals(false, networkFound);
-
- boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
- assertEquals(true, skip);
}
@Test
- public void hasNetworkNoCollectionTest() throws Exception {
- //clear collection and updated network status to INVENTORIED - when it was found by name
+ public void networkFoundTest() throws Exception {
try {
- serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID));
network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID,execution.getLookupMap().get(ResourceKey.NETWORK_ID));
} catch(BBObjectNotFoundException e) {
- serviceInstance = setServiceInstance();
}
- serviceInstance.setCollection(null);
- network.setOrchestrationStatus(OrchestrationStatus.INVENTORIED);
- boolean hasCollection = assignNetwork.hasCollection(execution);
boolean networkFound = assignNetwork.networkFoundByName(execution);
- assertEquals(false, hasCollection);
assertEquals(true, networkFound);
-
- boolean skip = assignNetwork.skipNetworkCreationInAAI(execution);
- assertEquals(true, skip);
}
-
}