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));
}
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);
}
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);
}
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();
}
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);
}
Aggregations