X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=bpmn%2Fso-bpmn-tasks%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fso%2Fbpmn%2Finfrastructure%2Fadapter%2Fvnfm%2Ftasks%2FMonitorVnfmNodeJobTest.java;h=6b84f6a9187f3cab927bd2c0e795802ff4317a11;hb=f47919f1fe367b612fa9c96d34c59f01a541e882;hp=aa3ab113a011761349f73b4fda2fadbbbee2c5fa;hpb=54452b80a1cf4d22ef750bc1377f8c1b05431d57;p=so.git diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java index aa3ab113a0..6b84f6a918 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmNodeJobTest.java @@ -46,66 +46,66 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; */ public class MonitorVnfmNodeJobTest extends BaseTaskTest { - private static final String VNF_ID = UUID.randomUUID().toString(); - - private static final String VNF_NAME = "VNF_NAME"; - - private MonitorVnfmNodeTask objUnderTest; - - @Mock - private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider; - - private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution(); - - @Before - public void setUp() { - objUnderTest = getEtsiVnfMonitorNodeJobTask(); - } - - @Test - public void testGetNodeStatusCreate() throws Exception { - GenericVnf vnf = getGenericVnf(); - vnf.setOrchestrationStatus(VNF_CREATED); - when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); - objUnderTest.getNodeStatus(stubbedxecution); - assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); - } - - @Test - public void testGetNodeStatusDelete() throws Exception { - GenericVnf vnf = getGenericVnf(); - vnf.setOrchestrationStatus(VNF_ASSIGNED); - when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); - objUnderTest.getNodeStatus(stubbedxecution); - assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); - } - - @Test - public void testGetNodeStatusException() throws Exception { - when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class); - objUnderTest.getNodeStatus(stubbedxecution); - assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); - assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); - verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220), - any(Exception.class)); - } - - @Test - public void testTimeOutLogFailue() throws Exception { - objUnderTest.timeOutLogFailue(stubbedxecution); - verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221), - eq("Node operation time out")); - } - - private GenericVnf getGenericVnf() { - final GenericVnf genericVnf = new GenericVnf(); - genericVnf.setVnfId(VNF_ID); - genericVnf.setVnfName(VNF_NAME); - return genericVnf; - } - - private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() { - return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil); - } + private static final String VNF_ID = UUID.randomUUID().toString(); + + private static final String VNF_NAME = "VNF_NAME"; + + private MonitorVnfmNodeTask objUnderTest; + + @Mock + private VnfmAdapterServiceProvider mockedVnfmAdapterServiceProvider; + + private final BuildingBlockExecution stubbedxecution = new StubbedBuildingBlockExecution(); + + @Before + public void setUp() { + objUnderTest = getEtsiVnfMonitorNodeJobTask(); + } + + @Test + public void testGetNodeStatusCreate() throws Exception { + GenericVnf vnf = getGenericVnf(); + vnf.setOrchestrationStatus(VNF_CREATED); + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); + objUnderTest.getNodeStatus(stubbedxecution); + assertTrue(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); + } + + @Test + public void testGetNodeStatusDelete() throws Exception { + GenericVnf vnf = getGenericVnf(); + vnf.setOrchestrationStatus(VNF_ASSIGNED); + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenReturn(vnf); + objUnderTest.getNodeStatus(stubbedxecution); + assertTrue(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); + } + + @Test + public void testGetNodeStatusException() throws Exception { + when(extractPojosForBB.extractByKey(any(), eq(ResourceKey.GENERIC_VNF_ID))).thenThrow(RuntimeException.class); + objUnderTest.getNodeStatus(stubbedxecution); + assertNull(stubbedxecution.getVariable(CREATE_VNF_NODE_STATUS)); + assertNull(stubbedxecution.getVariable(DELETE_VNF_NODE_STATUS)); + verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1220), + any(Exception.class)); + } + + @Test + public void testTimeOutLogFailue() throws Exception { + objUnderTest.timeOutLogFailue(stubbedxecution); + verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1221), + eq("Node operation time out")); + } + + private GenericVnf getGenericVnf() { + final GenericVnf genericVnf = new GenericVnf(); + genericVnf.setVnfId(VNF_ID); + genericVnf.setVnfName(VNF_NAME); + return genericVnf; + } + + private MonitorVnfmNodeTask getEtsiVnfMonitorNodeJobTask() { + return new MonitorVnfmNodeTask(extractPojosForBB, exceptionUtil); + } }