Skip to content

Commit

Permalink
Merge pull request #30500 from ia3andy/fix-unknown-category
Browse files Browse the repository at this point in the history
Place extension with an unknown category in the uncategorized category
  • Loading branch information
gsmet committed Jan 23, 2023
2 parents 892de7b + 2445888 commit a4d9f50
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -32,8 +33,12 @@ public static CatalogProcessor of(ExtensionCatalog catalog) {

public static List<ProcessedCategory> getProcessedCategoriesInOrder(ExtensionCatalog catalog) {
final Map<String, List<Extension>> extsByCategory = new HashMap<>(catalog.getCategories().size());
final Set<String> availableCategories = catalog.getCategories().stream().map(Category::getId)
.collect(Collectors.toSet());
for (Extension e : catalog.getExtensions()) {
List<String> categories = new ArrayList<>(ExtensionProcessor.of(e).getCategories());
List<String> 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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,31 @@
"keywords": [
"uncategorized"
],
"categories": [
"unknown"
],
"status": "preview",
"built-with-quarkus-core": "999-FAKE"
},
"artifact": "io.quarkus:quarkus-uncategorized-extension::jar:999-FAKE",
"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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

0 comments on commit a4d9f50

Please sign in to comment.