@Test
public void convertWithActionStateVariablesWorks() throws IOException {

  Map<String, String> stateVariables = new LinkedHashMap<>();
  stateVariables.put("foo", "1");
  stateVariables.put("bar", "quux");
  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).setUpdatedStateVariables(stateVariables).build();
  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)
      .setSignal(Optional.empty()).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.ACTION_STATE_VARIABLES));
  verify(nflowObjectMapper).readTree("1");
  verify(nflowObjectMapper).readTree("quux");
  assertThat(resp.id, is(i.id));
  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(nullValue()));
  assertThat(resp.actions, contains(reflectEquals(new Action(a.id, a.type.name(), a.state, a.stateText, a.retryNo,
      a.executionStart, a.executionEnd, a.executorId, expectedStateVariables))));
}