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%2Fmanualhandling%2Ftasks%2FManualHandlingTasksTest.java;h=f9ad473e5aeac5c8702cf745d970d4fbed5eed7c;hb=f47919f1fe367b612fa9c96d34c59f01a541e882;hp=5e9565446f7559fba99defb15bfdaa01112e3058;hpb=54452b80a1cf4d22ef750bc1377f8c1b05431d57;p=so.git diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java index 5e9565446f..f9ad473e5a 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/manualhandling/tasks/ManualHandlingTasksTest.java @@ -6,10 +6,8 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - import java.util.HashMap; import java.util.Map; - import org.camunda.bpm.engine.ProcessEngineServices; import org.camunda.bpm.engine.TaskService; import org.camunda.bpm.engine.delegate.DelegateExecution; @@ -23,76 +21,76 @@ import org.onap.so.bpmn.BaseTaskTest; import org.onap.so.db.request.beans.InfraActiveRequests; public class ManualHandlingTasksTest extends BaseTaskTest { - @InjectMocks - protected ManualHandlingTasks manualHandlingTasks = new ManualHandlingTasks(); - - @Mock - TaskService taskService; - - @Mock - private DelegateExecution mockExecution; - - @Mock - ProcessEngineServices processEngineServices; - - @Mock - private DelegateTask task; - - private DelegateExecution delegateExecution; - - @Before - public void before() throws Exception { - delegateExecution = new DelegateExecutionFake(); - } - - @Test - public void setFalloutTaskVariables_Test () { - when(task.getId()).thenReturn("taskId"); - when(task.getExecution()).thenReturn(mockExecution); - when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices); - when(processEngineServices.getTaskService()).thenReturn(taskService); - manualHandlingTasks.setFalloutTaskVariables(task); - verify(taskService, times(1)).setVariables(any(String.class), any(Map.class)); - } - - @Test - public void setPauseTaskVariables_Test () { - when(task.getId()).thenReturn("taskId"); - when(task.getExecution()).thenReturn(mockExecution); - when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices); - when(processEngineServices.getTaskService()).thenReturn(taskService); - manualHandlingTasks.setPauseTaskVariables(task); - verify(taskService, times(1)).setVariables(any(String.class), any(Map.class)); - } - - @Test - public void completeTask_Test() throws Exception{ - when(task.getId()).thenReturn("taskId"); - when(task.getExecution()).thenReturn(mockExecution); - Map taskVariables = new HashMap(); - taskVariables.put("responseValue", "resume"); - when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices); - when(processEngineServices.getTaskService()).thenReturn(taskService); - when(taskService.getVariables(any(String.class))).thenReturn(taskVariables); - manualHandlingTasks.completeTask(task); - verify(mockExecution, times(1)).setVariable("responseValueTask", "Resume"); - } - - @Test - public void updateRequestDbStatus_Test() throws Exception{ - InfraActiveRequests mockedRequest = new InfraActiveRequests(); - delegateExecution.setVariable("msoRequestId", "testMsoRequestId"); - when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); - doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); - manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS"); - verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); - assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS"); - } - - @Test - public void createExternalTicket_Test() throws Exception{ - delegateExecution.setVariable("msoRequestId", ("testMsoRequestId")); - delegateExecution.setVariable("vnfType", "testVnfType"); - manualHandlingTasks.createExternalTicket(delegateExecution); - } + @InjectMocks + protected ManualHandlingTasks manualHandlingTasks = new ManualHandlingTasks(); + + @Mock + TaskService taskService; + + @Mock + private DelegateExecution mockExecution; + + @Mock + ProcessEngineServices processEngineServices; + + @Mock + private DelegateTask task; + + private DelegateExecution delegateExecution; + + @Before + public void before() throws Exception { + delegateExecution = new DelegateExecutionFake(); + } + + @Test + public void setFalloutTaskVariables_Test() { + when(task.getId()).thenReturn("taskId"); + when(task.getExecution()).thenReturn(mockExecution); + when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices); + when(processEngineServices.getTaskService()).thenReturn(taskService); + manualHandlingTasks.setFalloutTaskVariables(task); + verify(taskService, times(1)).setVariables(any(String.class), any(Map.class)); + } + + @Test + public void setPauseTaskVariables_Test() { + when(task.getId()).thenReturn("taskId"); + when(task.getExecution()).thenReturn(mockExecution); + when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices); + when(processEngineServices.getTaskService()).thenReturn(taskService); + manualHandlingTasks.setPauseTaskVariables(task); + verify(taskService, times(1)).setVariables(any(String.class), any(Map.class)); + } + + @Test + public void completeTask_Test() throws Exception { + when(task.getId()).thenReturn("taskId"); + when(task.getExecution()).thenReturn(mockExecution); + Map taskVariables = new HashMap(); + taskVariables.put("responseValue", "resume"); + when(mockExecution.getProcessEngineServices()).thenReturn(processEngineServices); + when(processEngineServices.getTaskService()).thenReturn(taskService); + when(taskService.getVariables(any(String.class))).thenReturn(taskVariables); + manualHandlingTasks.completeTask(task); + verify(mockExecution, times(1)).setVariable("responseValueTask", "Resume"); + } + + @Test + public void updateRequestDbStatus_Test() throws Exception { + InfraActiveRequests mockedRequest = new InfraActiveRequests(); + delegateExecution.setVariable("msoRequestId", "testMsoRequestId"); + when(requestsDbClient.getInfraActiveRequestbyRequestId(any(String.class))).thenReturn(mockedRequest); + doNothing().when(requestsDbClient).updateInfraActiveRequests(any(InfraActiveRequests.class)); + manualHandlingTasks.updateRequestDbStatus(delegateExecution, "IN_PROGRESS"); + verify(requestsDbClient, times(1)).updateInfraActiveRequests(any(InfraActiveRequests.class)); + assertEquals(mockedRequest.getRequestStatus(), "IN_PROGRESS"); + } + + @Test + public void createExternalTicket_Test() throws Exception { + delegateExecution.setVariable("msoRequestId", ("testMsoRequestId")); + delegateExecution.setVariable("vnfType", "testVnfType"); + manualHandlingTasks.createExternalTicket(delegateExecution); + } }