use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest 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();
applicationCreationWSWorkflowExecutor.cleanUpPendingTask(workflowDTO.getExternalWorkflowReference());
}
use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest method testWorkflowExecuteWithoutExecutorParam.
@Test
public void testWorkflowExecuteWithoutExecutorParam() throws Exception {
ApplicationWorkflowDTO workflowDTO = new ApplicationWorkflowDTO();
Application application = new Application("TestAPP", new Subscriber(null));
application.setTier("Gold");
application.setCallbackUrl("www.wso2.com");
application.setDescription("Description");
workflowDTO.setApplication(application);
workflowDTO.setTenantDomain("wso2");
workflowDTO.setUserName("admin");
workflowDTO.setCallbackUrl("http://localhost:8280/workflow-callback");
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
PowerMockito.doNothing().when(apiMgtDAO).updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);
ServiceReferenceHolderMockCreator serviceRefMock = new ServiceReferenceHolderMockCreator(-1234);
ServiceReferenceHolderMockCreator.initContextService();
PowerMockito.whenNew(ServiceClient.class).withArguments(Mockito.any(ConfigurationContext.class), Mockito.any(AxisService.class)).thenReturn(serviceClient);
applicationCreationWSWorkflowExecutor.setUsername(null);
applicationCreationWSWorkflowExecutor.setPassword(null);
try {
// shouldn't fail. this checks for unsecured enpoint use case
Assert.assertNotNull(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
}
// empty values
applicationCreationWSWorkflowExecutor.setUsername("");
applicationCreationWSWorkflowExecutor.setPassword("".toCharArray());
try {
// shouldn't fail. this checks for unsecured enpoint use case
Assert.assertNotNull(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
}
// one empty value and other null
applicationCreationWSWorkflowExecutor.setUsername("");
applicationCreationWSWorkflowExecutor.setPassword(null);
try {
// shouldn't fail. this checks for unsecured enpoint use case
Assert.assertNotNull(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
}
applicationCreationWSWorkflowExecutor.setUsername(null);
applicationCreationWSWorkflowExecutor.setPassword("".toCharArray());
try {
// shouldn't fail. this checks for unsecured enpoint use case
Assert.assertNotNull(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
}
// without a password
applicationCreationWSWorkflowExecutor.setUsername("admin");
applicationCreationWSWorkflowExecutor.setPassword("".toCharArray());
try {
// shouldn't fail. this checks for unsecured enpoint use case.
Assert.assertNotNull(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
}
applicationCreationWSWorkflowExecutor.setUsername("admin");
applicationCreationWSWorkflowExecutor.setPassword(null);
try {
// shouldn't fail. this checks for unsecured enpoint use case.
Assert.assertNotNull(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
}
}
use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest method testWorkflowCreate.
@Test
public void testWorkflowCreate() throws APIManagementException, WorkflowException {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
workflowDTO.setStatus(WorkflowStatus.CREATED);
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_CREATED);
applicationCreationWSWorkflowExecutor.complete(workflowDTO);
Mockito.verify(apiMgtDAO, Mockito.times(1)).updateApplicationStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.ApplicationStatus.APPLICATION_CREATED);
}
use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest 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);
applicationCreationWSWorkflowExecutor.complete(workflowDTO);
}
use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO 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);
}
Aggregations