@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 testObserverMultipleEndpointsReturn() {
    ExpansionServiceClient expansionServiceClient = Mockito.mock(ExpansionServiceClient.class);
    Mockito.when(clientFactory.getExpansionServiceClient(Mockito.any()))
        .thenReturn(expansionServiceClient);
    Mockito.when(expansionServiceClient.discover(Mockito.any()))
        .thenReturn(
            DiscoverSchemaTransformResponse.newBuilder()
                .putSchemaTransformConfigs(
                    "schematransform_key_1", SchemaTransformConfig.newBuilder().build())
                .build())
        .thenReturn(
            DiscoverSchemaTransformResponse.newBuilder()
                .putSchemaTransformConfigs(
                    "schematransform_key_2", SchemaTransformConfig.newBuilder().build())
                .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(2, discoverResponseCapture.getValue().getSchemaTransformConfigsCount());
    assertTrue(
        discoverResponseCapture
            .getValue()
            .getSchemaTransformConfigsMap()
            .containsKey("schematransform_key_1"));
    assertTrue(
        discoverResponseCapture
            .getValue()
            .getSchemaTransformConfigsMap()
            .containsKey("schematransform_key_2"));
  }