Search in sources :

Example 11 with TopicCreationData

use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.

the class KafkaTopicServiceTest method shouldDeleteTopicFromTopicRegistry.

@Test
void shouldDeleteTopicFromTopicRegistry() {
    final String topicName = UUID.randomUUID().toString();
    this.successfulMock();
    final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, null, null, null);
    final Completable completable = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.DOUBLE, requestData);
    assertThat(completable.blockingGet()).isNull();
    assertThat(this.topicService.deleteTopic(topicName).blockingGet()).isNull();
    verify(this.mirrorService).deleteMirror(topicName);
    assertThatNullPointerException().isThrownBy(() -> this.topicRegistryClient.getTopicData(topicName));
}
Also used : TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) Completable(io.reactivex.Completable) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 12 with TopicCreationData

use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.

the class KafkaTopicServiceTest method shouldRegisterTopicGraphQLSchema.

@Test
void shouldRegisterTopicGraphQLSchema() {
    final String topicName = UUID.randomUUID().toString();
    this.successfulMock();
    when(this.gatewayService.getGateway(GATEWAY_SCHEMA.getGateway())).thenReturn(Single.just(new GatewayDescription("test", 1, "latest")));
    when(this.gatewayClient.getWriteSchema(anyString(), anyString())).thenReturn(Single.just(new SchemaData(SCHEMA)));
    final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, GATEWAY_SCHEMA, null, null);
    final Completable completable = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.SCHEMA, requestData);
    assertThat(completable.blockingGet()).isNull();
    final TopicData expected = new TopicData(topicName, TopicWriteType.MUTABLE, QuickTopicType.DOUBLE, QuickTopicType.SCHEMA, SCHEMA);
    assertThat(this.topicRegistryClient.getTopicData(topicName).blockingGet()).usingRecursiveComparison().isEqualTo(expected);
}
Also used : TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) Completable(io.reactivex.Completable) SchemaData(com.bakdata.quick.common.api.model.gateway.SchemaData) GatewayDescription(com.bakdata.quick.common.api.model.manager.GatewayDescription) TopicData(com.bakdata.quick.common.api.model.TopicData) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 13 with TopicCreationData

use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.

the class KafkaTopicServiceTest method shouldRegisterTopicAvroSchema.

@Test
void shouldRegisterTopicAvroSchema() throws IOException, RestClientException {
    final String topicName = UUID.randomUUID().toString();
    this.successfulMock();
    when(this.gatewayService.getGateway(GATEWAY_SCHEMA.getGateway())).thenReturn(Single.just(new GatewayDescription("test", 1, "latest")));
    when(this.gatewayClient.getWriteSchema(anyString(), anyString())).thenReturn(Single.just(new SchemaData(SCHEMA)));
    final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, GATEWAY_SCHEMA, null, null);
    final Completable completable = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.SCHEMA, requestData);
    assertThat(completable.blockingGet()).isNull();
    final SchemaRegistryClient schemaRegistryClient = this.schemaRegistry.getSchemaRegistryClient();
    final String subject = topicName + "-value";
    final Schema expectedSchema = this.graphQLToAvroConverter.convertToSchema(SCHEMA);
    assertThat(schemaRegistryClient.getAllSubjects()).containsExactly(subject);
    assertThat(schemaRegistryClient.getBySubjectAndId(subject, 1)).isEqualTo(expectedSchema);
}
Also used : TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) Completable(io.reactivex.Completable) SchemaData(com.bakdata.quick.common.api.model.gateway.SchemaData) Schema(org.apache.avro.Schema) GatewaySchema(com.bakdata.quick.common.api.model.manager.GatewaySchema) GatewayDescription(com.bakdata.quick.common.api.model.manager.GatewayDescription) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) Test(org.junit.jupiter.api.Test)

Example 14 with TopicCreationData

use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.

the class KafkaTopicServiceTest method shouldCreateTopic.

@Test
void shouldCreateTopic() {
    final String topicName = UUID.randomUUID().toString();
    this.successfulMock();
    final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, null, null, null);
    final Completable completable = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.DOUBLE, requestData);
    assertThat(completable.blockingGet()).isNull();
    assertThat(kafkaCluster.exists(topicName)).isTrue();
}
Also used : TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) Completable(io.reactivex.Completable) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 15 with TopicCreationData

use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.

the class TopicControllerTest method testCreateTopicWhenQueryIsNotDefined.

@Test
void testCreateTopicWhenQueryIsNotDefined() {
    when(this.service.createTopic(anyString(), any(), any(), any())).thenReturn(Completable.complete());
    final TopicCreationData creationData = new TopicCreationData(TopicWriteType.MUTABLE, null, new GatewaySchema("test", "test"), null);
    this.client.toBlocking().exchange(POST(baseUri, creationData));
    verify(this.service).createTopic(NAME, QuickTopicType.LONG, QuickTopicType.SCHEMA, creationData);
}
Also used : TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) GatewaySchema(com.bakdata.quick.common.api.model.manager.GatewaySchema) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest) Test(org.junit.jupiter.api.Test)

Aggregations

TopicCreationData (com.bakdata.quick.common.api.model.manager.creation.TopicCreationData)15 Test (org.junit.jupiter.api.Test)14 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 Completable (io.reactivex.Completable)8 GatewayDescription (com.bakdata.quick.common.api.model.manager.GatewayDescription)5 BadArgumentException (com.bakdata.quick.common.exception.BadArgumentException)5 TopicData (com.bakdata.quick.common.api.model.TopicData)4 SchemaData (com.bakdata.quick.common.api.model.gateway.SchemaData)4 GatewaySchema (com.bakdata.quick.common.api.model.manager.GatewaySchema)3 MirrorCreationData (com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData)2 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)2 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)2 Duration (java.time.Duration)2 List (java.util.List)2 Schema (org.apache.avro.Schema)2 GatewayClient (com.bakdata.quick.common.api.client.GatewayClient)1 TopicRegistryClient (com.bakdata.quick.common.api.client.TopicRegistryClient)1 KeyValueEnum (com.bakdata.quick.common.api.model.KeyValueEnum)1 KEY (com.bakdata.quick.common.api.model.KeyValueEnum.KEY)1 VALUE (com.bakdata.quick.common.api.model.KeyValueEnum.VALUE)1