use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO 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);
}
use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutorTest method testWorkflowExecute.
@Test
public void testWorkflowExecute() throws Exception {
SubscriptionWorkflowDTO workflowDTO = new SubscriptionWorkflowDTO();
workflowDTO.setApiContext("/test");
workflowDTO.setApiName("TestAPI");
workflowDTO.setApiVersion("1.0");
workflowDTO.setApiProvider("admin");
workflowDTO.setSubscriber("admin");
workflowDTO.setApplicationName("TestApp");
workflowDTO.setTierName("Gold");
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);
try {
Assert.assertNotNull(subscriptionCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Subscription creation ws workflow");
}
}
use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutorTest method testWorkflowExecuteWithDifferentMediatype.
@Test
public void testWorkflowExecuteWithDifferentMediatype() throws Exception {
SubscriptionWorkflowDTO workflowDTO = new SubscriptionWorkflowDTO();
workflowDTO.setApiContext("/test");
workflowDTO.setApiName("TestAPI");
workflowDTO.setApiVersion("1.0");
workflowDTO.setApiProvider("admin");
workflowDTO.setSubscriber("admin");
workflowDTO.setApplicationName("TestApp");
workflowDTO.setTierName("Gold");
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);
subscriptionCreationWSWorkflowExecutor.setContentType("application/xml");
try {
// shouldn't fail.
Assert.assertNotNull(subscriptionCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Subscription creation ws workflow");
}
}
use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutorTest method testWorkflowReject.
@Test
public void testWorkflowReject() throws APIManagementException, WorkflowException {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
workflowDTO.setStatus(WorkflowStatus.REJECTED);
PowerMockito.doNothing().when(apiMgtDAO).updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);
subscriptionCreationWSWorkflowExecutor.complete(workflowDTO);
Mockito.verify(apiMgtDAO, Mockito.times(1)).updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);
}
use of org.wso2.carbon.apimgt.impl.dto.WorkflowDTO in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutorTest method testWorkflowCleanupTaskExceptionWhenMessageProcessingFailed.
@Test(expected = WorkflowException.class)
public void testWorkflowCleanupTaskExceptionWhenMessageProcessingFailed() throws Exception {
WorkflowDTO workflowDTO = new WorkflowDTO();
workflowDTO.setWorkflowReference("1");
workflowDTO.setExternalWorkflowReference(UUID.randomUUID().toString());
ServiceReferenceHolderMockCreator serviceRefMock = new ServiceReferenceHolderMockCreator(-1234);
ServiceReferenceHolderMockCreator.initContextService();
PowerMockito.mockStatic(AXIOMUtil.class);
PowerMockito.when(AXIOMUtil.stringToOM(Mockito.anyString())).thenThrow(new XMLStreamException("Error " + "converting String to OMElement"));
subscriptionCreationWSWorkflowExecutor.cleanUpPendingTask(workflowDTO.getExternalWorkflowReference());
}
Aggregations