Skip to content

Commit

Permalink
Merge pull request #18815 from gastaldi/compare_ext
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi authored Jul 19, 2021
2 parents c776e22 + 7038c0f commit be320a1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public List<Extension> getSortedExtensions() {
private Comparator<Extension> extensionsComparator() {
final List<String> pinnedList = MetadataValue.get(category.getMetadata(), MD_PINNED).asStringList();
return Comparator.<Extension> comparingInt(e -> getPinnedIndex(pinnedList, e))
.thenComparing(Extension::getName);
.thenComparing(Extension::getName, String.CASE_INSENSITIVE_ORDER);
}

private int getPinnedIndex(List<String> pinnedList, Extension e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

0 comments on commit be320a1

Please sign in to comment.