MoshiSerializationStrategy implements SerializationStrategy<T> { @Override public T deserialize(String serializedEntity) { try { return mJsonAdapter.fromJson(serializedEntity); } catch (IOException e) { throw new RuntimeException(e); } } MoshiSerializationStrategy(JsonAdapter<T> adapter); @Override String serialize(T value); @Override T deserialize(String serializedEntity);  }
@Test public void shouldSuccessfullyDeserializeStringToJson() { String jsonString = getJsonString(); MoshiSerializationStrategy<Cinema> serializationStrategy = getMoshiSerializationStrategy(); Cinema cinema = serializationStrategy.deserialize(jsonString); assertNotNull(cinema); assertCinema(cinema); }
@Test public void shouldSuccessfullyDeserializeStringToList() { String jsonString = getJsonStrings(); MoshiSerializationStrategy<List<Cinema>> serializationStrategy = getListMoshiSerializationStrategy(); List<Cinema> cinemas = serializationStrategy.deserialize(jsonString); assertNotNull(cinemas); assertEquals(1, cinemas.size()); assertCinema(cinemas.get(0)); }