Last active
August 29, 2015 13:57
-
-
Save rtannenbaum/9922363 to your computer and use it in GitHub Desktop.
Serialization unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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