use of com.bakdata.quick.common.config.TopicRegistryConfig in project quick by bakdata.
the class TopicRegistryInitializerTest method shouldFailIfKafkaIsNotAvailable.
@Test
void shouldFailIfKafkaIsNotAvailable() {
final String topicName = UUID.randomUUID().toString();
this.successfulMock();
final KafkaConfig kafkaConfig = new KafkaConfig("nope:9092", this.schemaRegistry.getUrl());
final TopicRegistryConfig registryConfig = new TopicRegistryConfig(topicName, TEST_NAME, 3, (short) 1);
final TopicRegistryInitializer topicRegistryInitializer = new TopicRegistryInitializer(kafkaConfig, registryConfig, this.mock);
assertThatExceptionOfType(InternalErrorException.class).isThrownBy(() -> {
topicRegistryInitializer.onStartUp(new StartupEvent(this.applicationContext));
});
}
use of com.bakdata.quick.common.config.TopicRegistryConfig in project quick by bakdata.
the class TopicRegistryInitializerTest method shouldCreateSchema.
@Test
void shouldCreateSchema() throws IOException, RestClientException {
final String topicName = UUID.randomUUID().toString();
this.successfulMock();
final KafkaConfig kafkaConfig = new KafkaConfig(kafkaCluster.getBrokerList(), this.schemaRegistry.getUrl());
final TopicRegistryConfig registryConfig = new TopicRegistryConfig(topicName, TEST_NAME, 3, (short) 1);
final TopicRegistryInitializer topicRegistryInitializer = new TopicRegistryInitializer(kafkaConfig, registryConfig, this.mock);
topicRegistryInitializer.onStartUp(new StartupEvent(this.applicationContext));
final SchemaRegistryClient registryClient = this.schemaRegistry.getSchemaRegistryClient();
final String subject = topicName + "-value";
assertThat(registryClient.getAllSubjects()).containsExactly(subject);
assertThat(registryClient.getBySubjectAndId(subject, 1)).isEqualTo(AvroTopicData.getClassSchema());
}
use of com.bakdata.quick.common.config.TopicRegistryConfig in project quick by bakdata.
the class TopicRegistryInitializerTest method shouldNotFailIfSchemaExists.
@Test
void shouldNotFailIfSchemaExists() {
final String topicName = UUID.randomUUID().toString();
this.successfulMock();
final KafkaConfig kafkaConfig = new KafkaConfig(kafkaCluster.getBrokerList(), this.schemaRegistry.getUrl());
final TopicRegistryConfig registryConfig = new TopicRegistryConfig(topicName, TEST_NAME, 3, (short) 1);
final TopicRegistryInitializer topicRegistryInitializer = new TopicRegistryInitializer(kafkaConfig, registryConfig, this.mock);
assertThatCode(() -> {
topicRegistryInitializer.onStartUp(new StartupEvent(this.applicationContext));
}).doesNotThrowAnyException();
}
Aggregations