forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes: quarkusio#35871
- Loading branch information
Showing
2 changed files
with
78 additions
and
7 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
64 changes: 64 additions & 0 deletions
64
...a/io/quarkus/resteasy/reactive/jackson/deployment/test/JsonViewOnMethodParameterTest.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,64 @@ | ||
package io.quarkus.resteasy.reactive.jackson.deployment.test; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static jakarta.ws.rs.core.Response.Status.CREATED; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
import java.util.function.Supplier; | ||
|
||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
import org.jboss.resteasy.reactive.RestResponse; | ||
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; | ||
|
||
public class JsonViewOnMethodParameterTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(User.class, Views.class, Resource.class); | ||
} | ||
}); | ||
|
||
@Test | ||
public void test() { | ||
given().accept("application/json") | ||
.contentType("application/json") | ||
.body(""" | ||
{ | ||
"id": 1, | ||
"name": "Foo" | ||
} | ||
""") | ||
.post("test") | ||
.then() | ||
.statusCode(201) | ||
.body(not(containsString("1")), containsString("Foo")); | ||
} | ||
|
||
@Path("test") | ||
public static class Resource { | ||
|
||
@POST | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
public RestResponse<User> create(@JsonView(Views.Public.class) User user) { | ||
return RestResponse.status(CREATED, user); | ||
} | ||
} | ||
} |