Skip to content

Commit

Permalink
Merge pull request #405 from michalvavrik/feature/refactoring
Browse files Browse the repository at this point in the history
Refactor CodeQuarkusExtensions enum by adding REST CSFR extension, RESTEasy Classic bucket and drop commented out code that is no longer relevant
  • Loading branch information
jedla97 authored Sep 18, 2024
2 parents 1caf520 + 87f48fc commit 20523c0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ public void supportedExtensionsSubsetD(TestInfo testInfo) throws Exception {
testRuntime(testInfo, supportedEx.get(3), MvnCmds.MVNW_DEV);
}

@Test
public void supportedRestEasyClassicExtensions(TestInfo testInfo) throws Exception {
testRuntime(testInfo, CodeQuarkusExtensions.getRestEasyClassicExtensions(), MvnCmds.MVNW_DEV);
}

@Test
public void notSupportedExtensionsSubsetA(TestInfo testInfo) throws Exception {
testRuntime(testInfo, notSupportedEx.get(0).subList(0, Math.min(10, notSupportedEx.get(0).size())), MvnCmds.MVNW_DEV);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.ts.startstop.utils;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand All @@ -18,25 +19,20 @@ public enum CodeQuarkusExtensions {
QUARKUS_REST_CLIENT_REACTIVE_JAXB("quarkus-rest-client-jaxb", "REST Client JAXB", "ignored", true),
QUARKUS_REST_CLIENT_REACTIVE_JSONB("quarkus-rest-client-jsonb", "REST Client JSON-B", "ignored", true),
QUARKUS_REST_CLIENT_REACTIVE_KOTLIN_SERIALIZATION("quarkus-rest-client-kotlin-serialization", "REST Client Kotlin Serialization", "ignored", false),
// Should be directly in RESTEasy Reactive
// QUARKUS_CSRF_REACTIVE("quarkus-csrf-reactive", "Cross-Site Request Forgery Prevention Filter Reactive", "ignored", false),
QUARKUS_REST_CSRF("quarkus-rest-csrf", "Quarkus REST Cross-Site Request Forgery Prevention Filter", "ignored", false),
QUARKUS_OIDC_CLIENT_REACTIVE_FILTER("quarkus-rest-client-oidc-filter", "REST Client - OpenID Connect Filter", "ignored", true),
QUARKUS_OIDC_TOKEN_PROPAGATION_REACTIVE("quarkus-rest-client-oidc-token-propagation", "REST Client - OpenID Connect Token Propagation", "ignored", false),

// TODO Introduce buckets with non reactive jakarta-rest extensions
// To avoid java.lang.IllegalStateException: The 'quarkus-resteasy-reactive' and 'quarkus-resteasy' extensions cannot be used at the same time.
// QUARKUS_RESTEASY("quarkus-resteasy", "RESTEasy Jakarta REST", "98e", true),
// QUARKUS_RESTEASY_JACKSON("quarkus-resteasy-jackson", "RESTEasy Jackson", "pV1", true),
// QUARKUS_RESTEASY_JSONB("quarkus-resteasy-jsonb", "RESTEasy JSON-B", "49J", true),
// QUARKUS_RESTEASY_JAXB("quarkus-resteasy-jaxb", "RESTEasy JAXB", "d7W", true),
// QUARKUS_RESTEASY_MULTIPART("quarkus-resteasy-multipart", "RESTEasy Multipart", "kV0", true),
// QUARKUS_RESTEASY_LINKS("quarkus-resteasy-links", "RESTEasy Links", "rK1", false),
// QUARKUS_REST_CLIENT_MUTINY("quarkus-rest-client-mutiny", "Mutiny support for REST Client", "Ph0", false),
// QUARKUS_REST_CLIENT("quarkus-rest-client", "REST Client", "ekA", true),
// QUARKUS_REST_CLIENT_JAXB("quarkus-rest-client-jaxb", "REST Client JAXB", "8iY", true),
// QUARKUS_REST_CLIENT_JSONB("quarkus-rest-client-jsonb", "REST Client JSON-B", "Q3z", true),
// QUARKUS_REST_CLIENT_JACKSON("quarkus-rest-client-jackson", "REST Client Jackson", "pJg", true),
// QUARKUS_OIDC_CLIENT_FILTER("quarkus-oidc-client-filter", "OpenID Connect Client Filter", "T0U", true),
QUARKUS_RESTEASY("quarkus-resteasy", "RESTEasy Jakarta REST", "98e", true, true),
QUARKUS_RESTEASY_JACKSON("quarkus-resteasy-jackson", "RESTEasy Jackson", "pV1", true, true),
QUARKUS_RESTEASY_JSONB("quarkus-resteasy-jsonb", "RESTEasy JSON-B", "49J", true, true),
QUARKUS_RESTEASY_JAXB("quarkus-resteasy-jaxb", "RESTEasy JAXB", "d7W", true, true),
QUARKUS_RESTEASY_MULTIPART("quarkus-resteasy-multipart", "RESTEasy Multipart", "kV0", true, true),
QUARKUS_RESTEASY_CLIENT("quarkus-resteasy-client", "REST Client", "ekA", true, true),
QUARKUS_RESTEASY_CLIENT_JAXB("quarkus-resteasy-client-jaxb", "REST Client JAXB", "8iY", true, true),
QUARKUS_RESTEASY_CLIENT_JSONB("quarkus-resteasy-client-jsonb", "REST Client JSON-B", "Q3z", true, true),
QUARKUS_RESTEASY_CLIENT_JACKSON("quarkus-resteasy-client-jackson", "REST Client Jackson", "pJg", true, true),
QUARKUS_RESTEASY_CLIENT_OIDC_FILTER("quarkus-resteasy-client-oidc-filter", "OpenID Connect Client Filter", "T0U", true, true),

QUARKUS_VERTX_GRAPHQL("quarkus-vertx-graphql", "Eclipse Vert.x GraphQL", "F9R", false),
QUARKUS_HIBERNATE_VALIDATOR("quarkus-hibernate-validator", "Hibernate Validator", "YjV", true),
Expand Down Expand Up @@ -74,12 +70,8 @@ public enum CodeQuarkusExtensions {
// The Blaze-Persistence dependency is present but no persistence units have been defined.
// BLAZE_PERSISTENCE_INTEGRATION_QUARKUS("blaze-persistence-integration-quarkus", "Blaze-Persistence", "weW", false),
QUARKUS_CACHE("quarkus-cache", "Cache", "W1i", true),
// https://issues.redhat.com/browse/QUARKUS-1295
// QUARKUS_ELASTICSEARCH_REST_HIGH_LEVEL_CLIENT("quarkus-elasticsearch-rest-high-level-client", "Elasticsearch REST High Level Client", "OJe", false),
QUARKUS_ELASTICSEARCH_REST_CLIENT("quarkus-elasticsearch-rest-client", "Elasticsearch REST client", "NhW", false),
QUARKUS_FLYWAY("quarkus-flyway", "Flyway", "wTM", false),
// TODO Not present in the 3.0 platform
// QUARKUS_HAZELCAST_CLIENT("quarkus-hazelcast-client", "Hazelcast Client", "yii", false),
QUARKUS_HIBERNATE_ENVERS("quarkus-hibernate-envers", "Hibernate Envers", "8j9", false),
QUARKUS_HIBERNATE_ORM_PANACHE_KOTLIN("quarkus-hibernate-orm-panache-kotlin", "Hibernate ORM with Panache and Kotlin", "O3q", false),
QUARKUS_HIBERNATE_REACTIVE("quarkus-hibernate-reactive", "Hibernate Reactive", "r1s", false),
Expand All @@ -98,8 +90,6 @@ public enum CodeQuarkusExtensions {
// Caused by: java.lang.IllegalStateException: 'quarkus-narayana-lra' can only work if 'quarkus-resteasy-jackson' or 'quarkus-resteasy-reactive-jackson' is present
// QUARKUS_NARAYANA_LRA("quarkus-narayana-lra", "Narayana LRA - LRA Participant Support", "O8P", false),
QUARKUS_NARAYANA_STM("quarkus-narayana-stm", "Narayana STM - Software Transactional Memory", "Nl9", false),
// https://issues.redhat.com/browse/QUARKUS-1294
// QUARKUS_REDIS_CLIENT("quarkus-redis-client", "Redis Client", "jlX", false),
QUARKUS_MESSAGING("quarkus-messaging", "Messaging", "ignored", true),
// https://github.com/quarkusio/quarkus/issues/23383
// QUARKUS_SMALLRYE_REACTIVE_MESSAGING_AMQP("quarkus-smallrye-reactive-messaging-amqp", "SmallRye Reactive Messaging - AMQP Connector", "ur3", true),
Expand Down Expand Up @@ -443,12 +433,22 @@ public enum CodeQuarkusExtensions {
public final String name;
public final String shortId;
public final boolean supported;
private final boolean onlyRestEasyClassicBucket;

CodeQuarkusExtensions(String id, String name, String shortId, boolean supported) {
this.id = id;
this.name = name;
this.shortId = shortId;
this.supported = supported;
this.onlyRestEasyClassicBucket = false;
}

CodeQuarkusExtensions(String id, String name, String shortId, boolean supported, boolean onlyRestEasyClassicBucket) {
this.id = id;
this.name = name;
this.shortId = shortId;
this.supported = supported;
this.onlyRestEasyClassicBucket = onlyRestEasyClassicBucket;
}

public enum Flag {
Expand All @@ -461,7 +461,9 @@ public static List<List<CodeQuarkusExtensions>> partition(int buckets, Flag flag
if (buckets < 1) {
throw new IllegalArgumentException("Nope, buckets must be bigger than 0.");
}
List<CodeQuarkusExtensions> extensions = Stream.of(CodeQuarkusExtensions.values()).filter(x ->
List<CodeQuarkusExtensions> extensions = Stream.of(CodeQuarkusExtensions.values())
.filter(x -> !x.onlyRestEasyClassicBucket) // RESTEasy Classic has a separate bucket
.filter(x ->
flag == Flag.SUPPORTED && x.supported ||
flag == Flag.NOT_SUPPORTED && !x.supported ||
flag == Flag.MIXED).collect(Collectors.toUnmodifiableList());
Expand All @@ -485,4 +487,8 @@ public static List<List<CodeQuarkusExtensions>> partition(int buckets, Flag flag
}
return result;
}

public static List<CodeQuarkusExtensions> getRestEasyClassicExtensions() {
return EnumSet.allOf(CodeQuarkusExtensions.class).stream().filter(x -> x.onlyRestEasyClassicBucket).toList();
}
}

0 comments on commit 20523c0

Please sign in to comment.