ErrorHalRepresentation extends HalRepresentation { public static Builder builder() { return new Builder(); } private  ErrorHalRepresentation(Builder builder); static Builder builder(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); Map<String, List<Map<String, String>>> getErrors(); String getErrorMessage();  }
@Test public void shouldSerializeAndDeserializeWithObjectMapper() throws IOException { final ErrorHalRepresentation errorHalRepresentation = ErrorHalRepresentation.builder() .withErrorMessage("some error message") .withError("field", "key", "message", "rejected") .build(); final ObjectMapper objectMapper = new ObjectMapper(); final String json = objectMapper.writeValueAsString(errorHalRepresentation); final ErrorHalRepresentation deserialized = objectMapper.readValue(json, ErrorHalRepresentation.class); assertThat(deserialized, is(errorHalRepresentation)); }