Description
openedon Nov 13, 2024
Describe the bug
A Quarkus managed Jackson ObjectMapper
is unable to deserialize the HalEntityWrapper
type.
I am using this capability in a QuarkusTest
to make assertions about the body of the response returned by the Quarkus app.
Expected behavior
The Quarkus managed Jackson ObjectMapper
may deserialize objects of type HalEntityWrapper
.
@QuarkusTest
class GreetingResourceTest {
@Inject ObjectMapper mapper;
@BeforeEach
void before() {
RestAssured.config =
RestAssuredConfig.config()
.objectMapperConfig(
new ObjectMapperConfig().jackson2ObjectMapperFactory((type, s) -> mapper));
}
@Test
void test() {
final var wrapper =
given()
.queryParam("subject", "World")
.accept(RestMediaType.APPLICATION_HAL_JSON)
.when()
.get("/greeting")
.prettyPeek()
.then()
.statusCode(200)
.extract()
.as(new TypeRef<HalEntityWrapper<Greeting>>() {});
final var subject = wrapper.getEntity();
assertEquals(new Subject("World"), subject);
}
}
Actual behavior
Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `io.quarkus.hal.HalEntityWrapper` (no Creators, like default constructor, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]
How to Reproduce?
Reproducer attached. The following Quarkus test fails, because REST Assured cannot deserialize the response body using the Quarkus managed Jackson ObjectMapper
.
Output of uname -a
or ver
Darwin pixee-mbp-gilday.local 24.0.0 Darwin Kernel Version 24.0.0: Tue Sep 24 23:39:07 PDT 2024; root:xnu-11215.1.12~1/RELEASE_ARM64_T6000 arm64
Output of java -version
openjdk version "21.0.3" 2024-04-16 LTS OpenJDK Runtime Environment Temurin-21.0.3+9 (build 21.0.3+9-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.3+9 (build 21.0.3+9-LTS, mixed mode)
Quarkus version or git rev
3.16.2
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256) Maven home: /Users/jgilday/.m2/wrapper/dists/apache-maven-3.9.8-bin/337e6d14/apache-maven-3.9.8 Java version: 21.0.3, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-21.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "15.0.1", arch: "aarch64", family: "mac"
Additional information
No response