ProxyingDiscoveryService { @ApiMethod( name = "apis.getRpc", path = "apis/{api}/{version}/rpc" ) public RpcDescription getRpcDocument(HttpServletRequest request, @Named("api") String name, @Named("version") String version) throws NotFoundException, InternalServerErrorException { checkIsInitialized(); return discoveryProvider.getRpcDocument(getActualRoot(request), name, version); }  @ApiMethod(ignored = AnnotationBoolean.TRUE) synchronized void initialize(DiscoveryProvider discoveryProvider); @ApiMethod( name = "apis.getRest", path = "apis/{api}/{version}/rest" ) RestDescription getRestDocument(HttpServletRequest request, @Named("api") String name,
      @Named("version") String version); @ApiMethod( name = "apis.getRpc", path = "apis/{api}/{version}/rpc" ) RpcDescription getRpcDocument(HttpServletRequest request, @Named("api") String name,
      @Named("version") String version); @ApiMethod( name = "apis.list", path = "apis" ) DirectoryList getApiList(HttpServletRequest request);  }
@Test public void getRpcDocument() throws Exception { ProxyingDiscoveryService discoveryService = createDiscoveryService(true); when(provider.getRpcDocument(SERVER_ROOT, API_NAME, API_VERSION)).thenReturn(RPC_DOC); RpcDescription actual = discoveryService.getRpcDocument( createRequest("discovery/v1/apis/tictactoe/v1/rpc"), API_NAME, API_VERSION); assertThat(actual).isEqualTo(RPC_DOC); }
@Test public void getRpcDocument_notFound() throws Exception { ProxyingDiscoveryService discoveryService = createDiscoveryService(true); when(provider.getRpcDocument(SERVER_ROOT, API_NAME, API_VERSION)) .thenThrow(new NotFoundException("")); try { discoveryService.getRpcDocument( createRequest("discovery/v1/apis/tictactoe/v1/rpc"), API_NAME, API_VERSION); fail("expected NotFoundException"); } catch (NotFoundException e) { } }
@Test public void getRpcDocument_internalServerError() throws Exception { ProxyingDiscoveryService discoveryService = createDiscoveryService(true); when(provider.getRpcDocument(SERVER_ROOT, API_NAME, API_VERSION)) .thenThrow(new InternalServerErrorException("")); try { discoveryService.getRpcDocument( createRequest("discovery/v1/apis/tictactoe/v1/rest"), API_NAME, API_VERSION); fail("expected InternalServerErrorException"); } catch (InternalServerErrorException e) { } }
@Test public void getRpcDocument_uninitialized() throws Exception { try { ProxyingDiscoveryService discoveryService = createDiscoveryService(false); discoveryService.getRpcDocument(null , null , null ); fail("expected InternalServerErrorException"); } catch (InternalServerErrorException e) { } }