-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Register generic type in JAX-RS return type hierarchy for reflection
This is currently done only for the (most common) use case of having as single generic parameter in type hierarchy Fixes: #8849
- Loading branch information
Showing
7 changed files
with
130 additions
and
3 deletions.
There are no files selected for viewing
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
23 changes: 23 additions & 0 deletions
23
...sts/resteasy-jackson/src/main/java/io/quarkus/it/resteasy/jackson/generics/BaseClass.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,23 @@ | ||
package io.quarkus.it.resteasy.jackson.generics; | ||
|
||
public class BaseClass<T> { | ||
|
||
private String baseVariable; | ||
private T data; | ||
|
||
public String getBaseVariable() { | ||
return this.baseVariable; | ||
} | ||
|
||
public void setBaseVariable(String baseVariable) { | ||
this.baseVariable = baseVariable; | ||
} | ||
|
||
public T getData() { | ||
return this.data; | ||
} | ||
|
||
public void setData(T data) { | ||
this.data = data; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...resteasy-jackson/src/main/java/io/quarkus/it/resteasy/jackson/generics/ExtendedClass.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,14 @@ | ||
package io.quarkus.it.resteasy.jackson.generics; | ||
|
||
public class ExtendedClass extends BaseClass<MyData> { | ||
|
||
private String extendedVariable; | ||
|
||
public String getExtendedVariable() { | ||
return this.extendedVariable; | ||
} | ||
|
||
public void setExtendedVariable(String extendedVariable) { | ||
this.extendedVariable = extendedVariable; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...teasy-jackson/src/main/java/io/quarkus/it/resteasy/jackson/generics/GenericsResource.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,22 @@ | ||
package io.quarkus.it.resteasy.jackson.generics; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
@Path("/generics") | ||
public class GenericsResource { | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public ExtendedClass testExtendedClass() { | ||
final ExtendedClass c = new ExtendedClass(); | ||
c.setBaseVariable("myBaseVariable"); | ||
c.setExtendedVariable("myExtendedVariable"); | ||
final MyData d = new MyData(); | ||
d.setDataVariable("myData"); | ||
c.setData(d); | ||
return c; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...-tests/resteasy-jackson/src/main/java/io/quarkus/it/resteasy/jackson/generics/MyData.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,14 @@ | ||
package io.quarkus.it.resteasy.jackson.generics; | ||
|
||
public class MyData { | ||
|
||
private String dataVariable; | ||
|
||
public String getDataVariable() { | ||
return this.dataVariable; | ||
} | ||
|
||
public void setDataVariable(String dataVariable) { | ||
this.dataVariable = dataVariable; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...sts/resteasy-jackson/src/test/java/io/quarkus/it/resteasy/jackson/GenericsResourceIT.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,7 @@ | ||
package io.quarkus.it.resteasy.jackson; | ||
|
||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
|
||
@QuarkusIntegrationTest | ||
public class GenericsResourceIT extends GenericsResourceTest { | ||
} |
25 changes: 25 additions & 0 deletions
25
...s/resteasy-jackson/src/test/java/io/quarkus/it/resteasy/jackson/GenericsResourceTest.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,25 @@ | ||
package io.quarkus.it.resteasy.jackson; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.it.resteasy.jackson.generics.ExtendedClass; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class GenericsResourceTest { | ||
|
||
@Test | ||
public void testExtendedEndpoint() { | ||
ExtendedClass response = given() | ||
.when().get("/generics") | ||
.then() | ||
.statusCode(200) | ||
.extract().body().as(ExtendedClass.class); | ||
assertEquals("myBaseVariable", response.getBaseVariable()); | ||
assertEquals("myExtendedVariable", response.getExtendedVariable()); | ||
assertEquals("myData", response.getData().getDataVariable()); | ||
} | ||
} |