PipelineSource { @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(); }  @JsonProperty("id") @Nullable @Id @ObjectId abstract String id(); @JsonProperty("title") @Nullable abstract String title(); @JsonProperty("description") @Nullable abstract String description(); @JsonProperty("source") abstract String source(); @JsonProperty("created_at") @Nullable abstract DateTime createdAt(); @JsonProperty("modified_at") @Nullable abstract DateTime modifiedAt(); @JsonProperty("stages") abstract List<StageSource> stages(); @JsonProperty("errors") @Nullable abstract Set<ParseError> errors(); static Builder builder(); abstract Builder toBuilder(); @JsonCreator 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); static PipelineSource fromDao(PipelineRuleParser parser, PipelineDao dao);  }
@Test public void testSerialization() throws Exception { final StageSource stageSource = StageSource.create(23, true, 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_all").asBoolean()).isTrue(); assertThat(stageNode.path("rules").isArray()).isTrue(); assertThat(stageNode.path("rules")).hasSize(1); assertThat(stageNode.path("rules").get(0).asText()).isEqualTo("some-rule"); }