Search in sources :

Example 16 with Workflow

use of org.wso2.carbon.apimgt.core.workflow.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);
}
Also used : WorkflowConfig(org.wso2.carbon.apimgt.core.models.WorkflowConfig) Test(org.testng.annotations.Test)

Example 17 with Workflow

use of org.wso2.carbon.apimgt.core.workflow.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());
}
Also used : Response(javax.ws.rs.core.Response) APIMgtAdminServiceImpl(org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl) APIManagementException(org.wso2.carbon.apimgt.core.exception.APIManagementException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 18 with Workflow

use of org.wso2.carbon.apimgt.core.workflow.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());
}
Also used : Response(javax.ws.rs.core.Response) APIMgtAdminServiceImpl(org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl) ArrayList(java.util.ArrayList) ApplicationCreationWorkflow(org.wso2.carbon.apimgt.core.workflow.ApplicationCreationWorkflow) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) APIStateChangeWorkflow(org.wso2.carbon.apimgt.core.workflow.APIStateChangeWorkflow) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 19 with Workflow

use of org.wso2.carbon.apimgt.core.workflow.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());
}
Also used : Response(javax.ws.rs.core.Response) APIMgtAdminServiceImpl(org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl) APIStateChangeWorkflow(org.wso2.carbon.apimgt.core.workflow.APIStateChangeWorkflow) WorkflowRequestDTO(org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowRequestDTO) ApplicationCreationWorkflow(org.wso2.carbon.apimgt.core.workflow.ApplicationCreationWorkflow) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) APIStateChangeWorkflow(org.wso2.carbon.apimgt.core.workflow.APIStateChangeWorkflow) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 20 with Workflow

use of org.wso2.carbon.apimgt.core.workflow.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());
}
Also used : Response(javax.ws.rs.core.Response) APIMgtAdminServiceImpl(org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl) ArrayList(java.util.ArrayList) ApplicationCreationWorkflow(org.wso2.carbon.apimgt.core.workflow.ApplicationCreationWorkflow) Workflow(org.wso2.carbon.apimgt.core.workflow.Workflow) APIStateChangeWorkflow(org.wso2.carbon.apimgt.core.workflow.APIStateChangeWorkflow) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Workflow (org.wso2.carbon.apimgt.core.workflow.Workflow)28 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)26 Test (org.testng.annotations.Test)24 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)22 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)19 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)16 ApplicationCreationWorkflow (org.wso2.carbon.apimgt.core.workflow.ApplicationCreationWorkflow)12 Application (org.wso2.carbon.apimgt.core.models.Application)11 HashMap (java.util.HashMap)10 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)10 WorkflowExecutor (org.wso2.carbon.apimgt.core.api.WorkflowExecutor)10 API (org.wso2.carbon.apimgt.core.models.API)9 Response (javax.ws.rs.core.Response)8 Test (org.junit.Test)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)8 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)8 APIMgtAdminServiceImpl (org.wso2.carbon.apimgt.core.impl.APIMgtAdminServiceImpl)8 ErrorDTO (org.wso2.carbon.apimgt.rest.api.common.dto.ErrorDTO)8 ArrayList (java.util.ArrayList)6 Map (java.util.Map)6