From 7038c0f42cb56fd39e791a9fd246d4ae7a421eff Mon Sep 17 00:00:00 2001 From: George Gastaldi Date: Mon, 19 Jul 2021 11:15:27 -0300 Subject: [PATCH] Ignore case when comparing extension names Fixes #18808 --- .../catalog/processor/ProcessedCategory.java | 2 +- .../processor/ProcessedCategoryTest.java | 34 +++++++++++++++++++ .../catalog/CatalogProcessorTest.java | 1 + 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 independent-projects/tools/devtools-common/src/test/java/io/quarkus/platform/catalog/processor/ProcessedCategoryTest.java diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/ProcessedCategory.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/ProcessedCategory.java index 93639c4c9cbee..ac99f796a0e32 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/ProcessedCategory.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/ProcessedCategory.java @@ -34,7 +34,7 @@ public List getSortedExtensions() { private Comparator extensionsComparator() { final List pinnedList = MetadataValue.get(category.getMetadata(), MD_PINNED).asStringList(); return Comparator. comparingInt(e -> getPinnedIndex(pinnedList, e)) - .thenComparing(Extension::getName); + .thenComparing(Extension::getName, String.CASE_INSENSITIVE_ORDER); } private int getPinnedIndex(List pinnedList, Extension e) { diff --git a/independent-projects/tools/devtools-common/src/test/java/io/quarkus/platform/catalog/processor/ProcessedCategoryTest.java b/independent-projects/tools/devtools-common/src/test/java/io/quarkus/platform/catalog/processor/ProcessedCategoryTest.java new file mode 100644 index 0000000000000..5765f03d4bcd7 --- /dev/null +++ b/independent-projects/tools/devtools-common/src/test/java/io/quarkus/platform/catalog/processor/ProcessedCategoryTest.java @@ -0,0 +1,34 @@ +package io.quarkus.platform.catalog.processor; + +import static org.assertj.core.api.Assertions.assertThat; + +import io.quarkus.registry.catalog.Extension; +import io.quarkus.registry.catalog.json.JsonCategory; +import io.quarkus.registry.catalog.json.JsonExtension; +import java.util.List; +import org.junit.jupiter.api.Test; + +class ProcessedCategoryTest { + + @Test + void should_sort_extensions_ignoring_case() { + Extension zipFile = createExtension("Camel Zip File"); + Extension gRPC = createExtension("Camel gRPC"); + Extension iCal = createExtension("Camel iCal"); + Extension univocityParser = createExtension("Camel univocityParser"); + ProcessedCategory category = new ProcessedCategory(new JsonCategory(), List.of( + zipFile, + gRPC, + iCal, + univocityParser)); + assertThat(category.getSortedExtensions()).containsExactly(gRPC, iCal, univocityParser, zipFile); + } + + private Extension createExtension(String name) { + JsonExtension extension = new JsonExtension(); + extension.setGroupId("org.foo"); + extension.setArtifactId("bar-" + name); + extension.setName(name); + return extension; + } +} diff --git a/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/CatalogProcessorTest.java b/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/CatalogProcessorTest.java index e9952b59b7814..bc39dc45697c6 100644 --- a/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/CatalogProcessorTest.java +++ b/integration-tests/devtools/src/test/java/io/quarkus/platform/catalog/CatalogProcessorTest.java @@ -32,6 +32,7 @@ void testExtensionsOrder() { .startsWith("quarkus-resteasy", "quarkus-resteasy-jackson", "quarkus-resteasy-jsonb", "quarkus-apache-httpclient", "quarkus-vertx-http", "quarkus-vertx-graphql", + "quarkus-grpc", "quarkus-grpc-common", "quarkus-hibernate-validator"); } }