@Test
    public void testBookAuthor() throws Exception {

        MvcResult mvcResult = mvc.perform(get("/book")
                .accept(MediaType.APPLICATION_JSON)).andReturn();

        ObjectMapper mapper = new ObjectMapper();
        // supports Java 8 date time
        mapper.registerModule(new JavaTimeModule());

        Book book = mapper.readValue(mvcResult.getResponse().getContentAsString(), Book.class);

        List<Author> authors = book.getAuthors();

        Author obj1 = new Author(1L, "Raoul-Gabriel Urma", "111-1111111");
        Author obj2 = new Author(2L, "Mario Fusco", "222-2222222");
        Author obj3 = new Author(3L, "Alan Mycroft", "333-3333333");

        assertThat(authors.size(), is(3));

        assertThat(authors, hasItem(obj1));
        assertThat(authors, hasItem(obj2));
        assertThat(authors, hasItem(obj3));

        // need exactly list item but in any order
        assertThat(authors, containsInAnyOrder(obj3, obj1, obj2));

    }
{
"id" : 1,
"title" : "Modern Java in Action",
"tags" : [ "Java", "Java 8" ],
"authors" : [ {
"id" : 1,
"name" : "Raoul-Gabriel Urma",
"phoneNo" : "111-1111111"
}, {
"id" : 2,
"name" : "Mario Fusco",
"phoneNo" : "222-2222222"
}, {
"id" : 3,
"name" : "Alan Mycroft",
"phoneNo" : "333-3333333"
} ],
"publishedDate" : "2018-11-15",
"meta" : {
"isbn-10" : "1617293563",
"isbn-13" : "978-1617293566"
}
}
spring-boot-test-json/src/test/java/com/mkyong/WebControllerTest.java