Search in sources :

Example 1 with CollectionItem

use of saulmm.avengers.entities.CollectionItem in project Avengers by saulmm.

the class GsonDeserializersTest method testThatACollectionDeserialzierDeserializesACollection.

@Test
public void testThatACollectionDeserialzierDeserializesACollection() throws Exception {
    MarvelResultsDeserializer<CollectionItem> marvelResultsDeserializer = new MarvelResultsDeserializer<>();
    JsonElement collectionElement = new JsonParser().parse(getComicsCollectionJsonString());
    Type t = new TypeToken<List<CollectionItem>>() {
    }.getType();
    List<CollectionItem> collectionList = marvelResultsDeserializer.deserialize(collectionElement, t, mock(JsonDeserializationContext.class));
    assertThat(collectionList.isEmpty(), is(false));
    assertNotNull(collectionList.get(0).getThumbnail());
}
Also used : Type(java.lang.reflect.Type) JsonDeserializationContext(com.google.gson.JsonDeserializationContext) JsonElement(com.google.gson.JsonElement) List(java.util.List) CollectionItem(saulmm.avengers.entities.CollectionItem) MarvelResultsDeserializer(saulmm.avengers.rest.utils.deserializers.MarvelResultsDeserializer) JsonParser(com.google.gson.JsonParser) Test(org.junit.Test)

Aggregations

JsonDeserializationContext (com.google.gson.JsonDeserializationContext)1 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1 Type (java.lang.reflect.Type)1 List (java.util.List)1 Test (org.junit.Test)1 CollectionItem (saulmm.avengers.entities.CollectionItem)1 MarvelResultsDeserializer (saulmm.avengers.rest.utils.deserializers.MarvelResultsDeserializer)1