@Test public void convertWithActionsWorks() throws IOException { WorkflowInstanceAction a = new WorkflowInstanceAction.Builder().setId(929).setType(stateExecution).setState("oState") .setStateText("oState desc").setRetryNo(1).setExecutionStart(now().minusDays(1)).setExecutionEnd(now().plusDays(1)) .setExecutorId(999).build(); Map<String, String> stateVariables = new LinkedHashMap<>(); stateVariables.put("foo", "1"); stateVariables.put("bar", "quux"); DateTime started = now(); WorkflowInstance i = new WorkflowInstance.Builder().setId(1).setStatus(inProgress).setType("dummy") .setBusinessKey("businessKey").setParentWorkflowId(942L).setParentActionId(842L).setExternalId("externalId") .setState("cState").setStateText("cState desc").setNextActivation(now()).setActions(asList(a)) .setCreated(now().minusMinutes(1)).setCreated(now().minusHours(2)).setModified(now().minusHours(1)).setRetries(42) .setStateVariables(stateVariables).setSignal(Optional.of(42)).setStartedIfNotSet(started).build(); JsonNode node1 = mock(JsonNode.class); JsonNode nodeQuux = mock(JsonNode.class); when(nflowObjectMapper.readTree("1")).thenReturn(node1); when(nflowObjectMapper.readTree("quux")).thenReturn(nodeQuux); Map<String, Object> expectedStateVariables = new LinkedHashMap<>(); expectedStateVariables.put("foo", node1); expectedStateVariables.put("bar", nodeQuux); ListWorkflowInstanceResponse resp = converter.convert(i, EnumSet.of(WorkflowInstanceInclude.ACTIONS, WorkflowInstanceInclude.CURRENT_STATE_VARIABLES)); verify(nflowObjectMapper).readTree("1"); verify(nflowObjectMapper).readTree("quux"); assertThat(resp.id, is(i.id)); assertThat(resp.stateVariables, is(expectedStateVariables)); assertThat(resp.status, is(i.status.name())); assertThat(resp.type, is(i.type)); assertThat(resp.parentWorkflowId, is(i.parentWorkflowId)); assertThat(resp.parentActionId, is(i.parentActionId)); 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)); assertThat(resp.created, is(i.created)); assertThat(resp.modified, is(i.modified)); assertThat(resp.started, is(i.started)); assertThat(resp.retries, is(i.retries)); assertThat(resp.signal, is(i.signal.get())); assertThat(resp.actions, contains(reflectEquals( new Action(a.id, a.type.name(), a.state, a.stateText, a.retryNo, a.executionStart, a.executionEnd, a.executorId)))); }
public ListWorkflowInstanceResponse convert(WorkflowInstance instance, Set<WorkflowInstanceInclude> includes) { ListWorkflowInstanceResponse resp = new ListWorkflowInstanceResponse(); resp.id = instance.id; resp.status = instance.status.name(); resp.type = instance.type; resp.priority = instance.priority; resp.parentWorkflowId = instance.parentWorkflowId; resp.parentActionId = instance.parentActionId; resp.businessKey = instance.businessKey; resp.externalId = instance.externalId; resp.state = instance.state; resp.stateText = instance.stateText; resp.nextActivation = instance.nextActivation; resp.created = instance.created; resp.modified = instance.modified; resp.started = instance.started; resp.retries = instance.retries; resp.signal = instance.signal.orElse(null); if (includes.contains(WorkflowInstanceInclude.ACTIONS)) { resp.actions = new ArrayList<>(); for (WorkflowInstanceAction action : instance.actions) { if (includes.contains(WorkflowInstanceInclude.ACTION_STATE_VARIABLES)) { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId, stateVariablesToJson(action.updatedStateVariables))); } else { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId)); } } } if (includes.contains(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES)) { resp.stateVariables = stateVariablesToJson(instance.stateVariables); } if (includes.contains(WorkflowInstanceInclude.CHILD_WORKFLOW_IDS)) { resp.childWorkflows = instance.childWorkflows; } return resp; }
ListWorkflowInstanceConverter { public ListWorkflowInstanceResponse convert(WorkflowInstance instance, Set<WorkflowInstanceInclude> includes) { ListWorkflowInstanceResponse resp = new ListWorkflowInstanceResponse(); resp.id = instance.id; resp.status = instance.status.name(); resp.type = instance.type; resp.priority = instance.priority; resp.parentWorkflowId = instance.parentWorkflowId; resp.parentActionId = instance.parentActionId; resp.businessKey = instance.businessKey; resp.externalId = instance.externalId; resp.state = instance.state; resp.stateText = instance.stateText; resp.nextActivation = instance.nextActivation; resp.created = instance.created; resp.modified = instance.modified; resp.started = instance.started; resp.retries = instance.retries; resp.signal = instance.signal.orElse(null); if (includes.contains(WorkflowInstanceInclude.ACTIONS)) { resp.actions = new ArrayList<>(); for (WorkflowInstanceAction action : instance.actions) { if (includes.contains(WorkflowInstanceInclude.ACTION_STATE_VARIABLES)) { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId, stateVariablesToJson(action.updatedStateVariables))); } else { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId)); } } } if (includes.contains(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES)) { resp.stateVariables = stateVariablesToJson(instance.stateVariables); } if (includes.contains(WorkflowInstanceInclude.CHILD_WORKFLOW_IDS)) { resp.childWorkflows = instance.childWorkflows; } return resp; } }
ListWorkflowInstanceConverter { public ListWorkflowInstanceResponse convert(WorkflowInstance instance, Set<WorkflowInstanceInclude> includes) { ListWorkflowInstanceResponse resp = new ListWorkflowInstanceResponse(); resp.id = instance.id; resp.status = instance.status.name(); resp.type = instance.type; resp.priority = instance.priority; resp.parentWorkflowId = instance.parentWorkflowId; resp.parentActionId = instance.parentActionId; resp.businessKey = instance.businessKey; resp.externalId = instance.externalId; resp.state = instance.state; resp.stateText = instance.stateText; resp.nextActivation = instance.nextActivation; resp.created = instance.created; resp.modified = instance.modified; resp.started = instance.started; resp.retries = instance.retries; resp.signal = instance.signal.orElse(null); if (includes.contains(WorkflowInstanceInclude.ACTIONS)) { resp.actions = new ArrayList<>(); for (WorkflowInstanceAction action : instance.actions) { if (includes.contains(WorkflowInstanceInclude.ACTION_STATE_VARIABLES)) { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId, stateVariablesToJson(action.updatedStateVariables))); } else { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId)); } } } if (includes.contains(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES)) { resp.stateVariables = stateVariablesToJson(instance.stateVariables); } if (includes.contains(WorkflowInstanceInclude.CHILD_WORKFLOW_IDS)) { resp.childWorkflows = instance.childWorkflows; } return resp; }  }
ListWorkflowInstanceConverter { public ListWorkflowInstanceResponse convert(WorkflowInstance instance, Set<WorkflowInstanceInclude> includes) { ListWorkflowInstanceResponse resp = new ListWorkflowInstanceResponse(); resp.id = instance.id; resp.status = instance.status.name(); resp.type = instance.type; resp.priority = instance.priority; resp.parentWorkflowId = instance.parentWorkflowId; resp.parentActionId = instance.parentActionId; resp.businessKey = instance.businessKey; resp.externalId = instance.externalId; resp.state = instance.state; resp.stateText = instance.stateText; resp.nextActivation = instance.nextActivation; resp.created = instance.created; resp.modified = instance.modified; resp.started = instance.started; resp.retries = instance.retries; resp.signal = instance.signal.orElse(null); if (includes.contains(WorkflowInstanceInclude.ACTIONS)) { resp.actions = new ArrayList<>(); for (WorkflowInstanceAction action : instance.actions) { if (includes.contains(WorkflowInstanceInclude.ACTION_STATE_VARIABLES)) { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId, stateVariablesToJson(action.updatedStateVariables))); } else { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId)); } } } if (includes.contains(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES)) { resp.stateVariables = stateVariablesToJson(instance.stateVariables); } if (includes.contains(WorkflowInstanceInclude.CHILD_WORKFLOW_IDS)) { resp.childWorkflows = instance.childWorkflows; } return resp; }  ListWorkflowInstanceResponse convert(WorkflowInstance instance, Set<WorkflowInstanceInclude> includes); }
ListWorkflowInstanceConverter { public ListWorkflowInstanceResponse convert(WorkflowInstance instance, Set<WorkflowInstanceInclude> includes) { ListWorkflowInstanceResponse resp = new ListWorkflowInstanceResponse(); resp.id = instance.id; resp.status = instance.status.name(); resp.type = instance.type; resp.priority = instance.priority; resp.parentWorkflowId = instance.parentWorkflowId; resp.parentActionId = instance.parentActionId; resp.businessKey = instance.businessKey; resp.externalId = instance.externalId; resp.state = instance.state; resp.stateText = instance.stateText; resp.nextActivation = instance.nextActivation; resp.created = instance.created; resp.modified = instance.modified; resp.started = instance.started; resp.retries = instance.retries; resp.signal = instance.signal.orElse(null); if (includes.contains(WorkflowInstanceInclude.ACTIONS)) { resp.actions = new ArrayList<>(); for (WorkflowInstanceAction action : instance.actions) { if (includes.contains(WorkflowInstanceInclude.ACTION_STATE_VARIABLES)) { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId, stateVariablesToJson(action.updatedStateVariables))); } else { resp.actions.add(new Action(action.id, action.type.name(), action.state, action.stateText, action.retryNo, action.executionStart, action.executionEnd, action.executorId)); } } } if (includes.contains(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES)) { resp.stateVariables = stateVariablesToJson(instance.stateVariables); } if (includes.contains(WorkflowInstanceInclude.CHILD_WORKFLOW_IDS)) { resp.childWorkflows = instance.childWorkflows; } return resp; }  ListWorkflowInstanceResponse convert(WorkflowInstance instance, Set<WorkflowInstanceInclude> includes);  }