use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest method testWorkflowExecuteWithLimitedParam.
@Test
public void testWorkflowExecuteWithLimitedParam() throws Exception {
// application without a callback url
ApplicationWorkflowDTO workflowDTO = new ApplicationWorkflowDTO();
Application application = new Application("TestAPP", new Subscriber(null));
application.setTier("Gold");
application.setDescription("Description");
workflowDTO.setApplication(application);
workflowDTO.setTenantDomain("wso2");
workflowDTO.setUserName("admin");
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(applicationCreationWSWorkflowExecutor.execute(workflowDTO));
} catch (WorkflowException e) {
Assert.fail("Unexpected WorkflowException occurred while executing Application creation ws workflow");
}
}
use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest 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);
applicationCreationWSWorkflowExecutor.complete(workflowDTO);
}
use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest method testWorkflowCompleteExceptionWhenUpdatingApplication.
@Test(expected = WorkflowException.class)
public void testWorkflowCompleteExceptionWhenUpdatingApplication() 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).updateApplicationStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.ApplicationStatus.APPLICATION_APPROVED);
applicationCreationWSWorkflowExecutor.complete(workflowDTO);
}
use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class APIProviderImplTest method testChangeLifeCycleStatusAPIMgtException.
@Test(expected = APIManagementException.class)
public void testChangeLifeCycleStatusAPIMgtException() throws RegistryException, UserStoreException, APIManagementException, FaultGatewaysException, WorkflowException, XMLStreamException {
APIIdentifier apiId = new APIIdentifier("admin", "API1", "1.0.0");
APIProviderImplWrapper apiProvider = new APIProviderImplWrapper(apimgtDAO, scopesDAO);
prepareForChangeLifeCycleStatus(apiProvider, apimgtDAO, apiId, artifact);
GovernanceException exception = new GovernanceException(new APIManagementException("APIManagementException:" + "Error while retrieving Life cycle state"));
Mockito.when(artifact.getLifecycleState()).thenThrow(exception);
apiProvider.changeLifeCycleStatus(apiId, APIConstants.API_LC_ACTION_DEPRECATE, "org1");
}
use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class APIProviderImplTest method testChangeLifeCycleStatus_WFAlreadyStarted.
@Test
public void testChangeLifeCycleStatus_WFAlreadyStarted() throws RegistryException, UserStoreException, APIManagementException, FaultGatewaysException, WorkflowException {
APIIdentifier apiId = new APIIdentifier("admin", "API1", "1.0.0");
APIProviderImplWrapper apiProvider = new APIProviderImplWrapper(apimgtDAO, scopesDAO);
GenericArtifact apiArtifact = Mockito.mock(GenericArtifact.class);
Mockito.when(APIUtil.getAPIArtifact(apiId, apiProvider.registry)).thenReturn(apiArtifact);
Mockito.when(apiArtifact.getAttribute(APIConstants.API_OVERVIEW_PROVIDER)).thenReturn("admin");
Mockito.when(apiArtifact.getAttribute(APIConstants.API_OVERVIEW_NAME)).thenReturn("API1");
Mockito.when(apiArtifact.getAttribute(APIConstants.API_OVERVIEW_VERSION)).thenReturn("1.0.0");
Mockito.when(apiArtifact.getLifecycleState()).thenReturn("CREATED");
Mockito.when(apimgtDAO.getUUIDFromIdentifier(apiId, "org1")).thenReturn(apiUUID);
Mockito.when(apimgtDAO.getAPIID(apiUUID)).thenReturn(1);
// Workflow has started already
WorkflowDTO wfDTO = Mockito.mock(WorkflowDTO.class);
Mockito.when(wfDTO.getStatus()).thenReturn(WorkflowStatus.CREATED);
Mockito.when(apimgtDAO.retrieveWorkflowFromInternalReference("1", WorkflowConstants.WF_TYPE_AM_API_STATE)).thenReturn(wfDTO);
APIStateChangeResponse response = apiProvider.changeLifeCycleStatus(apiId, APIConstants.API_LC_ACTION_DEPRECATE, "org1");
Assert.assertNotNull(response);
}
Aggregations