diff --git a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Cloud.java b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Cloud.java index c9436f55f9c09..774b1e5f3c0ed 100644 --- a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Cloud.java +++ b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Cloud.java @@ -1,13 +1,139 @@ package io.quarkus.it.smallrye.config; +import java.time.Duration; +import java.time.Period; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.OptionalInt; + +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.Size; + import io.quarkus.arc.Unremovable; +import io.quarkus.runtime.annotations.RegisterForReflection; +import io.quarkus.runtime.configuration.DurationConverter; import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithConverter; +import io.smallrye.config.WithDefault; +import io.smallrye.config.WithName; import io.smallrye.config.WithParentName; @Unremovable @ConfigMapping(prefix = "cloud") @Prod public interface Cloud { + String host(); + + @Min(8000) + int port(); + + @WithConverter(DurationConverter.class) + Duration timeout(); + + @WithName("io-threads") + int threads(); + @WithParentName - Server server(); + Map form(); + + Optional ssl(); + + Optional proxy(); + + Optional cors(); + + Log log(); + + Info info(); + + interface Form { + String loginPage(); + + String errorPage(); + + String landingPage(); + + Optional cookie(); + + @WithDefault("1") + List positions(); + } + + interface Ssl { + int port(); + + String certificate(); + + @WithDefault("TLSv1.3,TLSv1.2") + List protocols(); + } + + interface Proxy { + boolean enable(); + + @Max(10) + int timeout(); + } + + interface Log { + @WithDefault("false") + boolean enabled(); + + @WithDefault(".log") + String suffix(); + + @WithDefault("true") + boolean rotate(); + + @WithDefault("COMMON") + Pattern pattern(); + + Period period(); + + @Max(15) + int days(); + + @RegisterForReflection + enum Pattern { + COMMON, + SHORT, + COMBINED, + LONG; + } + } + + interface Cors { + List origins(); + + List<@Size(min = 2) String> methods(); + + @RegisterForReflection + interface Origin { + @Size(min = 5) + String host(); + + @Min(8000) + int port(); + } + } + + interface Info { + Optional<@Size(max = 3) String> name(); + + @Max(3) + OptionalInt code(); + + Optional> alias(); + + Map> admins(); + + Map> firewall(); + + interface Admin { + @Size(max = 4) + String username(); + } + } } diff --git a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Prod.java b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Prod.java index 8926ce36b4107..0387cabd46b58 100644 --- a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Prod.java +++ b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Prod.java @@ -23,7 +23,7 @@ class Validator implements ConstraintValidator { @Override public boolean isValid(final Cloud value, final ConstraintValidatorContext context) { - return value.server().equals("prod"); + return value.host().equals("prod"); } } } diff --git a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Server.java b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Server.java index 499354ab42e0e..4fd4ab189f423 100644 --- a/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Server.java +++ b/integration-tests/smallrye-config/src/main/java/io/quarkus/it/smallrye/config/Server.java @@ -8,10 +8,6 @@ import java.util.Optional; import java.util.OptionalInt; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.Size; - import org.eclipse.microprofile.config.spi.Converter; import com.fasterxml.jackson.annotation.JsonProperty; @@ -31,7 +27,6 @@ public interface Server extends Alias { String host(); @JsonProperty - @Min(8000) int port(); @JsonProperty @@ -89,7 +84,6 @@ interface Proxy { boolean enable(); @JsonProperty - @Max(10) int timeout(); } @@ -115,7 +109,6 @@ interface Log { Period period(); @JsonProperty - @Max(15) int days(); @RegisterForReflection @@ -133,16 +126,14 @@ interface Cors { List origins(); @JsonProperty - List<@Size(min = 2) String> methods(); + List methods(); @RegisterForReflection interface Origin { @JsonProperty - @Size(min = 5) String host(); @JsonProperty - @Min(8000) int port(); } } @@ -150,25 +141,23 @@ interface Origin { @RegisterForReflection interface Info { @JsonProperty - Optional<@Size(max = 3) String> name(); + Optional name(); @JsonProperty - @Max(3) OptionalInt code(); @JsonProperty - Optional> alias(); + Optional> alias(); @JsonProperty Map> admins(); @JsonProperty - Map> firewall(); + Map> firewall(); @RegisterForReflection interface Admin { @JsonProperty - @Size(max = 4) String username(); } }