From 244588820ff215b85e58471670f2112192ac94f6 Mon Sep 17 00:00:00 2001 From: Andy Damevin Date: Fri, 20 Jan 2023 09:42:42 +0100 Subject: [PATCH] Place extension with an unknown category in the uncategorized category --- .../catalog/processor/CatalogProcessor.java | 7 ++++++- .../src/main/resources/fake-catalog.json | 18 ++++++++++++++++++ .../platform/catalog/CatalogProcessorTest.java | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/CatalogProcessor.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/CatalogProcessor.java index 4905ade770495..8fbd392efdce0 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/CatalogProcessor.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/platform/catalog/processor/CatalogProcessor.java @@ -3,6 +3,7 @@ import static io.quarkus.platform.catalog.processor.ExtensionProcessor.isUnlisted; import java.util.*; +import java.util.stream.Collectors; import io.quarkus.registry.catalog.Category; import io.quarkus.registry.catalog.Extension; @@ -32,8 +33,12 @@ public static CatalogProcessor of(ExtensionCatalog catalog) { public static List getProcessedCategoriesInOrder(ExtensionCatalog catalog) { final Map> extsByCategory = new HashMap<>(catalog.getCategories().size()); + final Set availableCategories = catalog.getCategories().stream().map(Category::getId) + .collect(Collectors.toSet()); for (Extension e : catalog.getExtensions()) { - List categories = new ArrayList<>(ExtensionProcessor.of(e).getCategories()); + List categories = ExtensionProcessor.of(e).getCategories().stream() + .filter(availableCategories::contains) + .collect(Collectors.toCollection(ArrayList::new)); if (!isUnlisted(e)) { if (categories.isEmpty()) { categories.add(UNCATEGORIZED_CATEGORY.getId()); diff --git a/independent-projects/tools/devtools-testing/src/main/resources/fake-catalog.json b/independent-projects/tools/devtools-testing/src/main/resources/fake-catalog.json index a98dad34954a2..5305537560a1c 100644 --- a/independent-projects/tools/devtools-testing/src/main/resources/fake-catalog.json +++ b/independent-projects/tools/devtools-testing/src/main/resources/fake-catalog.json @@ -220,6 +220,9 @@ "keywords": [ "uncategorized" ], + "categories": [ + "unknown" + ], "status": "preview", "built-with-quarkus-core": "999-FAKE" }, @@ -227,6 +230,21 @@ "origins": [ "io.quarkus:quarkus-fake-bom:999-FAKE:json:999-FAKE" ] + }, + { + "name": "extension in unknown category", + "description": "Some unknown category extension", + "metadata": { + "keywords": [ + "unknown-category" + ], + "status": "preview", + "built-with-quarkus-core": "999-FAKE" + }, + "artifact": "io.quarkus:quarkus-unknown-category-extension::jar:999-FAKE", + "origins": [ + "io.quarkus:quarkus-fake-bom:999-FAKE:json:999-FAKE" + ] } ], "categories": [ 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 eaf3677d2a46d..0b7f884660c55 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 @@ -46,6 +46,6 @@ void testUncategorizedExtensions() { assertThat(uncategorized.get().getSortedExtensions()) .map(Extension::getArtifact) .map(ArtifactCoords::getArtifactId) - .contains("quarkus-uncategorized-extension"); + .containsExactlyInAnyOrder("quarkus-unknown-category-extension", "quarkus-uncategorized-extension"); } }