Search in sources :

Example 6 with TopicRegistryConfig

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));
    });
}
Also used : StartupEvent(io.micronaut.context.event.StartupEvent) TopicRegistryConfig(com.bakdata.quick.common.config.TopicRegistryConfig) InternalErrorException(com.bakdata.quick.common.exception.InternalErrorException) KafkaConfig(com.bakdata.quick.common.config.KafkaConfig) Test(org.junit.jupiter.api.Test)

Example 7 with TopicRegistryConfig

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());
}
Also used : StartupEvent(io.micronaut.context.event.StartupEvent) TopicRegistryConfig(com.bakdata.quick.common.config.TopicRegistryConfig) KafkaConfig(com.bakdata.quick.common.config.KafkaConfig) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) Test(org.junit.jupiter.api.Test)

Example 8 with TopicRegistryConfig

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();
}
Also used : StartupEvent(io.micronaut.context.event.StartupEvent) TopicRegistryConfig(com.bakdata.quick.common.config.TopicRegistryConfig) KafkaConfig(com.bakdata.quick.common.config.KafkaConfig) Test(org.junit.jupiter.api.Test)

Aggregations

KafkaConfig (com.bakdata.quick.common.config.KafkaConfig)8 TopicRegistryConfig (com.bakdata.quick.common.config.TopicRegistryConfig)8 StartupEvent (io.micronaut.context.event.StartupEvent)8 Test (org.junit.jupiter.api.Test)8 InternalErrorException (com.bakdata.quick.common.exception.InternalErrorException)2 MirrorCreationData (com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData)1 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1