@Test public void verifySerialization() throws IOException { // Arrange ObjectMapper objectMapper = new ObjectMapperFactory().build(); // Act PostList testObject = objectMapper.readValue( FixtureHelpers.fixture("fixtures/post/test-post-list.json"), PostList.class); // Assert assertThat(testObject.getPosts().size()).isEqualTo(2); // Post 1 assertThat(testObject.getPosts().get(0).getId()).isEqualTo(1); assertThat(testObject.getPosts().get(0).getTitle()).isEqualTo("Title 1"); // Post 2 assertThat(testObject.getPosts().get(1).getId()).isEqualTo(2); assertThat(testObject.getPosts().get(1).getTitle()).isEqualTo("Title 2"); // Marshal FixtureAsserts.assertStringMatchesJsonFixture( "PostList", JsonHelpers.asJson(testObject), "/fixtures/post/test-post-list.json"); }
protected Object deserializeFromJsonFixtureFile(String fixturePath, Class type) throws IOException { return JsonHelpers.fromJson(FixtureHelpers.fixture("fixtures/ " + fixturePath), type); }