Add two JsonGetter examples

This commit is contained in:
Alex Theedom
2017-01-31 06:40:13 +00:00
parent e02f7825a3
commit 5bd907aa01
3 changed files with 61 additions and 4 deletions
@@ -16,10 +16,33 @@ import static org.assertj.core.api.Assertions.assertThat;
public class JsonGetterTest {
@Test
public void whenSerializingUsingJsonGetter_thenCorrect() throws JsonProcessingException {
public void whenSerializingUsingJsonGetter_andNoPropertyNameSet_thenCorrect() throws JsonProcessingException {
// arrange
Author author = new Author("Alex", "Theedom");
Author1 author = new Author1("Alex", "Theedom");
// act
String result = new ObjectMapper().writeValueAsString(author);
// assert
assertThat(from(result).getList("items")).isNotNull();
/*
{
"firstName": "Alex",
"lastName": "Theedom",
"items": []
}
*/
}
@Test
public void whenSerializingUsingJsonGetter_andPropertyNameSet_thenCorrect() throws JsonProcessingException {
// arrange
Author2 author = new Author2("Alex", "Theedom");
// act
String result = new ObjectMapper().writeValueAsString(author);