use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnSchemaFromGetKeySchemaIfFound.
@Test
public void shouldReturnSchemaFromGetKeySchemaIfFound() {
// When:
final SchemaResult result = supplier.getKeySchema(Optional.of(TOPIC_NAME), Optional.empty(), expectedFormat, SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES));
// 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 shouldReturnErrorFromGetValueSchemaIfSchemaIsNotInExpectedFormat.
@Test
public void shouldReturnErrorFromGetValueSchemaIfSchemaIsNotInExpectedFormat() {
// Given:
when(parsedSchema.schemaType()).thenReturn(ProtobufSchema.TYPE);
// 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, is(not(Optional.empty())));
assertThat(result.failureReason.get().getMessage(), is("Value schema is not in the expected format. " + "You may want to set VALUE_FORMAT to 'PROTOBUF'." + System.lineSeparator() + "topic: " + TOPIC_NAME + System.lineSeparator() + "expected format: AVRO" + System.lineSeparator() + "actual format from Schema Registry: PROTOBUF"));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetKeySchemaIfNotFound.
@Test
public void shouldReturnErrorFromGetKeySchemaIfNotFound() throws Exception {
// Given:
when(srClient.getLatestSchemaMetadata(any())).thenThrow(notFoundException());
// 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, is(not(Optional.empty())));
verifyFailureMessageForKey(result, Optional.empty());
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetKeySchemaIfSchemaIsNotInExpectedFormat.
@Test
public void shouldReturnErrorFromGetKeySchemaIfSchemaIsNotInExpectedFormat() {
// Given:
when(parsedSchema.schemaType()).thenReturn(ProtobufSchema.TYPE);
// 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, is(not(Optional.empty())));
assertThat(result.failureReason.get().getMessage(), is("Key schema is not in the expected format. " + "You may want to set KEY_FORMAT to 'PROTOBUF'." + System.lineSeparator() + "topic: " + TOPIC_NAME + System.lineSeparator() + "expected format: AVRO" + System.lineSeparator() + "actual format from Schema Registry: PROTOBUF"));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetKeyIfForbidden.
@Test
public void shouldReturnErrorFromGetKeyIfForbidden() throws Exception {
// Given:
when(srClient.getSchemaBySubjectAndId(any(), anyInt())).thenThrow(forbiddenException());
// When:
final SchemaResult result = supplier.getKeySchema(Optional.of(TOPIC_NAME), Optional.of(42), expectedFormat, SerdeFeatures.of(SerdeFeature.UNWRAP_SINGLES));
// Then:
assertThat(result.schemaAndId, is(Optional.empty()));
assertThat(result.failureReason, is(not(Optional.empty())));
verifyFailureMessageForKey(result, Optional.of(42));
}
Aggregations