Skip to content

Commit

Permalink
Add externalId to ListWorkflowInstanceResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
jsyrjala committed Sep 9, 2014
1 parent 4939719 commit 4a6d746
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public ListWorkflowInstanceResponse convert(WorkflowInstance instance, QueryWork
resp.id = instance.id;
resp.type = instance.type;
resp.businessKey = instance.businessKey;
resp.externalId = instance.externalId;
resp.state = instance.state;
resp.stateText = instance.stateText;
resp.nextActivation = instance.nextActivation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class ListWorkflowInstanceResponse {
@ApiModelProperty(value = "Main business key or identifier for the started workflow instance", required=false)
public String businessKey;

@ApiModelProperty(value = "Unique external identifier under workflow type. Generated by nflow if not given.", required=true)
public String externalId;

@ApiModelProperty(value = "State of the workflow instance", required=true)
public String state;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.nitorcreations.nflow.engine.workflow.instance.QueryWorkflowInstances;
import com.nitorcreations.nflow.engine.workflow.instance.WorkflowInstance;
import com.nitorcreations.nflow.engine.workflow.instance.WorkflowInstanceAction;
import com.nitorcreations.nflow.rest.v1.converter.ListWorkflowInstanceConverter;
import com.nitorcreations.nflow.rest.v1.msg.Action;
import com.nitorcreations.nflow.rest.v1.msg.ListWorkflowInstanceResponse;

Expand All @@ -36,12 +35,14 @@ public void convertWithActionsWorks() {
WorkflowInstanceAction a = new WorkflowInstanceAction.Builder().setState("oState").setStateText("oState desc").
setRetryNo(1).setExecutionStart(now().minusDays(1)).setExecutionEnd(now().plusDays(1)).build();
WorkflowInstance i = new WorkflowInstance.Builder().setId(1).setType("dummy").setBusinessKey("businessKey").
setState("cState").setStateText("cState desc").setNextActivation(now()).setActions(Arrays.asList(a)).build();
setExternalId("externalId").setState("cState").setStateText("cState desc").setNextActivation(now()).
setActions(Arrays.asList(a)).build();

ListWorkflowInstanceResponse resp = converter.convert(i, new QueryWorkflowInstances.Builder().setIncludeActions(true).build());
assertThat(resp.id, is(i.id));
assertThat(resp.type, is(i.type));
assertThat(resp.businessKey, is(i.businessKey));
assertThat(resp.externalId, is(i.externalId));
assertThat(resp.state, is(i.state));
assertThat(resp.stateText, is(i.stateText));
assertThat(resp.nextActivation, is(i.nextActivation));
Expand All @@ -54,12 +55,14 @@ public void convertWithoutActionsWorks() {
WorkflowInstanceAction a = new WorkflowInstanceAction.Builder().setState("oState").setStateText("oState desc").
setRetryNo(1).setExecutionStart(now().minusDays(1)).setExecutionEnd(now().plusDays(1)).build();
WorkflowInstance i = new WorkflowInstance.Builder().setId(1).setType("dummy").setBusinessKey("businessKey").
setState("cState").setStateText("cState desc").setNextActivation(now()).setActions(Arrays.asList(a)).build();
setExternalId("externalId").setState("cState").setStateText("cState desc").setNextActivation(now())
.setActions(Arrays.asList(a)).build();

ListWorkflowInstanceResponse resp = converter.convert(i, new QueryWorkflowInstances.Builder().build());
assertThat(resp.id, is(i.id));
assertThat(resp.type, is(i.type));
assertThat(resp.businessKey, is(i.businessKey));
assertThat(resp.externalId, is(i.externalId));
assertThat(resp.state, is(i.state));
assertThat(resp.stateText, is(i.stateText));
assertThat(resp.nextActivation, is(i.nextActivation));
Expand Down

0 comments on commit 4a6d746

Please sign in to comment.