AndroidPlacesApiJsonParser implements PlacesApiJsonParser { List<String> readTypesArray(JsonReader reader) throws IOException { List<String> types = new ArrayList<>(); reader.beginArray(); while (reader.hasNext()) { types.add(reader.nextString()); } 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 readTypesArrayTest() throws IOException { when(parser.readTypesArray(reader)).thenCallRealMethod(); when(reader.hasNext()).thenReturn(true, true, true, false); when(reader.nextString()).thenReturn("one", "two", "three"); List<String> expected = Arrays.asList("one", "two", "three"); List<String> actual = parser.readTypesArray(reader); assertEquals(expected, actual); }