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.
Properly support @JSONVIEW on Resource class
Fixes: quarkusio#35639
- Loading branch information
Showing
7 changed files
with
113 additions
and
14 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
81 changes: 81 additions & 0 deletions
81
...c/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/JsonViewOnClassTest.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,81 @@ | ||
package io.quarkus.resteasy.reactive.jackson.deployment.test; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import com.fasterxml.jackson.annotation.JsonView; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
class JsonViewOnClassTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(User.class, Views.class, Public.class, Private.class, Mixed.class); | ||
} | ||
}); | ||
|
||
@Test | ||
void test() { | ||
given().accept("application/json").get("public") | ||
.then() | ||
.statusCode(200) | ||
.body(not(containsString("1")), containsString("test")); | ||
|
||
given().accept("application/json").get("mixed") | ||
.then() | ||
.statusCode(200) | ||
.body(containsString("1"), containsString("test")); | ||
|
||
given().accept("application/json").get("private") | ||
.then() | ||
.statusCode(200) | ||
.body(containsString("1"), containsString("test")); | ||
} | ||
|
||
@JsonView(Views.Public.class) | ||
@Path("public") | ||
public static class Public { | ||
|
||
@GET | ||
public User get() { | ||
return User.testUser(); | ||
} | ||
} | ||
|
||
@JsonView(Views.Private.class) | ||
@Path("private") | ||
public static class Private { | ||
|
||
@GET | ||
public User get() { | ||
return User.testUser(); | ||
} | ||
} | ||
|
||
@JsonView(Views.Public.class) | ||
@Path("mixed") | ||
public static class Mixed { | ||
|
||
@GET | ||
@JsonView(Views.Private.class) | ||
public User get() { | ||
return User.testUser(); | ||
} | ||
} | ||
} |
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
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