@Override
  public void discoverSchemaTransform(
      ExpansionApi.DiscoverSchemaTransformRequest request,
      StreamObserver<ExpansionApi.DiscoverSchemaTransformResponse> responseObserver) {
    if (!checkedAllServices) {
      try {
        waitForAllServicesToBeReady();
      } catch (TimeoutException e) {
        throw new RuntimeException(e);
      }
      checkedAllServices = true;
    }
    try {
      responseObserver.onNext(processDiscover(request));
      responseObserver.onCompleted();
    } catch (RuntimeException exn) {
      responseObserver.onNext(
          ExpansionApi.DiscoverSchemaTransformResponse.newBuilder()
              .setError(Throwables.getStackTraceAsString(exn))
              .build());
      responseObserver.onCompleted();
    }
  }
@Test
  public void testObserverNoEndpointsReturn() {
    ExpansionServiceClient expansionServiceClient = Mockito.mock(ExpansionServiceClient.class);
    Mockito.when(clientFactory.getExpansionServiceClient(Mockito.any()))
        .thenReturn(expansionServiceClient);
    Mockito.when(expansionServiceClient.discover(Mockito.any()))
        .thenReturn(
            DiscoverSchemaTransformResponse.newBuilder().setError("discovery error 1").build())
        .thenReturn(
            DiscoverSchemaTransformResponse.newBuilder().setError("discovery error 2").build());

    DiscoverSchemaTransformRequest request = DiscoverSchemaTransformRequest.newBuilder().build();
    StreamObserver<DiscoverSchemaTransformResponse> responseObserver =
        Mockito.mock(StreamObserver.class);
    expansionService.discoverSchemaTransform(request, responseObserver);
    Mockito.verify(expansionServiceClient, Mockito.times(2)).discover(request);

    ArgumentCaptor<DiscoverSchemaTransformResponse> discoverResponseCapture =
        ArgumentCaptor.forClass(DiscoverSchemaTransformResponse.class);
    Mockito.verify(responseObserver).onNext(discoverResponseCapture.capture());
    assertEquals(0, discoverResponseCapture.getValue().getSchemaTransformConfigsCount());
  }