@Test public void convertWithEmptyStateVariablesWorks() { WorkflowInstanceAction a = new WorkflowInstanceAction.Builder().setId(929).setType(stateExecution).setState("oState") .setStateText("oState desc").setRetryNo(1).setExecutionStart(now().minusDays(1)).setExecutionEnd(now().plusDays(1)) .build(); WorkflowInstance i = new WorkflowInstance.Builder().setId(1).setStatus(inProgress).setType("dummy") .setBusinessKey("businessKey").setExternalId("externalId").setState("cState").setStateText("cState desc") .setNextActivation(now()).setActions(Arrays.asList(a)).setStateVariables(new LinkedHashMap<String, String>()).build(); ListWorkflowInstanceResponse resp = converter.convert(i, EnumSet.of(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES)); assertThat(resp.id, is(i.id)); assertThat(resp.status, is(i.status.name())); assertThat(resp.stateVariables, is((Map<String, Object>) null)); 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)); assertThat(resp.actions, nullValue()); }
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);  }