Skip to content

Instantly share code, notes, and snippets.

View richarth's full-sized avatar

Richard Thompson richarth

View GitHub Profile
@richarth
richarth / ModelTests.java
Created February 9, 2017 14:14
Sample code to demonstrate cannot serialize abstract class issue with Auto Value and Moshi
@RunWith(JUnit4.class)
public class ModelTests {
@Test
public void verifyJsonConvertsToModel() throws Exception {
String sampleMovieJson = "{\"adult\":false,\"backdrop_path\":\"/lubzBMQLLmG88CLQ4F3TxZr2Q7N.jpg\",\"belongs_to_collection\":{\"id\":427084,\"name\":\"The Secret Life of Pets Collection\",\"poster_path\":\"/aDNbXvuRiuYxk8qCwXNQQ7UEHau.jpg\",\"backdrop_path\":null},\"budget\":75000000,\"genres\":[{\"id\":12,\"name\":\"Adventure\"},{\"id\":16,\"name\":\"Animation\"},{\"id\":35,\"name\":\"Comedy\"},{\"id\":10751,\"name\":\"Family\"}],\"homepage\":\"http://www.thesecretlifeofpets.com/\",\"id\":328111,\"imdb_id\":\"tt2709768\",\"original_language\":\"en\",\"original_title\":\"The Secret Life of Pets\",\"overview\":\"The quiet life of a terrier named Max is upended when his owner takes in Duke, a stray whom Max instantly dislikes.\",\"popularity\":129.924005,\"poster_path\":\"/WLQN5aiQG8wc9SeKwixW7pAR8K.jpg\",\"production_companies\":[{\"name\":\"Universal Pictures\",\"id\":33},{\"name\":