Search in sources :

Example 1 with TopicRegistryConfig

use of com.bakdata.quick.common.config.TopicRegistryConfig in project quick by bakdata.

the class TopicRegistryInitializerTest method shouldNotFailIfTopicExists.

@Test
void shouldNotFailIfTopicExists() {
    final String topicName = UUID.randomUUID().toString();
    kafkaCluster.createTopic(TopicConfig.forTopic(topicName).useDefaults());
    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)

Example 2 with TopicRegistryConfig

use of com.bakdata.quick.common.config.TopicRegistryConfig in project quick by bakdata.

the class TopicRegistryInitializerTest method shouldCreateMirror.

@Test
void shouldCreateMirror() {
    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 MirrorCreationData mirrorCreationData = new MirrorCreationData(TEST_NAME, topicName, 1, null, null);
    verify(this.mock).createInternalMirror(mirrorCreationData);
}
Also used : StartupEvent(io.micronaut.context.event.StartupEvent) TopicRegistryConfig(com.bakdata.quick.common.config.TopicRegistryConfig) KafkaConfig(com.bakdata.quick.common.config.KafkaConfig) MirrorCreationData(com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData) Test(org.junit.jupiter.api.Test)

Example 3 with TopicRegistryConfig

use of com.bakdata.quick.common.config.TopicRegistryConfig in project quick by bakdata.

the class TopicRegistryInitializerTest method shouldFailIfSchemaRegistryIsNotAvailable.

@Test
void shouldFailIfSchemaRegistryIsNotAvailable() {
    final String topicName = UUID.randomUUID().toString();
    this.successfulMock();
    final KafkaConfig kafkaConfig = new KafkaConfig(kafkaCluster.getBrokerList(), "http://nope:9092");
    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 4 with TopicRegistryConfig

use of com.bakdata.quick.common.config.TopicRegistryConfig in project quick by bakdata.

the class TopicRegistryInitializerTest method shouldCreateTopicRegistryTopic.

@Test
void shouldCreateTopicRegistryTopic() {
    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));
    assertThat(kafkaCluster.exists(topicName)).isTrue();
}
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)

Example 5 with TopicRegistryConfig

use of com.bakdata.quick.common.config.TopicRegistryConfig in project quick by bakdata.

the class TopicRegistryInitializerTest method shouldNotFailIfTopicRegistryExists.

@Test
void shouldNotFailIfTopicRegistryExists() {
    final String topicName = UUID.randomUUID().toString();
    this.failingMock();
    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