use of com.bakdata.quick.common.api.model.manager.GatewayDescription 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.GatewayDescription 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");
}
use of com.bakdata.quick.common.api.model.manager.GatewayDescription in project quick by bakdata.
the class KafkaTopicServiceTest method shouldNotCreateTopicIfSubjectExists.
@Test
@Disabled("Compatibility test not supported in SR mock yet")
void shouldNotCreateTopicIfSubjectExists() throws RestClientException, IOException {
final String topicName = UUID.randomUUID().toString();
this.successfulMock();
this.schemaRegistry.registerValueSchema(topicName, this.graphQLToAvroConverter.convertToSchema(SCHEMA));
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 Throwable throwable = this.topicService.createTopic(topicName, QuickTopicType.DOUBLE, QuickTopicType.SCHEMA, requestData).blockingGet();
assertThat(throwable).isNotNull().isExactlyInstanceOf(BadArgumentException.class).extracting(Throwable::getMessage).asString().endsWith("already exists");
assertThat(kafkaCluster.exists(topicName)).isFalse();
assertThat(this.topicRegistryClient.topicDataExists(topicName).blockingGet()).isFalse();
assertThat(this.schemaRegistry.getSchemaRegistryClient().getAllSubjects()).isEmpty();
}
use of com.bakdata.quick.common.api.model.manager.GatewayDescription in project quick by bakdata.
the class GatewayControllerTest method shouldGetGatewayAvroSchema.
@Test
void shouldGetGatewayAvroSchema() throws IOException {
final Path workingDirectory = Path.of("src", "test", "resources", "schema", "avro");
final String avroSchema = new Schema.Parser().parse(Files.readString(workingDirectory.resolve("test.avsc"))).toString();
final SchemaData schemaData = new SchemaData(avroSchema);
final GatewayDescription gatewayDescription = new GatewayDescription(GATEWAY_NAME, 1, null);
when(this.gatewayService.getGateway(GATEWAY_NAME)).thenReturn(Single.just(gatewayDescription));
when(this.gatewayService.getGatewayWriteSchema(GATEWAY_NAME, "Test", SchemaFormat.AVRO)).thenReturn(Single.just(schemaData));
final String uri = UriBuilder.of(BASE_PATH + "/schema/{type}/avro").expand(Map.of("name", GATEWAY_NAME, "type", "Test")).toString();
assertEquals("/gateway/test-gateway/schema/Test/avro", uri);
final SchemaData retrievedAvroSchema = this.client.toBlocking().retrieve(GET(uri), SchemaData.class);
assertThat(retrievedAvroSchema).isEqualTo(schemaData);
}
use of com.bakdata.quick.common.api.model.manager.GatewayDescription in project quick by bakdata.
the class GatewayControllerTest method shouldGetGatewayList.
@Test
void shouldGetGatewayList() {
when(this.gatewayService.getGatewayList()).thenReturn(Single.just(List.of(new GatewayDescription(GATEWAY_NAME, 1, TAG))));
this.client.toBlocking().exchange(GET("/gateways"));
verify(this.gatewayService).getGatewayList();
}
Aggregations