Search in sources :

Example 6 with KafkaConfig

use of com.bakdata.quick.common.config.KafkaConfig 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 7 with KafkaConfig

use of com.bakdata.quick.common.config.KafkaConfig 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 8 with KafkaConfig

use of com.bakdata.quick.common.config.KafkaConfig 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 9 with KafkaConfig

use of com.bakdata.quick.common.config.KafkaConfig 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)

Example 10 with KafkaConfig

use of com.bakdata.quick.common.config.KafkaConfig 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)

Aggregations

KafkaConfig (com.bakdata.quick.common.config.KafkaConfig)15 TopicRegistryConfig (com.bakdata.quick.common.config.TopicRegistryConfig)8 StartupEvent (io.micronaut.context.event.StartupEvent)8 Test (org.junit.jupiter.api.Test)8 QuickTopicData (com.bakdata.quick.common.type.QuickTopicData)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)4 DataFetchingEnvironment (graphql.schema.DataFetchingEnvironment)3 InternalErrorException (com.bakdata.quick.common.exception.InternalErrorException)2 KafkaIngestService (com.bakdata.quick.gateway.ingest.KafkaIngestService)2 KeyValue (net.mguenther.kafka.junit.KeyValue)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 TestTopicTypeService (com.bakdata.quick.common.TestTopicTypeService)1 MirrorCreationData (com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData)1 TopicTypeService (com.bakdata.quick.common.type.TopicTypeService)1 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1 StringDeserializer (org.apache.kafka.common.serialization.StringDeserializer)1