@Test
public void convertWithMalformedStateVariablesWorks() throws JsonProcessingException, IOException {

  DateTime now = now();
  WorkflowInstanceAction a = new WorkflowInstanceAction.Builder() //
      .setId(929).setType(stateExecution).setState("oStDateTimeate").setStateText("oState desc").setRetryNo(1)
      .setExecutionStart(now.minusDays(1)).setExecutionEnd(now.plusDays(1)).build();
  Map<String, String> stateVariables = new LinkedHashMap<>();
  String value1 = "{\"a\":1";
  String value2 = "quux\"";
  stateVariables.put("foo", value1);
  stateVariables.put("bar", value2);
  WorkflowInstance i = new WorkflowInstance.Builder() //
      .setId(1) //
      .setStatus(inProgress).setType("dummy").setBusinessKey("businessKey").setExternalId("externalId").setState("cState")
      .setStateText("cState desc").setNextActivation(now).setActions(asList(a)).setStateVariables(stateVariables).build();
  when(nflowObjectMapper.readTree(value1)).thenThrow(new JsonParseException(null, "bad data"));
  when(nflowObjectMapper.readTree(value2)).thenThrow(new JsonParseException(null, "bad data"));
  ListWorkflowInstanceResponse resp = converter.convert(i, EnumSet.of(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES));
  verify(nflowObjectMapper).readTree(value1);
  verify(nflowObjectMapper).readTree(value2);
  Map<String, Object> expectedStateVariables = new LinkedHashMap<>();
  expectedStateVariables.put("foo", new TextNode(value1));
  expectedStateVariables.put("bar", new TextNode(value2));
  assertThat(resp.id, is(i.id));
  assertThat(resp.status, is(i.status.name()));
  assertThat(resp.stateVariables, is(expectedStateVariables));
  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());
}