Skip to content

Instantly share code, notes, and snippets.

@rtannenbaum rtannenbaum/ItemTest.java
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.