Skip to content

Commit

Permalink
Place extension with an unknown category in the uncategorized category
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Jan 20, 2023
1 parent 051f0c5 commit 2445888
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 2445888

Please sign in to comment.