Class ModelRequestSerializationCallback

java.lang.Object
ai.timefold.solver.service.test.impl.quarkus.ModelRequestSerializationCallback
All Implemented Interfaces:
io.quarkus.test.junit.callback.QuarkusTestBeforeClassCallback

public class ModelRequestSerializationCallback extends Object implements io.quarkus.test.junit.callback.QuarkusTestBeforeClassCallback
The default RestAssured object mapper serializes LocalDate as an array and by that fails platform schema validation.

This Quarkus test before class callback configures RestAssuredConfig.objectMapperConfig(ObjectMapperConfig) to use the ObjectMapper customized with the SDK defaults:

  • Enables failing on unknown properties.
  • Serialize only non-null properties by default JsonInclude.Include.NON_NULL.
  • Serialize datetime and duration objects as strings, rather than numeric timestamps.
  • Prevents adjusting the time zone offset values to the context time zone when serializing/deserializing.

A concrete model can opt-out of this behaviour by setting the system property "ai.timefold.platform.model.test.serialization.callback.disable" to true.

Note: A plain jUnit extension does not work due to classloading issues because Quarkus has to run tests in a custom classloader which JUnit is not aware of.
  • Field Details

    • LOGGER

      public static final org.slf4j.Logger LOGGER
    • DISABLE_SERIALIZATION_CALLBACK_PROPERTY_NAME

      public static final String DISABLE_SERIALIZATION_CALLBACK_PROPERTY_NAME
      See Also:
  • Constructor Details

    • ModelRequestSerializationCallback

      public ModelRequestSerializationCallback()
  • Method Details

    • beforeClass

      public void beforeClass(Class<?> testClass)
      Specified by:
      beforeClass in interface io.quarkus.test.junit.callback.QuarkusTestBeforeClassCallback