Search in sources :

Example 1 with TopicData

use of com.bakdata.quick.common.api.model.TopicData in project quick by bakdata.

the class TopicControllerTest method shouldGetTopicList.

@Test
void shouldGetTopicList() {
    final TopicData topic = new TopicData(NAME, TopicWriteType.MUTABLE, QuickTopicType.LONG, QuickTopicType.STRING, null);
    when(this.service.getTopicList()).thenReturn(Single.just(List.of(topic)));
    this.client.toBlocking().exchange(GET("/topics"));
    verify(this.service).getTopicList();
}
Also used : TopicData(com.bakdata.quick.common.api.model.TopicData) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest) Test(org.junit.jupiter.api.Test)

Example 2 with TopicData

use of com.bakdata.quick.common.api.model.TopicData in project quick by bakdata.

the class KafkaTopicServiceTest method shouldRegisterTopic.

@Test
void shouldRegisterTopic() {
    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);
    final TopicData expectedTopicData = new TopicData(topicName, TopicWriteType.MUTABLE, QuickTopicType.DOUBLE, QuickTopicType.DOUBLE, null);
    assertThat(completable.blockingGet()).isNull();
    assertThat(this.topicRegistryClient.getTopicData(topicName).blockingGet()).usingRecursiveComparison().isEqualTo(expectedTopicData);
}
Also used : TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) Completable(io.reactivex.Completable) TopicData(com.bakdata.quick.common.api.model.TopicData) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 3 with TopicData

use of com.bakdata.quick.common.api.model.TopicData in project quick by bakdata.

the class KafkaTopicServiceTest method shouldNotCreateTopicThatAlreadyExistsInRegistry.

@Test
void shouldNotCreateTopicThatAlreadyExistsInRegistry() throws RestClientException, IOException {
    final String topicName = UUID.randomUUID().toString();
    this.successfulMock();
    final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, null, null, null);
    this.topicRegistryClient.register(topicName, new TopicData(topicName, TopicWriteType.MUTABLE, null, null, null)).blockingAwait();
    assertThat(this.topicRegistryClient.topicDataExists(topicName).blockingGet()).isTrue();
    final Throwable exception = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.DOUBLE, requestData).blockingGet();
    final String expectedErrorMsg = String.format("Topic \"%s\" already exists", topicName);
    assertThat(exception).isExactlyInstanceOf(BadArgumentException.class).extracting(Throwable::getMessage).asString().startsWith(expectedErrorMsg);
    assertThat(kafkaCluster.exists(topicName)).isFalse();
    assertThat(this.schemaRegistry.getSchemaRegistryClient().getAllSubjects()).isEmpty();
}
Also used : BadArgumentException(com.bakdata.quick.common.exception.BadArgumentException) TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) TopicData(com.bakdata.quick.common.api.model.TopicData) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 4 with TopicData

use of com.bakdata.quick.common.api.model.TopicData in project quick by bakdata.

the class TopicDataClientTest method shouldReturnTrueIfTopicDoesNotExist.

@Test
void shouldReturnTrueIfTopicDoesNotExist() throws JsonProcessingException {
    final TopicData topicData = createTopicData("dummy");
    final String body = this.generateBody(topicData);
    this.server.enqueue(new MockResponse().setBody(body));
    final Boolean exists = this.topicDataClient.exists("dummy");
    assertThat(exists).isTrue();
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) TopicData(com.bakdata.quick.common.api.model.TopicData) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Example 5 with TopicData

use of com.bakdata.quick.common.api.model.TopicData in project quick by bakdata.

the class TopicDataClientTest method shouldReturnGetTopicDataWithSpecificKey.

@Test
void shouldReturnGetTopicDataWithSpecificKey() throws JsonProcessingException {
    final TopicData topicData = createTopicData("dummy");
    final String body = this.generateBody(topicData);
    this.server.enqueue(new MockResponse().setBody(body));
    final TopicData topic = this.topicDataClient.fetchValue("dummy");
    assertThat(Objects.requireNonNull(topic).getName()).isEqualTo("dummy");
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) TopicData(com.bakdata.quick.common.api.model.TopicData) Test(org.junit.jupiter.api.Test) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest)

Aggregations

TopicData (com.bakdata.quick.common.api.model.TopicData)10 Test (org.junit.jupiter.api.Test)8 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)5 TopicCreationData (com.bakdata.quick.common.api.model.manager.creation.TopicCreationData)4 MockResponse (okhttp3.mockwebserver.MockResponse)4 Completable (io.reactivex.Completable)3 BadArgumentException (com.bakdata.quick.common.exception.BadArgumentException)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)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 TopicWriteType (com.bakdata.quick.common.api.model.TopicWriteType)1 SchemaData (com.bakdata.quick.common.api.model.gateway.SchemaData)1 GatewayDescription (com.bakdata.quick.common.api.model.manager.GatewayDescription)1 GatewaySchema (com.bakdata.quick.common.api.model.manager.GatewaySchema)1 MirrorCreationData (com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData)1 KafkaConfig (com.bakdata.quick.common.config.KafkaConfig)1 QuickTopicConfig (com.bakdata.quick.common.config.QuickTopicConfig)1