@Override
  public SchemaPath getSchemaPath(TopicPath topicPath) throws IOException {
    GetTopicRequest request = GetTopicRequest.newBuilder().setTopic(topicPath.getPath()).build();
    Topic topic = publisherStub().getTopic(request);
    SchemaSettings schemaSettings = topic.getSchemaSettings();
    if (schemaSettings.getSchema().isEmpty()) {
      return null;
    }
    String schemaPath = schemaSettings.getSchema();
    if (schemaPath.equals(SchemaPath.DELETED_SCHEMA_PATH)) {
      return null;
    }
    return PubsubClient.schemaPathFromPath(schemaPath);
  }
@Test
  public void getSchemaPath() throws IOException {
    initializeClient(null, null);
    TopicPath topicDoesNotExist =
        PubsubClient.topicPathFromPath("projects/testProject/topics/idontexist");
    TopicPath topicExistsDeletedSchema =
        PubsubClient.topicPathFromPath("projects/testProject/topics/deletedSchema");
    TopicPath topicExistsNoSchema =
        PubsubClient.topicPathFromPath("projects/testProject/topics/noSchema");
    TopicPath topicExistsSchema =
        PubsubClient.topicPathFromPath("projects/testProject/topics/topicWithSchema");
    PublisherImplBase publisherImplBase =
        new PublisherImplBase() {
          @Override
          public void getTopic(GetTopicRequest request, StreamObserver<Topic> responseObserver) {
            String topicPath = request.getTopic();
            if (topicPath.equals(topicDoesNotExist.getPath())) {
              responseObserver.onError(
                  new IOException(String.format("%s does not exist", topicPath)));
            }
            if (topicPath.equals(topicExistsDeletedSchema.getPath())) {
              responseObserver.onNext(
                  Topic.newBuilder()
                      .setName(topicPath)
                      .setSchemaSettings(
                          SchemaSettings.newBuilder()
                              .setSchema(SchemaPath.DELETED_SCHEMA_PATH)
                              .build())
                      .build());
              responseObserver.onCompleted();
            }
            if (topicPath.equals(topicExistsNoSchema.getPath())) {
              responseObserver.onNext(Topic.newBuilder().setName(topicPath).build());
              responseObserver.onCompleted();
            }
            if (topicPath.equals(topicExistsSchema.getPath())) {
              responseObserver.onNext(
                  Topic.newBuilder()
                      .setName(topicPath)
                      .setSchemaSettings(
                          SchemaSettings.newBuilder().setSchema(SCHEMA.getPath()).build())
                      .build());
              responseObserver.onCompleted();
            }
          }
        };
    Server server =
        InProcessServerBuilder.forName(channelName).addService(publisherImplBase).build().start();
    try {
      assertThrows(
          "topic does not exist",
          StatusRuntimeException.class,
          () -> client.getSchemaPath(topicDoesNotExist));

      assertNull(
          "topic with deleted Schema should return null SchemaPath",
          client.getSchemaPath(topicExistsDeletedSchema));

      assertNull(
          "topic without Schema should return null SchemaPath",
          client.getSchemaPath(topicExistsNoSchema));

      assertEquals(SCHEMA.getPath(), client.getSchemaPath(topicExistsSchema).getPath());

    } finally {
      server.shutdownNow();
    }
  }