Search in sources :

Example 16 with Workflow

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);
}
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.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());
}
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.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());
}
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.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());
}
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.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());
}
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

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)53 Test (org.junit.Test)35 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)35 Workflow (org.wso2.carbon.apimgt.core.workflow.Workflow)28 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)26 ApiMgtDAO (org.wso2.carbon.apimgt.impl.dao.ApiMgtDAO)25 Test (org.testng.annotations.Test)24 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)22 WorkflowDTO (org.wso2.carbon.apimgt.impl.dto.WorkflowDTO)21 HashMap (java.util.HashMap)20 SubscriptionWorkflowDTO (org.wso2.carbon.apimgt.impl.dto.SubscriptionWorkflowDTO)20 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)19 JSONObject (org.json.simple.JSONObject)17 ApplicationWorkflowDTO (org.wso2.carbon.apimgt.impl.dto.ApplicationWorkflowDTO)17 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)16 ApplicationRegistrationWorkflowDTO (org.wso2.carbon.apimgt.impl.dto.ApplicationRegistrationWorkflowDTO)15 WorkflowExecutor (org.wso2.carbon.apimgt.impl.workflow.WorkflowExecutor)15 Application (org.wso2.carbon.apimgt.api.model.Application)14 ArrayList (java.util.ArrayList)12 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)11