use of com.baeldung.jackson.annotation.extra.AppendBeans.BeanWithoutAppend in project tutorials by eugenp.
the class ExtraAnnotationUnitTest method whenNotUsingJsonAppendAnnotation_thenCorrect.
@Test
public void whenNotUsingJsonAppendAnnotation_thenCorrect() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
BeanWithoutAppend bean = new BeanWithoutAppend(2, "Bean Without Append Annotation");
ObjectWriter writer = mapper.writerFor(BeanWithoutAppend.class).withAttribute("version", "1.0");
String jsonString = writer.writeValueAsString(bean);
assertThat(jsonString, not(containsString("version")));
assertThat(jsonString, not(containsString("1.0")));
}
Aggregations