Search in sources :

Example 6 with SchemaTranslator

use of io.confluent.ksql.serde.SchemaTranslator in project ksql by confluentinc.

the class SchemaRegistryTopicSchemaSupplierTest method setUp.

@Before
public void setUp() throws Exception {
    supplier = new SchemaRegistryTopicSchemaSupplier(srClient, f -> format);
    when(srClient.getLatestSchemaMetadata(any())).thenReturn(new SchemaMetadata(SCHEMA_ID, -1, AVRO_SCHEMA));
    when(srClient.getSchemaBySubjectAndId(any(), anyInt())).thenReturn(parsedSchema);
    when(parsedSchema.schemaType()).thenReturn(AvroSchema.TYPE);
    when(parsedSchema.canonicalString()).thenReturn(AVRO_SCHEMA);
    when(format.getSchemaTranslator(any())).thenReturn(schemaTranslator);
    when(format.getSchemaTranslator(any(), any())).thenReturn(schemaTranslator);
    when(schemaTranslator.toColumns(eq(parsedSchema), any(), anyBoolean())).thenReturn(ImmutableList.of(column1));
    when(schemaTranslator.name()).thenReturn("AVRO");
    when(expectedFormat.getProperties()).thenReturn(formatProperties);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) ProtobufSchema(io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) Mock(org.mockito.Mock) Assert.assertThrows(org.junit.Assert.assertThrows) Matchers.not(org.hamcrest.Matchers.not) RunWith(org.junit.runner.RunWith) HttpStatus(org.apache.http.HttpStatus) ArgumentMatchers.anyBoolean(org.mockito.ArgumentMatchers.anyBoolean) AvroSchema(io.confluent.kafka.schemaregistry.avro.AvroSchema) ImmutableList(com.google.common.collect.ImmutableList) SchemaResult(io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult) Map(java.util.Map) SimpleColumn(io.confluent.ksql.schema.ksql.SimpleColumn) RestClientException(io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) SerdeFeatures(io.confluent.ksql.serde.SerdeFeatures) ArgumentMatchers.anyInt(org.mockito.ArgumentMatchers.anyInt) Before(org.junit.Before) SerdeFeature(io.confluent.ksql.serde.SerdeFeature) SchemaTranslator(io.confluent.ksql.serde.SchemaTranslator) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) ParsedSchema(io.confluent.kafka.schemaregistry.ParsedSchema) Mockito.verify(org.mockito.Mockito.verify) Format(io.confluent.ksql.serde.Format) KsqlException(io.confluent.ksql.util.KsqlException) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) SchemaMetadata(io.confluent.kafka.schemaregistry.client.SchemaMetadata) FormatInfo(io.confluent.ksql.serde.FormatInfo) Matchers.containsString(org.hamcrest.Matchers.containsString) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) SchemaMetadata(io.confluent.kafka.schemaregistry.client.SchemaMetadata) Before(org.junit.Before)

Aggregations

SchemaTranslator (io.confluent.ksql.serde.SchemaTranslator)6 ParsedSchema (io.confluent.kafka.schemaregistry.ParsedSchema)4 Format (io.confluent.ksql.serde.Format)4 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)3 KsqlException (io.confluent.ksql.util.KsqlException)3 RestClientException (io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException)2 SimpleColumn (io.confluent.ksql.schema.ksql.SimpleColumn)2 AvroFormat (io.confluent.ksql.serde.avro.AvroFormat)2 KsqlStatementException (io.confluent.ksql.util.KsqlStatementException)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 IntegrationTest (io.confluent.common.utils.IntegrationTest)1 AvroSchema (io.confluent.kafka.schemaregistry.avro.AvroSchema)1 MockSchemaRegistryClient (io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient)1 SchemaMetadata (io.confluent.kafka.schemaregistry.client.SchemaMetadata)1 ProtobufSchema (io.confluent.kafka.schemaregistry.protobuf.ProtobufSchema)1 KsqlEntity (io.confluent.ksql.rest.entity.KsqlEntity)1 PhysicalSchema (io.confluent.ksql.schema.ksql.PhysicalSchema)1 SchemaResult (io.confluent.ksql.schema.ksql.inference.TopicSchemaSupplier.SchemaResult)1 FormatInfo (io.confluent.ksql.serde.FormatInfo)1