AndroidPlacesApiJsonParser implements PlacesApiJsonParser { DateTimePair readDateTimePair(JsonReader reader) throws IOException { String day = null; String time = null; reader.beginObject(); while (reader.hasNext()) { switch (reader.nextName()) { case "day": day = reader.nextString(); break; case "time": time = reader.nextString(); break; default: reader.skipValue(); break; } } reader.endObject(); return new DateTimePair(day, time); }  @Override PlacesAutocompleteResponse autocompleteFromStream(final InputStream is); @Override PlacesDetailsResponse detailsFromStream(final InputStream is); @Override List<Place> readHistoryJson(final InputStream in); @Override void writeHistoryJson(final OutputStream os, final List<Place> places);  }
@Test public void readDateTimePairTest() throws IOException { when(parser.readDateTimePair(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, false); when((reader.nextName())).thenReturn("day", "time", "skip"); when((reader.nextString())).thenReturn("one", "two"); DateTimePair expected = new DateTimePair("one", "two"); DateTimePair actual = parser.readDateTimePair(reader); assertEquals(expected, actual); }