use of org.wso2.carbon.apimgt.core.workflow.SubscriptionCreationWorkflow in project carbon-apimgt by wso2.
the class WorkflowMappingUtilTest method testToWorkflowListDTO.
@Test(description = "Convert List<Workflow> workflowList to WorkflowListDTO")
public void testToWorkflowListDTO() throws Exception {
List<Workflow> wfList = new ArrayList<>();
Workflow workflow1 = new ApplicationCreationWorkflow(null, null, null);
workflow1.setStatus(WorkflowStatus.APPROVED);
LocalDateTime date1 = LocalDateTime.now();
workflow1.setCreatedTime(date1);
workflow1.setWorkflowDescription("Description 1");
workflow1.setWorkflowType(WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION);
String ref1 = UUID.randomUUID().toString();
workflow1.setExternalWorkflowReference(ref1);
wfList.add(workflow1);
Workflow workflow2 = new SubscriptionCreationWorkflow(null, null, null);
workflow2.setStatus(WorkflowStatus.APPROVED);
LocalDateTime date2 = LocalDateTime.now();
workflow2.setCreatedTime(date2);
workflow2.setWorkflowDescription("Description 2");
workflow2.setWorkflowType(WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
String ref2 = UUID.randomUUID().toString();
workflow2.setExternalWorkflowReference(ref2);
wfList.add(workflow2);
WorkflowListDTO wfDtoList = WorkflowMappingUtil.toWorkflowListDTO(wfList);
int count = wfDtoList.getCount();
Assert.assertEquals(count, 2, "Mismatch in the workflow list item count");
Assert.assertEquals(wfDtoList.getList().get(0).getDescription(), "Description 1", "Invalid description for workflow item 1");
Assert.assertEquals(wfDtoList.getList().get(0).getType(), WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION, "Invalid type for workflow item 1");
Assert.assertEquals(wfDtoList.getList().get(0).getWorkflowStatus(), WorkflowStatus.APPROVED.toString(), "Invalid status for workflow item 1");
Assert.assertEquals(wfDtoList.getList().get(0).getReferenceId(), ref1, "Invalid reference id for workflow item 1");
Assert.assertEquals(wfDtoList.getList().get(1).getDescription(), "Description 2", "Invalid description for workflow item 2");
Assert.assertEquals(wfDtoList.getList().get(1).getType(), WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION, "Invalid type for workflow item 2");
Assert.assertEquals(wfDtoList.getList().get(1).getWorkflowStatus(), WorkflowStatus.APPROVED.toString(), "Invalid status for workflow item 2");
Assert.assertEquals(wfDtoList.getList().get(1).getReferenceId(), ref2, "Invalid reference id for workflow item 2");
}
Aggregations