use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetKeyIfUnauthorized.
@Test
public void shouldReturnErrorFromGetKeyIfUnauthorized() throws Exception {
// Given:
when(srClient.getSchemaBySubjectAndId(any(), anyInt())).thenThrow(unauthorizedException());
// 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));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetKeyWithIdSchemaIfNotFound.
@Test
public void shouldReturnErrorFromGetKeyWithIdSchemaIfNotFound() throws Exception {
// Given:
when(srClient.getSchemaBySubjectAndId(any(), anyInt())).thenThrow(notFoundException());
// 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));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetValueIfUnauthorized.
@Test
public void shouldReturnErrorFromGetValueIfUnauthorized() throws Exception {
// Given:
when(srClient.getSchemaBySubjectAndId(any(), anyInt())).thenThrow(unauthorizedException());
// When:
final SchemaResult result = supplier.getValueSchema(Optional.of(TOPIC_NAME), Optional.of(42), expectedFormat, SerdeFeatures.of());
// Then:
assertThat(result.schemaAndId, is(Optional.empty()));
assertThat(result.failureReason, is(not(Optional.empty())));
verifyFailureMessageForValue(result, Optional.of(42));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetValueIfForbidden.
@Test
public void shouldReturnErrorFromGetValueIfForbidden() throws Exception {
// Given:
when(srClient.getSchemaBySubjectAndId(any(), anyInt())).thenThrow(forbiddenException());
// When:
final SchemaResult result = supplier.getValueSchema(Optional.of(TOPIC_NAME), Optional.of(42), expectedFormat, SerdeFeatures.of());
// Then:
assertThat(result.schemaAndId, is(Optional.empty()));
assertThat(result.failureReason, is(not(Optional.empty())));
verifyFailureMessageForValue(result, Optional.of(42));
}
use of io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult in project ksql by confluentinc.
the class SchemaRegistryTopicSchemaSupplierTest method shouldReturnErrorFromGetValueSchemaIfNotFound.
@Test
public void shouldReturnErrorFromGetValueSchemaIfNotFound() throws Exception {
// Given:
when(srClient.getLatestSchemaMetadata(any())).thenThrow(notFoundException());
// 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())));
verifyFailureMessageForValue(result, Optional.empty());
}
Aggregations