use of org.wso2.carbon.apimgt.api.model.Workflow 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.api.model.Workflow in project carbon-apimgt by wso2.
the class WorkflowExecutorFactoryTest method testRegistryExceptionWhileInitialisingWorkflowConfigCache.
@Test
public void testRegistryExceptionWhileInitialisingWorkflowConfigCache() throws Exception {
String errorMessage = "Error occurred while creating workflow configurations for tenant " + tenantDomain;
Mockito.when(cache.get(Mockito.anyString())).thenReturn(null);
PowerMockito.whenNew(TenantWorkflowConfigHolder.class).withAnyArguments().thenReturn(tenantWorkflowConfigHolder);
PowerMockito.doThrow(new RegistryException(errorMessage)).when(tenantWorkflowConfigHolder).load();
try {
workflowExecutorFactory.getWorkflowConfigurations();
Assert.fail("Expected WorkflowException has not occurred while retrieving workflow configuration");
} catch (WorkflowException e) {
Assert.assertEquals(e.getMessage(), errorMessage);
}
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class ApplicationCreationWSWorkflowExecutorTest method testWorkflowExecuteException.
@Test(expected = WorkflowException.class)
public void testWorkflowExecuteException() 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();
applicationCreationWSWorkflowExecutor.execute(workflowDTO);
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class APIMappingUtil method toWorkflowResponseDTO.
/**
* Returns workflow state DTO from the provided information.
*
* @param lifecycleStateDTO Lifecycle state DTO
* @param stateChangeResponse workflow response from API lifecycle change
* @return workflow state DTO
*/
public static WorkflowResponseDTO toWorkflowResponseDTO(LifecycleStateDTO lifecycleStateDTO, APIStateChangeResponse stateChangeResponse) {
WorkflowResponseDTO workflowResponseDTO = new WorkflowResponseDTO();
if (WorkflowStatus.APPROVED.toString().equals(stateChangeResponse.getStateChangeStatus())) {
workflowResponseDTO.setWorkflowStatus(WorkflowResponseDTO.WorkflowStatusEnum.APPROVED);
} else if (WorkflowStatus.CREATED.toString().equals(stateChangeResponse.getStateChangeStatus())) {
workflowResponseDTO.setWorkflowStatus(WorkflowResponseDTO.WorkflowStatusEnum.CREATED);
} else if ((WorkflowStatus.REGISTERED.toString().equals(stateChangeResponse.getStateChangeStatus()))) {
workflowResponseDTO.setWorkflowStatus(WorkflowResponseDTO.WorkflowStatusEnum.REGISTERED);
} else if ((WorkflowStatus.REJECTED.toString().equals(stateChangeResponse.getStateChangeStatus()))) {
workflowResponseDTO.setWorkflowStatus(WorkflowResponseDTO.WorkflowStatusEnum.REJECTED);
} else {
log.error("Unrecognized state : " + stateChangeResponse.getStateChangeStatus());
workflowResponseDTO.setWorkflowStatus(WorkflowResponseDTO.WorkflowStatusEnum.CREATED);
}
workflowResponseDTO.setLifecycleState(lifecycleStateDTO);
return workflowResponseDTO;
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class APIAdminImpl method getworkflowReferenceByExternalWorkflowReferenceID.
/**
* The method converts the date into timestamp
*
* @param externelWorkflowRef External Workflow Reference of workflow pending request
* @param status Workflow status of workflow pending request
* @param tenantDomain tenant domain of user
* @return Workflow pending request
* @throws APIManagementException
*/
public Workflow getworkflowReferenceByExternalWorkflowReferenceID(String externelWorkflowRef, String status, String tenantDomain) throws APIManagementException {
Workflow workflow = null;
WorkflowProperties workflowConfig = org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration().getWorkflowProperties();
if (workflowConfig.isListTasks()) {
workflow = apiMgtDAO.getworkflowReferenceByExternalWorkflowReferenceID(externelWorkflowRef, status, tenantDomain);
}
if (workflow == null) {
String msg = "External workflow Reference: " + externelWorkflowRef + " was not found.";
throw new APIMgtResourceNotFoundException(msg);
}
return workflow;
}
Aggregations