11/7: merge casablanca to master
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / flowspecific / tasks / GenericVnfHealthCheckTest.java
index af390d1..e178599 100644 (file)
@@ -109,6 +109,36 @@ public class GenericVnfHealthCheckTest extends BaseTaskTest {
                
                doNothing().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);
+       }
+       
+       @Test
+       public void callAppcClientExceptionTest() throws Exception {
+               expectedException.expect(BpmnError.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(new BpmnError("BPMN Error")).when(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1002), eq("APPC Client Failed")); 
+               doThrow(new RuntimeException("APPC Client Failed")).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);
        }