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.
add test for custom serializer usage when reflection free serializati…
…on is enabled
- Loading branch information
1 parent
8d1764e
commit 18ccfcf
Showing
4 changed files
with
79 additions
and
3 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...on-tests/mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/product/Product.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,16 @@ | ||
package io.quarkus.it.mongodb.panache.product; | ||
|
||
import org.bson.types.ObjectId; | ||
|
||
public class Product { | ||
|
||
private ObjectId id; | ||
|
||
public ObjectId getId() { | ||
return id; | ||
} | ||
|
||
public void setId(ObjectId id) { | ||
this.id = id; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
.../mongodb-panache/src/main/java/io/quarkus/it/mongodb/panache/product/ProductResource.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,21 @@ | ||
package io.quarkus.it.mongodb.panache.product; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
|
||
import org.bson.types.ObjectId; | ||
|
||
@Path("/products") | ||
@RequestScoped | ||
public class ProductResource { | ||
|
||
public static final String PRODUCT_ID = "66fe4c9df58b4c036cc92298"; | ||
|
||
@GET | ||
public Product get() { | ||
var product = new Product(); | ||
product.setId(new ObjectId(PRODUCT_ID)); | ||
return product; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...-panache/src/test/java/io/quarkus/it/mongodb/panache/ReflectionFreeSerializationTest.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,39 @@ | ||
package io.quarkus.it.mongodb.panache; | ||
|
||
import java.util.Map; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.it.mongodb.panache.product.ProductResource; | ||
import io.quarkus.it.mongodb.panache.reactive.ReactiveMongodbPanacheResourceTest; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.QuarkusTestProfile; | ||
import io.quarkus.test.junit.TestProfile; | ||
import io.restassured.RestAssured; | ||
|
||
@QuarkusTest | ||
@TestProfile(ReflectionFreeSerializationTest.ReflectionFreeSerializationProfile.class) | ||
public class ReflectionFreeSerializationTest { | ||
|
||
@Test | ||
void testObjectICustomSerialization() { | ||
RestAssured.get("/products") | ||
.then() | ||
.statusCode(200) | ||
.body("id", Matchers.equalTo(ProductResource.PRODUCT_ID)); | ||
} | ||
|
||
@Test | ||
void testReactiveBookEntity() throws InterruptedException { | ||
ReactiveMongodbPanacheResourceTest.callReactiveBookEndpoint("/reactive/books/entity"); | ||
} | ||
|
||
public static class ReflectionFreeSerializationProfile implements QuarkusTestProfile { | ||
|
||
@Override | ||
public Map<String, String> getConfigOverrides() { | ||
return Map.of("quarkus.rest.jackson.optimization.enable-reflection-free-serializers", "true"); | ||
} | ||
} | ||
} |
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