use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.
the class TopicControllerTest method testCreateTopicWhenQueryIsSet.
@Test
void testCreateTopicWhenQueryIsSet() {
when(this.service.createTopic(anyString(), any(), any(), any())).thenReturn(Completable.complete());
final String uri = UriBuilder.of(baseUri).queryParam("keyType", QuickTopicType.STRING).queryParam("valueType", QuickTopicType.DOUBLE).build().toString();
final TopicCreationData creationData = new TopicCreationData(TopicWriteType.MUTABLE, null, null, null);
this.client.toBlocking().exchange(POST(uri, creationData));
verify(this.service).createTopic(NAME, QuickTopicType.STRING, QuickTopicType.DOUBLE, creationData);
}
use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData 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);
}
use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.
the class KafkaTopicServiceTest method shouldSetRetentionTime.
@Test
void shouldSetRetentionTime() {
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 Duration retentionTime = Duration.ofMinutes(30);
final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, GATEWAY_SCHEMA, null, retentionTime);
final Completable completable = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.DOUBLE, requestData);
assertThat(completable.blockingGet()).isNull();
final MirrorCreationData mirrorCreationData = new MirrorCreationData(topicName, topicName, 1, null, retentionTime);
verify(this.mirrorService).createMirror(mirrorCreationData);
}
use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.
the class KafkaTopicServiceTest method shouldRetrieveAllTopics.
@Test
void shouldRetrieveAllTopics() {
final int numberOfTopics = 10;
for (int i = 0; i < numberOfTopics; i++) {
final String topicName = UUID.randomUUID().toString();
this.successfulMock();
final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, null, null, null);
this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.DOUBLE, requestData).blockingAwait();
}
final Single<List<TopicData>> allTopics = this.topicRegistryClient.getAllTopics();
assertThat(allTopics.blockingGet().size()).isEqualTo(numberOfTopics);
}
use of com.bakdata.quick.common.api.model.manager.creation.TopicCreationData in project quick by bakdata.
the class KafkaTopicServiceTest method shouldNotCreateTopicWithInvalidGraphQLSchema.
@Test
void shouldNotCreateTopicWithInvalidGraphQLSchema() {
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.error(new BadArgumentException("Type OopsNotHere does not exist")));
final TopicCreationData requestData = new TopicCreationData(TopicWriteType.MUTABLE, GATEWAY_SCHEMA, null, null);
final Throwable throwable = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.SCHEMA, requestData).blockingGet();
assertThat(throwable).isNotNull().isExactlyInstanceOf(BadArgumentException.class).extracting(Throwable::getMessage).asString().startsWith("Type OopsNotHere does not exist");
}
Aggregations