public static boolean subjectExists(
      final SchemaRegistryClient srClient,
      final String subject
  ) {
    return getLatestSchema(srClient, subject).isPresent();
  }
@Test
  public void shouldThrowAuthorizationExceptionOnUnauthorizedSubjectAccess() throws Exception {
    // Given:
    when(schemaRegistryClient.getLatestSchemaMetadata("bar-value")).thenThrow(
        new RestClientException(
            "User is denied operation Write on Subject: bar-value; error code: 40301", 403, 40301)
    );

    // When:
    final Exception e = assertThrows(KsqlSchemaAuthorizationException.class,
        () -> SchemaRegistryUtil.subjectExists(schemaRegistryClient, "bar-value"));

    // Then:
    assertThat(e.getMessage(), equalTo(
        "Authorization denied to Write on Schema Registry subject: [bar-value]"));
  }