Search in sources :

Example 1 with WorkflowExecution

use of com.amazonaws.services.simpleworkflow.model.WorkflowExecution in project camel by apache.

the class CamelSWFWorkflowClient method describeWorkflowInstance.

public Map<String, Object> describeWorkflowInstance(String workflowId, String runId) {
    DescribeWorkflowExecutionRequest describeRequest = new DescribeWorkflowExecutionRequest();
    describeRequest.setDomain(configuration.getDomainName());
    describeRequest.setExecution(new WorkflowExecution().withWorkflowId(workflowId).withRunId(runId));
    WorkflowExecutionDetail executionDetail = endpoint.getSWClient().describeWorkflowExecution(describeRequest);
    WorkflowExecutionInfo instanceMetadata = executionDetail.getExecutionInfo();
    Map<String, Object> info = new HashMap<String, Object>();
    info.put("closeStatus", instanceMetadata.getCloseStatus());
    info.put("closeTimestamp", instanceMetadata.getCloseTimestamp());
    info.put("executionStatus", instanceMetadata.getExecutionStatus());
    info.put("tagList", instanceMetadata.getTagList());
    info.put("executionDetail", executionDetail);
    return info;
}
Also used : WorkflowExecutionDetail(com.amazonaws.services.simpleworkflow.model.WorkflowExecutionDetail) WorkflowExecutionInfo(com.amazonaws.services.simpleworkflow.model.WorkflowExecutionInfo) HashMap(java.util.HashMap) DescribeWorkflowExecutionRequest(com.amazonaws.services.simpleworkflow.model.DescribeWorkflowExecutionRequest) WorkflowExecution(com.amazonaws.services.simpleworkflow.model.WorkflowExecution)

Example 2 with WorkflowExecution

use of com.amazonaws.services.simpleworkflow.model.WorkflowExecution in project camel by apache.

the class CamelSWFWorkflowClientTest method testDescribeWorkflowInstance.

@Test
public void testDescribeWorkflowInstance() throws Exception {
    WorkflowExecutionInfo executionInfo = new WorkflowExecutionInfo();
    executionInfo.setCloseStatus("COMPLETED");
    Date closeTimestamp = new Date();
    executionInfo.setCloseTimestamp(closeTimestamp);
    executionInfo.setExecutionStatus("CLOSED");
    executionInfo.setTagList(Collections.EMPTY_LIST);
    WorkflowExecutionDetail workflowExecutionDetail = new WorkflowExecutionDetail();
    workflowExecutionDetail.setExecutionInfo(executionInfo);
    when(swClient.describeWorkflowExecution(any(DescribeWorkflowExecutionRequest.class))).thenReturn(workflowExecutionDetail);
    Map<String, Object> description = camelSWFWorkflowClient.describeWorkflowInstance("123", "run1");
    DescribeWorkflowExecutionRequest describeRequest = new DescribeWorkflowExecutionRequest();
    describeRequest.setDomain(configuration.getDomainName());
    describeRequest.setExecution(new WorkflowExecution().withWorkflowId("123").withRunId("run1"));
    verify(swClient).describeWorkflowExecution(describeRequest);
    assertThat((String) description.get("closeStatus"), is("COMPLETED"));
    assertThat((Date) description.get("closeTimestamp"), is(closeTimestamp));
    assertThat((String) description.get("executionStatus"), is("CLOSED"));
    assertThat((List) description.get("tagList"), is(Collections.EMPTY_LIST));
    assertThat((WorkflowExecutionDetail) description.get("executionDetail"), is(workflowExecutionDetail));
}
Also used : WorkflowExecutionDetail(com.amazonaws.services.simpleworkflow.model.WorkflowExecutionDetail) WorkflowExecutionInfo(com.amazonaws.services.simpleworkflow.model.WorkflowExecutionInfo) DescribeWorkflowExecutionRequest(com.amazonaws.services.simpleworkflow.model.DescribeWorkflowExecutionRequest) WorkflowExecution(com.amazonaws.services.simpleworkflow.model.WorkflowExecution) Date(java.util.Date) Test(org.junit.Test)

Example 3 with WorkflowExecution

use of com.amazonaws.services.simpleworkflow.model.WorkflowExecution in project camel by apache.

the class CamelSWFWorkflowClientTest method testStartWorkflowExecution.

@Test
public void testStartWorkflowExecution() throws Throwable {
    WorkflowExecution workflowExecution = new WorkflowExecution();
    workflowExecution.setWorkflowId("123");
    workflowExecution.setRunId("run1");
    when(clientExternal.getWorkflowExecution()).thenReturn(workflowExecution);
    String[] ids = camelSWFWorkflowClient.startWorkflowExecution(null, null, "eventName", "version", null, Collections.singletonList("camelTest"));
    verify(clientExternal).startWorkflowExecution(new Object[] { null });
    assertThat("123", is(ids[0]));
    assertThat("run1", is(ids[1]));
}
Also used : WorkflowExecution(com.amazonaws.services.simpleworkflow.model.WorkflowExecution) Test(org.junit.Test)

Example 4 with WorkflowExecution

use of com.amazonaws.services.simpleworkflow.model.WorkflowExecution in project camel by apache.

the class CamelSWFWorkflowClient method getDynamicWorkflowClient.

DynamicWorkflowClientExternal getDynamicWorkflowClient(String workflowId, String runId) {
    GenericWorkflowClientExternalImpl genericClient = new GenericWorkflowClientExternalImpl(endpoint.getSWClient(), configuration.getDomainName());
    WorkflowExecution workflowExecution = new WorkflowExecution();
    workflowExecution.setWorkflowId(workflowId != null ? workflowId : genericClient.generateUniqueId());
    workflowExecution.setRunId(runId);
    return new DynamicWorkflowClientExternalImpl(workflowExecution, null, endpoint.getStartWorkflowOptions(), configuration.getDataConverter(), genericClient);
}
Also used : DynamicWorkflowClientExternalImpl(com.amazonaws.services.simpleworkflow.flow.DynamicWorkflowClientExternalImpl) GenericWorkflowClientExternalImpl(com.amazonaws.services.simpleworkflow.flow.worker.GenericWorkflowClientExternalImpl) WorkflowExecution(com.amazonaws.services.simpleworkflow.model.WorkflowExecution)

Aggregations

WorkflowExecution (com.amazonaws.services.simpleworkflow.model.WorkflowExecution)4 DescribeWorkflowExecutionRequest (com.amazonaws.services.simpleworkflow.model.DescribeWorkflowExecutionRequest)2 WorkflowExecutionDetail (com.amazonaws.services.simpleworkflow.model.WorkflowExecutionDetail)2 WorkflowExecutionInfo (com.amazonaws.services.simpleworkflow.model.WorkflowExecutionInfo)2 Test (org.junit.Test)2 DynamicWorkflowClientExternalImpl (com.amazonaws.services.simpleworkflow.flow.DynamicWorkflowClientExternalImpl)1 GenericWorkflowClientExternalImpl (com.amazonaws.services.simpleworkflow.flow.worker.GenericWorkflowClientExternalImpl)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1