Search in sources :

Example 6 with GatewayDescription

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");
}
Also used : GatewayDescription(com.bakdata.quick.common.api.model.manager.GatewayDescription) KubernetesTest(com.bakdata.quick.manager.k8s.KubernetesTest) Test(org.junit.jupiter.api.Test)

Example 7 with GatewayDescription

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);
}
Also used : TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) Completable(io.reactivex.Completable) SchemaData(com.bakdata.quick.common.api.model.gateway.SchemaData) GatewayDescription(com.bakdata.quick.common.api.model.manager.GatewayDescription) TopicData(com.bakdata.quick.common.api.model.TopicData) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 8 with GatewayDescription

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);
}
Also used : TopicCreationData(com.bakdata.quick.common.api.model.manager.creation.TopicCreationData) Completable(io.reactivex.Completable) SchemaData(com.bakdata.quick.common.api.model.gateway.SchemaData) Schema(org.apache.avro.Schema) GatewaySchema(com.bakdata.quick.common.api.model.manager.GatewaySchema) GatewayDescription(com.bakdata.quick.common.api.model.manager.GatewayDescription) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) SchemaRegistryClient(io.confluent.kafka.schemaregistry.client.SchemaRegistryClient) Test(org.junit.jupiter.api.Test)

Example 9 with GatewayDescription

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));
}
Also used : SchemaData(com.bakdata.quick.common.api.model.gateway.SchemaData) GatewayDescription(com.bakdata.quick.common.api.model.manager.GatewayDescription) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MicronautTest(io.micronaut.test.extensions.junit5.annotation.MicronautTest) Test(org.junit.jupiter.api.Test)

Aggregations

GatewayDescription (com.bakdata.quick.common.api.model.manager.GatewayDescription)9 Test (org.junit.jupiter.api.Test)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 SchemaData (com.bakdata.quick.common.api.model.gateway.SchemaData)6 TopicCreationData (com.bakdata.quick.common.api.model.manager.creation.TopicCreationData)5 MicronautTest (io.micronaut.test.extensions.junit5.annotation.MicronautTest)3 Completable (io.reactivex.Completable)3 BadArgumentException (com.bakdata.quick.common.exception.BadArgumentException)2 TopicData (com.bakdata.quick.common.api.model.TopicData)1 GatewaySchema (com.bakdata.quick.common.api.model.manager.GatewaySchema)1 MirrorCreationData (com.bakdata.quick.common.api.model.manager.creation.MirrorCreationData)1 KubernetesTest (com.bakdata.quick.manager.k8s.KubernetesTest)1 SchemaRegistryClient (io.confluent.kafka.schemaregistry.client.SchemaRegistryClient)1 Path (java.nio.file.Path)1 Duration (java.time.Duration)1 Schema (org.apache.avro.Schema)1 Disabled (org.junit.jupiter.api.Disabled)1