@Test
public void shouldDeserializeTriggerWithParameters() throws Exception {

  String jsonExec0 = executionJson("exec-id-0", "busybox:1.0","commit-sha0", TEST_RUNNER_ID, "09", "FAILED",
      Optional.of("Exit code 1"));
  String jsonExec1 = executionJson("exec-id-1", "busybox:1.1","commit-sha1", TEST_RUNNER_ID, "10", "SUCCESS",
      Optional.empty());
  String json =
      "{"
      + "\"trigger_id\":\"trig-0\","
      + "\"timestamp\":\"" + time("07:55") + "\","
      + "\"parameters\":{\"env\":{\"FOO\":\"foo\",\"BAR\":\"bar\"}},"
      + "\"complete\":true,"
      + "\"executions\":["
      + jsonExec0 + "," + jsonExec1
      + "]}";
  Trigger trigger = OBJECT_MAPPER.readValue(json, Trigger.class);
  Trigger expected = Trigger.create(
      "trig-0",
      time("07:55"),
      TriggerParameters.builder()
          .env("FOO", "foo",
              "BAR", "bar")
          .build(),
      true,
      Arrays.asList(
          Execution.create(
              Optional.of("exec-id-0"),
              Optional.of("busybox:1.0"),
              Optional.of("commit-sha0"),
              Optional.of("test"),
              Arrays.asList(
                  ExecStatus.create(Instant.parse("2016-08-03T09:56:03.607Z"), "STARTED", Optional.empty()),
                  ExecStatus.create(Instant.parse("2016-08-03T09:57:03.607Z"), "RUNNING", Optional.empty()),
                  ExecStatus.create(Instant.parse("2016-08-03T09:58:03.607Z"), "FAILED", Optional.of("Exit code 1"))
              )
          ),
          Execution.create(
              Optional.of("exec-id-1"),
              Optional.of("busybox:1.1"),
              Optional.of("commit-sha1"),
              Optional.of("test"),
              Arrays.asList(
                  ExecStatus.create(Instant.parse("2016-08-03T10:56:03.607Z"), "STARTED", Optional.empty()),
                  ExecStatus.create(Instant.parse("2016-08-03T10:57:03.607Z"), "RUNNING", Optional.empty()),
                  ExecStatus.create(Instant.parse("2016-08-03T10:58:03.607Z"), "SUCCESS", Optional.empty())
              )
          )
      )
  );
  assertThat(trigger, is(expected));
}