diff options
author | Marcus Williams <marcus.williams@intel.com> | 2019-01-28 20:43:35 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-01-28 20:43:35 +0000 |
commit | 902b6a93925067f0bb8c7a1639b62cbd64604465 (patch) | |
tree | 1869cb1b23e0fc0f7113ca812e9d26fc8fa2a403 /bpmn/so-bpmn-tasks/src/test | |
parent | 1f57cd06a3bf1deeb277430dba310088368c82fa (diff) | |
parent | fe91155454a27401e8c23780fa247c0ede196747 (diff) |
Merge "Merge 'origin/casablanca' into master"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/test')
5 files changed, 96 insertions, 6 deletions
diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java index e17859969d..7fdf2535bf 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericVnfHealthCheckTest.java @@ -35,6 +35,7 @@ import java.util.UUID; import org.camunda.bpm.engine.delegate.BpmnError; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.mockito.ArgumentMatchers; import org.mockito.InjectMocks; @@ -142,4 +143,34 @@ public class GenericVnfHealthCheckTest extends BaseTaskTest { genericVnfHealthCheck.callAppcClient(execution); verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); } + + @Test + @Ignore //The runAppCCommand method in not capable of throwing this exception + public void callAppcClientTimeOutExceptionTest() { + expectedException.expect(java.util.concurrent.TimeoutException.class); + Action action = Action.HealthCheck; + String vnfId = genericVnf.getVnfId(); + String payload = "{\"testName\":\"testValue\",}"; + String controllerType = "testType"; + HashMap<String, String> payloadInfo = new HashMap<String, String>(); + payloadInfo.put("vnfName", "testVnfName"); + payloadInfo.put("vfModuleId", "testVfModuleId"); + payloadInfo.put("oamIpAddress", "testOamIpAddress"); + payloadInfo.put("vnfHostIpAddress", "testOamIpAddress"); + execution.setVariable("action", Action.HealthCheck.toString()); + execution.setVariable("msoRequestId", msoRequestId); + execution.setVariable("controllerType", controllerType); + execution.setVariable("vnfId", "testVnfId1"); + execution.setVariable("vnfName", "testVnfName"); + execution.setVariable("vfModuleId", "testVfModuleId"); + execution.setVariable("oamIpAddress", "testOamIpAddress"); + execution.setVariable("vnfHostIpAddress", "testOamIpAddress"); + execution.setVariable("payload", payload); + + doThrow(java.util.concurrent.TimeoutException.class).when(appCClient).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + + + genericVnfHealthCheck.callAppcClient(execution); + verify(appCClient, times(1)).runAppCCommand(action, msoRequestId, vnfId, Optional.of(payload), payloadInfo, controllerType); + } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java new file mode 100644 index 0000000000..4ace2727be --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/OrchestrationStatusValidatorUnitTest.java @@ -0,0 +1,45 @@ +package org.onap.so.bpmn.infrastructure.workflow.tasks; + +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; +import static org.mockito.Mockito.when; + +import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.DelegateExecutionImpl; +import org.onap.so.db.catalog.beans.BuildingBlockDetail; +import org.onap.so.db.catalog.beans.OrchestrationAction; +import org.onap.so.db.catalog.beans.OrchestrationStatusValidationDirective; +import org.onap.so.db.catalog.beans.ResourceType; +import org.onap.so.db.catalog.client.CatalogDbClient; + +@RunWith(MockitoJUnitRunner.class) +public class OrchestrationStatusValidatorUnitTest { + + @Mock + private CatalogDbClient catalogDbClient; + + @InjectMocks + private OrchestrationStatusValidator validator; + @Test + public void skipValidationTest() { + BuildingBlockDetail bbDetail = new BuildingBlockDetail(); + bbDetail.setBuildingBlockName("customBB"); + bbDetail.setResourceType(ResourceType.NO_VALIDATE); + bbDetail.setTargetAction(OrchestrationAction.CUSTOM); + when(catalogDbClient.getBuildingBlockDetail("customBB")).thenReturn(bbDetail); + BuildingBlockExecution execution = new DelegateExecutionImpl(new DelegateExecutionFake()); + execution.setVariable("flowToBeCalled", "customBB"); + execution.setVariable("aLaCarte", false); + validator.validateOrchestrationStatus(execution); + + + assertThat(execution.getVariable("orchestrationStatusValidationResult"), equalTo(OrchestrationStatusValidationDirective.VALIDATION_SKIPPED)); + } + +} diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java index 99e76450af..339e9cbf17 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterObjectMapperTest.java @@ -230,7 +230,16 @@ public class VnfAdapterObjectMapperTest { } @Test - public void test_deleteVolumeGroupRequestMapper() throws Exception { + public void test_deleteVolumeGroupHeatIdRequestMapper() throws Exception{ + this.test_deleteVolumeGroupRequestMapper("heatStackId"); + } + + @Test + public void test_deleteVolumeGroupNoHeatIdRequestMapper() throws Exception{ + this.test_deleteVolumeGroupRequestMapper(null); + } + + private void test_deleteVolumeGroupRequestMapper(String heatStackId) throws Exception { DeleteVolumeGroupRequest expectedDeleteVolumeGroupRequest = new DeleteVolumeGroupRequest(); CloudRegion cloudRegion = new CloudRegion(); @@ -244,8 +253,13 @@ public class VnfAdapterObjectMapperTest { volumeGroup.setVolumeGroupId("volumeGroupId"); expectedDeleteVolumeGroupRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId()); - volumeGroup.setHeatStackId("heatStackId"); - expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId()); + if (heatStackId != null){ + volumeGroup.setHeatStackId("heatStackId"); + expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId()); + } else { + volumeGroup.setVolumeGroupName("volumeGroupName"); + expectedDeleteVolumeGroupRequest.setVolumeGroupStackId(volumeGroup.getVolumeGroupName()); + } expectedDeleteVolumeGroupRequest.setSkipAAI(true); @@ -269,7 +283,7 @@ public class VnfAdapterObjectMapperTest { assertThat(actualDeleteVolumeGroupRequest, sameBeanAs(expectedDeleteVolumeGroupRequest)); } - + @Test @Ignore public void test_createVolumeGroupParams() throws Exception { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java index 32a495e094..a156c382d1 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperPayloadTest.java @@ -845,7 +845,7 @@ public class VnfAdapterVfModuleObjectMapperPayloadTest { jsonToCompare, DeleteVfModuleRequest.class); - assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl")); + assertThat(vfModuleVNFAdapterRequest, sameBeanAs(reqMapper1).ignoring("messageId").ignoring("notificationUrl").ignoring("vfModuleStackId")); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java index 85750874dd..160feed426 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapperTest.java @@ -43,7 +43,7 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; import org.onap.so.entity.MsoRequest; -public class VnfAdapterVfModuleObjectMapperTest{ +public class VnfAdapterVfModuleObjectMapperTest { @Spy private VnfAdapterVfModuleObjectMapper mapper = new VnfAdapterVfModuleObjectMapper(); |