summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/test
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2020-04-01 10:41:17 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-04-17 12:05:16 -0400
commitfbb984e6a8823ca26eae20a65c6d261feac02b7b (patch)
tree00e6f3c385587a351ab644112ffca733f77465e7 /bpmn/so-bpmn-tasks/src/test
parenteceef88af7a5e13a7840059004116e8b6cbf35ac (diff)
openstack inventory capture
Begin heatbridge refactor initial check in of heatbridge Additional commits of heatbridge Update Heat bridge to write more AAI data Update to utlize HeatBrdige to populate AAI Adjust simulator endpoints to work again Remove not needed BB Test case, fix tc Refactor how AAI relationships are being built Issue-ID: SO-2777 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Iffccc24e18b278188c3fe98bcb1ad9685229d0a2
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java3
-rw-r--r--bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModuleTest.java108
2 files changed, 111 insertions, 0 deletions
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 03ffd9c4c1..29177f8275 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
@@ -24,6 +24,7 @@ package org.onap.so.bpmn;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.infrastructure.flowspecific.tasks.AssignNetworkBBUtils;
@@ -32,6 +33,8 @@ import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetup;
import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.client.adapter.network.mapper.NetworkAdapterObjectMapper;
import org.onap.so.client.appc.ApplicationControllerAction;
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModuleTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModuleTest.java
new file mode 100644
index 0000000000..63f7d6cbfc
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModuleTest.java
@@ -0,0 +1,108 @@
+package org.onap.so.bpmn.infrastructure.vfmodule;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import java.util.Optional;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.BaseTaskTest;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.Tenant;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.AAIResultWrapper;
+import org.onap.so.client.aai.entities.Relationships;
+import org.onap.so.client.aai.entities.uri.AAIPluralResourceUri;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.cloud.resource.beans.CloudInformation;
+import org.onap.so.cloud.resource.beans.NodeType;
+
+
+
+public class CreateVFModuleTest extends BaseTaskTest {
+
+ @Spy
+ @InjectMocks
+ public CreateVFModule createVFModule;
+
+ @Mock
+ protected AAIResourcesClient aaiResourcesClient;
+
+ @Mock
+ protected AAIResultWrapper aaiIResultWrapper;
+
+ @Mock
+ protected Relationships relationships;
+
+ @Mock
+ protected BuildingBlockExecution execution;
+
+
+ public GeneralBuildingBlock gbb;
+ public CloudRegion cloudRegion;
+ private GenericVnf genericVnf;
+ private VfModule vfModule;
+ private ServiceInstance service;
+
+ @Before
+ public void before() {
+ cloudRegion = new CloudRegion();
+ cloudRegion.setCloudOwner("CloudOwner");
+ cloudRegion.setLcpCloudRegionId("testRegion");
+ Tenant tenant = new Tenant();
+ tenant.setTenantId("tenant-001");
+ tenant.setTenantName("test-tenant");
+ tenant.setTenantContext("testContext");
+ service = setServiceInstance();
+ genericVnf = setGenericVnf();
+ vfModule = setVfModule();
+ gbb = new GeneralBuildingBlock();
+ gbb.setCloudRegion(cloudRegion);
+ gbb.setTenant(tenant);
+ }
+
+ @Test
+ public void createInventoryVariableTest() throws BBObjectNotFoundException {
+ doReturn(gbb).when(execution).getGeneralBuildingBlock();
+ doReturn(genericVnf).when(extractPojosForBB).extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
+ doReturn(vfModule).when(extractPojosForBB).extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ doReturn("heat-stack-id").when(execution).getVariable("heatStackId");
+ doReturn(NodeType.GREENFIELD).when(createVFModule).getNodeType(any(CloudRegion.class));
+ createVFModule.createInventoryVariable(execution);
+ verify(execution).setVariable(eq("cloudInformation"), any(CloudInformation.class));
+ }
+
+ @Test
+ public void getNodeTypeBrownfieldTest() {
+ doReturn(aaiResourcesClient).when(createVFModule).getAAIClient();
+ doReturn(aaiIResultWrapper).when(aaiResourcesClient).get(any(AAIResourceUri.class));
+ doReturn(Optional.empty()).when(aaiIResultWrapper).getRelationships();
+
+ assertEquals(NodeType.BROWNFIELD, createVFModule.getNodeType(cloudRegion));
+ }
+
+ @Test
+ public void getNodeTypeGreenfieldTest() {
+ doReturn(aaiResourcesClient).when(createVFModule).getAAIClient();
+ doReturn(aaiIResultWrapper).when(aaiResourcesClient).get(any(AAIResourceUri.class));
+ doReturn(aaiIResultWrapper).when(aaiResourcesClient).get(any(AAIPluralResourceUri.class));
+ doReturn(Optional.of(relationships)).when(aaiIResultWrapper).getRelationships();
+
+ assertEquals(NodeType.GREENFIELD, createVFModule.getNodeType(cloudRegion));
+ }
+}