use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class WorkflowExtensionsConfigBuilderTestCase method testWorkflowConfigWithoutConfigFile.
@Test(description = "Test situation where workflow config file loading during a missing config file")
public void testWorkflowConfigWithoutConfigFile() {
WorkflowConfig config = WorkflowExtensionsConfigBuilder.getWorkflowConfig();
Assert.assertNotNull(config.getApplicationCreation(), "Default application creation workflow not set");
Assert.assertNotNull(config.getSubscriptionCreation(), "Default subscription creation workflow not set");
Assert.assertNotNull(config.getApplicationDeletion(), "Default application deletion workflow not set");
Assert.assertNotNull(config.getSubscriptionDeletion(), "Default subscription deletion workflow not set");
WorkflowExtensionsConfigBuilder obj = new WorkflowExtensionsConfigBuilder();
Assert.assertNotNull(obj);
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsWorkflowReferenceIdGetException.
@Test
public void testWorkflowsWorkflowReferenceIdGetException() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
String workflowRefId = UUID.randomUUID().toString();
String message = "Error while retrieving workflow entry for :" + workflowRefId;
Mockito.doThrow(new APIManagementException(message, ExceptionCodes.APIMGT_DAO_EXCEPTION)).when(adminService).retrieveWorkflow(workflowRefId);
Response response = workflowsApiService.workflowsWorkflowReferenceIdGet(workflowRefId, getRequest());
assertEquals(500, response.getStatus());
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsGetWithType.
@Test
public void testWorkflowsGetWithType() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
List<Workflow> workflowList = new ArrayList<>();
Mockito.doReturn(workflowList).doThrow(new IllegalArgumentException()).when(adminService).retrieveUncompletedWorkflowsByType(WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION);
Response response = workflowsApiService.workflowsGet(null, null, WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION, getRequest());
assertEquals(200, response.getStatus());
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsWorkflowReferenceIdPutAlreadyPublished.
@Test
public void testWorkflowsWorkflowReferenceIdPutAlreadyPublished() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
String workflowRefId = UUID.randomUUID().toString();
WorkflowRequestDTO workflowRequestDTO = new WorkflowRequestDTO();
workflowRequestDTO.setDescription("Test Desc");
workflowRequestDTO.setStatus(WorkflowRequestDTO.StatusEnum.APPROVED);
Workflow workflow = new APIStateChangeWorkflow(null, null, null, null, null, null);
workflow.setStatus(WorkflowStatus.APPROVED);
Mockito.doReturn(workflow).doThrow(new IllegalArgumentException()).when(adminService).retrieveWorkflow(workflowRefId);
Response response = workflowsApiService.workflowsWorkflowReferenceIdPut(workflowRefId, workflowRequestDTO, getRequest());
assertEquals(400, response.getStatus());
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class WorkflowsApiServiceImplTestCase method testWorkflowsGetWithoutType.
@Test
public void testWorkflowsGetWithoutType() throws Exception {
printTestMethodName();
WorkflowsApiServiceImpl workflowsApiService = new WorkflowsApiServiceImpl();
APIMgtAdminServiceImpl adminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(adminService);
List<Workflow> workflowList = new ArrayList<>();
Mockito.doReturn(workflowList).doThrow(new IllegalArgumentException()).when(adminService).retrieveUncompletedWorkflows();
Response response = workflowsApiService.workflowsGet(null, null, null, getRequest());
assertEquals(200, response.getStatus());
}
Aggregations