From ceb82b0c42a5deda287c6533458a3c1ade14c74e Mon Sep 17 00:00:00 2001 From: aindriu-aiven <121855584+aindriu-aiven@users.noreply.github.com> Date: Thu, 11 May 2023 15:12:45 +0100 Subject: [PATCH] Return Schema Promotion button using new TopicOverview button (#1181) Change in API requires finding the environments a topic is provisioned on by a different look up. Signed-off-by: Aindriu Lavelle --- .../io/aiven/klaw/service/SchemaOverviewService.java | 9 +++++++-- .../io/aiven/klaw/service/SchemaOverviewServiceTest.java | 4 ++-- openapi.yaml | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/io/aiven/klaw/service/SchemaOverviewService.java b/core/src/main/java/io/aiven/klaw/service/SchemaOverviewService.java index caaac4b4f4..f7da95a565 100644 --- a/core/src/main/java/io/aiven/klaw/service/SchemaOverviewService.java +++ b/core/src/main/java/io/aiven/klaw/service/SchemaOverviewService.java @@ -163,8 +163,13 @@ private void updateAvroSchema( // A team owns a topic across all environments so we can assume if the search returned // one or more topics it is owned by this users team. if (topics.size() > 0) { + // Set Promotion Details - processSchemaPromotionDetails(schemaOverview, tenantId, schemaEnv, kafkaEnvIds); + processSchemaPromotionDetails( + schemaOverview, + tenantId, + schemaEnv, + topics.stream().map(topic -> topic.getEnvironment()).toList()); log.info("Getting schema details for: " + topicNameSearch); } } @@ -182,7 +187,7 @@ private void updateAvroSchema( private void processSchemaPromotionDetails( SchemaOverview schemaOverview, int tenantId, Env schemaEnv, List kafkaEnvIds) { - log.info("SchemaEnv Id {}", schemaEnv.getId()); + log.debug("SchemaEnv Id {} KafkaEnvIds {}", schemaEnv.getId(), kafkaEnvIds); Map promotionDetails = new HashMap<>(); generatePromotionDetails( tenantId, diff --git a/core/src/test/java/io/aiven/klaw/service/SchemaOverviewServiceTest.java b/core/src/test/java/io/aiven/klaw/service/SchemaOverviewServiceTest.java index 34d2649397..722985b199 100644 --- a/core/src/test/java/io/aiven/klaw/service/SchemaOverviewServiceTest.java +++ b/core/src/test/java/io/aiven/klaw/service/SchemaOverviewServiceTest.java @@ -117,9 +117,9 @@ public void getGivenASchemaWithManySchemaEnv_ReturnNextInPromotion() throws Exce when(commonUtilsService.getTeamId(anyString())).thenReturn(10); when(handleDbRequests.getAllTopicsByTopicNameAndTeamIdAndTenantId( eq(TESTTOPIC), eq(10), eq(101))) - .thenReturn(List.of(createTopic(TESTTOPIC, "1"))); + .thenReturn(List.of(createTopic(TESTTOPIC, "1"), createTopic(TESTTOPIC, "2"))); SchemaOverview returnedValue = - schemaOverviewService.getSchemaOfTopic(TESTTOPIC, "1", List.of("1", "2")); + schemaOverviewService.getSchemaOfTopic(TESTTOPIC, "1", List.of("1")); assertThat(returnedValue.getSchemaPromotionDetails()).isNotNull(); assertThat(returnedValue.getSchemaPromotionDetails().get("DEV").containsKey("status")).isTrue(); diff --git a/openapi.yaml b/openapi.yaml index b34a6ed2ea..bd8e5b3986 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -10,7 +10,7 @@ "name" : "Apache 2.0", "url" : "https://www.apache.org/licenses/LICENSE-2.0.html" }, - "version" : "2.2.0" + "version" : "2.3.0" }, "externalDocs" : { "description" : "Klaw documentation",