Search in sources :

Example 1 with RestClientException

use of io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException in project ksql by confluentinc.

the class AvroUtilTest method shouldFailForInvalidResultAvroSchema.

@Test
public void shouldFailForInvalidResultAvroSchema() throws IOException, RestClientException {
    SchemaRegistryClient schemaRegistryClient = mock(SchemaRegistryClient.class);
    KsqlTopic resultTopic = new KsqlTopic("testTopic", "testTopic", new KsqlAvroTopicSerDe());
    Schema resultSchema = SerDeUtil.getSchemaFromAvro(ordersAveroSchemaStr);
    PersistentQueryMetadata persistentQueryMetadata = new PersistentQueryMetadata("", null, null, "", null, DataSource.DataSourceType.KSTREAM, "", mock(KafkaTopicClient.class), resultSchema, resultTopic, null);
    expect(schemaRegistryClient.testCompatibility(anyString(), anyObject())).andReturn(false);
    replay(schemaRegistryClient);
    try {
        avroUtil.validatePersistentQueryResults(persistentQueryMetadata, schemaRegistryClient);
        fail();
    } catch (Exception e) {
        assertThat("Incorrect exception message", "Cannot register avro schema for testTopic since " + "it is not valid for schema registry.", equalTo(e.getMessage()));
    }
}
Also used : KsqlAvroTopicSerDe(io.confluent.ksql.serde.avro.KsqlAvroTopicSerDe) Schema(org.apache.kafka.connect.data.Schema) RestClientException(io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException) IOException(java.io.IOException) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) KsqlTopic(io.confluent.ksql.metastore.KsqlTopic) Test(org.junit.Test)

Aggregations

SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1 RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)1 KsqlTopic (io.confluent.ksql.metastore.KsqlTopic)1 KsqlAvroTopicSerDe (io.confluent.ksql.serde.avro.KsqlAvroTopicSerDe)1 IOException (java.io.IOException)1 Schema (org.apache.kafka.connect.data.Schema)1 Test (org.junit.Test)1