use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnSchemaFromGetValueSchemaIfFound.
@Test
public void shouldReturnSchemaFromGetValueSchemaIfFound() {
// When:
final SchemaResult result = supplier.getValueSchema(Optional.of(TOPIC_NAME), Optional.empty(), expectedFormat, SerdeFeatures.of());
// Then:
assertThat(result.schemaAndId, is(not(Optional.empty())));
assertThat(result.schemaAndId.get().id, is(SCHEMA_ID));
assertThat(result.schemaAndId.get().columns, is(ImmutableList.of(column1)));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetKeySchemaOnMultipleColumns.
@Test
public void shouldReturnErrorFromGetKeySchemaOnMultipleColumns() {
// Given:
when(schemaTranslator.toColumns(parsedSchema, SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES), true)).thenReturn(ImmutableList.of(column1, column2));
// When:
final SchemaResult result = supplier.getKeySchema(Optional.of(TOPIC_NAME), Optional.empty(), expectedFormat, SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES));
// Then:
assertThat(result.schemaAndId, is(Optional.empty()));
assertThat(result.failureReason.get().getMessage(), containsString("The key schema for topic: some-topic contains multiple columns, " + "which is not supported by ksqlDB at this time."));
assertThat(result.failureReason.get().getMessage(), containsString(AVRO_SCHEMA));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method verifyFailureMessage.
private void verifyFailureMessage(final SchemaResult result, final boolean isKey, Optional<Integer> id) {
final String keyOrValue = isKey ? "keys" : "values";
final String keyOrValueSuffix = isKey ? "key" : "value";
final String schemaIdMsg = id.map(integer -> "Schema Id: " + integer + System.lineSeparator()).orElse("");
assertThat(result.failureReason.get().getMessage(), is("Schema for message " + keyOrValue + " on topic '" + TOPIC_NAME + "' does not exist in the Schema Registry." + System.lineSeparator() + "Subject: " + TOPIC_NAME + "-" + keyOrValueSuffix + System.lineSeparator() + schemaIdMsg + "Possible causes include:" + System.lineSeparator() + "- The topic itself does not exist" + System.lineSeparator() + "\t-> Use SHOW TOPICS; to check" + System.lineSeparator() + "- Messages on the topic are not serialized using a format Schema Registry supports" + System.lineSeparator() + "\t-> Use PRINT '" + TOPIC_NAME + "' FROM BEGINNING; to verify" + System.lineSeparator() + "- Messages on the topic have not been serialized using a Confluent Schema Registry supported serializer" + System.lineSeparator() + "\t-> See https://docs.confluent.io/current/schema-registry/docs/serializer-formatter.html" + System.lineSeparator() + "- The schema is registered on a different instance of the Schema Registry" + System.lineSeparator() + "\t-> Use the REST API to list available subjects\thttps://docs.confluent.io/current/schema-registry/docs/api.html#get--subjects" + System.lineSeparator() + "- You do not have permissions to access the Schema Registry." + System.lineSeparator() + "\t-> See https://docs.confluent.io/current/schema-registry/docs/security.html"));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetKeySchemaIfCanNotConvertToConnectSchema.
@Test
public void shouldReturnErrorFromGetKeySchemaIfCanNotConvertToConnectSchema() {
// Given:
when(schemaTranslator.toColumns(any(), any(), anyBoolean())).thenThrow(new RuntimeException("it went boom"));
// When:
final SchemaResult result = supplier.getKeySchema(Optional.of(TOPIC_NAME), Optional.empty(), expectedFormat, SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES));
// Then:
assertThat(result.schemaAndId, is(Optional.empty()));
assertThat(result.failureReason.get().getMessage(), containsString("Unable to verify if the key schema for topic: some-topic is compatible with ksqlDB."));
assertThat(result.failureReason.get().getMessage(), containsString("it went boom"));
assertThat(result.failureReason.get().getMessage(), containsString(AVRO_SCHEMA));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetValueSchemaIfCanNotConvertToConnectSchema.
@Test
public void shouldReturnErrorFromGetValueSchemaIfCanNotConvertToConnectSchema() {
// Given:
when(schemaTranslator.toColumns(any(), any(), anyBoolean())).thenThrow(new RuntimeException("it went boom"));
// When:
final SchemaResult result = supplier.getValueSchema(Optional.of(TOPIC_NAME), Optional.empty(), expectedFormat, SerdeFeatures.of());
// Then:
assertThat(result.schemaAndId, is(Optional.empty()));
assertThat(result.failureReason.get().getMessage(), containsString("Unable to verify if the value schema for topic: some-topic is compatible with ksqlDB."));
assertThat(result.failureReason.get().getMessage(), containsString("it went boom"));
assertThat(result.failureReason.get().getMessage(), containsString(AVRO_SCHEMA));
}
Aggregations