Commit 87f3e855 authored by Aalekh Jain's avatar Aalekh Jain
Browse files

Updated UTs for WorkflowManagerService

parent a6fddde0
......@@ -14,7 +14,6 @@ import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.workflow.exception.ResourceConflictException;
import org.opengroup.osdu.workflow.exception.WorkflowNotFoundException;
import org.opengroup.osdu.workflow.gsm.WorkflowStatusPublisher;
import org.opengroup.osdu.workflow.logging.AuditLogger;
import org.opengroup.osdu.workflow.model.CreateWorkflowRequest;
import org.opengroup.osdu.workflow.model.WorkflowEngineRequest;
......@@ -22,6 +21,7 @@ import org.opengroup.osdu.workflow.model.WorkflowMetadata;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowEngineService;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowMetadataRepository;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowRunService;
import org.opengroup.osdu.workflow.provider.interfaces.IWorkflowSystemMetadataRepository;
import org.opengroup.osdu.workflow.service.WorkflowManagerServiceImpl;
import java.util.List;
......@@ -81,6 +81,9 @@ public class WorkflowManagerServiceTest {
@Mock
private IWorkflowMetadataRepository workflowMetadataRepository;
@Mock
private IWorkflowSystemMetadataRepository workflowSystemMetadataRepository;
@Mock
private DpsHeaders dpsHeaders;
......@@ -197,12 +200,15 @@ public class WorkflowManagerServiceTest {
final ArgumentCaptor<String> workflowIdCaptor = ArgumentCaptor.forClass(String.class);
when(workflowMetadataRepository.getWorkflow(workflowIdCaptor.capture()))
.thenThrow(WorkflowNotFoundException.class);
when(workflowSystemMetadataRepository.getSystemWorkflow(workflowIdCaptor.capture()))
.thenThrow(WorkflowNotFoundException.class);
//when and then
Assertions.assertThrows(WorkflowNotFoundException.class, () -> {
workflowManagerService.getWorkflowByName(WORKFLOW_NAME);
});
verify(workflowMetadataRepository).getWorkflow(anyString());
verify(workflowMetadataRepository).getWorkflow(eq(WORKFLOW_NAME));
verify(workflowSystemMetadataRepository).getSystemWorkflow(eq(WORKFLOW_NAME));
assertThat(workflowIdCaptor.getValue(), equalTo(WORKFLOW_NAME));
}
......@@ -269,8 +275,11 @@ public class WorkflowManagerServiceTest {
public void testGetAllWorkflowsSuccess() {
//given
final List<WorkflowMetadata> mockedWorkflowMetadataList = mock(List.class);
final List<WorkflowMetadata> mockedSystemWorkflowMetadataList = mock(List.class);
when(workflowMetadataRepository.getAllWorkflowForTenant(eq(PREFIX_INPUT))).
thenReturn(mockedWorkflowMetadataList);
when(workflowSystemMetadataRepository.getAllSystemWorkflow(eq(PREFIX_INPUT))).
thenReturn(mockedSystemWorkflowMetadataList);
//when
List<WorkflowMetadata> responseWorkflowMetadataList =
......@@ -278,6 +287,8 @@ public class WorkflowManagerServiceTest {
//then
verify(workflowMetadataRepository).getAllWorkflowForTenant(eq(PREFIX_INPUT));
verify(mockedWorkflowMetadataList).addAll(eq(mockedSystemWorkflowMetadataList));
verify(workflowSystemMetadataRepository).getAllSystemWorkflow(eq(PREFIX_INPUT));
assertThat(responseWorkflowMetadataList, equalTo(mockedWorkflowMetadataList));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment