use of io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategy in project kafka-rest by confluentinc.
the class SchemaManagerImplTest method getSchema_avro_schemaVersion_subjectNameStrategy.
@Test
public void getSchema_avro_schemaVersion_subjectNameStrategy() throws Exception {
ParsedSchema schema = new AvroSchema("{\"type\": \"int\"}");
SubjectNameStrategy strategy = new MySubjectNameStrategy();
String subject = strategy.subjectName(TOPIC_NAME, /* isKey= */
true, /* schema= */
null);
int schemaId = schemaRegistryClient.register(subject, schema);
int schemaVersion = schemaRegistryClient.getVersion(subject, schema);
RegisteredSchema actual = schemaManager.getSchema(TOPIC_NAME, /* format= */
Optional.empty(), /* subject= */
Optional.empty(), /* subjectNameStrategy= */
Optional.of(strategy), /* schemaId= */
Optional.empty(), /* schemaVersion= */
Optional.of(schemaVersion), /* rawSchema= */
Optional.empty(), /* isKey= */
true);
assertEquals(RegisteredSchema.create(subject, schemaId, schemaVersion, schema), actual);
}
use of io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategy in project kafka-rest by confluentinc.
the class SchemaManagerImplTest method getSchema_avro_rawSchema_subjectNameStrategy.
@Test
public void getSchema_avro_rawSchema_subjectNameStrategy() throws Exception {
SubjectNameStrategy strategy = new MySubjectNameStrategy();
String subject = strategy.subjectName(TOPIC_NAME, /* isKey= */
true, /* schema= */
null);
RegisteredSchema actual = schemaManager.getSchema(TOPIC_NAME, /* format= */
Optional.of(EmbeddedFormat.AVRO), /* subject= */
Optional.empty(), /* subjectNameStrategy= */
Optional.of(strategy), /* schemaId= */
Optional.empty(), /* schemaVersion= */
Optional.empty(), /* rawSchema= */
Optional.of("{\"type\": \"int\"}"), /* isKey= */
true);
ParsedSchema schema = schemaRegistryClient.getSchemaById(actual.getSchemaId());
int schemaId = schemaRegistryClient.getId(subject, schema);
int schemaVersion = schemaRegistryClient.getVersion(subject, schema);
assertEquals(RegisteredSchema.create(subject, schemaId, schemaVersion, schema), actual);
}
Aggregations