use of org.wso2.carbon.apimgt.impl.workflow.GeneralWorkflowResponse in project carbon-apimgt by wso2.
the class ApprovalWorkflowExecutor method execute.
/**
* {@inheritDoc}
*/
@Override
public WorkflowResponse execute(Workflow workFlow) throws WorkflowException {
if (log.isDebugEnabled()) {
log.debug("Executing execute() in Workflow for " + workFlow.getWorkflowType());
}
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
// set the state to pending
workflowResponse.setWorkflowStatus(WorkflowStatus.CREATED);
return workflowResponse;
}
use of org.wso2.carbon.apimgt.impl.workflow.GeneralWorkflowResponse in project carbon-apimgt by wso2.
the class ApprovalWorkflowExecutor method complete.
/**
* Complete the external process status
* Based on the workflow status we will update the status column of the
* Application table
*
* @param workFlow - Workflow
*/
public WorkflowResponse complete(Workflow workFlow) throws WorkflowException {
if (log.isDebugEnabled()) {
log.debug("Executing complete() in Workflow for " + workFlow.getWorkflowType());
}
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
workflowResponse.setWorkflowStatus(workFlow.getStatus());
return workflowResponse;
}
use of org.wso2.carbon.apimgt.impl.workflow.GeneralWorkflowResponse in project carbon-apimgt by wso2.
the class WorkflowMappingUtilTest method testToWorkflowResponseDTO.
@Test(description = "Convert WorkflowResponse to WorkflowResponseDTO")
public void testToWorkflowResponseDTO() throws Exception {
WorkflowResponse response = new GeneralWorkflowResponse();
response.setWorkflowStatus(WorkflowStatus.APPROVED);
WorkflowResponseDTO dto = WorkflowMappingUtil.toWorkflowResponseDTO(response);
Assert.assertEquals(dto.getWorkflowStatus(), WorkflowStatusEnum.APPROVED, "Invalid workflow status");
Assert.assertEquals(dto.getJsonPayload(), "", "Invalid workflow payload");
}
use of org.wso2.carbon.apimgt.impl.workflow.GeneralWorkflowResponse in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method testApisChangeLifecyclePostWithChecklistItemChange.
@Test
public void testApisChangeLifecyclePostWithChecklistItemChange() throws Exception {
printTestMethodName();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIPublisher apiPublisher = Mockito.mock(APIPublisherImpl.class);
String checklist = "test1:test1,test2:test2";
String action = "CheckListItemChange";
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
workflowResponse.setWorkflowStatus(WorkflowStatus.APPROVED);
Map<String, Boolean> lifecycleChecklistMap = new HashMap<>();
PowerMockito.mockStatic(RestAPIPublisherUtil.class);
PowerMockito.when(RestAPIPublisherUtil.getApiPublisher(USER)).thenReturn(apiPublisher);
String apiId = UUID.randomUUID().toString();
Mockito.doNothing().doThrow(new IllegalArgumentException()).when(apiPublisher).updateCheckListItem(apiId, action, lifecycleChecklistMap);
Response response = apisApiService.apisChangeLifecyclePost(action, apiId, checklist, null, null, getRequest());
assertEquals(response.getStatus(), 200);
assertTrue(response.getEntity().toString().contains("APPROVED"));
}
use of org.wso2.carbon.apimgt.impl.workflow.GeneralWorkflowResponse in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method testApisChangeLifecyclePostWithoutChecklistItemNonChange.
@Test
public void testApisChangeLifecyclePostWithoutChecklistItemNonChange() throws Exception {
printTestMethodName();
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
APIPublisher apiPublisher = Mockito.mock(APIPublisherImpl.class);
String checklist = "test1:test1,test2:test2";
String action = "CheckListItemChangeDifferent";
Map<String, Boolean> lifecycleChecklistMap = new HashMap<>();
if (checklist != null) {
String[] checkList = checklist.split(",");
for (String checkList1 : checkList) {
StringTokenizer attributeTokens = new StringTokenizer(checkList1, ":");
String attributeName = attributeTokens.nextToken();
Boolean attributeValue = Boolean.valueOf(attributeTokens.nextToken());
lifecycleChecklistMap.put(attributeName, attributeValue);
}
}
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
workflowResponse.setWorkflowStatus(WorkflowStatus.CREATED);
PowerMockito.mockStatic(RestAPIPublisherUtil.class);
PowerMockito.when(RestAPIPublisherUtil.getApiPublisher(USER)).thenReturn(apiPublisher);
String apiId = UUID.randomUUID().toString();
Mockito.doReturn(workflowResponse).doThrow(new IllegalArgumentException()).when(apiPublisher).updateAPIStatus(apiId, action, lifecycleChecklistMap);
Response response = apisApiService.apisChangeLifecyclePost(action, apiId, checklist, null, null, getRequest());
assertEquals(response.getStatus(), 202);
assertTrue(response.getEntity().toString().contains("CREATED"));
}
Aggregations