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()));
}
}
Aggregations