use of com.bakdata.quick.common.api.model.manager.GatewayDescription in project quick by bakdata.
the class KubernetesGatewayServiceTest method shouldGetGateway.
@Test
void shouldGetGateway() {
this.createGateway(GATEWAY_NAME, 1, null);
final GatewayDescription gatewayDescription = this.gatewayService.getGateway(GATEWAY_NAME).blockingGet();
assertThat(gatewayDescription.getName()).isEqualTo(GATEWAY_NAME);
assertThat(gatewayDescription.getReplicas()).isEqualTo(1);
assertThat(gatewayDescription.getTag()).isEqualTo("latest");
}
use of com.bakdata.quick.common.api.model.manager.GatewayDescription 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.GatewayDescription 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.GatewayDescription in project quick by bakdata.
the class GatewayControllerTest method shouldGetGatewayGraphQLSchema.
@Test
void shouldGetGatewayGraphQLSchema() {
final String schema = "type Test { test: Int }";
final SchemaData schemaData = new SchemaData(schema);
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.GRAPHQL)).thenReturn(Single.just(schemaData));
final String uri = UriBuilder.of(BASE_PATH + "/schema/{type}/graphql").expand(Map.of("name", GATEWAY_NAME, "type", "Test")).toString();
assertEquals("/gateway/test-gateway/schema/Test/graphql", uri);
final SchemaData graphqlSchema = this.client.toBlocking().retrieve(GET(uri), SchemaData.class);
assertThat(graphqlSchema).isEqualTo(new SchemaData(schema));
}
Aggregations