diff options
author | Steve Smokowski <ss835w@att.com> | 2020-04-22 12:35:15 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-22 12:35:15 +0000 |
commit | 761567ec1de6e322c419f47f00a66a691f58a7af (patch) | |
tree | b61e950ceca83290b17dab54868974bc493341e8 /bpmn/so-bpmn-tasks/src/test/java/org | |
parent | 21e51ae1290ac58d9f579333199098f98615f5b2 (diff) | |
parent | fbb984e6a8823ca26eae20a65c6d261feac02b7b (diff) |
Merge "openstack inventory capture"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test/java/org')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/BaseTaskTest.java | 3 | ||||
-rw-r--r-- | bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/vfmodule/CreateVFModuleTest.java | 108 |
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)); + } +} |