forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request quarkusio#43700 from danielbobbert/main
Use generic return type of method to construct proper Jackson writer
- Loading branch information
Showing
8 changed files
with
177 additions
and
2 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...t/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/PolymorphicBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.quarkus.resteasy.reactive.jackson.deployment.test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
|
||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = PolymorphicSub.class, name = "sub") | ||
}) | ||
public class PolymorphicBase { | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...c/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/PolymorphicEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.resteasy.reactive.jackson.deployment.test; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("poly") | ||
public class PolymorphicEndpoint { | ||
|
||
@Produces(MediaType.APPLICATION_JSON) | ||
@GET | ||
@Path("single") | ||
public PolymorphicBase getSingle() { | ||
return new PolymorphicSub(); | ||
} | ||
|
||
@Produces(MediaType.APPLICATION_JSON) | ||
@GET | ||
@Path("many") | ||
public List<PolymorphicBase> getMany() { | ||
return List.of(new PolymorphicSub(), new PolymorphicSub()); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...nt/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/PolymorphicSub.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.quarkus.resteasy.reactive.jackson.deployment.test; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
|
||
@JsonTypeName("sub") | ||
public class PolymorphicSub extends PolymorphicBase { | ||
|
||
} |
45 changes: 45 additions & 0 deletions
45
...t/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/PolymorphicTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.quarkus.resteasy.reactive.jackson.deployment.test; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class PolymorphicTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(PolymorphicEndpoint.class, PolymorphicBase.class, PolymorphicSub.class) | ||
.addAsResource(new StringAsset(""), "application.properties"); | ||
} | ||
}); | ||
|
||
@Test | ||
public void testSingle() { | ||
RestAssured.get("/poly/single") | ||
.then() | ||
.statusCode(200) | ||
.contentType("application/json") | ||
.body(Matchers.is("{\"type\":\"sub\"}")); | ||
} | ||
|
||
@Test | ||
public void testMany() { | ||
RestAssured.get("/poly/many") | ||
.then() | ||
.statusCode(200) | ||
.contentType("application/json") | ||
.body(Matchers.is("[{\"type\":\"sub\"},{\"type\":\"sub\"}]")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters