use of org.wso2.carbon.apimgt.impl.workflow.WorkflowException in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest method testWorkflowCompleteException.
@Test(expected = WorkflowException.class)
public void testWorkflowCompleteException() throws APIManagementException, WorkflowException {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
workflowDTO.setStatus(WorkflowStatus.APPROVED);
Application app = Mockito.mock(Application.class);
// application is not in DB for the given id
PowerMockito.doReturn(null).when(apiMgtDAO).getApplicationById(Integer.parseInt(workflowDTO.getWorkflowReference()));
PowerMockito.doNothing().when(apiMgtDAO).updateApplicationStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.ApplicationStatus.APPLICATION_APPROVED);
applicationCreationWSWorkflowExecutor.complete(workflowDTO);
}
use of org.wso2.carbon.apimgt.impl.workflow.WorkflowException in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest method testWorkflowApprove.
@Test
public void testWorkflowApprove() throws APIManagementException, WorkflowException {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
workflowDTO.setStatus(WorkflowStatus.APPROVED);
Application app = Mockito.mock(Application.class);
PowerMockito.doReturn(app).when(apiMgtDAO).getApplicationById(Integer.parseInt(workflowDTO.getWorkflowReference()));
PowerMockito.doNothing().when(apiMgtDAO).updateApplicationStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.ApplicationStatus.APPLICATION_APPROVED);
applicationCreationWSWorkflowExecutor.complete(workflowDTO);
Mockito.verify(apiMgtDAO, Mockito.times(1)).updateApplicationStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.ApplicationStatus.APPLICATION_APPROVED);
}
use of org.wso2.carbon.apimgt.impl.workflow.WorkflowException in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutorTest method testWorkflowNotAllowedStatus.
@Test
public void testWorkflowNotAllowedStatus() throws APIManagementException, WorkflowException {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
workflowDTO.setStatus(WorkflowStatus.CREATED);
subscriptionCreationWSWorkflowExecutor.complete(workflowDTO);
// shouldn't update status
Mockito.verify(apiMgtDAO, Mockito.never()).updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.UNBLOCKED);
Mockito.verify(apiMgtDAO, Mockito.never()).updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);
}
use of org.wso2.carbon.apimgt.impl.workflow.WorkflowException in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutorTest method testWorkflowApproveException.
@Test(expected = WorkflowException.class)
public void testWorkflowApproveException() throws APIManagementException, WorkflowException {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
workflowDTO.setStatus(WorkflowStatus.APPROVED);
PowerMockito.doThrow(new APIManagementException("")).when(apiMgtDAO).updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.UNBLOCKED);
subscriptionCreationWSWorkflowExecutor.complete(workflowDTO);
}
use of org.wso2.carbon.apimgt.impl.workflow.WorkflowException in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutorTest method testWorkflowRejectException.
@Test(expected = WorkflowException.class)
public void testWorkflowRejectException() throws APIManagementException, WorkflowException {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
workflowDTO.setStatus(WorkflowStatus.REJECTED);
PowerMockito.doThrow(new APIManagementException("")).when(apiMgtDAO).updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);
subscriptionCreationWSWorkflowExecutor.complete(workflowDTO);
}
Aggregations