use of org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowDTO 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.rest.api.admin.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class ApplicationRegistrationSimpleWorkflowExecutorTest method init.
@Before
public void init() throws APIManagementException {
PowerMockito.mockStatic(ApiMgtDAO.class);
PowerMockito.mockStatic(KeyManagerHolder.class);
apiMgtDAO = Mockito.mock(ApiMgtDAO.class);
keyManager = Mockito.mock(KeyManager.class);
application = new Application("test", new Subscriber("testUser"));
oAuthAppRequest = new OAuthAppRequest();
oAuthApplicationInfo = new OAuthApplicationInfo();
oAuthAppRequest.setOAuthApplicationInfo(oAuthApplicationInfo);
workflowDTO = new ApplicationRegistrationWorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setApplication(application);
workflowDTO.setAppInfoDTO(oAuthAppRequest);
workflowDTO.setKeyManager("default");
KeyManagerConfigurationDTO kmConfigDTO = new KeyManagerConfigurationDTO();
kmConfigDTO.setOrganization("carbon.super");
kmConfigDTO.setName("default");
PowerMockito.when(apiMgtDAO.getKeyManagerConfigurationByUUID("default")).thenReturn(kmConfigDTO);
PowerMockito.when(ApiMgtDAO.getInstance()).thenReturn(apiMgtDAO);
PowerMockito.when(KeyManagerHolder.getKeyManagerInstance("carbon.super", "default")).thenReturn(keyManager);
KeyManagerConfiguration keyManagerConfiguration = new KeyManagerConfiguration();
Mockito.when(keyManager.getKeyManagerConfiguration()).thenReturn(keyManagerConfiguration);
applicationRegistrationSimpleWorkflowExecutor = new ApplicationRegistrationSimpleWorkflowExecutor();
}
use of org.wso2.carbon.apimgt.rest.api.admin.dto.WorkflowDTO 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.rest.api.admin.dto.WorkflowDTO 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.rest.api.admin.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutorTest method testWorkflowCleanupTaskException.
@Test(expected = WorkflowException.class)
public void testWorkflowCleanupTaskException() throws Exception {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
ServiceReferenceHolderMockCreator serviceRefMock = new ServiceReferenceHolderMockCreator(-1234);
ServiceReferenceHolderMockCreator.initContextService();
subscriptionCreationWSWorkflowExecutor.cleanUpPendingTask(workflowDTO.getExternalWorkflowReference());
}
Aggregations