AndroidPlacesApiJsonParser implements PlacesApiJsonParser { List<PlaceType> readPlaceTypesArray(JsonReader reader) throws IOException { List<PlaceType> types = new ArrayList<>(); reader.beginArray(); while (reader.hasNext()) { switch (reader.nextString()) { case "route": types.add(PlaceType.ROUTE); break; case "geocode": types.add(PlaceType.GEOCODE); break; default: reader.skipValue(); break; } } reader.endArray(); return types; }  @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 readPlaceTypesArrayTest() throws IOException { when(parser.readPlaceTypesArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, false); when(reader.nextString()).thenReturn("route", "geocode", "skip"); List<PlaceType> expected = Arrays.asList(PlaceType.ROUTE, PlaceType.GEOCODE); List<PlaceType> actual = parser.readPlaceTypesArray(reader); assertEquals(expected, actual); }