use of com.bakdata.quick.common.api.model.gateway.SchemaData in project quick by bakdata.
the class GatewayControllerTest method shouldCreateDefinition.
@Test
void shouldCreateDefinition() {
when(this.gatewayService.updateSchema(anyString(), anyString())).thenReturn(Completable.complete());
final String uri = UriBuilder.of(BASE_PATH + "/schema").expand(Collections.singletonMap("name", GATEWAY_NAME)).toString();
assertEquals("/gateway/test-gateway/schema", uri);
this.client.toBlocking().exchange(POST(uri, new SchemaData("type Query { test: String }")));
verify(this.gatewayService).updateSchema(GATEWAY_NAME, "type Query { test: String }");
}
use of com.bakdata.quick.common.api.model.gateway.SchemaData in project quick by bakdata.
the class KubernetesGatewayServiceTest method shouldUpdateConfigMap.
@Test
void shouldUpdateConfigMap() {
this.createGateway(GATEWAY_NAME, 1, null);
final String graphQLSchema = "type Query { find: String }";
Mockito.when(this.gatewayClient.updateSchema(GATEWAY_NAME, new SchemaData(graphQLSchema))).thenReturn(Completable.complete());
this.gatewayService.updateSchema(GATEWAY_NAME, graphQLSchema).blockingAwait();
final List<ConfigMap> configMaps = this.getConfigMaps();
assertThat(configMaps).hasSize(1).first().satisfies(configMap -> assertThat(configMap.getMetadata().getName()).isEqualTo(DEPLOYMENT_NAME + "-config")).satisfies(configMap -> assertThat(configMap.getData().get("schema.graphql")).isEqualTo(graphQLSchema));
}
use of com.bakdata.quick.common.api.model.gateway.SchemaData 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.gateway.SchemaData 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.gateway.SchemaData 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