use of email.schaal.ocreader.api.json.ItemTypeAdapter in project ocreader by schaal.
the class JsonTest method TestItemToJson.
@Test
public void TestItemToJson() throws IOException {
Moshi moshi = new Moshi.Builder().add(Item.class, new ItemTypeAdapter()).build();
Item item = new Item.Builder().setId(1).setContentHash("oijoijo").setUnreadChanged(true).setUnread(false).build();
String itemJson = moshi.adapter(Item.class).toJson(item);
ReducedItem reducedItem = moshi.adapter(ReducedItem.class).fromJson(itemJson);
ReducedItem expectedReducedItem = new ReducedItem();
expectedReducedItem.id = 1;
expectedReducedItem.contentHash = "oijoijo";
expectedReducedItem.isUnread = false;
expectedReducedItem.isStarred = null;
assertEquals(expectedReducedItem, reducedItem);
}
Aggregations