From 86980e1ca41d41979407a1f09a789d1e3aead9f2 Mon Sep 17 00:00:00 2001 From: Phillip Kruger Date: Fri, 27 Oct 2023 11:03:45 +1100 Subject: [PATCH] Tests to check content type between Services and OpenAPI Signed-off-by: Phillip Kruger --- bom/application/pom.xml | 2 +- .../deployment/SmallRyeOpenApiProcessor.java | 4 + .../test/jaxrs/DefaultContentTypeTest.java | 2 +- .../java/io/quarkus/it/rest/TestResource.java | 1 + .../io/quarkus/it/main/OpenApiTestCase.java | 11 +- integration-tests/openapi/pom.xml | 171 +++++++++++++ .../java/io/quarkus/it/openapi/Greeting.java | 31 +++ .../it/openapi/jaxrs/BigDecimalResource.java | 98 ++++++++ .../it/openapi/jaxrs/BigIntegerResource.java | 98 ++++++++ .../it/openapi/jaxrs/BooleanResource.java | 136 ++++++++++ .../it/openapi/jaxrs/ByteArrayResource.java | 84 +++++++ .../it/openapi/jaxrs/FileResource.java | 83 +++++++ .../it/openapi/jaxrs/InputStreamResource.java | 85 +++++++ .../it/openapi/jaxrs/IntegerResource.java | 149 +++++++++++ .../it/openapi/jaxrs/LongResource.java | 149 +++++++++++ .../it/openapi/jaxrs/PojoResource.java | 115 +++++++++ .../it/openapi/jaxrs/ReaderResource.java | 85 +++++++ .../it/openapi/jaxrs/ShortResource.java | 136 ++++++++++ .../it/openapi/jaxrs/StringResource.java | 113 +++++++++ .../quarkus/it/openapi/jaxrs/URLResource.java | 123 +++++++++ .../it/openapi/spring/BigDecimalResource.java | 86 +++++++ .../it/openapi/spring/BigIntegerResource.java | 86 +++++++ .../it/openapi/spring/BooleanResource.java | 119 +++++++++ .../it/openapi/spring/ByteArrayResource.java | 76 ++++++ .../it/openapi/spring/FileResource.java | 75 ++++++ .../openapi/spring/InputStreamResource.java | 77 ++++++ .../it/openapi/spring/IntegerResource.java | 130 ++++++++++ .../it/openapi/spring/LongResource.java | 130 ++++++++++ .../it/openapi/spring/PojoResource.java | 101 ++++++++ .../it/openapi/spring/ReaderResource.java | 77 ++++++ .../it/openapi/spring/ShortResource.java | 119 +++++++++ .../it/openapi/spring/StringResource.java | 100 ++++++++ .../it/openapi/spring/URLResource.java | 109 ++++++++ .../it/openapi/AbstractByteArrayTest.java | 59 +++++ .../quarkus/it/openapi/AbstractFileTest.java | 58 +++++ .../it/openapi/AbstractInputStreamTest.java | 58 +++++ .../it/openapi/AbstractReaderTest.java | 58 +++++ .../io/quarkus/it/openapi/AbstractTest.java | 101 ++++++++ .../it/openapi/jaxrs/BigDecimalTest.java | 149 +++++++++++ .../it/openapi/jaxrs/BigIntegerTest.java | 149 +++++++++++ .../quarkus/it/openapi/jaxrs/BooleanTest.java | 213 ++++++++++++++++ .../it/openapi/jaxrs/ByteArrayTest.java | 110 +++++++++ .../io/quarkus/it/openapi/jaxrs/FileTest.java | 110 +++++++++ .../it/openapi/jaxrs/InputStreamTest.java | 110 +++++++++ .../quarkus/it/openapi/jaxrs/IntegerTest.java | 232 +++++++++++++++++ .../io/quarkus/it/openapi/jaxrs/LongTest.java | 232 +++++++++++++++++ .../io/quarkus/it/openapi/jaxrs/PojoTest.java | 172 +++++++++++++ .../quarkus/it/openapi/jaxrs/ReaderTest.java | 110 +++++++++ .../quarkus/it/openapi/jaxrs/ShortTest.java | 211 ++++++++++++++++ .../quarkus/it/openapi/jaxrs/StringTest.java | 169 +++++++++++++ .../io/quarkus/it/openapi/jaxrs/URLTest.java | 169 +++++++++++++ .../it/openapi/spring/BigDecimalTest.java | 149 +++++++++++ .../it/openapi/spring/BigIntegerTest.java | 149 +++++++++++ .../it/openapi/spring/BooleanTest.java | 211 ++++++++++++++++ .../it/openapi/spring/ByteArrayTest.java | 110 +++++++++ .../quarkus/it/openapi/spring/FileTest.java | 110 +++++++++ .../it/openapi/spring/InputStreamTest.java | 110 +++++++++ .../it/openapi/spring/IntegerTest.java | 232 +++++++++++++++++ .../quarkus/it/openapi/spring/LongTest.java | 233 ++++++++++++++++++ .../quarkus/it/openapi/spring/PojoTest.java | 175 +++++++++++++ .../quarkus/it/openapi/spring/ReaderTest.java | 110 +++++++++ .../quarkus/it/openapi/spring/ShortTest.java | 212 ++++++++++++++++ .../quarkus/it/openapi/spring/StringTest.java | 169 +++++++++++++ .../io/quarkus/it/openapi/spring/URLTest.java | 169 +++++++++++++ integration-tests/pom.xml | 1 + 65 files changed, 7564 insertions(+), 7 deletions(-) create mode 100644 integration-tests/openapi/pom.xml create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/Greeting.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BigDecimalResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BigIntegerResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BooleanResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ByteArrayResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/FileResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/InputStreamResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/IntegerResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/LongResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/PojoResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ReaderResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ShortResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/StringResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/URLResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BigDecimalResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BigIntegerResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BooleanResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ByteArrayResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/FileResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/InputStreamResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/IntegerResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/LongResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/PojoResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ReaderResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ShortResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/StringResource.java create mode 100644 integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/URLResource.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractByteArrayTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractFileTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractInputStreamTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractReaderTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BigDecimalTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BigIntegerTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BooleanTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ByteArrayTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/FileTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/InputStreamTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/IntegerTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/LongTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/PojoTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ReaderTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ShortTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/StringTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/URLTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BigDecimalTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BigIntegerTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BooleanTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ByteArrayTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/FileTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/InputStreamTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/IntegerTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/LongTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/PojoTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ReaderTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ShortTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/StringTest.java create mode 100644 integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/URLTest.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index b94f8b9ae7cde..0860f6eb7cc44 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -54,7 +54,7 @@ 3.4.1 4.0.4 4.0.0 - 3.6.2 + 3.7.0 2.5.1 3.0.3 6.2.6 diff --git a/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java b/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java index 5b1f46f1dd2f5..851e82a60e179 100644 --- a/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java +++ b/extensions/smallrye-openapi/deployment/src/main/java/io/quarkus/smallrye/openapi/deployment/SmallRyeOpenApiProcessor.java @@ -162,6 +162,10 @@ public class SmallRyeOpenApiProcessor { private static final String VERT_X = "Vert.x"; static { + System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_PRODUCES_STREAMING, + "application/octet-stream"); + System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_CONSUMES_STREAMING, + "application/octet-stream"); System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_PRODUCES, "application/json"); System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_CONSUMES, "application/json"); System.setProperty(io.smallrye.openapi.api.constants.OpenApiConstants.DEFAULT_PRODUCES_PRIMITIVES, "text/plain"); diff --git a/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/jaxrs/DefaultContentTypeTest.java b/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/jaxrs/DefaultContentTypeTest.java index dc053a88f90de..bd26dca753448 100644 --- a/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/jaxrs/DefaultContentTypeTest.java +++ b/extensions/smallrye-openapi/deployment/src/test/java/io/quarkus/smallrye/openapi/test/jaxrs/DefaultContentTypeTest.java @@ -34,4 +34,4 @@ public void testOpenApiPathAccessResource() { Matchers.containsString("#/components/schemas/Greeting")); } -} +} \ No newline at end of file diff --git a/integration-tests/main/src/main/java/io/quarkus/it/rest/TestResource.java b/integration-tests/main/src/main/java/io/quarkus/it/rest/TestResource.java index 41a282aba4a3d..bb58c4aaf7749 100644 --- a/integration-tests/main/src/main/java/io/quarkus/it/rest/TestResource.java +++ b/integration-tests/main/src/main/java/io/quarkus/it/rest/TestResource.java @@ -150,6 +150,7 @@ public CompletionStage cs() { @GET @Path("/rx") + @Produces("text/plain") public Single rx() { return Single.just("Hello"); } diff --git a/integration-tests/main/src/test/java/io/quarkus/it/main/OpenApiTestCase.java b/integration-tests/main/src/test/java/io/quarkus/it/main/OpenApiTestCase.java index 214f452efa1b7..f52a42054287f 100644 --- a/integration-tests/main/src/test/java/io/quarkus/it/main/OpenApiTestCase.java +++ b/integration-tests/main/src/test/java/io/quarkus/it/main/OpenApiTestCase.java @@ -22,7 +22,7 @@ public class OpenApiTestCase { private static final String DEFAULT_MEDIA_TYPE = "application/json"; - private static final String DEFAULT_MEDIA_TYPE_PRIMITAVE = "text/plain"; + private static final String DEFAULT_MEDIA_TYPE_PRIMITIVE = "text/plain"; @TestHTTPResource("q/openapi") URL uri; @@ -64,10 +64,10 @@ public void testOpenAPIJSON() throws Exception { // test RESTEasy extensions JsonObject schemasObj = obj.getJsonObject("components").getJsonObject("schemas"); - String testSchemaType = schemaType("200", DEFAULT_MEDIA_TYPE_PRIMITAVE, + String testSchemaType = schemaType("200", DEFAULT_MEDIA_TYPE_PRIMITIVE, testObj.getJsonObject("get").getJsonObject("responses"), schemasObj); - String rxSchemaType = schemaType("200", DEFAULT_MEDIA_TYPE, + String rxSchemaType = schemaType("200", DEFAULT_MEDIA_TYPE_PRIMITIVE, injectionObj.getJsonObject("get").getJsonObject("responses"), schemasObj); // make sure String, CompletionStage and Single are detected the same @@ -76,7 +76,8 @@ public void testOpenAPIJSON() throws Exception { "Normal and RX/Single have same schema"); JsonObject csObj = paths.getJsonObject("/test/cs"); Assertions.assertEquals(testSchemaType, - schemaType("200", DEFAULT_MEDIA_TYPE, csObj.getJsonObject("get").getJsonObject("responses"), schemasObj), + schemaType("200", DEFAULT_MEDIA_TYPE_PRIMITIVE, csObj.getJsonObject("get").getJsonObject("responses"), + schemasObj), "Normal and RX/CS have same schema"); JsonObject paramsObj = paths.getJsonObject("/test/params/{path}"); @@ -90,7 +91,7 @@ public void testOpenAPIJSON() throws Exception { Assertions.assertEquals(1, keys.size()); Assertions.assertEquals("get", keys.iterator().next()); - String uniSchemaType = schemaType("200", DEFAULT_MEDIA_TYPE_PRIMITAVE, + String uniSchemaType = schemaType("200", DEFAULT_MEDIA_TYPE_PRIMITIVE, uniObj.getJsonObject("get").getJsonObject("responses"), schemasObj); // make sure String, CompletionStage and Uni are detected the same diff --git a/integration-tests/openapi/pom.xml b/integration-tests/openapi/pom.xml new file mode 100644 index 0000000000000..068a587db5118 --- /dev/null +++ b/integration-tests/openapi/pom.xml @@ -0,0 +1,171 @@ + + + + quarkus-integration-tests-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-integration-test-openapi + Quarkus - Integration Tests - OpenAPI + The openapi integration tests module + + + + io.quarkus + quarkus-smallrye-openapi + + + io.quarkus + quarkus-resteasy-reactive-jackson + + + io.quarkus + quarkus-reactive-routes + + + io.quarkus + quarkus-spring-web + + + + + io.quarkus + quarkus-junit5 + test + + + io.quarkus + quarkus-junit5-component + test + + + io.rest-assured + rest-assured + test + + + org.assertj + assertj-core + test + + + + + io.quarkus + quarkus-reactive-routes-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-resteasy-reactive-jackson-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-smallrye-openapi-deployment + ${project.version} + pom + test + + + * + * + + + + + io.quarkus + quarkus-spring-web-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + + src/main/resources + true + + + + + io.quarkus + quarkus-maven-plugin + + + + build + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + alphabetical + + + + + + + + + native-image + + + native + + + + + true + + + + + no-native + + + !native + + + + + uber-jar + + + + + + diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/Greeting.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/Greeting.java new file mode 100644 index 0000000000000..4312e491c305f --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/Greeting.java @@ -0,0 +1,31 @@ +package io.quarkus.it.openapi; + +public class Greeting { + private int id; + private String salutation; + + public Greeting() { + + } + + public Greeting(int id, String salutation) { + this.id = id; + this.salutation = salutation; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSalutation() { + return salutation; + } + + public void setSalutation(String salutation) { + this.salutation = salutation; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BigDecimalResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BigDecimalResource.java new file mode 100644 index 0000000000000..a30b2c8759db7 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BigDecimalResource.java @@ -0,0 +1,98 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class BigDecimalResource { + @GET + @Path("/justBigDecimal") + public BigDecimal justBigDecimal() { + return new BigDecimal("0"); + } + + @POST + @Path("/justBigDecimal") + public BigDecimal justBigDecimal(BigDecimal body) { + return body; + } + + @GET + @Path("/restResponseBigDecimal") + public RestResponse restResponseBigDecimal() { + return RestResponse.ok(new BigDecimal("0")); + } + + @POST + @Path("/restResponseBigDecimal") + public RestResponse restResponseBigDecimal(BigDecimal body) { + return RestResponse.ok(body); + } + + @GET + @Path("/optionalBigDecimal") + public Optional optionalBigDecimal() { + return Optional.of(new BigDecimal("0")); + } + + @POST + @Path("/optionalBigDecimal") + public Optional optionalBigDecimal(Optional body) { + return body; + } + + @GET + @Path("/uniBigDecimal") + public Uni uniBigDecimal() { + return Uni.createFrom().item(new BigDecimal("0")); + } + + @GET + @Path("/completionStageBigDecimal") + public CompletionStage completionStageBigDecimal() { + return CompletableFuture.completedStage(new BigDecimal("0")); + } + + @GET + @Path("/completedFutureBigDecimal") + public CompletableFuture completedFutureBigDecimal() { + return CompletableFuture.completedFuture(new BigDecimal("0")); + } + + @GET + @Path("/listBigDecimal") + public List listBigDecimal() { + return Arrays.asList(new BigDecimal[] { new BigDecimal("0") }); + } + + @POST + @Path("/listBigDecimal") + public List listBigDecimal(List body) { + return body; + } + + @GET + @Path("/arrayBigDecimal") + public BigDecimal[] arrayBigDecimal() { + return new BigDecimal[] { new BigDecimal("0") }; + } + + @POST + @Path("/arrayBigDecimal") + public BigDecimal[] arrayBigDecimal(BigDecimal[] body) { + return body; + } + +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BigIntegerResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BigIntegerResource.java new file mode 100644 index 0000000000000..26c1e6a1fb35d --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BigIntegerResource.java @@ -0,0 +1,98 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class BigIntegerResource { + @GET + @Path("/justBigInteger") + public BigInteger justBigInteger() { + return new BigInteger("0"); + } + + @POST + @Path("/justBigInteger") + public BigInteger justBigInteger(BigInteger body) { + return body; + } + + @GET + @Path("/restResponseBigInteger") + public RestResponse restResponseBigInteger() { + return RestResponse.ok(new BigInteger("0")); + } + + @POST + @Path("/restResponseBigInteger") + public RestResponse restResponseBigInteger(BigInteger body) { + return RestResponse.ok(body); + } + + @GET + @Path("/optionalBigInteger") + public Optional optionalBigInteger() { + return Optional.of(new BigInteger("0")); + } + + @POST + @Path("/optionalBigInteger") + public Optional optionalBigInteger(Optional body) { + return body; + } + + @GET + @Path("/uniBigInteger") + public Uni uniBigInteger() { + return Uni.createFrom().item(new BigInteger("0")); + } + + @GET + @Path("/completionStageBigInteger") + public CompletionStage completionStageBigInteger() { + return CompletableFuture.completedStage(new BigInteger("0")); + } + + @GET + @Path("/completedFutureBigInteger") + public CompletableFuture completedFutureBigInteger() { + return CompletableFuture.completedFuture(new BigInteger("0")); + } + + @GET + @Path("/listBigInteger") + public List listBigInteger() { + return Arrays.asList(new BigInteger[] { new BigInteger("0") }); + } + + @POST + @Path("/listBigInteger") + public List listBigInteger(List body) { + return body; + } + + @GET + @Path("/arrayBigInteger") + public BigInteger[] arrayBigInteger() { + return new BigInteger[] { new BigInteger("0") }; + } + + @POST + @Path("/arrayBigInteger") + public BigInteger[] arrayBigInteger(BigInteger[] body) { + return body; + } + +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BooleanResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BooleanResource.java new file mode 100644 index 0000000000000..3e3c2aeabd1f1 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/BooleanResource.java @@ -0,0 +1,136 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class BooleanResource { + @GET + @Path("/justBoolean") + public Boolean justBoolean() { + return Boolean.TRUE; + } + + @POST + @Path("/justBoolean") + public Boolean justBoolean(Boolean body) { + return body; + } + + @GET + @Path("/justBool") + public boolean justBool() { + return true; + } + + @POST + @Path("/justBool") + public boolean justBool(boolean body) { + return body; + } + + @GET + @Path("/restResponseBoolean") + public RestResponse restResponseBoolean() { + return RestResponse.ok(Boolean.TRUE); + } + + @POST + @Path("/restResponseBoolean") + public RestResponse restResponseBoolean(Boolean body) { + return RestResponse.ok(body); + } + + @GET + @Path("/optionalBoolean") + public Optional optionalBoolean() { + return Optional.of(Boolean.TRUE); + } + + @POST + @Path("/optionalBoolean") + public Optional optionalBoolean(Optional body) { + return body; + } + + @GET + @Path("/uniBoolean") + public Uni uniBoolean() { + return Uni.createFrom().item(Boolean.TRUE); + } + + @GET + @Path("/completionStageBoolean") + public CompletionStage completionStageBoolean() { + return CompletableFuture.completedStage(Boolean.TRUE); + } + + @GET + @Path("/completedFutureBoolean") + public CompletableFuture completedFutureBoolean() { + return CompletableFuture.completedFuture(Boolean.TRUE); + } + + @GET + @Path("/listBoolean") + public List listBoolean() { + return Arrays.asList(new Boolean[] { Boolean.TRUE }); + } + + @POST + @Path("/listBoolean") + public List listBoolean(List body) { + return body; + } + + @GET + @Path("/arrayBoolean") + public Boolean[] arrayBoolean() { + return new Boolean[] { Boolean.TRUE }; + } + + @POST + @Path("/arrayBoolean") + public Boolean[] arrayBoolean(Boolean[] body) { + return body; + } + + @GET + @Path("/arrayBool") + public boolean[] arrayBool() { + return new boolean[] { true }; + } + + @POST + @Path("/arrayBool") + public boolean[] arrayBool(boolean[] body) { + return body; + } + + @GET + @Path("/mapBoolean") + public Map mapBoolean() { + Map m = new HashMap<>(); + m.put(true, true); + return m; + } + + @POST + @Path("/mapBoolean") + public Map mapBoolean(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ByteArrayResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ByteArrayResource.java new file mode 100644 index 0000000000000..065f682d808fd --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ByteArrayResource.java @@ -0,0 +1,84 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.io.IOException; +import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class ByteArrayResource { + @GET + @Path("/justByteArray/{fileName}") + public byte[] justByteArray(@PathParam("fileName") String filename) { + return toByteArray(filename); + } + + @POST + @Path("/justByteArray") + public byte[] justByteArray(byte[] bs) { + return bs; + } + + @GET + @Path("/restResponseByteArray/{fileName}") + public RestResponse restResponseByteArray(@PathParam("fileName") String filename) { + return RestResponse.ok(toByteArray(filename)); + } + + @POST + @Path("/restResponseByteArray") + public RestResponse restResponseByteArray(byte[] bs) { + return RestResponse.ok(bs); + } + + @GET + @Path("/optionalByteArray/{fileName}") + public Optional optionalByteArray(@PathParam("fileName") String filename) { + return Optional.of(toByteArray(filename)); + } + + @POST + @Path("/optionalByteArray") + public Optional optionalByteArray(Optional inputStream) { + return inputStream; + } + + @GET + @Path("/uniByteArray/{fileName}") + public Uni uniByteArray(@PathParam("fileName") String filename) { + return Uni.createFrom().item(toByteArray(filename)); + } + + @GET + @Path("/completionStageByteArray/{fileName}") + public CompletionStage completionStageByteArray(@PathParam("fileName") String filename) { + return CompletableFuture.completedStage(toByteArray(filename)); + } + + @GET + @Path("/completedFutureByteArray/{fileName}") + public CompletableFuture completedFutureByteArray(@PathParam("fileName") String filename) { + return CompletableFuture.completedFuture(toByteArray(filename)); + } + + private byte[] toByteArray(String filename) { + try { + String f = URLDecoder.decode(filename, "UTF-8"); + return Files.readAllBytes(Paths.get(f)); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/FileResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/FileResource.java new file mode 100644 index 0000000000000..9dc4c40567769 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/FileResource.java @@ -0,0 +1,83 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class FileResource { + @GET + @Path("/justFile/{fileName}") + public File justFile(@PathParam("fileName") String filename) { + return toFile(filename); + } + + @POST + @Path("/justFile") + public File justFile(File file) { + return file; + } + + @GET + @Path("/restResponseFile/{fileName}") + public RestResponse restResponseFile(@PathParam("fileName") String filename) { + return RestResponse.ok(toFile(filename)); + } + + @POST + @Path("/restResponseFile") + public RestResponse restResponseFile(File file) { + return RestResponse.ok(file); + } + + @GET + @Path("/optionalFile/{fileName}") + public Optional optionalFile(@PathParam("fileName") String filename) { + return Optional.of(toFile(filename)); + } + + @POST + @Path("/optionalFile") + public Optional optionalFile(Optional file) { + return file; + } + + @GET + @Path("/uniFile/{fileName}") + public Uni uniFile(@PathParam("fileName") String filename) { + return Uni.createFrom().item(toFile(filename)); + } + + @GET + @Path("/completionStageFile/{fileName}") + public CompletionStage completionStageFile(@PathParam("fileName") String filename) { + return CompletableFuture.completedStage(toFile(filename)); + } + + @GET + @Path("/completedFutureFile/{fileName}") + public CompletableFuture completedFutureFile(@PathParam("fileName") String filename) { + return CompletableFuture.completedFuture(toFile(filename)); + } + + private File toFile(String filename) { + try { + String f = URLDecoder.decode(filename, "UTF-8"); + return new File(f); + } catch (UnsupportedEncodingException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/InputStreamResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/InputStreamResource.java new file mode 100644 index 0000000000000..d609f152f555c --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/InputStreamResource.java @@ -0,0 +1,85 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class InputStreamResource { + @GET + @Path("/justInputStream/{fileName}") + public InputStream justInputStream(@PathParam("fileName") String filename) { + return toInputStream(filename); + } + + @POST + @Path("/justInputStream") + public InputStream justInputStream(InputStream inputStream) { + return inputStream; + } + + @GET + @Path("/restResponseInputStream/{fileName}") + public RestResponse restResponseInputStream(@PathParam("fileName") String filename) { + return RestResponse.ok(toInputStream(filename)); + } + + @POST + @Path("/restResponseInputStream") + public RestResponse restResponseInputStream(InputStream inputStream) { + return RestResponse.ok(inputStream); + } + + @GET + @Path("/optionalInputStream/{fileName}") + public Optional optionalInputStream(@PathParam("fileName") String filename) { + return Optional.of(toInputStream(filename)); + } + + @POST + @Path("/optionalInputStream") + public Optional optionalInputStream(Optional inputStream) { + return inputStream; + } + + @GET + @Path("/uniInputStream/{fileName}") + public Uni uniInputStream(@PathParam("fileName") String filename) { + return Uni.createFrom().item(toInputStream(filename)); + } + + @GET + @Path("/completionStageInputStream/{fileName}") + public CompletionStage completionStageInputStream(@PathParam("fileName") String filename) { + return CompletableFuture.completedStage(toInputStream(filename)); + } + + @GET + @Path("/completedFutureInputStream/{fileName}") + public CompletableFuture completedFutureInputStream(@PathParam("fileName") String filename) { + return CompletableFuture.completedFuture(toInputStream(filename)); + } + + private InputStream toInputStream(String filename) { + try { + String f = URLDecoder.decode(filename, "UTF-8"); + return Files.newInputStream(Paths.get(f)); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/IntegerResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/IntegerResource.java new file mode 100644 index 0000000000000..0187610d2e17c --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/IntegerResource.java @@ -0,0 +1,149 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class IntegerResource { + @GET + @Path("/justInteger") + public Integer justInteger() { + return 0; + } + + @POST + @Path("/justInteger") + public Integer justInteger(Integer body) { + return body; + } + + @GET + @Path("/justInt") + public int justInt() { + return 0; + } + + @POST + @Path("/justInt") + public int justInt(int body) { + return body; + } + + @GET + @Path("/restResponseInteger") + public RestResponse restResponseInteger() { + return RestResponse.ok(0); + } + + @POST + @Path("/restResponseInteger") + public RestResponse restResponseInteger(Integer body) { + return RestResponse.ok(body); + } + + @GET + @Path("/optionalInteger") + public Optional optionalInteger() { + return Optional.of(0); + } + + @POST + @Path("/optionalInteger") + public Optional optionalInteger(Optional body) { + return body; + } + + @GET + @Path("/optionalInt") + public OptionalInt optionalInt() { + return OptionalInt.of(0); + } + + @POST + @Path("/optionalInt") + public OptionalInt optionalInt(OptionalInt body) { + return body; + } + + @GET + @Path("/uniInteger") + public Uni uniInteger() { + return Uni.createFrom().item(0); + } + + @GET + @Path("/completionStageInteger") + public CompletionStage completionStageInteger() { + return CompletableFuture.completedStage(0); + } + + @GET + @Path("/completedFutureInteger") + public CompletableFuture completedFutureInteger() { + return CompletableFuture.completedFuture(0); + } + + @GET + @Path("/listInteger") + public List listInteger() { + return Arrays.asList(new Integer[] { 0 }); + } + + @POST + @Path("/listInteger") + public List listInteger(List body) { + return body; + } + + @GET + @Path("/arrayInteger") + public Integer[] arrayInteger() { + return new Integer[] { 0 }; + } + + @POST + @Path("/arrayInteger") + public Integer[] arrayInteger(Integer[] body) { + return body; + } + + @GET + @Path("/arrayInt") + public int[] arrayInt() { + return new int[] { 0 }; + } + + @POST + @Path("/arrayInt") + public int[] arrayInt(int[] body) { + return body; + } + + @GET + @Path("/mapInteger") + public Map mapInteger() { + Map m = new HashMap<>(); + m.put(0, 0); + return m; + } + + @POST + @Path("/mapInteger") + public Map mapInteger(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/LongResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/LongResource.java new file mode 100644 index 0000000000000..ee5501f6dd647 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/LongResource.java @@ -0,0 +1,149 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.OptionalLong; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class LongResource { + @GET + @Path("/justLong") + public Long justLong() { + return 0L; + } + + @POST + @Path("/justLong") + public Long justLong(Long body) { + return body; + } + + @GET + @Path("/justPrimitiveLong") + public long justPrimitiveLong() { + return 0L; + } + + @POST + @Path("/justPrimitiveLong") + public long justPrimitiveLong(long body) { + return body; + } + + @GET + @Path("/restResponseLong") + public RestResponse restResponseLong() { + return RestResponse.ok(0L); + } + + @POST + @Path("/restResponseLong") + public RestResponse restResponseLong(Long body) { + return RestResponse.ok(body); + } + + @GET + @Path("/optionalLong") + public Optional optionalLong() { + return Optional.of(0L); + } + + @POST + @Path("/optionalLong") + public Optional optionalLong(Optional body) { + return body; + } + + @GET + @Path("/optionalPrimitiveLong") + public OptionalLong optionalPrimitiveLong() { + return OptionalLong.of(0L); + } + + @POST + @Path("/optionalPrimitiveLong") + public OptionalLong optionalPrimitiveLong(OptionalLong body) { + return body; + } + + @GET + @Path("/uniLong") + public Uni uniLong() { + return Uni.createFrom().item(0L); + } + + @GET + @Path("/completionStageLong") + public CompletionStage completionStageLong() { + return CompletableFuture.completedStage(0L); + } + + @GET + @Path("/completedFutureLong") + public CompletableFuture completedFutureLong() { + return CompletableFuture.completedFuture(0L); + } + + @GET + @Path("/listLong") + public List listLong() { + return Arrays.asList(new Long[] { 0L }); + } + + @POST + @Path("/listLong") + public List listLong(List body) { + return body; + } + + @GET + @Path("/arrayLong") + public Long[] arrayLong() { + return new Long[] { 0L }; + } + + @POST + @Path("/arrayLong") + public Long[] arrayLong(Long[] body) { + return body; + } + + @GET + @Path("/arrayPrimitiveLong") + public long[] arrayPrimitiveLong() { + return new long[] { 0L }; + } + + @POST + @Path("/arrayPrimitiveLong") + public long[] arrayPrimitiveLong(long[] body) { + return body; + } + + @GET + @Path("/mapLong") + public Map mapLong() { + Map m = new HashMap<>(); + m.put(0L, 0L); + return m; + } + + @POST + @Path("/mapLong") + public Map mapLong(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/PojoResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/PojoResource.java new file mode 100644 index 0000000000000..d325122a7ad79 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/PojoResource.java @@ -0,0 +1,115 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.quarkus.it.openapi.Greeting; +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class PojoResource { + + @GET + @Path("/justPojo") + public Greeting justPojo() { + return new Greeting(0, "justPojo"); + } + + @POST + @Path("/justPojo") + public Greeting justPojo(Greeting greeting) { + return greeting; + } + + @GET + @Path("/restResponsePojo") + public RestResponse restResponsePojo() { + return RestResponse.ok(new Greeting(0, "restResponsePojo")); + } + + @POST + @Path("/restResponsePojo") + public RestResponse restResponsePojo(Greeting greeting) { + return RestResponse.ok(greeting); + } + + @GET + @Path("/optionalPojo") + public Optional optionalPojo() { + return Optional.of(new Greeting(0, "optionalPojo")); + } + + @POST + @Path("/optionalPojo") + public Optional optionalPojo(Optional greeting) { + return greeting; + } + + @GET + @Path("/uniPojo") + public Uni uniPojo() { + return Uni.createFrom().item(new Greeting(0, "uniPojo")); + } + + @GET + @Path("/completionStagePojo") + public CompletionStage completionStagePojo() { + return CompletableFuture.completedStage(new Greeting(0, "completionStagePojo")); + } + + @GET + @Path("/completedFuturePojo") + public CompletableFuture completedFuturePojo() { + return CompletableFuture.completedFuture(new Greeting(0, "completedFuturePojo")); + } + + @GET + @Path("/listPojo") + public List listPojo() { + return Arrays.asList(new Greeting[] { new Greeting(0, "listPojo") }); + } + + @POST + @Path("/listPojo") + public List listPojo(List greeting) { + return greeting; + } + + @GET + @Path("/arrayPojo") + public Greeting[] arrayPojo() { + return new Greeting[] { new Greeting(0, "arrayPojo") }; + } + + @POST + @Path("/arrayPojo") + public Greeting[] arrayPojo(Greeting[] greeting) { + return greeting; + } + + @GET + @Path("/mapPojo") + public Map mapPojo() { + Map m = new HashMap<>(); + Greeting g = new Greeting(0, "mapPojo"); + m.put("mapPojo", g); + return m; + } + + @POST + @Path("/mapPojo") + public Map mapPojo(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ReaderResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ReaderResource.java new file mode 100644 index 0000000000000..0ccfc743b0247 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ReaderResource.java @@ -0,0 +1,85 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.io.IOException; +import java.io.Reader; +import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.PathParam; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class ReaderResource { + @GET + @Path("/justReader/{fileName}") + public Reader justReader(@PathParam("fileName") String filename) { + return toReader(filename); + } + + @POST + @Path("/justReader") + public Reader justReader(Reader inputStream) { + return inputStream; + } + + @GET + @Path("/restResponseReader/{fileName}") + public RestResponse restResponseReader(@PathParam("fileName") String filename) { + return RestResponse.ok(toReader(filename)); + } + + @POST + @Path("/restResponseReader") + public RestResponse restResponseReader(Reader inputStream) { + return RestResponse.ok(inputStream); + } + + @GET + @Path("/optionalReader/{fileName}") + public Optional optionalReader(@PathParam("fileName") String filename) { + return Optional.of(toReader(filename)); + } + + @POST + @Path("/optionalReader") + public Optional optionalReader(Optional inputStream) { + return inputStream; + } + + @GET + @Path("/uniReader/{fileName}") + public Uni uniReader(@PathParam("fileName") String filename) { + return Uni.createFrom().item(toReader(filename)); + } + + @GET + @Path("/completionStageReader/{fileName}") + public CompletionStage completionStageReader(@PathParam("fileName") String filename) { + return CompletableFuture.completedStage(toReader(filename)); + } + + @GET + @Path("/completedFutureReader/{fileName}") + public CompletableFuture completedFutureReader(@PathParam("fileName") String filename) { + return CompletableFuture.completedFuture(toReader(filename)); + } + + private Reader toReader(String filename) { + try { + String f = URLDecoder.decode(filename, "UTF-8"); + return Files.newBufferedReader(Paths.get(f)); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ShortResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ShortResource.java new file mode 100644 index 0000000000000..098683380ac01 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/ShortResource.java @@ -0,0 +1,136 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class ShortResource { + @GET + @Path("/justShort") + public Short justShort() { + return 0; + } + + @POST + @Path("/justShort") + public Short justShort(Short body) { + return body; + } + + @GET + @Path("/justPrimitiveShort") + public short justPrimitiveShort() { + return 0; + } + + @POST + @Path("/justPrimitiveShort") + public int justPrimitiveShort(int body) { + return body; + } + + @GET + @Path("/restResponseShort") + public RestResponse restResponseShort() { + return RestResponse.ok((short) 0); + } + + @POST + @Path("/restResponseShort") + public RestResponse restResponseShort(Short body) { + return RestResponse.ok(body); + } + + @GET + @Path("/optionalShort") + public Optional optionalShort() { + return Optional.of((short) 0); + } + + @POST + @Path("/optionalShort") + public Optional optionalShort(Optional body) { + return body; + } + + @GET + @Path("/uniShort") + public Uni uniShort() { + return Uni.createFrom().item((short) 0); + } + + @GET + @Path("/completionStageShort") + public CompletionStage completionStageShort() { + return CompletableFuture.completedStage((short) 0); + } + + @GET + @Path("/completedFutureShort") + public CompletableFuture completedFutureShort() { + return CompletableFuture.completedFuture((short) 0); + } + + @GET + @Path("/listShort") + public List listShort() { + return Arrays.asList(new Short[] { 0 }); + } + + @POST + @Path("/listShort") + public List listShort(List body) { + return body; + } + + @GET + @Path("/arrayShort") + public Short[] arrayShort() { + return new Short[] { (short) 0 }; + } + + @POST + @Path("/arrayShort") + public Short[] arrayShort(Short[] body) { + return body; + } + + @GET + @Path("/arrayPrimitiveShort") + public short[] arrayPrimitiveShort() { + return new short[] { (short) 0 }; + } + + @POST + @Path("/arrayPrimitiveShort") + public short[] arrayPrimitiveShort(short[] body) { + return body; + } + + @GET + @Path("/mapShort") + public Map mapShort() { + Map m = new HashMap<>(); + m.put((short) 0, (short) 0); + return m; + } + + @POST + @Path("/mapShort") + public Map mapShort(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/StringResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/StringResource.java new file mode 100644 index 0000000000000..1b3bb05320f55 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/StringResource.java @@ -0,0 +1,113 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class StringResource { + + @GET + @Path("/justString") + public String justString() { + return "justString"; + } + + @POST + @Path("/justString") + public String justString(String body) { + return body; + } + + @GET + @Path("/restResponseString") + public RestResponse restResponseString() { + return RestResponse.ok("restResponseString"); + } + + @POST + @Path("/restResponseString") + public RestResponse restResponseString(String body) { + return RestResponse.ok(body); + } + + @GET + @Path("/optionalString") + public Optional optionalString() { + return Optional.of("optionalString"); + } + + @POST + @Path("/optionalString") + public Optional optionalString(Optional body) { + return body; + } + + @GET + @Path("/uniString") + public Uni uniString() { + return Uni.createFrom().item("uniString"); + } + + @GET + @Path("/completionStageString") + public CompletionStage completionStageString() { + return CompletableFuture.completedStage("completionStageString"); + } + + @GET + @Path("/completedFutureString") + public CompletableFuture completedFutureString() { + return CompletableFuture.completedFuture("completedFutureString"); + } + + @GET + @Path("/listString") + public List listString() { + return Arrays.asList(new String[] { "listString" }); + } + + @POST + @Path("/listString") + public List listString(List body) { + return body; + } + + @GET + @Path("/arrayString") + public String[] arrayString() { + return new String[] { "arrayString" }; + } + + @POST + @Path("/arrayString") + public String[] arrayString(String[] body) { + return body; + } + + @GET + @Path("/mapString") + public Map mapString() { + Map m = new HashMap<>(); + m.put("mapString", "mapString"); + return m; + } + + @POST + @Path("/mapString") + public Map mapString(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/URLResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/URLResource.java new file mode 100644 index 0000000000000..ff852a26c51bd --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/jaxrs/URLResource.java @@ -0,0 +1,123 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.POST; +import jakarta.ws.rs.Path; + +import org.jboss.resteasy.reactive.RestResponse; + +import io.smallrye.mutiny.Uni; + +@Path("/jax-rs/defaultContentType") +public class URLResource { + + @GET + @Path("/justURL") + public URL justURL() { + return url(); + } + + @POST + @Path("/justURL") + public URL justURL(URL url) { + return url; + } + + @GET + @Path("/restResponseURL") + public RestResponse restResponseURL() { + return RestResponse.ok(url()); + } + + @POST + @Path("/restResponseURL") + public RestResponse restResponseURL(URL body) { + return RestResponse.ok(body); + } + + @GET + @Path("/optionalURL") + public Optional optionalURL() { + return Optional.of(url()); + } + + @POST + @Path("/optionalURL") + public Optional optionalURL(Optional body) { + return body; + } + + @GET + @Path("/uniURL") + public Uni uniURL() { + return Uni.createFrom().item(url()); + } + + @GET + @Path("/completionStageURL") + public CompletionStage completionStageURL() { + return CompletableFuture.completedStage(url()); + } + + @GET + @Path("/completedFutureURL") + public CompletableFuture completedFutureURL() { + return CompletableFuture.completedFuture(url()); + } + + @GET + @Path("/listURL") + public List listURL() { + return Arrays.asList(new URL[] { url() }); + } + + @POST + @Path("/listURL") + public List listURL(List body) { + return body; + } + + @GET + @Path("/arrayURL") + public URL[] arrayURL() { + return new URL[] { url() }; + } + + @POST + @Path("/arrayURL") + public URL[] arrayURL(URL[] body) { + return body; + } + + @GET + @Path("/mapURL") + public Map mapURL() { + Map m = new HashMap<>(); + m.put("mapURL", url()); + return m; + } + + @POST + @Path("/mapURL") + public Map mapURL(Map body) { + return body; + } + + private URL url() { + try { + return new URL("https://quarkus.io/"); + } catch (MalformedURLException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BigDecimalResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BigDecimalResource.java new file mode 100644 index 0000000000000..7263e47e60e3d --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BigDecimalResource.java @@ -0,0 +1,86 @@ +package io.quarkus.it.openapi.spring; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class BigDecimalResource { + @GetMapping("/justBigDecimal") + public BigDecimal justBigDecimal() { + return new BigDecimal("0"); + } + + @PostMapping("/justBigDecimal") + public BigDecimal justBigDecimal(BigDecimal body) { + return body; + } + + @GetMapping("/responseEntityBigDecimal") + public ResponseEntity responseEntityBigDecimal() { + return ResponseEntity.ok(new BigDecimal("0")); + } + + @PostMapping("/responseEntityBigDecimal") + public ResponseEntity responseEntityBigDecimal(BigDecimal body) { + return ResponseEntity.ok(body); + } + + @GetMapping("/optionalBigDecimal") + public Optional optionalBigDecimal() { + return Optional.of(new BigDecimal("0")); + } + + @PostMapping("/optionalBigDecimal") + public Optional optionalBigDecimal(Optional body) { + return body; + } + + @GetMapping("/uniBigDecimal") + public Uni uniBigDecimal() { + return Uni.createFrom().item(new BigDecimal("0")); + } + + @GetMapping("/completionStageBigDecimal") + public CompletionStage completionStageBigDecimal() { + return CompletableFuture.completedStage(new BigDecimal("0")); + } + + @GetMapping("/completedFutureBigDecimal") + public CompletableFuture completedFutureBigDecimal() { + return CompletableFuture.completedFuture(new BigDecimal("0")); + } + + @GetMapping("/listBigDecimal") + public List listBigDecimal() { + return Arrays.asList(new BigDecimal[] { new BigDecimal("0") }); + } + + @PostMapping("/listBigDecimal") + public List listBigDecimal(List body) { + return body; + } + + @GetMapping("/arrayBigDecimal") + public BigDecimal[] arrayBigDecimal() { + return new BigDecimal[] { new BigDecimal("0") }; + } + + @PostMapping("/arrayBigDecimal") + public BigDecimal[] arrayBigDecimal(BigDecimal[] body) { + return body; + } + +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BigIntegerResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BigIntegerResource.java new file mode 100644 index 0000000000000..b35860e51beab --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BigIntegerResource.java @@ -0,0 +1,86 @@ +package io.quarkus.it.openapi.spring; + +import java.math.BigInteger; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class BigIntegerResource { + @GetMapping("/justBigInteger") + public BigInteger justBigInteger() { + return new BigInteger("0"); + } + + @PostMapping("/justBigInteger") + public BigInteger justBigInteger(BigInteger body) { + return body; + } + + @GetMapping("/responseEntityBigInteger") + public ResponseEntity responseEntityBigInteger() { + return ResponseEntity.ok(new BigInteger("0")); + } + + @PostMapping("/responseEntityBigInteger") + public ResponseEntity responseEntityBigInteger(BigInteger body) { + return ResponseEntity.ok(body); + } + + @GetMapping("/optionalBigInteger") + public Optional optionalBigInteger() { + return Optional.of(new BigInteger("0")); + } + + @PostMapping("/optionalBigInteger") + public Optional optionalBigInteger(Optional body) { + return body; + } + + @GetMapping("/uniBigInteger") + public Uni uniBigInteger() { + return Uni.createFrom().item(new BigInteger("0")); + } + + @GetMapping("/completionStageBigInteger") + public CompletionStage completionStageBigInteger() { + return CompletableFuture.completedStage(new BigInteger("0")); + } + + @GetMapping("/completedFutureBigInteger") + public CompletableFuture completedFutureBigInteger() { + return CompletableFuture.completedFuture(new BigInteger("0")); + } + + @GetMapping("/listBigInteger") + public List listBigInteger() { + return Arrays.asList(new BigInteger[] { new BigInteger("0") }); + } + + @PostMapping("/listBigInteger") + public List listBigInteger(List body) { + return body; + } + + @GetMapping("/arrayBigInteger") + public BigInteger[] arrayBigInteger() { + return new BigInteger[] { new BigInteger("0") }; + } + + @PostMapping("/arrayBigInteger") + public BigInteger[] arrayBigInteger(BigInteger[] body) { + return body; + } + +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BooleanResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BooleanResource.java new file mode 100644 index 0000000000000..e080de6bd9af0 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/BooleanResource.java @@ -0,0 +1,119 @@ +package io.quarkus.it.openapi.spring; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class BooleanResource { + + @GetMapping("/justBoolean") + public Boolean justBoolean() { + return Boolean.TRUE; + } + + @PostMapping("/justBoolean") + public Boolean justBoolean(Boolean body) { + return body; + } + + @GetMapping("/justBool") + public boolean justBool() { + return true; + } + + @PostMapping("/justBool") + public boolean justBool(boolean body) { + return body; + } + + @GetMapping("/responseEntityBoolean") + public ResponseEntity responseEntityBoolean() { + return ResponseEntity.ok(Boolean.TRUE); + } + + @PostMapping("/responseEntityBoolean") + public ResponseEntity responseEntityBoolean(Boolean body) { + return ResponseEntity.ok(body); + } + + @GetMapping("/optionalBoolean") + public Optional optionalBoolean() { + return Optional.of(Boolean.TRUE); + } + + @PostMapping("/optionalBoolean") + public Optional optionalBoolean(Optional body) { + return body; + } + + @GetMapping("/uniBoolean") + public Uni uniBoolean() { + return Uni.createFrom().item(Boolean.TRUE); + } + + @GetMapping("/completionStageBoolean") + public CompletionStage completionStageBoolean() { + return CompletableFuture.completedStage(Boolean.TRUE); + } + + @GetMapping("/completedFutureBoolean") + public CompletableFuture completedFutureBoolean() { + return CompletableFuture.completedFuture(Boolean.TRUE); + } + + @GetMapping("/listBoolean") + public List listBoolean() { + return Arrays.asList(new Boolean[] { Boolean.TRUE }); + } + + @PostMapping("/listBoolean") + public List listBoolean(List body) { + return body; + } + + @GetMapping("/arrayBoolean") + public Boolean[] arrayBoolean() { + return new Boolean[] { Boolean.TRUE }; + } + + @PostMapping("/arrayBoolean") + public Boolean[] arrayBoolean(Boolean[] body) { + return body; + } + + @GetMapping("/arrayBool") + public boolean[] arrayBool() { + return new boolean[] { true }; + } + + @PostMapping("/arrayBool") + public boolean[] arrayBool(boolean[] body) { + return body; + } + + @GetMapping("/mapBoolean") + public Map mapBoolean() { + Map m = new HashMap<>(); + m.put(true, true); + return m; + } + + @PostMapping("/mapBoolean") + public Map mapBoolean(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ByteArrayResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ByteArrayResource.java new file mode 100644 index 0000000000000..5a52f09c4dea2 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ByteArrayResource.java @@ -0,0 +1,76 @@ +package io.quarkus.it.openapi.spring; + +import java.io.IOException; +import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class ByteArrayResource { + @GetMapping("/justByteArray/{fileName}") + public byte[] justByteArray(@PathVariable("fileName") String filename) { + return toByteArray(filename); + } + + @PostMapping("/justByteArray") + public byte[] justByteArray(byte[] inputStream) { + return inputStream; + } + + @GetMapping("/responseEntityByteArray/{fileName}") + public ResponseEntity responseEntityByteArray(@PathVariable("fileName") String filename) { + return ResponseEntity.ok(toByteArray(filename)); + } + + @PostMapping("/responseEntityByteArray") + public ResponseEntity responseEntityByteArray(byte[] inputStream) { + return ResponseEntity.ok(inputStream); + } + + @GetMapping("/optionalByteArray/{fileName}") + public Optional optionalByteArray(@PathVariable("fileName") String filename) { + return Optional.of(toByteArray(filename)); + } + + @PostMapping("/optionalByteArray") + public Optional optionalByteArray(Optional inputStream) { + return inputStream; + } + + @GetMapping("/uniByteArray/{fileName}") + public Uni uniByteArray(@PathVariable("fileName") String filename) { + return Uni.createFrom().item(toByteArray(filename)); + } + + @GetMapping("/completionStageByteArray/{fileName}") + public CompletionStage completionStageByteArray(@PathVariable("fileName") String filename) { + return CompletableFuture.completedStage(toByteArray(filename)); + } + + @GetMapping("/completedFutureByteArray/{fileName}") + public CompletableFuture completedFutureByteArray(@PathVariable("fileName") String filename) { + return CompletableFuture.completedFuture(toByteArray(filename)); + } + + private byte[] toByteArray(String filename) { + try { + String f = URLDecoder.decode(filename, "UTF-8"); + return Files.readAllBytes(Paths.get(f)); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/FileResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/FileResource.java new file mode 100644 index 0000000000000..538ac8585476c --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/FileResource.java @@ -0,0 +1,75 @@ +package io.quarkus.it.openapi.spring; + +import java.io.File; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class FileResource { + @GetMapping("/justFile/{fileName}") + public File justFile(@PathVariable("fileName") String filename) { + return toFile(filename); + } + + @PostMapping("/justFile") + public File justFile(File file) { + return file; + } + + @GetMapping("/responseEntityFile/{fileName}") + public ResponseEntity restResponseFile(@PathVariable("fileName") String filename) { + return ResponseEntity.ok(toFile(filename)); + } + + @PostMapping("/responseEntityFile") + public ResponseEntity restResponseFile(File file) { + return ResponseEntity.ok(file); + } + + @GetMapping("/optionalFile/{fileName}") + public Optional optionalFile(@PathVariable("fileName") String filename) { + return Optional.of(toFile(filename)); + } + + @PostMapping("/optionalFile") + public Optional optionalFile(Optional file) { + return file; + } + + @GetMapping("/uniFile/{fileName}") + public Uni uniFile(@PathVariable("fileName") String filename) { + return Uni.createFrom().item(toFile(filename)); + } + + @GetMapping("/completionStageFile/{fileName}") + public CompletionStage completionStageFile(@PathVariable("fileName") String filename) { + return CompletableFuture.completedStage(toFile(filename)); + } + + @GetMapping("/completedFutureFile/{fileName}") + public CompletableFuture completedFutureFile(@PathVariable("fileName") String filename) { + return CompletableFuture.completedFuture(toFile(filename)); + } + + private File toFile(String filename) { + try { + String f = URLDecoder.decode(filename, "UTF-8"); + return new File(f); + } catch (UnsupportedEncodingException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/InputStreamResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/InputStreamResource.java new file mode 100644 index 0000000000000..1fd68155ac2ac --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/InputStreamResource.java @@ -0,0 +1,77 @@ +package io.quarkus.it.openapi.spring; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class InputStreamResource { + @GetMapping("/justInputStream/{fileName}") + public InputStream justInputStream(@PathVariable("fileName") String filename) { + return toInputStream(filename); + } + + @PostMapping("/justInputStream") + public InputStream justInputStream(InputStream file) { + return file; + } + + @GetMapping("/responseEntityInputStream/{fileName}") + public ResponseEntity restResponseInputStream(@PathVariable("fileName") String filename) { + return ResponseEntity.ok(toInputStream(filename)); + } + + @PostMapping("/responseEntityInputStream") + public ResponseEntity restResponseInputStream(InputStream file) { + return ResponseEntity.ok(file); + } + + @GetMapping("/optionalInputStream/{fileName}") + public Optional optionalInputStream(@PathVariable("fileName") String filename) { + return Optional.of(toInputStream(filename)); + } + + @PostMapping("/optionalInputStream") + public Optional optionalInputStream(Optional file) { + return file; + } + + @GetMapping("/uniInputStream/{fileName}") + public Uni uniInputStream(@PathVariable("fileName") String filename) { + return Uni.createFrom().item(toInputStream(filename)); + } + + @GetMapping("/completionStageInputStream/{fileName}") + public CompletionStage completionStageInputStream(@PathVariable("fileName") String filename) { + return CompletableFuture.completedStage(toInputStream(filename)); + } + + @GetMapping("/completedFutureInputStream/{fileName}") + public CompletableFuture completedFutureInputStream(@PathVariable("fileName") String filename) { + return CompletableFuture.completedFuture(toInputStream(filename)); + } + + private InputStream toInputStream(String filename) { + try { + String f = URLDecoder.decode(filename, "UTF-8"); + return Files.newInputStream(Paths.get(f)); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/IntegerResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/IntegerResource.java new file mode 100644 index 0000000000000..97520ab8553a6 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/IntegerResource.java @@ -0,0 +1,130 @@ +package io.quarkus.it.openapi.spring; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class IntegerResource { + + @GetMapping("/justInteger") + public Integer justInteger() { + return 0; + } + + @PostMapping("/justInteger") + public Integer justInteger(Integer body) { + return body; + } + + @GetMapping("/justInt") + public int justInt() { + return 0; + } + + @PostMapping("/justInt") + public int justInt(int body) { + return body; + } + + @GetMapping("/responseEntityInteger") + public ResponseEntity responseEntityInteger() { + return ResponseEntity.ok(0); + } + + @PostMapping("/responseEntityInteger") + public ResponseEntity responseEntityInteger(Integer body) { + return ResponseEntity.ok(body); + } + + @GetMapping("/optionalInteger") + public Optional optionalInteger() { + return Optional.of(0); + } + + @PostMapping("/optionalInteger") + public Optional optionalInteger(Optional body) { + return body; + } + + @GetMapping("/optionalInt") + public OptionalInt optionalInt() { + return OptionalInt.of(0); + } + + @PostMapping("/optionalInt") + public OptionalInt optionalInt(OptionalInt body) { + return body; + } + + @GetMapping("/uniInteger") + public Uni uniInteger() { + return Uni.createFrom().item(0); + } + + @GetMapping("/completionStageInteger") + public CompletionStage completionStageInteger() { + return CompletableFuture.completedStage(0); + } + + @GetMapping("/completedFutureInteger") + public CompletableFuture completedFutureInteger() { + return CompletableFuture.completedFuture(0); + } + + @GetMapping("/listInteger") + public List listInteger() { + return Arrays.asList(new Integer[] { 0 }); + } + + @PostMapping("/listInteger") + public List listInteger(List body) { + return body; + } + + @GetMapping("/arrayInteger") + public Integer[] arrayInteger() { + return new Integer[] { 0 }; + } + + @PostMapping("/arrayInteger") + public Integer[] arrayInteger(Integer[] body) { + return body; + } + + @GetMapping("/arrayInt") + public int[] arrayInt() { + return new int[] { 0 }; + } + + @PostMapping("/arrayInt") + public int[] arrayInt(int[] body) { + return body; + } + + @GetMapping("/mapInteger") + public Map mapInteger() { + Map m = new HashMap<>(); + m.put(0, 0); + return m; + } + + @PostMapping("/mapInteger") + public Map mapInteger(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/LongResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/LongResource.java new file mode 100644 index 0000000000000..8dc69c8763532 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/LongResource.java @@ -0,0 +1,130 @@ +package io.quarkus.it.openapi.spring; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.OptionalLong; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class LongResource { + + @GetMapping("/justLong") + public Long justLong() { + return 0L; + } + + @PostMapping("/justLong") + public Long justLong(Long body) { + return body; + } + + @GetMapping("/justPrimitiveLong") + public long justPrimitiveLong() { + return 0L; + } + + @PostMapping("/justPrimitiveLong") + public long justPrimitiveLong(long body) { + return body; + } + + @GetMapping("/responseEntityLong") + public ResponseEntity responseEntityLong() { + return ResponseEntity.ok(0L); + } + + @PostMapping("/responseEntityLong") + public ResponseEntity responseEntityLong(Long body) { + return ResponseEntity.ok(body); + } + + @GetMapping("/optionalLong") + public Optional optionalLong() { + return Optional.of(0L); + } + + @PostMapping("/optionalLong") + public Optional optionalLong(Optional body) { + return body; + } + + @GetMapping("/optionalPrimitiveLong") + public OptionalLong optionalPrimitiveLong() { + return OptionalLong.of(0L); + } + + @PostMapping("/optionalPrimitiveLong") + public OptionalLong optionalPrimitiveLong(OptionalLong body) { + return body; + } + + @GetMapping("/uniLong") + public Uni uniLong() { + return Uni.createFrom().item(0L); + } + + @GetMapping("/completionStageLong") + public CompletionStage completionStageLong() { + return CompletableFuture.completedStage(0L); + } + + @GetMapping("/completedFutureLong") + public CompletableFuture completedFutureLong() { + return CompletableFuture.completedFuture(0L); + } + + @GetMapping("/listLong") + public List listLong() { + return Arrays.asList(new Long[] { 0L }); + } + + @PostMapping("/listLong") + public List listLong(List body) { + return body; + } + + @GetMapping("/arrayLong") + public Long[] arrayLong() { + return new Long[] { 0L }; + } + + @PostMapping("/arrayLong") + public Long[] arrayLong(Long[] body) { + return body; + } + + @GetMapping("/arrayPrimitiveLong") + public long[] arrayPrimitiveLong() { + return new long[] { 0L }; + } + + @PostMapping("/arrayPrimitiveLong") + public long[] arrayPrimitiveLong(long[] body) { + return body; + } + + @GetMapping("/mapLong") + public Map mapLong() { + Map m = new HashMap<>(); + m.put(0L, 0L); + return m; + } + + @PostMapping("/mapLong") + public Map mapLong(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/PojoResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/PojoResource.java new file mode 100644 index 0000000000000..61a400ce0ab15 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/PojoResource.java @@ -0,0 +1,101 @@ +package io.quarkus.it.openapi.spring; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.quarkus.it.openapi.Greeting; +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class PojoResource { + + @GetMapping("/justPojo") + public Greeting justPojo() { + return new Greeting(0, "justPojo"); + } + + @PostMapping("/justPojo") + public Greeting justPojo(Greeting greeting) { + return greeting; + } + + @GetMapping("/responseEntityPojo") + public ResponseEntity responseEntityPojo() { + return ResponseEntity.ok(new Greeting(0, "responseEntityPojo")); + } + + @PostMapping("/responseEntityPojo") + public ResponseEntity responseEntityPojo(Greeting greeting) { + return ResponseEntity.ok(greeting); + } + + @GetMapping("/optionalPojo") + public Optional optionalPojo() { + return Optional.of(new Greeting(0, "optionalPojo")); + } + + @PostMapping("/optionalPojo") + public Optional optionalPojo(Optional greeting) { + return greeting; + } + + @GetMapping("/uniPojo") + public Uni uniPojo() { + return Uni.createFrom().item(new Greeting(0, "uniPojo")); + } + + @GetMapping("/completionStagePojo") + public CompletionStage completionStagePojo() { + return CompletableFuture.completedStage(new Greeting(0, "completionStagePojo")); + } + + @GetMapping("/completedFuturePojo") + public CompletableFuture completedFuturePojo() { + return CompletableFuture.completedFuture(new Greeting(0, "completedFuturePojo")); + } + + @GetMapping("/listPojo") + public List listPojo() { + return Arrays.asList(new Greeting[] { new Greeting(0, "listPojo") }); + } + + @PostMapping("/listPojo") + public List listPojo(List greeting) { + return greeting; + } + + @GetMapping("/arrayPojo") + public Greeting[] arrayPojo() { + return new Greeting[] { new Greeting(0, "arrayPojo") }; + } + + @PostMapping("/arrayPojo") + public Greeting[] arrayPojo(Greeting[] greeting) { + return greeting; + } + + @GetMapping("/mapPojo") + public Map mapPojo() { + Map m = new HashMap<>(); + Greeting g = new Greeting(0, "mapPojo"); + m.put("mapPojo", g); + return m; + } + + @PostMapping("/mapPojo") + public Map mapPojo(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ReaderResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ReaderResource.java new file mode 100644 index 0000000000000..ccce8056f5940 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ReaderResource.java @@ -0,0 +1,77 @@ +package io.quarkus.it.openapi.spring; + +import java.io.IOException; +import java.io.Reader; +import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class ReaderResource { + @GetMapping("/justReader/{fileName}") + public Reader justReader(@PathVariable("fileName") String filename) { + return toReader(filename); + } + + @PostMapping("/justReader") + public Reader justReader(Reader file) { + return file; + } + + @GetMapping("/responseEntityReader/{fileName}") + public ResponseEntity restResponseReader(@PathVariable("fileName") String filename) { + return ResponseEntity.ok(toReader(filename)); + } + + @PostMapping("/responseEntityReader") + public ResponseEntity restResponseReader(Reader file) { + return ResponseEntity.ok(file); + } + + @GetMapping("/optionalReader/{fileName}") + public Optional optionalReader(@PathVariable("fileName") String filename) { + return Optional.of(toReader(filename)); + } + + @PostMapping("/optionalReader") + public Optional optionalReader(Optional file) { + return file; + } + + @GetMapping("/uniReader/{fileName}") + public Uni uniReader(@PathVariable("fileName") String filename) { + return Uni.createFrom().item(toReader(filename)); + } + + @GetMapping("/completionStageReader/{fileName}") + public CompletionStage completionStageReader(@PathVariable("fileName") String filename) { + return CompletableFuture.completedStage(toReader(filename)); + } + + @GetMapping("/completedFutureReader/{fileName}") + public CompletableFuture completedFutureReader(@PathVariable("fileName") String filename) { + return CompletableFuture.completedFuture(toReader(filename)); + } + + private Reader toReader(String filename) { + try { + String f = URLDecoder.decode(filename, "UTF-8"); + return Files.newBufferedReader(Paths.get(f)); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ShortResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ShortResource.java new file mode 100644 index 0000000000000..103e4b4aa87d8 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/ShortResource.java @@ -0,0 +1,119 @@ +package io.quarkus.it.openapi.spring; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class ShortResource { + + @GetMapping("/justShort") + public Short justShort() { + return (short) 0; + } + + @PostMapping("/justShort") + public Short justShort(Short body) { + return body; + } + + @GetMapping("/justPrimitiveShort") + public short justPrimitiveShort() { + return (short) 0; + } + + @PostMapping("/justPrimitiveShort") + public short justPrimitiveShort(short body) { + return body; + } + + @GetMapping("/responseEntityShort") + public ResponseEntity responseEntityShort() { + return ResponseEntity.ok((short) 0); + } + + @PostMapping("/responseEntityShort") + public ResponseEntity responseEntityShort(Short body) { + return ResponseEntity.ok(body); + } + + @GetMapping("/optionalShort") + public Optional optionalShort() { + return Optional.of((short) 0); + } + + @PostMapping("/optionalShort") + public Optional optionalShort(Optional body) { + return body; + } + + @GetMapping("/uniShort") + public Uni uniShort() { + return Uni.createFrom().item((short) 0); + } + + @GetMapping("/completionStageShort") + public CompletionStage completionStageShort() { + return CompletableFuture.completedStage((short) 0); + } + + @GetMapping("/completedFutureShort") + public CompletableFuture completedFutureShort() { + return CompletableFuture.completedFuture((short) 0); + } + + @GetMapping("/listShort") + public List listShort() { + return Arrays.asList(new Short[] { (short) 0 }); + } + + @PostMapping("/listShort") + public List listShort(List body) { + return body; + } + + @GetMapping("/arrayShort") + public Short[] arrayShort() { + return new Short[] { (short) 0 }; + } + + @PostMapping("/arrayShort") + public Short[] arrayShort(Short[] body) { + return body; + } + + @GetMapping("/arrayPrimitiveShort") + public short[] arrayPrimitiveShort() { + return new short[] { (short) 0 }; + } + + @PostMapping("/arrayPrimitiveShort") + public short[] arrayPrimitiveShort(short[] body) { + return body; + } + + @GetMapping("/mapShort") + public Map mapShort() { + Map m = new HashMap<>(); + m.put((short) 0, (short) 0); + return m; + } + + @PostMapping("/mapShort") + public Map mapShort(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/StringResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/StringResource.java new file mode 100644 index 0000000000000..a8f68604b32c1 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/StringResource.java @@ -0,0 +1,100 @@ +package io.quarkus.it.openapi.spring; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class StringResource { + + @GetMapping("/justString") + public String justString() { + return "justString"; + } + + @PostMapping("/justString") + public String justString(@RequestBody String body) { + return body; + } + + @GetMapping("/responseEntityString") + public ResponseEntity responseEntityString() { + return ResponseEntity.ok("responseEntityString"); + } + + @PostMapping("/responseEntityString") + public ResponseEntity responseEntityString(@RequestBody String body) { + return ResponseEntity.ok(body); + } + + @GetMapping("/optionalString") + public Optional optionalString() { + return Optional.of("optionalString"); + } + + @PostMapping("/optionalString") + public Optional optionalString(@RequestBody Optional body) { + return body; + } + + @GetMapping("/uniString") + public Uni uniString() { + return Uni.createFrom().item("uniString"); + } + + @GetMapping("/completionStageString") + public CompletionStage completionStageString() { + return CompletableFuture.completedStage("completionStageString"); + } + + @GetMapping("/completedFutureString") + public CompletableFuture completedFutureString() { + return CompletableFuture.completedFuture("completedFutureString"); + } + + @GetMapping("/listString") + public List listString() { + return Arrays.asList(new String[] { "listString" }); + } + + @PostMapping("/listString") + public List listString(@RequestBody List body) { + return body; + } + + @GetMapping("/arrayString") + public String[] arrayString() { + return new String[] { "arrayString" }; + } + + @PostMapping("/arrayString") + public String[] arrayString(@RequestBody String[] body) { + return body; + } + + @GetMapping("/mapString") + public Map mapString() { + Map m = new HashMap<>(); + m.put("mapString", "mapString"); + return m; + } + + @PostMapping("/mapString") + public Map mapString(Map body) { + return body; + } +} diff --git a/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/URLResource.java b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/URLResource.java new file mode 100644 index 0000000000000..436ada590afe2 --- /dev/null +++ b/integration-tests/openapi/src/main/java/io/quarkus/it/openapi/spring/URLResource.java @@ -0,0 +1,109 @@ +package io.quarkus.it.openapi.spring; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.smallrye.mutiny.Uni; + +@RestController +@RequestMapping(value = "/spring/defaultContentType") +public class URLResource { + + @GetMapping("/justURL") + public URL justURL() { + return url(); + } + + @PostMapping("/justURL") + public URL justURL(URL url) { + return url; + } + + @GetMapping("/restResponseURL") + public ResponseEntity restResponseURL() { + return ResponseEntity.ok(url()); + } + + @PostMapping("/restResponseURL") + public ResponseEntity restResponseURL(URL body) { + return ResponseEntity.ok(body); + } + + @GetMapping("/optionalURL") + public Optional optionalURL() { + return Optional.of(url()); + } + + @PostMapping("/optionalURL") + public Optional optionalURL(Optional body) { + return body; + } + + @GetMapping("/uniURL") + public Uni uniURL() { + return Uni.createFrom().item(url()); + } + + @GetMapping("/completionStageURL") + public CompletionStage completionStageURL() { + return CompletableFuture.completedStage(url()); + } + + @GetMapping("/completedFutureURL") + public CompletableFuture completedFutureURL() { + return CompletableFuture.completedFuture(url()); + } + + @GetMapping("/listURL") + public List listURL() { + return Arrays.asList(new URL[] { url() }); + } + + @PostMapping("/listURL") + public List listURL(List body) { + return body; + } + + @GetMapping("/arrayURL") + public URL[] arrayURL() { + return new URL[] { url() }; + } + + @PostMapping("/arrayURL") + public URL[] arrayURL(URL[] body) { + return body; + } + + @GetMapping("/mapURL") + public Map mapURL() { + Map m = new HashMap<>(); + m.put("mapURL", url()); + return m; + } + + @PostMapping("/mapURL") + public Map mapURL(Map body) { + return body; + } + + private URL url() { + try { + return new URL("https://quarkus.io/"); + } catch (MalformedURLException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractByteArrayTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractByteArrayTest.java new file mode 100644 index 0000000000000..8fab3d07a34f4 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractByteArrayTest.java @@ -0,0 +1,59 @@ +package io.quarkus.it.openapi; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.file.Files; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Assertions; + +import io.restassured.RestAssured; + +public abstract class AbstractByteArrayTest extends AbstractTest { + protected static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + protected void testServiceByteArrayRequest(String path, String expectedContentType) throws IOException { + + byte[] b = Files.readAllBytes(tempFile().toPath()); + byte[] responseFile = RestAssured + .with().body(b) + .and() + .with().contentType(APPLICATION_OCTET_STREAM) + .when() + .post(path) + .then() + .header("Content-Type", Matchers.startsWith(APPLICATION_OCTET_STREAM)) + .extract().asByteArray(); + + Assertions.assertEquals(b.length, responseFile.length); + + } + + protected void testServiceByteArrayResponse(String path, String expectedResponseType) + throws UnsupportedEncodingException, IOException { + // Service + File f = tempFile(); + byte[] b = Files.readAllBytes(f.toPath()); + String filename = URLEncoder.encode(f.getAbsoluteFile().toString(), "UTF-8"); + byte[] responseFile = RestAssured + .when() + .get(path + "/" + filename) + .then() + .header("Content-Type", Matchers.startsWith(expectedResponseType)) + .and() + .extract().asByteArray(); + + Assertions.assertEquals(b.length, responseFile.length); + } + + private File tempFile() { + try { + java.nio.file.Path createTempFile = Files.createTempFile("", ""); + return createTempFile.toFile(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractFileTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractFileTest.java new file mode 100644 index 0000000000000..479f722c3e474 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractFileTest.java @@ -0,0 +1,58 @@ +package io.quarkus.it.openapi; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.file.Files; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Assertions; + +import io.restassured.RestAssured; + +public abstract class AbstractFileTest extends AbstractTest { + protected static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + protected void testServiceFileRequest(String path, String expectedContentType) throws IOException { + + File f = tempFile(); + byte[] responseFile = RestAssured + .with().body(f) + .and() + .with().contentType(APPLICATION_OCTET_STREAM) + .when() + .post(path) + .then() + .header("Content-Type", Matchers.startsWith(APPLICATION_OCTET_STREAM)) + .extract().asByteArray(); + + Assertions.assertEquals(Files.readAllBytes(f.toPath()).length, responseFile.length); + + } + + protected void testServiceFileResponse(String path, String expectedResponseType) + throws UnsupportedEncodingException, IOException { + // Service + File f = tempFile(); + String filename = URLEncoder.encode(f.getAbsoluteFile().toString(), "UTF-8"); + byte[] responseFile = RestAssured + .when() + .get(path + "/" + filename) + .then() + .header("Content-Type", Matchers.startsWith(expectedResponseType)) + .and() + .extract().asByteArray(); + + Assertions.assertEquals(Files.readAllBytes(f.toPath()).length, responseFile.length); + } + + private File tempFile() { + try { + java.nio.file.Path createTempFile = Files.createTempFile("", ""); + return createTempFile.toFile(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractInputStreamTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractInputStreamTest.java new file mode 100644 index 0000000000000..6c0aff9418141 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractInputStreamTest.java @@ -0,0 +1,58 @@ +package io.quarkus.it.openapi; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.file.Files; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Assertions; + +import io.restassured.RestAssured; + +public abstract class AbstractInputStreamTest extends AbstractTest { + protected static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + protected void testServiceInputStreamRequest(String path, String expectedContentType) throws IOException { + + File f = tempFile(); + byte[] responseFile = RestAssured + .with().body(f) + .and() + .with().contentType(APPLICATION_OCTET_STREAM) + .when() + .post(path) + .then() + .header("Content-Type", Matchers.startsWith(APPLICATION_OCTET_STREAM)) + .extract().asByteArray(); + + Assertions.assertEquals(Files.readAllBytes(f.toPath()).length, responseFile.length); + + } + + protected void testServiceInputStreamResponse(String path, String expectedResponseType) + throws UnsupportedEncodingException, IOException { + // Service + File f = tempFile(); + String filename = URLEncoder.encode(f.getAbsoluteFile().toString(), "UTF-8"); + byte[] responseFile = RestAssured + .when() + .get(path + "/" + filename) + .then() + .header("Content-Type", Matchers.startsWith(expectedResponseType)) + .and() + .extract().asByteArray(); + + Assertions.assertEquals(Files.readAllBytes(f.toPath()).length, responseFile.length); + } + + private File tempFile() { + try { + java.nio.file.Path createTempFile = Files.createTempFile("", ""); + return createTempFile.toFile(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractReaderTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractReaderTest.java new file mode 100644 index 0000000000000..a1cb6cce20c6d --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractReaderTest.java @@ -0,0 +1,58 @@ +package io.quarkus.it.openapi; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.nio.file.Files; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Assertions; + +import io.restassured.RestAssured; + +public abstract class AbstractReaderTest extends AbstractTest { + protected static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; + + protected void testServiceReaderRequest(String path, String expectedContentType) throws IOException { + + File f = tempFile(); + byte[] responseFile = RestAssured + .with().body(f) + .and() + .with().contentType(APPLICATION_OCTET_STREAM) + .when() + .post(path) + .then() + .header("Content-Type", Matchers.startsWith(APPLICATION_OCTET_STREAM)) + .extract().asByteArray(); + + Assertions.assertEquals(Files.readAllBytes(f.toPath()).length, responseFile.length); + + } + + protected void testServiceReaderResponse(String path, String expectedResponseType) + throws UnsupportedEncodingException, IOException { + // Service + File f = tempFile(); + String filename = URLEncoder.encode(f.getAbsoluteFile().toString(), "UTF-8"); + byte[] responseFile = RestAssured + .when() + .get(path + "/" + filename) + .then() + .header("Content-Type", Matchers.startsWith(expectedResponseType)) + .and() + .extract().asByteArray(); + + Assertions.assertEquals(Files.readAllBytes(f.toPath()).length, responseFile.length); + } + + private File tempFile() { + try { + java.nio.file.Path createTempFile = Files.createTempFile("", ""); + return createTempFile.toFile(); + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractTest.java new file mode 100644 index 0000000000000..b158ea39250f6 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/AbstractTest.java @@ -0,0 +1,101 @@ +package io.quarkus.it.openapi; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import jakarta.inject.Inject; + +import org.hamcrest.Matchers; +import org.jboss.logging.Logger; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import io.restassured.RestAssured; + +public abstract class AbstractTest { + private static final Logger LOG = Logger.getLogger(AbstractTest.class); + private static final String OPEN_API_PATH = "/q/openapi"; + + protected static final String TEXT_PLAIN = "text/plain"; + protected static final String APPLICATION_JSON = "application/json"; + + @Inject + protected ObjectMapper om; + + protected void testServiceRequest(String path, String expectedContentType, String expectedValue) { + // Service + RestAssured + .with().body(expectedValue) + .and() + .with().contentType(expectedContentType) + .when() + .post(path) + .then() + .header("Content-Type", Matchers.startsWith(expectedContentType)) + .and() + .body(Matchers.equalTo(expectedValue)); + } + + protected void testServiceResponse(String path, String expectedResponseType, String expectedValue) { + // Service + RestAssured + .when() + .get(path) + .then() + .header("Content-Type", Matchers.startsWith(expectedResponseType)) + .and() + .body(Matchers.equalTo(expectedValue)); + } + + protected void testOpenAPIRequest(String path, String expectedRequestType) { + // OpenAPI + RestAssured.given().queryParam("format", "JSON") + .when().get(OPEN_API_PATH) + .then() + .header("Content-Type", "application/json;charset=UTF-8") + .body("paths.'" + path + "'.post.requestBody.content.'" + expectedRequestType + "'", + Matchers.notNullValue()); + } + + protected void testOpenAPIResponse(String path, String expectedResponseType) { + // OpenAPI + RestAssured.given().queryParam("format", "JSON") + .when().get(OPEN_API_PATH) + .then() + .header("Content-Type", "application/json;charset=UTF-8") + .body("paths.'" + path + "'.get.responses.'200'.content.'" + expectedResponseType + "'", + Matchers.notNullValue()); + } + + protected String createExpected(String message) { + try { + Greeting g = new Greeting(0, message); + return om.writeValueAsString(g); + } catch (JsonProcessingException ex) { + throw new RuntimeException(ex); + } + } + + protected String createExpectedList(String message) { + try { + List l = new ArrayList<>(); + l.add(new Greeting(0, message)); + return om.writeValueAsString(l); + } catch (JsonProcessingException ex) { + throw new RuntimeException(ex); + } + } + + protected String createExpectedMap(String message) { + try { + Map m = new HashMap<>(); + m.put(message, new Greeting(0, message)); + return om.writeValueAsString(m); + } catch (JsonProcessingException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BigDecimalTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BigDecimalTest.java new file mode 100644 index 0000000000000..cab2e6601fb47 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BigDecimalTest.java @@ -0,0 +1,149 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class BigDecimalTest extends AbstractTest { + + // Just BigDecimal + @Test + public void testJustBigDecimalInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testJustBigDecimalInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testJustBigDecimalInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justBigDecimal", TEXT_PLAIN); + } + + @Test + public void testJustBigDecimalInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justBigDecimal", TEXT_PLAIN); + } + + // RestResponse + @Test + public void testRestResponseBigDecimalInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponseBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseBigDecimalInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponseBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseBigDecimalInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseBigDecimal", TEXT_PLAIN); + } + + @Test + public void testRestResponseBigDecimalInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseBigDecimal", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalBigDecimalInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalBigDecimal", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalBigDecimalInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalBigDecimalInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalBigDecimal", TEXT_PLAIN); + } + + @Test + public void testOptionalBigDecimalInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalBigDecimal", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniBigDecimalInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testUniBigDecimalInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniBigDecimal", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageBigDecimalInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStageBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageBigDecimalInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageBigDecimal", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureBigDecimalInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFutureBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureBigDecimalInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageBigDecimal", TEXT_PLAIN); + } + + // List + @Test + public void testListBigDecimalInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listBigDecimal", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListBigDecimalInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listBigDecimal", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListBigDecimalInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listBigDecimal", APPLICATION_JSON); + } + + @Test + public void testListBigDecimalInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listBigDecimal", APPLICATION_JSON); + } + + // BigDecimal[] + @Test + public void testArrayBigDecimalInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayBigDecimal", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayBigDecimalInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayBigDecimal", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayBigDecimalInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayBigDecimal", APPLICATION_JSON); + } + + @Test + public void testArrayBigDecimalInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayBigDecimal", APPLICATION_JSON); + } + +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BigIntegerTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BigIntegerTest.java new file mode 100644 index 0000000000000..89488705d6536 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BigIntegerTest.java @@ -0,0 +1,149 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class BigIntegerTest extends AbstractTest { + + // Just BigInteger + @Test + public void testJustBigIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testJustBigIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testJustBigIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justBigInteger", TEXT_PLAIN); + } + + @Test + public void testJustBigIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justBigInteger", TEXT_PLAIN); + } + + // RestResponse + @Test + public void testRestResponseBigIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponseBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseBigIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponseBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseBigIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseBigInteger", TEXT_PLAIN); + } + + @Test + public void testRestResponseBigIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseBigInteger", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalBigIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalBigInteger", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalBigIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalBigIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalBigInteger", TEXT_PLAIN); + } + + @Test + public void testOptionalBigIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalBigInteger", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniBigIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testUniBigIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniBigInteger", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageBigIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStageBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageBigIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageBigInteger", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureBigIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFutureBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureBigIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageBigInteger", TEXT_PLAIN); + } + + // List + @Test + public void testListBigIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listBigInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListBigIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listBigInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListBigIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listBigInteger", APPLICATION_JSON); + } + + @Test + public void testListBigIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listBigInteger", APPLICATION_JSON); + } + + // BigInteger[] + @Test + public void testArrayBigIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayBigInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayBigIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayBigInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayBigIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayBigInteger", APPLICATION_JSON); + } + + @Test + public void testArrayBigIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayBigInteger", APPLICATION_JSON); + } + +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BooleanTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BooleanTest.java new file mode 100644 index 0000000000000..3a327ba0c2cab --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/BooleanTest.java @@ -0,0 +1,213 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class BooleanTest extends AbstractTest { + + // Just Boolean + @Test + public void testJustBooleanInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testJustBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testJustBooleanInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justBoolean", TEXT_PLAIN); + } + + @Test + public void testJustBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justBoolean", TEXT_PLAIN); + } + + // Just boolean + @Test + public void testJustBoolInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justBool", TEXT_PLAIN, "true"); + } + + @Test + public void testJustBoolInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justBool", TEXT_PLAIN, "true"); + } + + @Test + public void testJustBoolInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justBool", TEXT_PLAIN); + } + + @Test + public void testJustBoolInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justBool", TEXT_PLAIN); + } + + // RestResponse + @Test + public void testRestResponseBooleanInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponseBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testRestResponseBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponseBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testRestResponseBooleanInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseBoolean", TEXT_PLAIN); + } + + @Test + public void testRestResponseBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseBoolean", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalBooleanInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalBoolean", TEXT_PLAIN, "true"); + } + + //@Test + public void testOptionalBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testOptionalBooleanInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalBoolean", TEXT_PLAIN); + } + + @Test + public void testOptionalBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalBoolean", TEXT_PLAIN); + } + + // Uni + + @Test + public void testUniBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testUniBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniBoolean", TEXT_PLAIN); + } + + // CompletionStage + + @Test + public void testCompletionStageBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStageBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testCompletionStageBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageBoolean", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFutureBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testCompletedFutureBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageBoolean", TEXT_PLAIN); + } + + // List + @Test + public void testListBooleanInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listBoolean", APPLICATION_JSON, "[true]"); + } + + @Test + public void testListBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listBoolean", APPLICATION_JSON, "[true]"); + } + + @Test + public void testListBooleanInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listBoolean", APPLICATION_JSON); + } + + @Test + public void testListBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listBoolean", APPLICATION_JSON); + } + + // Boolean[] + @Test + public void testArrayBooleanInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayBoolean", APPLICATION_JSON, "[true]"); + } + + @Test + public void testArrayBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayBoolean", APPLICATION_JSON, "[true]"); + } + + @Test + public void testArrayBooleanInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayBoolean", APPLICATION_JSON); + } + + @Test + public void testArrayBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayBoolean", APPLICATION_JSON); + } + + // boolean[] + @Test + public void testArrayBoolInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayBool", APPLICATION_JSON, "[true]"); + } + + @Test + public void testArrayBoolInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayBool", APPLICATION_JSON, "[true]"); + } + + @Test + public void testArrayBoolInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayBool", APPLICATION_JSON); + } + + @Test + public void testArrayBoolInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayBool", APPLICATION_JSON); + } + + // Map + @Test + public void testMapBooleanInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/mapBoolean", APPLICATION_JSON, "{\"true\":true}"); + } + + @Test + public void testMapBooleanInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/mapBoolean", APPLICATION_JSON, "{\"true\":true}"); + } + + @Test + public void testMapBooleanInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/mapBoolean", APPLICATION_JSON); + } + + @Test + public void testMapBooleanInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/mapBoolean", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ByteArrayTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ByteArrayTest.java new file mode 100644 index 0000000000000..30d1ec241c67c --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ByteArrayTest.java @@ -0,0 +1,110 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractByteArrayTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class ByteArrayTest extends AbstractByteArrayTest { + + // Just byte[] + @Test + public void testJustByteArrayInJaxRsServiceRequest() throws IOException { + testServiceByteArrayRequest("/jax-rs/defaultContentType/justByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJusByteArrayInJaxRsServiceResponse() throws IOException { + testServiceByteArrayResponse("/jax-rs/defaultContentType/justByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustByteArrayInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustByteArrayInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // RestResponse + @Test + public void testRestResponseByteArrayInJaxRsServiceRequest() throws IOException { + testServiceByteArrayRequest("/jax-rs/defaultContentType/restResponseByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseByteArrayInJaxRsServiceResponse() throws IOException { + testServiceByteArrayResponse("/jax-rs/defaultContentType/restResponseByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseByteArrayInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseByteArrayInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Optional + //@Test + public void testOptionalByteArrayInJaxRsServiceRequest() throws IOException { + testServiceByteArrayRequest("/jax-rs/defaultContentType/optionalByteArray", APPLICATION_OCTET_STREAM); + } + + //@Test + public void testOptionalByteArrayInJaxRsServiceResponse() throws IOException { + testServiceByteArrayResponse("/jax-rs/defaultContentType/optionalByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalByteArrayInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalByteArrayInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Uni + + @Test + public void testUniByteArrayInJaxRsServiceResponse() throws IOException { + testServiceByteArrayResponse("/jax-rs/defaultContentType/uniByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testUniByteArrayInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletionStage + + @Test + public void testCompletionStageByteArrayInJaxRsServiceResponse() throws IOException { + testServiceByteArrayResponse("/jax-rs/defaultContentType/completionStageByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletionStageByteArrayInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletedFuture + @Test + public void testCompletedFutureByteArrayInJaxRsServiceResponse() throws IOException { + testServiceByteArrayResponse("/jax-rs/defaultContentType/completedFutureByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletedFutureByteArrayInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/FileTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/FileTest.java new file mode 100644 index 0000000000000..9dbefa77babed --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/FileTest.java @@ -0,0 +1,110 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractFileTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class FileTest extends AbstractFileTest { + + // Just File + @Test + public void testJustFileInJaxRsServiceRequest() throws IOException { + testServiceFileRequest("/jax-rs/defaultContentType/justFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustFileInJaxRsServiceResponse() throws IOException { + testServiceFileResponse("/jax-rs/defaultContentType/justFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustFileInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustFileInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // RestResponse + @Test + public void testRestResponseFileInJaxRsServiceRequest() throws IOException { + testServiceFileRequest("/jax-rs/defaultContentType/restResponseFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseFileInJaxRsServiceResponse() throws IOException { + testServiceFileResponse("/jax-rs/defaultContentType/restResponseFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseFileInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseFileInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Optional + //@Test + public void testOptionalFileInJaxRsServiceRequest() throws IOException { + testServiceFileRequest("/jax-rs/defaultContentType/optionalFile", APPLICATION_OCTET_STREAM); + } + + //@Test + public void testOptionalFileInJaxRsServiceResponse() throws IOException { + testServiceFileResponse("/jax-rs/defaultContentType/optionalFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalFileInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalFileInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Uni + + @Test + public void testUniFileInJaxRsServiceResponse() throws IOException { + testServiceFileResponse("/jax-rs/defaultContentType/uniFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testUniFileInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletionStage + + @Test + public void testCompletionStageFileInJaxRsServiceResponse() throws IOException { + testServiceFileResponse("/jax-rs/defaultContentType/completionStageFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletionStageFileInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletedFuture + @Test + public void testCompletedFutureFileInJaxRsServiceResponse() throws IOException { + testServiceFileResponse("/jax-rs/defaultContentType/completedFutureFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletedFutureFileInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageFile/{fileName}", APPLICATION_OCTET_STREAM); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/InputStreamTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/InputStreamTest.java new file mode 100644 index 0000000000000..11c73a3defed5 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/InputStreamTest.java @@ -0,0 +1,110 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractInputStreamTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class InputStreamTest extends AbstractInputStreamTest { + + // Just InputStream + @Test + public void testJustInputStreamInJaxRsServiceRequest() throws IOException { + testServiceInputStreamRequest("/jax-rs/defaultContentType/justInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustInputStreamInJaxRsServiceResponse() throws IOException { + testServiceInputStreamResponse("/jax-rs/defaultContentType/justInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustInputStreamInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustInputStreamInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // RestResponse + @Test + public void testRestResponseInputStreamInJaxRsServiceRequest() throws IOException { + testServiceInputStreamRequest("/jax-rs/defaultContentType/restResponseInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseInputStreamInJaxRsServiceResponse() throws IOException { + testServiceInputStreamResponse("/jax-rs/defaultContentType/restResponseInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseInputStreamInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseInputStreamInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Optional + //@Test + public void testOptionalInputStreamInJaxRsServiceRequest() throws IOException { + testServiceInputStreamRequest("/jax-rs/defaultContentType/optionalInputStream", APPLICATION_OCTET_STREAM); + } + + //@Test + public void testOptionalInputStreamInJaxRsServiceResponse() throws IOException { + testServiceInputStreamResponse("/jax-rs/defaultContentType/optionalInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalInputStreamInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalInputStreamInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Uni + + @Test + public void testUniInputStreamInJaxRsServiceResponse() throws IOException { + testServiceInputStreamResponse("/jax-rs/defaultContentType/uniInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testUniInputStreamInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletionStage + + @Test + public void testCompletionStageInputStreamInJaxRsServiceResponse() throws IOException { + testServiceInputStreamResponse("/jax-rs/defaultContentType/completionStageInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletionStageInputStreamInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletedFuture + @Test + public void testCompletedFutureInputStreamInJaxRsServiceResponse() throws IOException { + testServiceInputStreamResponse("/jax-rs/defaultContentType/completedFutureInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletedFutureInputStreamInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/IntegerTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/IntegerTest.java new file mode 100644 index 0000000000000..cd82af12661f7 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/IntegerTest.java @@ -0,0 +1,232 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class IntegerTest extends AbstractTest { + + // Just Integer + @Test + public void testJustIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testJustIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testJustIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justInteger", TEXT_PLAIN); + } + + @Test + public void testJustIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justInteger", TEXT_PLAIN); + } + + // Just int + @Test + public void testJustIntInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justInt", TEXT_PLAIN, "0"); + } + + @Test + public void testJustIntInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justInt", TEXT_PLAIN, "0"); + } + + @Test + public void testJustIntInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justInt", TEXT_PLAIN); + } + + @Test + public void testJustIntInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justInt", TEXT_PLAIN); + } + + // RestResponse + @Test + public void testRestResponseIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponseInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponseInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseInteger", TEXT_PLAIN); + } + + @Test + public void testRestResponseIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseInteger", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalInteger", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalInteger", TEXT_PLAIN); + } + + @Test + public void testOptionalIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalInteger", TEXT_PLAIN); + } + + // OptionalInt + //@Test + public void testOptionalIntInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalInt", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalIntInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalInt", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalIntInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalInt", TEXT_PLAIN); + } + + @Test + public void testOptionalIntInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalInt", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testUniIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniInteger", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStageInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageInteger", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFutureInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageInteger", TEXT_PLAIN); + } + + // List + @Test + public void testListIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listInteger", APPLICATION_JSON); + } + + @Test + public void testListIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listInteger", APPLICATION_JSON); + } + + // Integer[] + @Test + public void testArrayIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayInteger", APPLICATION_JSON); + } + + @Test + public void testArrayIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayInteger", APPLICATION_JSON); + } + + // int[] + @Test + public void testArrayIntInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayInt", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayIntInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayInt", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayIntInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayInt", APPLICATION_JSON); + } + + @Test + public void testArrayIntInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayInt", APPLICATION_JSON); + } + + // Map + @Test + public void testMapIntegerInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/mapInteger", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapIntegerInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/mapInteger", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapIntegerInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/mapInteger", APPLICATION_JSON); + } + + @Test + public void testMapIntegerInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/mapInteger", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/LongTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/LongTest.java new file mode 100644 index 0000000000000..3a73aff55488c --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/LongTest.java @@ -0,0 +1,232 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class LongTest extends AbstractTest { + + // Just Long + @Test + public void testJustLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justLong", TEXT_PLAIN, "0"); + } + + @Test + public void testJustLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justLong", TEXT_PLAIN, "0"); + } + + @Test + public void testJustLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justLong", TEXT_PLAIN); + } + + @Test + public void testJustLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justLong", TEXT_PLAIN); + } + + // Just long + @Test + public void testJustPrimitiveLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justPrimitiveLong", TEXT_PLAIN, "0"); + } + + @Test + public void testJustPrimitiveLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justPrimitiveLong", TEXT_PLAIN, "0"); + } + + @Test + public void testJustPrimitiveLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justPrimitiveLong", TEXT_PLAIN); + } + + @Test + public void testJustPrimitiveLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justPrimitiveLong", TEXT_PLAIN); + } + + // RestResponse + @Test + public void testRestResponseLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponseLong", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponseLong", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseLong", TEXT_PLAIN); + } + + @Test + public void testRestResponseLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseLong", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalLong", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalLong", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalLong", TEXT_PLAIN); + } + + @Test + public void testOptionalLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalLong", TEXT_PLAIN); + } + + // OptionalLong + //@Test + public void testOptionalPrimitiveLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalPrimitiveLong", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalPrimitiveLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalPrimitiveLong", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalPrimitiveLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalPrimitiveLong", TEXT_PLAIN); + } + + @Test + public void testOptionalPrimitiveLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalPrimitiveLong", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniLong", TEXT_PLAIN, "0"); + } + + @Test + public void testUniLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniLong", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStageLong", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageLong", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFutureLong", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageLong", TEXT_PLAIN); + } + + // List + @Test + public void testListLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listLong", APPLICATION_JSON); + } + + @Test + public void testListLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listLong", APPLICATION_JSON); + } + + // Long[] + @Test + public void testArrayLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayLong", APPLICATION_JSON); + } + + @Test + public void testArrayLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayLong", APPLICATION_JSON); + } + + // long[] + @Test + public void testArrayPrimitiveLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayPrimitiveLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayPrimitiveLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayPrimitiveLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayPrimitiveLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayPrimitiveLong", APPLICATION_JSON); + } + + @Test + public void testArrayPrimitiveLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayPrimitiveLong", APPLICATION_JSON); + } + + // Map + @Test + public void testMapLongInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/mapLong", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapLongInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/mapLong", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapLongInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/mapLong", APPLICATION_JSON); + } + + @Test + public void testMapLongInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/mapLong", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/PojoTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/PojoTest.java new file mode 100644 index 0000000000000..a50094712b9b0 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/PojoTest.java @@ -0,0 +1,172 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class PojoTest extends AbstractTest { + + // Just Pojo + @Test + public void testJustPojoInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justPojo", APPLICATION_JSON, createExpected("justPojo")); + } + + @Test + public void testJustPojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justPojo", APPLICATION_JSON, createExpected("justPojo")); + } + + @Test + public void testJustPojoInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justPojo", APPLICATION_JSON); + } + + @Test + public void testJustPojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justPojo", APPLICATION_JSON); + } + + // RestResponse + @Test + public void testRestResponsePojoInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponsePojo", APPLICATION_JSON, createExpected("restResponsePojo")); + } + + @Test + public void testRestResponsePojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponsePojo", APPLICATION_JSON, + createExpected("restResponsePojo")); + } + + @Test + public void testRestResponsePojoInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponsePojo", APPLICATION_JSON); + } + + @Test + public void testRestResponsePojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponsePojo", APPLICATION_JSON); + } + + // Optional + @Test + public void testOptionalPojoInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalPojo", APPLICATION_JSON, createExpected("optionalPojo")); + } + + @Test + public void testOptionalPojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalPojo", APPLICATION_JSON, createExpected("optionalPojo")); + } + + @Test + public void testOptionalPojoInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalPojo", APPLICATION_JSON); + } + + @Test + public void testOptionalPojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalPojo", APPLICATION_JSON); + } + + // Uni + @Test + public void testUniPojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniPojo", APPLICATION_JSON, createExpected("uniPojo")); + } + + @Test + public void testUniPojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniPojo", APPLICATION_JSON); + } + + // CompletionStage + @Test + public void testCompletionStagePojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStagePojo", APPLICATION_JSON, + createExpected("completionStagePojo")); + } + + @Test + public void testCompletionStagePojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStagePojo", APPLICATION_JSON); + } + + // CompletedFuture + @Test + public void testCompletedFuturePojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFuturePojo", APPLICATION_JSON, + createExpected("completedFuturePojo")); + } + + @Test + public void testCompletedFuturePojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completedFuturePojo", APPLICATION_JSON); + } + + // List + @Test + public void testListPojoInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listPojo", APPLICATION_JSON, createExpectedList("listPojo")); + } + + @Test + public void testListPojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listPojo", APPLICATION_JSON, createExpectedList("listPojo")); + } + + @Test + public void testListPojoInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listPojo", APPLICATION_JSON); + } + + @Test + public void testListPojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listPojo", APPLICATION_JSON); + } + + // Pojo[] + @Test + public void testArrayPojoInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayPojo", APPLICATION_JSON, createExpectedList("arrayPojo")); + } + + @Test + public void testArrayPojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayPojo", APPLICATION_JSON, createExpectedList("arrayPojo")); + } + + @Test + public void testArrayPojoInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayPojo", APPLICATION_JSON); + } + + @Test + public void testArrayPojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayPojo", APPLICATION_JSON); + } + + // Map + @Test + public void testMapPojoInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/mapPojo", APPLICATION_JSON, createExpectedMap("mapPojo")); + } + + @Test + public void testMapPojoInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/mapPojo", APPLICATION_JSON, createExpectedMap("mapPojo")); + } + + @Test + public void testMapPojoInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/mapPojo", APPLICATION_JSON); + } + + @Test + public void testMapPojoInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/mapPojo", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ReaderTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ReaderTest.java new file mode 100644 index 0000000000000..53983b630bedf --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ReaderTest.java @@ -0,0 +1,110 @@ +package io.quarkus.it.openapi.jaxrs; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractReaderTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class ReaderTest extends AbstractReaderTest { + + // Just Reader + @Test + public void testJustReaderInJaxRsServiceRequest() throws IOException { + testServiceReaderRequest("/jax-rs/defaultContentType/justReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJusReaderInJaxRsServiceResponse() throws IOException { + testServiceReaderResponse("/jax-rs/defaultContentType/justReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustReaderInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustReaderInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // RestResponse + @Test + public void testRestResponseReaderInJaxRsServiceRequest() throws IOException { + testServiceReaderRequest("/jax-rs/defaultContentType/restResponseReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseReaderInJaxRsServiceResponse() throws IOException { + testServiceReaderResponse("/jax-rs/defaultContentType/restResponseReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseReaderInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseReaderInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Optional + //@Test + public void testOptionalReaderInJaxRsServiceRequest() throws IOException { + testServiceReaderRequest("/jax-rs/defaultContentType/optionalReader", APPLICATION_OCTET_STREAM); + } + + //@Test + public void testOptionalReaderInJaxRsServiceResponse() throws IOException { + testServiceReaderResponse("/jax-rs/defaultContentType/optionalReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalReaderInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalReaderInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Uni + + @Test + public void testUniReaderInJaxRsServiceResponse() throws IOException { + testServiceReaderResponse("/jax-rs/defaultContentType/uniReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testUniReaderInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletionStage + + @Test + public void testCompletionStageReaderInJaxRsServiceResponse() throws IOException { + testServiceReaderResponse("/jax-rs/defaultContentType/completionStageReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletionStageReaderInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletedFuture + @Test + public void testCompletedFutureReaderInJaxRsServiceResponse() throws IOException { + testServiceReaderResponse("/jax-rs/defaultContentType/completedFutureReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletedFutureReaderInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageReader/{fileName}", APPLICATION_OCTET_STREAM); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ShortTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ShortTest.java new file mode 100644 index 0000000000000..410859d6e40d9 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/ShortTest.java @@ -0,0 +1,211 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class ShortTest extends AbstractTest { + + // Just Short + //@Test + public void testJustShortInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justShort", TEXT_PLAIN, "0"); + } + + @Test + public void testJustShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justShort", TEXT_PLAIN, "0"); + } + + @Test + public void testJustShortInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justShort", TEXT_PLAIN); + } + + @Test + public void testJustShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justShort", TEXT_PLAIN); + } + + // Just long + @Test + public void testJustPrimitiveShortInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justPrimitiveShort", TEXT_PLAIN, "0"); + } + + @Test + public void testJustPrimitiveShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justPrimitiveShort", TEXT_PLAIN, "0"); + } + + @Test + public void testJustPrimitiveShortInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justPrimitiveShort", TEXT_PLAIN); + } + + @Test + public void testJustPrimitiveShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justPrimitiveShort", TEXT_PLAIN); + } + + // RestResponse + //@Test + public void testRestResponseShortInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponseShort", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponseShort", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseShortInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseShort", TEXT_PLAIN); + } + + @Test + public void testRestResponseShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseShort", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalShortInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalShort", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalShort", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalShortInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalShort", TEXT_PLAIN); + } + + @Test + public void testOptionalShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalShort", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniShort", TEXT_PLAIN, "0"); + } + + @Test + public void testUniShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniShort", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStageShort", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageShort", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFutureShort", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageShort", TEXT_PLAIN); + } + + // List + @Test + public void testListShortInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListShortInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listShort", APPLICATION_JSON); + } + + @Test + public void testListShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listShort", APPLICATION_JSON); + } + + // Short[] + @Test + public void testArrayShortInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayShortInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayShort", APPLICATION_JSON); + } + + @Test + public void testArrayShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayShort", APPLICATION_JSON); + } + + // long[] + @Test + public void testArrayPrimitiveShortInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayPrimitiveShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayPrimitiveShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayPrimitiveShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayPrimitiveShortInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayPrimitiveShort", APPLICATION_JSON); + } + + @Test + public void testArrayPrimitiveShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayPrimitiveShort", APPLICATION_JSON); + } + + // Map + @Test + public void testMapShortInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/mapShort", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapShortInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/mapShort", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapShortInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/mapShort", APPLICATION_JSON); + } + + @Test + public void testMapShortInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/mapShort", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/StringTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/StringTest.java new file mode 100644 index 0000000000000..9b3eba2f4df31 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/StringTest.java @@ -0,0 +1,169 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class StringTest extends AbstractTest { + + // Just String + @Test + public void testJustStringInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justString", TEXT_PLAIN, "justString"); + } + + @Test + public void testJustStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justString", TEXT_PLAIN, "justString"); + } + + @Test + public void testJustStringInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justString", TEXT_PLAIN); + } + + @Test + public void testJustStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justString", TEXT_PLAIN); + } + + // RestResponse + @Test + public void testRestResponseStringInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponseString", TEXT_PLAIN, "restResponseString"); + } + + @Test + public void testRestResponseStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponseString", TEXT_PLAIN, "restResponseString"); + } + + @Test + public void testRestResponseStringInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseString", TEXT_PLAIN); + } + + @Test + public void testRestResponseStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseString", TEXT_PLAIN); + } + + // Optional + // @Test + public void testOptionalStringInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalString", TEXT_PLAIN, "optionalString"); + } + + // @Test + public void testOptionalStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalString", TEXT_PLAIN, "optionalString"); + } + + @Test + public void testOptionalStringInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalString", TEXT_PLAIN); + } + + @Test + public void testOptionalStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalString", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniString", TEXT_PLAIN, "uniString"); + } + + @Test + public void testUniStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniString", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStageString", TEXT_PLAIN, "completionStageString"); + } + + @Test + public void testCompletionStageStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageString", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFutureString", TEXT_PLAIN, "completedFutureString"); + } + + @Test + public void testCompletedFutureStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completedFutureString", TEXT_PLAIN); + } + + // List + @Test + public void testListStringInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listString", APPLICATION_JSON, "[\"listString\"]"); + } + + @Test + public void testListStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listString", APPLICATION_JSON, "[\"listString\"]"); + } + + @Test + public void testListStringInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listString", APPLICATION_JSON); + } + + @Test + public void testListStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listString", APPLICATION_JSON); + } + + // String[] + @Test + public void testArrayStringInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayString", APPLICATION_JSON, "[\"arrayString\"]"); + } + + @Test + public void testArrayStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayString", APPLICATION_JSON, "[\"arrayString\"]"); + } + + @Test + public void testArrayStringInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayString", APPLICATION_JSON); + } + + @Test + public void testArrayStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayString", APPLICATION_JSON); + } + + // Map + @Test + public void testMapStringInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/mapString", APPLICATION_JSON, "{\"mapString\":\"mapString\"}"); + } + + @Test + public void testMapStringInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/mapString", APPLICATION_JSON, "{\"mapString\":\"mapString\"}"); + } + + @Test + public void testMapStringInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/mapString", APPLICATION_JSON); + } + + @Test + public void testMapStringInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/mapString", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/URLTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/URLTest.java new file mode 100644 index 0000000000000..290f421944004 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/jaxrs/URLTest.java @@ -0,0 +1,169 @@ +package io.quarkus.it.openapi.jaxrs; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class URLTest extends AbstractTest { + + // Just URL + @Test + public void testJustURLInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/justURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testJustURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/justURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testJustURLInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/justURL", APPLICATION_JSON); + } + + @Test + public void testJustURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/justURL", APPLICATION_JSON); + } + + // RestResponse + @Test + public void testRestResponseURLInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/restResponseURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testRestResponseURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/restResponseURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testRestResponseURLInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/restResponseURL", APPLICATION_JSON); + } + + @Test + public void testRestResponseURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/restResponseURL", APPLICATION_JSON); + } + + // Optional + // @Test + public void testOptionalURLInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/optionalURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + // @Test + public void testOptionalURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/optionalURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testOptionalURLInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/optionalURL", APPLICATION_JSON); + } + + @Test + public void testOptionalURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/optionalURL", APPLICATION_JSON); + } + + // Uni + @Test + public void testUniURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/uniURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testUniURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/uniURL", APPLICATION_JSON); + } + + // CompletionStage + @Test + public void testCompletionStageURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completionStageURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testCompletionStageURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completionStageURL", APPLICATION_JSON); + } + + // CompletedFuture + @Test + public void testCompletedFutureURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/completedFutureURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testCompletedFutureURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/completedFutureURL", APPLICATION_JSON); + } + + // List + @Test + public void testListURLInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/listURL", APPLICATION_JSON, "[\"https://quarkus.io/\"]"); + } + + @Test + public void testListURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/listURL", APPLICATION_JSON, "[\"https://quarkus.io/\"]"); + } + + @Test + public void testListURLInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/listURL", APPLICATION_JSON); + } + + @Test + public void testListURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/listURL", APPLICATION_JSON); + } + + // URL[] + @Test + public void testArrayURLInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/arrayURL", APPLICATION_JSON, "[\"https://quarkus.io/\"]"); + } + + @Test + public void testArrayURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/arrayURL", APPLICATION_JSON, "[\"https://quarkus.io/\"]"); + } + + @Test + public void testArrayURLInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/arrayURL", APPLICATION_JSON); + } + + @Test + public void testArrayURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/arrayURL", APPLICATION_JSON); + } + + // Map + @Test + public void testMapURLInJaxRsServiceRequest() { + testServiceRequest("/jax-rs/defaultContentType/mapURL", APPLICATION_JSON, "{\"mapURL\":\"https://quarkus.io/\"}"); + } + + @Test + public void testMapURLInJaxRsServiceResponse() { + testServiceResponse("/jax-rs/defaultContentType/mapURL", APPLICATION_JSON, "{\"mapURL\":\"https://quarkus.io/\"}"); + } + + @Test + public void testMapURLInJaxRsOpenAPIRequest() { + testOpenAPIRequest("/jax-rs/defaultContentType/mapURL", APPLICATION_JSON); + } + + @Test + public void testMapURLInJaxRsOpenAPIResponse() { + testOpenAPIResponse("/jax-rs/defaultContentType/mapURL", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BigDecimalTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BigDecimalTest.java new file mode 100644 index 0000000000000..300b58cb31f14 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BigDecimalTest.java @@ -0,0 +1,149 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class BigDecimalTest extends AbstractTest { + + // Just BigDecimal + @Test + public void testJustBigDecimalInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testJustBigDecimalInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testJustBigDecimalInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justBigDecimal", TEXT_PLAIN); + } + + @Test + public void testJustBigDecimalInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justBigDecimal", TEXT_PLAIN); + } + + // ResponseEntity + @Test + public void testRestResponseBigDecimalInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/responseEntityBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseBigDecimalInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/responseEntityBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseBigDecimalInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityBigDecimal", TEXT_PLAIN); + } + + @Test + public void testRestResponseBigDecimalInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityBigDecimal", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalBigDecimalInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalBigDecimal", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalBigDecimalInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalBigDecimalInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalBigDecimal", TEXT_PLAIN); + } + + @Test + public void testOptionalBigDecimalInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalBigDecimal", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniBigDecimalInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testUniBigDecimalInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniBigDecimal", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageBigDecimalInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStageBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageBigDecimalInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageBigDecimal", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureBigDecimalInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFutureBigDecimal", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureBigDecimalInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageBigDecimal", TEXT_PLAIN); + } + + // List + @Test + public void testListBigDecimalInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listBigDecimal", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListBigDecimalInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listBigDecimal", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListBigDecimalInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listBigDecimal", APPLICATION_JSON); + } + + @Test + public void testListBigDecimalInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listBigDecimal", APPLICATION_JSON); + } + + // BigDecimal[] + @Test + public void testArrayBigDecimalInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayBigDecimal", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayBigDecimalInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayBigDecimal", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayBigDecimalInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayBigDecimal", APPLICATION_JSON); + } + + @Test + public void testArrayBigDecimalInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayBigDecimal", APPLICATION_JSON); + } + +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BigIntegerTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BigIntegerTest.java new file mode 100644 index 0000000000000..6f35621d2c841 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BigIntegerTest.java @@ -0,0 +1,149 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class BigIntegerTest extends AbstractTest { + + // Just BigInteger + @Test + public void testJustBigIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testJustBigIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testJustBigIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justBigInteger", TEXT_PLAIN); + } + + @Test + public void testJustBigIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justBigInteger", TEXT_PLAIN); + } + + // ResponseEntity + @Test + public void testRestResponseBigIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/responseEntityBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseBigIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/responseEntityBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testRestResponseBigIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityBigInteger", TEXT_PLAIN); + } + + @Test + public void testRestResponseBigIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityBigInteger", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalBigIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalBigInteger", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalBigIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalBigIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalBigInteger", TEXT_PLAIN); + } + + @Test + public void testOptionalBigIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalBigInteger", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniBigIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testUniBigIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniBigInteger", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageBigIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStageBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageBigIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageBigInteger", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureBigIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFutureBigInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureBigIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageBigInteger", TEXT_PLAIN); + } + + // List + @Test + public void testListBigIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listBigInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListBigIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listBigInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListBigIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listBigInteger", APPLICATION_JSON); + } + + @Test + public void testListBigIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listBigInteger", APPLICATION_JSON); + } + + // BigInteger[] + @Test + public void testArrayBigIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayBigInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayBigIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayBigInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayBigIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayBigInteger", APPLICATION_JSON); + } + + @Test + public void testArrayBigIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayBigInteger", APPLICATION_JSON); + } + +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BooleanTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BooleanTest.java new file mode 100644 index 0000000000000..c6c8a1d9e98f6 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/BooleanTest.java @@ -0,0 +1,211 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class BooleanTest extends AbstractTest { + + // Just Boolean + @Test + public void testJustBooleanInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testJustBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testJustBooleanInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justBoolean", TEXT_PLAIN); + } + + @Test + public void testJustBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justBoolean", TEXT_PLAIN); + } + + // Just boolean + @Test + public void testJustBoolInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justBool", TEXT_PLAIN, "true"); + } + + @Test + public void testJustBoolInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justBool", TEXT_PLAIN, "true"); + } + + @Test + public void testJustBoolInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justBool", TEXT_PLAIN); + } + + @Test + public void testJustBoolInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justBool", TEXT_PLAIN); + } + + // ResponseEntity + @Test + public void testResponseEntityBooleanInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/responseEntityBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testResponseEntityBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/responseEntityBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testResponseEntityBooleanInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityBoolean", TEXT_PLAIN); + } + + @Test + public void testResponseEntityBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityBoolean", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalBooleanInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalBoolean", TEXT_PLAIN, "true"); + } + + //@Test + public void testOptionalBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testOptionalBooleanInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalBoolean", TEXT_PLAIN); + } + + @Test + public void testOptionalBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalBoolean", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testUniBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniBoolean", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStageBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testCompletionStageBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageBoolean", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFutureBoolean", TEXT_PLAIN, "true"); + } + + @Test + public void testCompletedFutureBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageBoolean", TEXT_PLAIN); + } + + // List + @Test + public void testListBooleanInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listBoolean", APPLICATION_JSON, "[true]"); + } + + @Test + public void testListBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listBoolean", APPLICATION_JSON, "[true]"); + } + + @Test + public void testListBooleanInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listBoolean", APPLICATION_JSON); + } + + @Test + public void testListBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listBoolean", APPLICATION_JSON); + } + + // Boolean[] + @Test + public void testArrayBooleanInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayBoolean", APPLICATION_JSON, "[true]"); + } + + @Test + public void testArrayBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayBoolean", APPLICATION_JSON, "[true]"); + } + + @Test + public void testArrayBooleanInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayBoolean", APPLICATION_JSON); + } + + @Test + public void testArrayBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayBoolean", APPLICATION_JSON); + } + + // boolean[] + @Test + public void testArrayBoolInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayBool", APPLICATION_JSON, "[true]"); + } + + @Test + public void testArrayBoolInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayBool", APPLICATION_JSON, "[true]"); + } + + @Test + public void testArrayBoolInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayBool", APPLICATION_JSON); + } + + @Test + public void testArrayBoolInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayBool", APPLICATION_JSON); + } + + // Map + @Test + public void testMapBooleanInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/mapBoolean", APPLICATION_JSON, "{\"true\":true}"); + } + + @Test + public void testMapBooleanInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/mapBoolean", APPLICATION_JSON, "{\"true\":true}"); + } + + @Test + public void testMapBooleanInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/mapBoolean", APPLICATION_JSON); + } + + @Test + public void testMapBooleanInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/mapBoolean", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ByteArrayTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ByteArrayTest.java new file mode 100644 index 0000000000000..72a0068dde59e --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ByteArrayTest.java @@ -0,0 +1,110 @@ +package io.quarkus.it.openapi.spring; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractByteArrayTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class ByteArrayTest extends AbstractByteArrayTest { + + // Just byte[] + @Test + public void testJustByteArrayInSpringServiceRequest() throws IOException { + testServiceByteArrayRequest("/spring/defaultContentType/justByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJusByteArrayInSpringServiceResponse() throws IOException { + testServiceByteArrayResponse("/spring/defaultContentType/justByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustByteArrayInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustByteArrayInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // ResponseEntity + @Test + public void testResponseEntityByteArrayInSpringServiceRequest() throws IOException { + testServiceByteArrayRequest("/spring/defaultContentType/responseEntityByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityByteArrayInSpringServiceResponse() throws IOException { + testServiceByteArrayResponse("/spring/defaultContentType/responseEntityByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseByteArrayInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testRestResponseByteArrayInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Optional + //@Test + public void testOptionalByteArrayInSpringServiceRequest() throws IOException { + testServiceByteArrayRequest("/spring/defaultContentType/optionalByteArray", APPLICATION_OCTET_STREAM); + } + + //@Test + public void testOptionalByteArrayInSpringServiceResponse() throws IOException { + testServiceByteArrayResponse("/spring/defaultContentType/optionalByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalByteArrayInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalByteArrayInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Uni + + @Test + public void testUniByteArrayInSpringServiceResponse() throws IOException { + testServiceByteArrayResponse("/spring/defaultContentType/uniByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testUniByteArrayInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletionStage + + @Test + public void testCompletionStageByteArrayInSpringServiceResponse() throws IOException { + testServiceByteArrayResponse("/spring/defaultContentType/completionStageByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletionStageByteArrayInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletedFuture + @Test + public void testCompletedFutureByteArrayInSpringServiceResponse() throws IOException { + testServiceByteArrayResponse("/spring/defaultContentType/completedFutureByteArray", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletedFutureByteArrayInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageByteArray/{fileName}", APPLICATION_OCTET_STREAM); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/FileTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/FileTest.java new file mode 100644 index 0000000000000..118562d81df1d --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/FileTest.java @@ -0,0 +1,110 @@ +package io.quarkus.it.openapi.spring; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractFileTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class FileTest extends AbstractFileTest { + + // Just File + @Test + public void testJustFileInSpringServiceRequest() throws IOException { + testServiceFileRequest("/spring/defaultContentType/justFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustFileInSpringServiceResponse() throws IOException { + testServiceFileResponse("/spring/defaultContentType/justFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustFileInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustFileInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // ResponseEntity + @Test + public void testResponseEntityFileInSpringServiceRequest() throws IOException { + testServiceFileRequest("/spring/defaultContentType/responseEntityFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityFileInSpringServiceResponse() throws IOException { + testServiceFileResponse("/spring/defaultContentType/responseEntityFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityFileInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityFileInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Optional + //@Test + public void testOptionalFileInSpringServiceRequest() throws IOException { + testServiceFileRequest("/spring/defaultContentType/optionalFile", APPLICATION_OCTET_STREAM); + } + + //@Test + public void testOptionalFileInSpringServiceResponse() throws IOException { + testServiceFileResponse("/spring/defaultContentType/optionalFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalFileInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalFileInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Uni + + @Test + public void testUniFileInSpringServiceResponse() throws IOException { + testServiceFileResponse("/spring/defaultContentType/uniFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testUniFileInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletionStage + + @Test + public void testCompletionStageFileInSpringServiceResponse() throws IOException { + testServiceFileResponse("/spring/defaultContentType/completionStageFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletionStageFileInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageFile/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletedFuture + @Test + public void testCompletedFutureFileInSpringServiceResponse() throws IOException { + testServiceFileResponse("/spring/defaultContentType/completedFutureFile", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletedFutureFileInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageFile/{fileName}", APPLICATION_OCTET_STREAM); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/InputStreamTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/InputStreamTest.java new file mode 100644 index 0000000000000..b7c03a44ab09c --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/InputStreamTest.java @@ -0,0 +1,110 @@ +package io.quarkus.it.openapi.spring; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractInputStreamTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class InputStreamTest extends AbstractInputStreamTest { + + // Just InputStream + @Test + public void testJustInputStreamInSpringServiceRequest() throws IOException { + testServiceInputStreamRequest("/spring/defaultContentType/justInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJusInputStreamInSpringServiceResponse() throws IOException { + testServiceInputStreamResponse("/spring/defaultContentType/justInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustInputStreamInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustInputStreamInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // ResponseEntity + @Test + public void testResponseEntityInputStreamInSpringServiceRequest() throws IOException { + testServiceInputStreamRequest("/spring/defaultContentType/responseEntityInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityInputStreamInSpringServiceResponse() throws IOException { + testServiceInputStreamResponse("/spring/defaultContentType/responseEntityInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityInputStreamInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityInputStreamInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Optional + //@Test + public void testOptionalInputStreamInSpringServiceRequest() throws IOException { + testServiceInputStreamRequest("/spring/defaultContentType/optionalInputStream", APPLICATION_OCTET_STREAM); + } + + //@Test + public void testOptionalInputStreamInSpringServiceResponse() throws IOException { + testServiceInputStreamResponse("/spring/defaultContentType/optionalInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalInputStreamInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalInputStreamInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Uni + + @Test + public void testUniInputStreamInSpringServiceResponse() throws IOException { + testServiceInputStreamResponse("/spring/defaultContentType/uniInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testUniInputStreamInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletionStage + + @Test + public void testCompletionStageInputStreamInSpringServiceResponse() throws IOException { + testServiceInputStreamResponse("/spring/defaultContentType/completionStageInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletionStageInputStreamInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletedFuture + @Test + public void testCompletedFutureInputStreamInSpringServiceResponse() throws IOException { + testServiceInputStreamResponse("/spring/defaultContentType/completedFutureInputStream", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletedFutureInputStreamInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageInputStream/{fileName}", APPLICATION_OCTET_STREAM); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/IntegerTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/IntegerTest.java new file mode 100644 index 0000000000000..94e7cc9f1b702 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/IntegerTest.java @@ -0,0 +1,232 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class IntegerTest extends AbstractTest { + + // Just Integer + @Test + public void testJustIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testJustIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testJustIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justInteger", TEXT_PLAIN); + } + + @Test + public void testJustIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justInteger", TEXT_PLAIN); + } + + // Just int + @Test + public void testJustIntInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justInt", TEXT_PLAIN, "0"); + } + + @Test + public void testJustIntInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justInt", TEXT_PLAIN, "0"); + } + + @Test + public void testJustIntInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justInt", TEXT_PLAIN); + } + + @Test + public void testJustIntInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justInt", TEXT_PLAIN); + } + + // ResponseEntity + @Test + public void testResponseEntityIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/responseEntityInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testResponseEntityIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/responseEntityInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testResponseEntityIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityInteger", TEXT_PLAIN); + } + + @Test + public void testResponseEntityIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityInteger", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalInteger", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalInteger", TEXT_PLAIN); + } + + @Test + public void testOptionalIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalInteger", TEXT_PLAIN); + } + + // OptionalInt + //@Test + public void testOptionalIntInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalInt", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalIntInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalInt", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalIntInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalInt", TEXT_PLAIN); + } + + @Test + public void testOptionalIntInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalInt", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testUniIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniInteger", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStageInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageInteger", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFutureInteger", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageInteger", TEXT_PLAIN); + } + + // List + @Test + public void testListIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listInteger", APPLICATION_JSON); + } + + @Test + public void testListIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listInteger", APPLICATION_JSON); + } + + // Integer[] + @Test + public void testArrayIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayInteger", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayInteger", APPLICATION_JSON); + } + + @Test + public void testArrayIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayInteger", APPLICATION_JSON); + } + + // int[] + @Test + public void testArrayIntInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayInt", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayIntInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayInt", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayIntInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayInt", APPLICATION_JSON); + } + + @Test + public void testArrayIntInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayInt", APPLICATION_JSON); + } + + // Map + @Test + public void testMapIntegerInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/mapInteger", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapIntegerInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/mapInteger", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapIntegerInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/mapInteger", APPLICATION_JSON); + } + + @Test + public void testMapIntegerInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/mapInteger", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/LongTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/LongTest.java new file mode 100644 index 0000000000000..046de5dea3f18 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/LongTest.java @@ -0,0 +1,233 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class LongTest extends AbstractTest { + + // Just Long + @Test + public void testJustLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justLong", TEXT_PLAIN, "0"); + } + + @Test + public void testJustLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justLong", TEXT_PLAIN, "0"); + } + + @Test + public void testJustLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justLong", TEXT_PLAIN); + } + + @Test + public void testJustLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justLong", TEXT_PLAIN); + } + + // Just long + @Test + public void testJustPrimitiveLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justPrimitiveLong", TEXT_PLAIN, "0"); + } + + @Test + public void testJustPrimitiveLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justPrimitiveLong", TEXT_PLAIN, "0"); + } + + @Test + public void testJustPrimitiveLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justPrimitiveLong", TEXT_PLAIN); + } + + @Test + public void testJustPrimitiveLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justPrimitiveLong", TEXT_PLAIN); + } + + // ResponseEntity + @Test + public void testResponseEntityLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/responseEntityLong", TEXT_PLAIN, "0"); + } + + @Test + public void testResponseEntityLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/responseEntityLong", TEXT_PLAIN, "0"); + } + + @Test + public void testResponseEntityLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityLong", TEXT_PLAIN); + } + + @Test + public void testResponseEntityLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityLong", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalLong", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalLong", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalLong", TEXT_PLAIN); + } + + @Test + public void testOptionalLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalLong", TEXT_PLAIN); + } + + // OptionalLong + //@Test + public void testOptionalPrimitiveLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalPrimitiveLong", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalPrimitiveLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalPrimitiveLong", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalPrimitiveLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalPrimitiveLong", TEXT_PLAIN); + } + + @Test + public void testOptionalPrimitiveLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalPrimitiveLong", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniLong", TEXT_PLAIN, "0"); + } + + @Test + public void testUniLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniLong", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStageLong", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageLong", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFutureLong", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageLong", TEXT_PLAIN); + } + + // List + @Test + public void testListLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listLong", APPLICATION_JSON); + } + + @Test + public void testListLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listLong", APPLICATION_JSON); + } + + // Long[] + @Test + public void testArrayLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayLong", APPLICATION_JSON); + } + + @Test + public void testArrayLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayLong", APPLICATION_JSON); + } + + // long[] + @Test + public void testArrayPrimitiveLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayPrimitiveLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayPrimitiveLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayPrimitiveLong", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayPrimitiveLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayPrimitiveLong", APPLICATION_JSON); + } + + @Test + public void testArrayPrimitiveLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayPrimitiveLong", APPLICATION_JSON); + } + + // Map + @Test + public void testMapLongInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/mapLong", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapLongInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/mapLong", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapLongInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/mapLong", APPLICATION_JSON); + } + + @Test + public void testMapLongInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/mapLong", APPLICATION_JSON); + } + +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/PojoTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/PojoTest.java new file mode 100644 index 0000000000000..b94f41fc7ae81 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/PojoTest.java @@ -0,0 +1,175 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class PojoTest extends AbstractTest { + + // Just Pojo + @Test + public void testJustPojoInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justPojo", APPLICATION_JSON, createExpected("justPojo")); + } + + @Test + public void testJustPojoInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justPojo", APPLICATION_JSON, createExpected("justPojo")); + } + + @Test + public void testJustPojoInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justPojo", APPLICATION_JSON); + } + + @Test + public void testJustPojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justPojo", APPLICATION_JSON); + } + + // ResponseEntity + @Test + public void testResponseEntityPojoInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/responseEntityPojo", APPLICATION_JSON, + createExpected("responseEntityPojo")); + } + + @Test + public void testResponseEntityPojoInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/responseEntityPojo", APPLICATION_JSON, + createExpected("responseEntityPojo")); + } + + @Test + public void testResponseEntityPojoInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityPojo", APPLICATION_JSON); + } + + @Test + public void testResponseEntityPojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityPojo", APPLICATION_JSON); + } + + // Optional + @Test + public void testOptionalPojoInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalPojo", APPLICATION_JSON, createExpected("optionalPojo")); + } + + @Test + public void testOptionalPojoInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalPojo", APPLICATION_JSON, createExpected("optionalPojo")); + } + + @Test + public void testOptionalPojoInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalPojo", APPLICATION_JSON); + } + + @Test + public void testOptionalPojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalPojo", APPLICATION_JSON); + } + + // Uni + @Test + public void testUniPojoInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniPojo", APPLICATION_JSON, createExpected("uniPojo")); + } + + @Test + public void testUniPojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniPojo", APPLICATION_JSON); + } + + // CompletionStage + @Test + public void testCompletionStagePojoInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStagePojo", APPLICATION_JSON, + createExpected("completionStagePojo")); + } + + @Test + public void testCompletionStagePojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStagePojo", APPLICATION_JSON); + } + + // CompletedFuture + @Test + public void testCompletedFuturePojoInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFuturePojo", APPLICATION_JSON, + createExpected("completedFuturePojo")); + } + + @Test + public void testCompletedFuturePojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completedFuturePojo", APPLICATION_JSON); + } + + // List + @Test + public void testListPojoInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listPojo", APPLICATION_JSON, createExpectedList("listPojo")); + } + + @Test + public void testListPojoInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listPojo", APPLICATION_JSON, createExpectedList("listPojo")); + } + + @Test + public void testListPojoInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listPojo", APPLICATION_JSON); + } + + @Test + public void testListPojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listPojo", APPLICATION_JSON); + } + + // Pojo[] + @Test + public void testArrayPojoInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayPojo", APPLICATION_JSON, createExpectedList("arrayPojo")); + } + + @Test + public void testArrayPojoInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayPojo", APPLICATION_JSON, createExpectedList("arrayPojo")); + } + + @Test + public void testArrayPojoInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayPojo", APPLICATION_JSON); + } + + @Test + public void testArrayPojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayPojo", APPLICATION_JSON); + } + + // Map + @Test + public void testMapPojoInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/mapPojo", APPLICATION_JSON, createExpectedMap("mapPojo")); + } + + @Test + public void testMapPojoInSpringServiceResponse() { + + testServiceResponse("/spring/defaultContentType/mapPojo", APPLICATION_JSON, createExpectedMap("mapPojo")); + } + + @Test + public void testMapPojoInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/mapPojo", APPLICATION_JSON); + } + + @Test + public void testMapPojoInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/mapPojo", APPLICATION_JSON); + } + +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ReaderTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ReaderTest.java new file mode 100644 index 0000000000000..0a2c7231d8922 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ReaderTest.java @@ -0,0 +1,110 @@ +package io.quarkus.it.openapi.spring; + +import java.io.IOException; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractReaderTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class ReaderTest extends AbstractReaderTest { + + // Just Reader + @Test + public void testJustReaderInSpringServiceRequest() throws IOException { + testServiceReaderRequest("/spring/defaultContentType/justReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJusReaderInSpringServiceResponse() throws IOException { + testServiceReaderResponse("/spring/defaultContentType/justReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustReaderInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testJustReaderInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // ResponseEntity + @Test + public void testResponseEntityReaderInSpringServiceRequest() throws IOException { + testServiceReaderRequest("/spring/defaultContentType/responseEntityReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityReaderInSpringServiceResponse() throws IOException { + testServiceReaderResponse("/spring/defaultContentType/responseEntityReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityReaderInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testResponseEntityReaderInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Optional + //@Test + public void testOptionalReaderInSpringServiceRequest() throws IOException { + testServiceReaderRequest("/spring/defaultContentType/optionalReader", APPLICATION_OCTET_STREAM); + } + + //@Test + public void testOptionalReaderInSpringServiceResponse() throws IOException { + testServiceReaderResponse("/spring/defaultContentType/optionalReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalReaderInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testOptionalReaderInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // Uni + + @Test + public void testUniReaderInSpringServiceResponse() throws IOException { + testServiceReaderResponse("/spring/defaultContentType/uniReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testUniReaderInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletionStage + + @Test + public void testCompletionStageReaderInSpringServiceResponse() throws IOException { + testServiceReaderResponse("/spring/defaultContentType/completionStageReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletionStageReaderInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageReader/{fileName}", APPLICATION_OCTET_STREAM); + } + + // CompletedFuture + @Test + public void testCompletedFutureReaderInSpringServiceResponse() throws IOException { + testServiceReaderResponse("/spring/defaultContentType/completedFutureReader", APPLICATION_OCTET_STREAM); + } + + @Test + public void testCompletedFutureReaderInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageReader/{fileName}", APPLICATION_OCTET_STREAM); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ShortTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ShortTest.java new file mode 100644 index 0000000000000..c7b58ed5e81f9 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/ShortTest.java @@ -0,0 +1,212 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class ShortTest extends AbstractTest { + + // Just Short + //@Test + public void testJustShortInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justShort", TEXT_PLAIN, "0"); + } + + @Test + public void testJustShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justShort", TEXT_PLAIN, "0"); + } + + @Test + public void testJustShortInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justShort", TEXT_PLAIN); + } + + @Test + public void testJustShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justShort", TEXT_PLAIN); + } + + // Just short + @Test + public void testJustPrimitiveShortInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justPrimitiveShort", TEXT_PLAIN, "0"); + } + + @Test + public void testJustPrimitiveShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justPrimitiveShort", TEXT_PLAIN, "0"); + } + + @Test + public void testJustPrimitiveShortInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justPrimitiveShort", TEXT_PLAIN); + } + + @Test + public void testJustPrimitiveShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justPrimitiveShort", TEXT_PLAIN); + } + + // ResponseEntity + //@Test + public void testResponseEntityShortInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/responseEntityShort", TEXT_PLAIN, "0"); + } + + @Test + public void testResponseEntityShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/responseEntityShort", TEXT_PLAIN, "0"); + } + + @Test + public void testResponseEntityShortInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityShort", TEXT_PLAIN); + } + + @Test + public void testResponseEntityShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityShort", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalShortInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalShort", TEXT_PLAIN, "0"); + } + + //@Test + public void testOptionalShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalShort", TEXT_PLAIN, "0"); + } + + @Test + public void testOptionalShortInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalShort", TEXT_PLAIN); + } + + @Test + public void testOptionalShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalShort", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniShort", TEXT_PLAIN, "0"); + } + + @Test + public void testUniShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniShort", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStageShort", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletionStageShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageShort", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFutureShort", TEXT_PLAIN, "0"); + } + + @Test + public void testCompletedFutureShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageShort", TEXT_PLAIN); + } + + // List + @Test + public void testListShortInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testListShortInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listShort", APPLICATION_JSON); + } + + @Test + public void testListShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listShort", APPLICATION_JSON); + } + + // Short[] + @Test + public void testArrayShortInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayShortInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayShort", APPLICATION_JSON); + } + + @Test + public void testArrayShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayShort", APPLICATION_JSON); + } + + // long[] + @Test + public void testArrayPrimitiveShortInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayPrimitiveShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayPrimitiveShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayPrimitiveShort", APPLICATION_JSON, "[0]"); + } + + @Test + public void testArrayPrimitiveShortInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayPrimitiveShort", APPLICATION_JSON); + } + + @Test + public void testArrayPrimitiveShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayPrimitiveShort", APPLICATION_JSON); + } + + // Map + @Test + public void testMapShortInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/mapShort", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapShortInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/mapShort", APPLICATION_JSON, "{\"0\":0}"); + } + + @Test + public void testMapShortInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/mapShort", APPLICATION_JSON); + } + + @Test + public void testMapShortInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/mapShort", APPLICATION_JSON); + } + +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/StringTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/StringTest.java new file mode 100644 index 0000000000000..3322e7bda0992 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/StringTest.java @@ -0,0 +1,169 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class StringTest extends AbstractTest { + + // Just String + @Test + public void testJustStringInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justString", TEXT_PLAIN, "justString"); + } + + @Test + public void testJustStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justString", TEXT_PLAIN, "justString"); + } + + @Test + public void testJustStringInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justString", TEXT_PLAIN); + } + + @Test + public void testJustStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justString", TEXT_PLAIN); + } + + // ResponseEntity + @Test + public void testResponseEntityStringInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/responseEntityString", TEXT_PLAIN, "responseEntityString"); + } + + @Test + public void testResponseEntityStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/responseEntityString", TEXT_PLAIN, "responseEntityString"); + } + + @Test + public void testResponseEntityStringInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/responseEntityString", TEXT_PLAIN); + } + + @Test + public void testResponseEntityStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/responseEntityString", TEXT_PLAIN); + } + + // Optional + //@Test + public void testOptionalStringInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalString", TEXT_PLAIN, "optionalString"); + } + + //@Test + public void testOptionalStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalString", TEXT_PLAIN, "optionalString"); + } + + @Test + public void testOptionalStringInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalString", TEXT_PLAIN); + } + + @Test + public void testOptionalStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalString", TEXT_PLAIN); + } + + // Uni + @Test + public void testUniStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniString", TEXT_PLAIN, "uniString"); + } + + @Test + public void testUniStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniString", TEXT_PLAIN); + } + + // CompletionStage + @Test + public void testCompletionStageStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStageString", TEXT_PLAIN, "completionStageString"); + } + + @Test + public void testCompletionStageStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageString", TEXT_PLAIN); + } + + // CompletedFuture + @Test + public void testCompletedFutureStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFutureString", TEXT_PLAIN, "completedFutureString"); + } + + @Test + public void testCompletedFutureStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completedFutureString", TEXT_PLAIN); + } + + // List + @Test + public void testListStringInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listString", APPLICATION_JSON, "[\"listString\"]"); + } + + @Test + public void testListStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listString", APPLICATION_JSON, "[\"listString\"]"); + } + + @Test + public void testListStringInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listString", APPLICATION_JSON); + } + + @Test + public void testListStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listString", APPLICATION_JSON); + } + + // String[] + @Test + public void testArrayStringInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayString", APPLICATION_JSON, "[\"arrayString\"]"); + } + + @Test + public void testArrayStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayString", APPLICATION_JSON, "[\"arrayString\"]"); + } + + @Test + public void testArrayStringInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayString", APPLICATION_JSON); + } + + @Test + public void testArrayStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayString", APPLICATION_JSON); + } + + // Map + @Test + public void testMapStringInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/mapString", APPLICATION_JSON, "{\"mapString\":\"mapString\"}"); + } + + @Test + public void testMapStringInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/mapString", APPLICATION_JSON, "{\"mapString\":\"mapString\"}"); + } + + @Test + public void testMapStringInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/mapString", APPLICATION_JSON); + } + + @Test + public void testMapStringInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/mapString", APPLICATION_JSON); + } +} diff --git a/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/URLTest.java b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/URLTest.java new file mode 100644 index 0000000000000..0e9f1bc07a2e3 --- /dev/null +++ b/integration-tests/openapi/src/test/java/io/quarkus/it/openapi/spring/URLTest.java @@ -0,0 +1,169 @@ +package io.quarkus.it.openapi.spring; + +import org.junit.jupiter.api.Test; + +import io.quarkus.it.openapi.AbstractTest; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class URLTest extends AbstractTest { + + // Just URL + @Test + public void testJustURLInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/justURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testJustURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/justURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testJustURLInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/justURL", APPLICATION_JSON); + } + + @Test + public void testJustURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/justURL", APPLICATION_JSON); + } + + // RestResponse + @Test + public void testRestResponseURLInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/restResponseURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testRestResponseURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/restResponseURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testRestResponseURLInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/restResponseURL", APPLICATION_JSON); + } + + @Test + public void testRestResponseURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/restResponseURL", APPLICATION_JSON); + } + + // Optional + // @Test + public void testOptionalURLInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/optionalURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + // @Test + public void testOptionalURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/optionalURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testOptionalURLInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/optionalURL", APPLICATION_JSON); + } + + @Test + public void testOptionalURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/optionalURL", APPLICATION_JSON); + } + + // Uni + @Test + public void testUniURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/uniURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testUniURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/uniURL", APPLICATION_JSON); + } + + // CompletionStage + @Test + public void testCompletionStageURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completionStageURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testCompletionStageURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completionStageURL", APPLICATION_JSON); + } + + // CompletedFuture + @Test + public void testCompletedFutureURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/completedFutureURL", APPLICATION_JSON, "\"https://quarkus.io/\""); + } + + @Test + public void testCompletedFutureURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/completedFutureURL", APPLICATION_JSON); + } + + // List + @Test + public void testListURLInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/listURL", APPLICATION_JSON, "[\"https://quarkus.io/\"]"); + } + + @Test + public void testListURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/listURL", APPLICATION_JSON, "[\"https://quarkus.io/\"]"); + } + + @Test + public void testListURLInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/listURL", APPLICATION_JSON); + } + + @Test + public void testListURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/listURL", APPLICATION_JSON); + } + + // URL[] + @Test + public void testArrayURLInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/arrayURL", APPLICATION_JSON, "[\"https://quarkus.io/\"]"); + } + + @Test + public void testArrayURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/arrayURL", APPLICATION_JSON, "[\"https://quarkus.io/\"]"); + } + + @Test + public void testArrayURLInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/arrayURL", APPLICATION_JSON); + } + + @Test + public void testArrayURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/arrayURL", APPLICATION_JSON); + } + + // Map + @Test + public void testMapURLInSpringServiceRequest() { + testServiceRequest("/spring/defaultContentType/mapURL", APPLICATION_JSON, "{\"mapURL\":\"https://quarkus.io/\"}"); + } + + @Test + public void testMapURLInSpringServiceResponse() { + testServiceResponse("/spring/defaultContentType/mapURL", APPLICATION_JSON, "{\"mapURL\":\"https://quarkus.io/\"}"); + } + + @Test + public void testMapURLInSpringOpenAPIRequest() { + testOpenAPIRequest("/spring/defaultContentType/mapURL", APPLICATION_JSON); + } + + @Test + public void testMapURLInSpringOpenAPIResponse() { + testOpenAPIResponse("/spring/defaultContentType/mapURL", APPLICATION_JSON); + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 4ffed18b7049f..b623b32388ee6 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -263,6 +263,7 @@ oidc-client-wiremock oidc-token-propagation oidc-token-propagation-reactive + openapi smallrye-jwt-oidc-webapp smallrye-jwt-token-propagation oidc-code-flow