@JsonCreator
    public static PipelineSource create(@JsonProperty("id") @Id @ObjectId @Nullable String id,
                                        @JsonProperty("title") String title,
                                        @JsonProperty("description") @Nullable String description,
                                        @JsonProperty("source") String source,
                                        @Nullable @JsonProperty("stages") List<StageSource> stages,
                                        @Nullable @JsonProperty("created_at") DateTime createdAt,
                                        @Nullable @JsonProperty("modified_at") DateTime modifiedAt) {
        return builder()
                .id(id)
                .title(title)
                .description(description)
                .source(source)
                .createdAt(createdAt)
                .modifiedAt(modifiedAt)
                .stages(stages == null ? Collections.emptyList() : stages)
                .build();
    }
@Test
    public void testSerialization() throws Exception {
        final StageSource stageSource = StageSource.create(23, Stage.Match.ALL, Collections.singletonList("some-rule"));
        final PipelineSource pipelineSource = PipelineSource.create(
                "id",
                "title",
                "description",
                "source",
                Collections.singletonList(stageSource),
                new DateTime(2017, 7, 4, 15, 0, DateTimeZone.UTC),
                new DateTime(2017, 7, 4, 15, 0, DateTimeZone.UTC)
        );
        final JsonNode json = objectMapper.convertValue(pipelineSource, JsonNode.class);

        assertThat(json.path("id").asText()).isEqualTo("id");
        assertThat(json.path("title").asText()).isEqualTo("title");
        assertThat(json.path("description").asText()).isEqualTo("description");
        assertThat(json.path("source").asText()).isEqualTo("source");
        assertThat(json.path("created_at").asText()).isEqualTo("2017-07-04T15:00:00.000Z");
        assertThat(json.path("modified_at").asText()).isEqualTo("2017-07-04T15:00:00.000Z");
        assertThat(json.path("stages").isArray()).isTrue();
        assertThat(json.path("stages")).hasSize(1);

        final JsonNode stageNode = json.path("stages").get(0);
        assertThat(stageNode.path("stage").asInt()).isEqualTo(23);
        assertThat(stageNode.path("match").asText()).isEqualTo("ALL");
        assertThat(stageNode.path("rules").isArray()).isTrue();
        assertThat(stageNode.path("rules")).hasSize(1);
        assertThat(stageNode.path("rules").get(0).asText()).isEqualTo("some-rule");
    }