ProxyingDiscoveryProvider extends AbstractDiscoveryProvider { @Override public DirectoryList getDirectory(String root) throws InternalServerErrorException { try { Map<ApiKey, String> configStrings = configWriter.writeConfig(rewriteConfigsWithRoot(getAllApiConfigs(), root)); ApiConfigs configs = new ApiConfigs(); configs.setConfigs(Lists.newArrayList(configStrings.values())); return discovery.apis().generateDirectory(configs).execute(); } catch (IOException | ApiConfigException e) { logger.atSevere().withCause(e).log("Could not generate or cache directory"); 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 getDirectory() throws Exception { when(directoryRequest.execute()).thenReturn(DIRECTORY); DirectoryList actual = provider.getDirectory(REWRITTEN_ROOT); assertThat(actual).isEqualTo(DIRECTORY); verify(apis).generateDirectory(withConfigs(V1_JSON_API_CONFIG, V2_JSON_API_CONFIG)); }
@Test public void getDirectory_internalServerError() throws Exception { when(directoryRequest.execute()).thenThrow(new IOException()); try { provider.getDirectory(REWRITTEN_ROOT); fail("expected InternalServerErrorException"); } catch (InternalServerErrorException e) { } }