@Test void shouldSerializeFlattenStructure() throws Exception { QueryDTO queryDTO = QueryDTO.and( CriterionDTO.from(FieldName.SUBJECT, Operator.CONTAINS, SUBJECT), CriterionDTO.from(FieldName.SENDER, Operator.EQUALS, SENDER.asString()), CriterionDTO.from(FieldName.HAS_ATTACHMENT, Operator.EQUALS, "true") ); JsonAssertions.assertThatJson(queryElementSerializer.serialize(queryDTO)) .isEqualTo("{ " + " \"combinator\": \"and\", " + " \"criteria\": [ " + " {\"fieldName\": \"subject\", \"operator\": \"contains\", \"value\": \"" + SUBJECT + "\"}," + " {\"fieldName\": \"sender\", \"operator\": \"equals\", \"value\": \"" + SENDER.asString() + "\"}," + " {\"fieldName\": \"hasAttachment\", \"operator\": \"equals\", \"value\": \"true\"}" + " ] " + "} " ); }
public String serialize(QueryElement queryElement) throws IOException { return objectMapper.writeValueAsString(queryElement); }
QueryElementSerializer { public String serialize(QueryElement queryElement) throws IOException { return objectMapper.writeValueAsString(queryElement); } }
QueryElementSerializer { public String serialize(QueryElement queryElement) throws IOException { return objectMapper.writeValueAsString(queryElement); } @Inject  QueryElementSerializer(ObjectMapper objectMapper); }
QueryElementSerializer { public String serialize(QueryElement queryElement) throws IOException { return objectMapper.writeValueAsString(queryElement); } @Inject  QueryElementSerializer(ObjectMapper objectMapper); String serialize(QueryElement queryElement); }
QueryElementSerializer { public String serialize(QueryElement queryElement) throws IOException { return objectMapper.writeValueAsString(queryElement); } @Inject  QueryElementSerializer(ObjectMapper objectMapper); String serialize(QueryElement queryElement);  }