AndroidPlacesApiJsonParser implements PlacesApiJsonParser { Status readStatus(JsonReader reader) throws IOException { switch (reader.nextString()) { case "OK": return Status.OK; case "ZERO_RESULTS": return Status.ZERO_RESULTS; case "OVER_QUERY_LIMIT": return Status.OVER_QUERY_LIMIT; case "REQUEST_DENIED": return Status.REQUEST_DENIED; case "INVALID_REQUEST": return Status.INVALID_REQUEST; default: return null; } }  @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 readStatusTest() throws IOException { when(parser.readStatus(reader)).thenCallRealMethod(); when(reader.nextString()).thenReturn("OK", "ZERO_RESULTS", "OVER_QUERY_LIMIT", "REQUEST_DENIED", "INVALID_REQUEST", "skip"); assertEquals(Status.OK, parser.readStatus(reader)); assertEquals(Status.ZERO_RESULTS, parser.readStatus(reader)); assertEquals(Status.OVER_QUERY_LIMIT, parser.readStatus(reader)); assertEquals(Status.REQUEST_DENIED, parser.readStatus(reader)); assertEquals(Status.INVALID_REQUEST, parser.readStatus(reader)); assertNull(parser.readStatus(reader)); }