Class WithObjectMapper

java.lang.Object
fr.ght1pc9kc.testy.core.extensions.WithObjectMapper
All Implemented Interfaces:
org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension, org.junit.jupiter.api.extension.ParameterResolver

public class WithObjectMapper extends Object implements org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.ParameterResolver
Allow getting a Jackson ObjectMapper in Tests.

By default this extension search and register modules in classpath, but it is possible to pass specific module list at creation time.

The SerializationFeature.WRITE_DATES_AS_TIMESTAMPS feature is disable, only no null properties was included in serialization.

  • Constructor Details

    • WithObjectMapper

      public WithObjectMapper()
  • Method Details

    • builder

    • beforeAll

      public void beforeAll(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      beforeAll in interface org.junit.jupiter.api.extension.BeforeAllCallback
    • beforeEach

      public void beforeEach(org.junit.jupiter.api.extension.ExtensionContext context)
      Specified by:
      beforeEach in interface org.junit.jupiter.api.extension.BeforeEachCallback
    • supportsParameter

      public boolean supportsParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
      Specified by:
      supportsParameter in interface org.junit.jupiter.api.extension.ParameterResolver
    • resolveParameter

      public Object resolveParameter(org.junit.jupiter.api.extension.ParameterContext parameterContext, org.junit.jupiter.api.extension.ExtensionContext extensionContext)
      Specified by:
      resolveParameter in interface org.junit.jupiter.api.extension.ParameterResolver
    • getObjectMapper

      public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper(org.junit.jupiter.api.extension.ExtensionContext context)