ProxyingDiscoveryProvider extends AbstractDiscoveryProvider { @Override public RestDescription getRestDocument(String root, String name, String version) throws NotFoundException, InternalServerErrorException { try { return discovery.apis() .generateRest(new com.google.api.services.discovery.model.ApiConfig().setConfig( getApiConfigStringWithRoot(getApiConfigs(name, version), root))).execute(); } catch (IOException | ApiConfigException e) { logger.atSevere().withCause(e).log("Could not generate or cache discovery doc"); throw new InternalServerErrorException("Internal Server Error", e); } } ProxyingDiscoveryProvider(
      ImmutableList<ApiConfig> apiConfigs, ApiConfigWriter configWriter);  ProxyingDiscoveryProvider(
      ImmutableList<ApiConfig> apiConfigs, ApiConfigWriter configWriter, Discovery discovery); @Override RestDescription getRestDocument(String root, String name, String version); @Override RpcDescription getRpcDocument(String root, String name, String version); @Override DirectoryList getDirectory(String root);  }
@Test public void getRestDocument() throws Exception { when(restRequest.execute()).thenReturn(REST_DOC); RestDescription actual = provider.getRestDocument(REWRITTEN_ROOT, NAME, V1); assertThat(actual).isEqualTo(REST_DOC); verify(apis).generateRest( new com.google.api.services.discovery.model.ApiConfig().setConfig(V1_JSON_API_CONFIG)); }
@Test public void getRestDocument_notFound() throws Exception { try { provider.getRestDocument(REWRITTEN_ROOT, WRONG_NAME, V1); fail("expected NotFoundException"); } catch (NotFoundException e) { } }
@Test public void getRestDocument_internalServerError() throws Exception { when(restRequest.execute()).thenThrow(new IOException()); try { provider.getRestDocument(REWRITTEN_ROOT, NAME, V1); fail("expected InternalServerErrorException"); } catch (InternalServerErrorException e) { } }