Skip to content

Instantly share code, notes, and snippets.

@rtannenbaum
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtannenbaum/9922363 to your computer and use it in GitHub Desktop.
Save rtannenbaum/9922363 to your computer and use it in GitHub Desktop.
Serialization unit tests
public class ItemTest {
private static ObjectMapper MAPPER = new ObjectMapperFactory().build();
private Item item = Item.create("AB123_S", "038678561125", false, true, 0, 1);
@Test
public void testJsonSerialization() throws IOException {
String json = MAPPER.writeValueAsString(item);
assertEquals(jsonFixture("fixtures/Item.json"), json);
}
@Test
public void testJsonDeserialization() throws IOException {
Item item2 = MAPPER.readValue(
jsonFixture("fixtures/Item.json"), Item.class);
assertEquals(item, item2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment