From 1b4c4ca8a339d3fce2accc48932e6e82be25c0c9 Mon Sep 17 00:00:00 2001 From: Tuomo Ala-Vannesluoma Date: Wed, 23 Aug 2023 12:35:58 +0300 Subject: [PATCH] Provide engine ObjectMapper via custom interface (#615) * Bring back Primary ObjectMapper annotation * Provide ObjectMapper to engine via custom interface to avoid multiple ObjectMapper beans --------- Co-authored-by: Tuomo Ala-Vannesluoma --- .../engine/config/EngineConfiguration.java | 7 +++-- .../io/nflow/engine/guice/EngineModule.java | 6 ++-- .../internal/dao/WorkflowDefinitionDao.java | 5 +-- .../internal/workflow/ObjectStringMapper.java | 5 +-- .../config/EngineConfigurationTest.java | 2 +- .../nflow/engine/guice/EngineModuleTest.java | 3 +- .../internal/dao/DaoTestConfiguration.java | 7 +++-- .../executor/WorkflowStateProcessorTest.java | 2 +- .../workflow/ObjectStringMapperTest.java | 2 +- .../full-stack-kotlin/src/NflowApplication.kt | 26 +++------------- .../fullstack/gradle/DemoApplication.java | 31 ++----------------- .../fullstack/maven/DemoApplication.java | 31 ++----------------- .../nflow/rest/config/RestConfiguration.java | 19 +++++------- .../CreateWorkflowConverterTest.java | 2 +- .../config/jaxrs/RestConfigurationTest.java | 2 +- .../jaxrs/WorkflowInstanceResourceTest.java | 2 +- 16 files changed, 45 insertions(+), 107 deletions(-) diff --git a/nflow-engine/src/main/java/io/nflow/engine/config/EngineConfiguration.java b/nflow-engine/src/main/java/io/nflow/engine/config/EngineConfiguration.java index 5cf151d87..ac597844b 100644 --- a/nflow-engine/src/main/java/io/nflow/engine/config/EngineConfiguration.java +++ b/nflow-engine/src/main/java/io/nflow/engine/config/EngineConfiguration.java @@ -4,6 +4,7 @@ import static java.lang.Runtime.getRuntime; import java.util.concurrent.ThreadFactory; +import java.util.function.Supplier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; @@ -26,6 +27,8 @@ @ComponentScan("io.nflow.engine") public class EngineConfiguration { + public interface EngineObjectMapperSupplier extends Supplier {} + /** * Creates a workflow instance executor for processing workflow instances. * @@ -62,11 +65,11 @@ public ThreadFactory nflowThreadFactory() { */ @Bean @NFlow - public ObjectMapper nflowObjectMapper() { + public EngineObjectMapperSupplier nflowObjectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(NON_EMPTY); mapper.registerModule(new JodaModule()); - return mapper; + return () -> mapper; } /** diff --git a/nflow-engine/src/main/java/io/nflow/engine/guice/EngineModule.java b/nflow-engine/src/main/java/io/nflow/engine/guice/EngineModule.java index 180b7eb85..09f0441ad 100644 --- a/nflow-engine/src/main/java/io/nflow/engine/guice/EngineModule.java +++ b/nflow-engine/src/main/java/io/nflow/engine/guice/EngineModule.java @@ -21,12 +21,12 @@ import org.springframework.transaction.interceptor.TransactionInterceptor; import org.springframework.transaction.support.TransactionTemplate; -import com.fasterxml.jackson.databind.ObjectMapper; import com.google.inject.AbstractModule; import com.google.inject.Provides; import com.google.inject.Singleton; import io.nflow.engine.config.EngineConfiguration; +import io.nflow.engine.config.EngineConfiguration.EngineObjectMapperSupplier; import io.nflow.engine.config.NFlow; import io.nflow.engine.config.db.DatabaseConfiguration; import io.nflow.engine.config.db.Db2DatabaseConfiguration; @@ -95,8 +95,8 @@ public WorkflowInstanceExecutor nflowExecutor(@NFlow ThreadFactory factory, Envi @Provides @NFlow @Singleton - public ObjectMapper nflowObjectMapper() { - return engineConfiguration.nflowObjectMapper(); + public EngineObjectMapperSupplier nflowObjectMapper() { + return () -> engineConfiguration.nflowObjectMapper().get(); } @Provides diff --git a/nflow-engine/src/main/java/io/nflow/engine/internal/dao/WorkflowDefinitionDao.java b/nflow-engine/src/main/java/io/nflow/engine/internal/dao/WorkflowDefinitionDao.java index 730b2137f..031a3d2c4 100644 --- a/nflow-engine/src/main/java/io/nflow/engine/internal/dao/WorkflowDefinitionDao.java +++ b/nflow-engine/src/main/java/io/nflow/engine/internal/dao/WorkflowDefinitionDao.java @@ -20,6 +20,7 @@ import java.util.Map; import java.util.Map.Entry; +import io.nflow.engine.config.EngineConfiguration.EngineObjectMapperSupplier; import jakarta.inject.Inject; import org.slf4j.Logger; @@ -52,11 +53,11 @@ public class WorkflowDefinitionDao { @Inject public WorkflowDefinitionDao(SQLVariants sqlVariants, @NFlow NamedParameterJdbcTemplate nflowNamedParameterJdbcTemplate, - @NFlow ObjectMapper nflowObjectMapper, + @NFlow EngineObjectMapperSupplier nflowObjectMapper, ExecutorDao executorDao) { this.sqlVariants = sqlVariants; this.namedJdbc = nflowNamedParameterJdbcTemplate; - this.nflowObjectMapper = nflowObjectMapper; + this.nflowObjectMapper = nflowObjectMapper.get(); this.executorInfo = executorDao; } diff --git a/nflow-engine/src/main/java/io/nflow/engine/internal/workflow/ObjectStringMapper.java b/nflow-engine/src/main/java/io/nflow/engine/internal/workflow/ObjectStringMapper.java index 3de4235b0..62bb47f7e 100644 --- a/nflow-engine/src/main/java/io/nflow/engine/internal/workflow/ObjectStringMapper.java +++ b/nflow-engine/src/main/java/io/nflow/engine/internal/workflow/ObjectStringMapper.java @@ -5,6 +5,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Type; +import io.nflow.engine.config.EngineConfiguration.EngineObjectMapperSupplier; import jakarta.inject.Inject; import org.springframework.stereotype.Component; @@ -24,8 +25,8 @@ public class ObjectStringMapper { private final ObjectMapper mapper; @Inject - public ObjectStringMapper(@NFlow ObjectMapper nflowObjectMapper) { - this.mapper = nflowObjectMapper; + public ObjectStringMapper(@NFlow EngineObjectMapperSupplier nflowObjectMapper) { + this.mapper = nflowObjectMapper.get(); } @SuppressWarnings("unchecked") diff --git a/nflow-engine/src/test/java/io/nflow/engine/config/EngineConfigurationTest.java b/nflow-engine/src/test/java/io/nflow/engine/config/EngineConfigurationTest.java index 0a596abf8..66ae15818 100644 --- a/nflow-engine/src/test/java/io/nflow/engine/config/EngineConfigurationTest.java +++ b/nflow-engine/src/test/java/io/nflow/engine/config/EngineConfigurationTest.java @@ -70,7 +70,7 @@ public void nflowThreadFactoryInstantiated() { @Test public void nflowObjectMapperInstantiated() { - ObjectMapper mapper = configuration.nflowObjectMapper(); + ObjectMapper mapper = configuration.nflowObjectMapper().get(); assertThat(mapper.canSerialize(DateTime.class), is(true)); assertThat(mapper.getSerializationConfig().getDefaultPropertyInclusion().getValueInclusion(), is(JsonInclude.Include.NON_EMPTY)); diff --git a/nflow-engine/src/test/java/io/nflow/engine/guice/EngineModuleTest.java b/nflow-engine/src/test/java/io/nflow/engine/guice/EngineModuleTest.java index 21db966eb..6353b4c6e 100644 --- a/nflow-engine/src/test/java/io/nflow/engine/guice/EngineModuleTest.java +++ b/nflow-engine/src/test/java/io/nflow/engine/guice/EngineModuleTest.java @@ -27,6 +27,7 @@ import com.zaxxer.hikari.HikariDataSource; import io.nflow.engine.config.EngineConfiguration; +import io.nflow.engine.config.EngineConfiguration.EngineObjectMapperSupplier; import io.nflow.engine.config.NFlow; import io.nflow.engine.config.db.H2DatabaseConfiguration; import io.nflow.engine.internal.executor.WorkflowInstanceExecutor; @@ -62,7 +63,7 @@ public void testEngineConfiguration() { assertThat(((CustomizableThreadFactory) factory).getThreadNamePrefix(), is("nflow-executor-")); assertThat(((CustomizableThreadFactory) factory).getThreadGroup().getName(), is("nflow")); - ObjectMapper mapper = injector.getInstance(Key.get(ObjectMapper.class, NFlow.class)); + ObjectMapper mapper = injector.getInstance(Key.get(EngineObjectMapperSupplier.class, NFlow.class)).get(); assertThat(mapper.canSerialize(DateTime.class), is(true)); assertThat(mapper.getSerializationConfig().getDefaultPropertyInclusion().getValueInclusion(), is(JsonInclude.Include.NON_EMPTY)); diff --git a/nflow-engine/src/test/java/io/nflow/engine/internal/dao/DaoTestConfiguration.java b/nflow-engine/src/test/java/io/nflow/engine/internal/dao/DaoTestConfiguration.java index 734ac006f..39f132bfb 100644 --- a/nflow-engine/src/test/java/io/nflow/engine/internal/dao/DaoTestConfiguration.java +++ b/nflow-engine/src/test/java/io/nflow/engine/internal/dao/DaoTestConfiguration.java @@ -4,6 +4,7 @@ import javax.sql.DataSource; +import io.nflow.engine.config.EngineConfiguration.EngineObjectMapperSupplier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.context.annotation.PropertySource; @@ -53,7 +54,7 @@ public WorkflowInstanceDao workflowInstanceDao(SQLVariants sqlVariants, @Bean public WorkflowDefinitionDao workflowDefinitionDao(SQLVariants sqlVariants, @NFlow NamedParameterJdbcTemplate nflowNamedParameterJdbcTemplate, - @NFlow ObjectMapper nflowObjectMapper, + @NFlow EngineObjectMapperSupplier nflowObjectMapper, ExecutorDao executorDao) { return new WorkflowDefinitionDao(sqlVariants, nflowNamedParameterJdbcTemplate, @@ -94,11 +95,11 @@ public PlatformTransactionManager transactionManager(DataSource ds) { @Bean @NFlow - public ObjectMapper objectMapper() { + public EngineObjectMapperSupplier objectMapper() { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(NON_EMPTY); mapper.registerModule(new JodaModule()); - return mapper; + return () -> mapper; } @Bean diff --git a/nflow-engine/src/test/java/io/nflow/engine/internal/executor/WorkflowStateProcessorTest.java b/nflow-engine/src/test/java/io/nflow/engine/internal/executor/WorkflowStateProcessorTest.java index 391247858..4bdb98eab 100644 --- a/nflow-engine/src/test/java/io/nflow/engine/internal/executor/WorkflowStateProcessorTest.java +++ b/nflow-engine/src/test/java/io/nflow/engine/internal/executor/WorkflowStateProcessorTest.java @@ -176,7 +176,7 @@ public class WorkflowStateProcessorTest extends BaseNflowTest { @Captor ArgumentCaptor> workflows; - ObjectStringMapper objectMapper = new ObjectStringMapper(new ObjectMapper()); + ObjectStringMapper objectMapper = new ObjectStringMapper(ObjectMapper::new); WorkflowStateProcessor executor; diff --git a/nflow-engine/src/test/java/io/nflow/engine/internal/workflow/ObjectStringMapperTest.java b/nflow-engine/src/test/java/io/nflow/engine/internal/workflow/ObjectStringMapperTest.java index 094122f88..663a6d8b7 100644 --- a/nflow-engine/src/test/java/io/nflow/engine/internal/workflow/ObjectStringMapperTest.java +++ b/nflow-engine/src/test/java/io/nflow/engine/internal/workflow/ObjectStringMapperTest.java @@ -20,7 +20,7 @@ @ExtendWith(MockitoExtension.class) class ObjectStringMapperTest { - private final ObjectStringMapper mapper = new ObjectStringMapper(new ObjectMapper()); + private final ObjectStringMapper mapper = new ObjectStringMapper(ObjectMapper::new); @Mock StateExecution execution; diff --git a/nflow-examples/spring-boot/full-stack-kotlin/src/NflowApplication.kt b/nflow-examples/spring-boot/full-stack-kotlin/src/NflowApplication.kt index 8dcac3857..f1dc8ab85 100644 --- a/nflow-examples/spring-boot/full-stack-kotlin/src/NflowApplication.kt +++ b/nflow-examples/spring-boot/full-stack-kotlin/src/NflowApplication.kt @@ -1,26 +1,18 @@ package nflow.kotlin -import com.fasterxml.jackson.databind.DeserializationFeature -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.SerializationFeature -import io.nflow.engine.config.EngineConfiguration -import io.nflow.engine.config.NFlow import io.nflow.engine.service.WorkflowInstanceService import io.nflow.engine.workflow.instance.WorkflowInstanceFactory -import io.nflow.rest.config.NflowRestApiPropertiesConfiguration import io.nflow.rest.config.RestConfiguration -import io.nflow.rest.config.RestConfiguration.REST_OBJECT_MAPPER import jakarta.inject.Inject -import jakarta.inject.Named import nflow.kotlin.workflow.ExampleWorkflow import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.boot.context.event.ApplicationReadyEvent import org.springframework.boot.runApplication -import org.springframework.context.annotation.* -import org.springframework.context.event.EventListener; +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Import +import org.springframework.context.event.EventListener -@Import(value = [EngineConfiguration::class, NflowRestApiPropertiesConfiguration::class]) -@ComponentScan(value = ["io.nflow.rest"], excludeFilters = [ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = [RestConfiguration::class])]) +@Import(RestConfiguration::class) @Configuration class WorkflowAppConfig @@ -41,14 +33,6 @@ class WorkflowApplication { .putStateVariable(ExampleWorkflow.VAR_COUNTER, 0) .build()) } - - @Primary - @Bean - @Named(REST_OBJECT_MAPPER) - fun nflowRestObjectMapper(@NFlow nflowObjectMapper: ObjectMapper): ObjectMapper = nflowObjectMapper.copy().apply { - configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) - enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS) - } } fun main(args: Array) { diff --git a/nflow-examples/spring-boot/full-stack/gradle/src/main/java/io/nflow/springboot/fullstack/gradle/DemoApplication.java b/nflow-examples/spring-boot/full-stack/gradle/src/main/java/io/nflow/springboot/fullstack/gradle/DemoApplication.java index 93ac37f3c..f09e53811 100644 --- a/nflow-examples/spring-boot/full-stack/gradle/src/main/java/io/nflow/springboot/fullstack/gradle/DemoApplication.java +++ b/nflow-examples/spring-boot/full-stack/gradle/src/main/java/io/nflow/springboot/fullstack/gradle/DemoApplication.java @@ -1,33 +1,18 @@ package io.nflow.springboot.fullstack.gradle; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.nflow.engine.config.EngineConfiguration; -import io.nflow.engine.config.NFlow; -import io.nflow.rest.config.NflowRestApiPropertiesConfiguration; +import io.nflow.engine.service.WorkflowInstanceService; +import io.nflow.engine.workflow.instance.WorkflowInstanceFactory; import io.nflow.rest.config.RestConfiguration; import jakarta.inject.Inject; - -import jakarta.inject.Named; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Primary; import org.springframework.context.event.EventListener; -import io.nflow.engine.service.WorkflowInstanceService; -import io.nflow.engine.workflow.instance.WorkflowInstanceFactory; - -import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_TRAILING_TOKENS; -import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS; -import static io.nflow.rest.config.RestConfiguration.REST_OBJECT_MAPPER; - @SpringBootApplication -@Import({ EngineConfiguration.class, NflowRestApiPropertiesConfiguration.class }) -@ComponentScan(value = "io.nflow.rest", excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RestConfiguration.class)) +@Import(RestConfiguration.class) public class DemoApplication { @Inject @@ -45,16 +30,6 @@ public void insertWorkflowInstance() { .build()); } - @Primary - @Bean - @Named(REST_OBJECT_MAPPER) - public ObjectMapper nflowRestObjectMapper(@NFlow ObjectMapper nflowObjectMapper) { - ObjectMapper restObjectMapper = nflowObjectMapper.copy(); - restObjectMapper.configure(WRITE_DATES_AS_TIMESTAMPS, false); - restObjectMapper.enable(FAIL_ON_TRAILING_TOKENS); - return restObjectMapper; - } - @Bean public ExampleWorkflow exampleWorkflow() { return new ExampleWorkflow(); diff --git a/nflow-examples/spring-boot/full-stack/maven/src/main/java/io/nflow/springboot/fullstack/maven/DemoApplication.java b/nflow-examples/spring-boot/full-stack/maven/src/main/java/io/nflow/springboot/fullstack/maven/DemoApplication.java index f86d530a8..f8be206e6 100644 --- a/nflow-examples/spring-boot/full-stack/maven/src/main/java/io/nflow/springboot/fullstack/maven/DemoApplication.java +++ b/nflow-examples/spring-boot/full-stack/maven/src/main/java/io/nflow/springboot/fullstack/maven/DemoApplication.java @@ -1,33 +1,18 @@ package io.nflow.springboot.fullstack.maven; -import com.fasterxml.jackson.databind.ObjectMapper; -import io.nflow.engine.config.EngineConfiguration; -import io.nflow.engine.config.NFlow; -import io.nflow.rest.config.NflowRestApiPropertiesConfiguration; +import io.nflow.engine.service.WorkflowInstanceService; +import io.nflow.engine.workflow.instance.WorkflowInstanceFactory; import io.nflow.rest.config.RestConfiguration; import jakarta.inject.Inject; - -import jakarta.inject.Named; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Primary; import org.springframework.context.event.EventListener; -import io.nflow.engine.service.WorkflowInstanceService; -import io.nflow.engine.workflow.instance.WorkflowInstanceFactory; - -import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_TRAILING_TOKENS; -import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS; -import static io.nflow.rest.config.RestConfiguration.REST_OBJECT_MAPPER; - @SpringBootApplication -@Import({ EngineConfiguration.class, NflowRestApiPropertiesConfiguration.class }) -@ComponentScan(value = "io.nflow.rest", excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RestConfiguration.class)) +@Import(RestConfiguration.class) public class DemoApplication { @Inject @@ -45,16 +30,6 @@ public void insertWorkflowInstance() { .build()); } - @Primary - @Bean - @Named(REST_OBJECT_MAPPER) - public ObjectMapper nflowRestObjectMapper(@NFlow ObjectMapper nflowObjectMapper) { - ObjectMapper restObjectMapper = nflowObjectMapper.copy(); - restObjectMapper.configure(WRITE_DATES_AS_TIMESTAMPS, false); - restObjectMapper.enable(FAIL_ON_TRAILING_TOKENS); - return restObjectMapper; - } - @Bean public ExampleWorkflow exampleWorkflow() { return new ExampleWorkflow(); diff --git a/nflow-rest-api-common/src/main/java/io/nflow/rest/config/RestConfiguration.java b/nflow-rest-api-common/src/main/java/io/nflow/rest/config/RestConfiguration.java index fdfea8a8b..f9b025398 100644 --- a/nflow-rest-api-common/src/main/java/io/nflow/rest/config/RestConfiguration.java +++ b/nflow-rest-api-common/src/main/java/io/nflow/rest/config/RestConfiguration.java @@ -1,20 +1,17 @@ package io.nflow.rest.config; -import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_TRAILING_TOKENS; -import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS; - +import com.fasterxml.jackson.databind.ObjectMapper; +import io.nflow.engine.config.EngineConfiguration; +import io.nflow.engine.config.EngineConfiguration.EngineObjectMapperSupplier; +import io.nflow.engine.config.NFlow; import jakarta.inject.Named; - import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.context.annotation.Primary; -import com.fasterxml.jackson.databind.ObjectMapper; - -import io.nflow.engine.config.EngineConfiguration; -import io.nflow.engine.config.NFlow; +import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_TRAILING_TOKENS; +import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS; @Configuration @Import({ EngineConfiguration.class, NflowRestApiPropertiesConfiguration.class }) @@ -25,8 +22,8 @@ public class RestConfiguration { @Bean @Named(REST_OBJECT_MAPPER) - public ObjectMapper nflowRestObjectMapper(@NFlow ObjectMapper nflowObjectMapper) { - ObjectMapper restObjectMapper = nflowObjectMapper.copy(); + public ObjectMapper nflowRestObjectMapper(@NFlow EngineObjectMapperSupplier nflowObjectMapper) { + ObjectMapper restObjectMapper = nflowObjectMapper.get().copy(); restObjectMapper.configure(WRITE_DATES_AS_TIMESTAMPS, false); restObjectMapper.enable(FAIL_ON_TRAILING_TOKENS); return restObjectMapper; diff --git a/nflow-rest-api-common/src/test/java/io/nflow/rest/v1/converter/CreateWorkflowConverterTest.java b/nflow-rest-api-common/src/test/java/io/nflow/rest/v1/converter/CreateWorkflowConverterTest.java index 079913b59..19be38f0a 100644 --- a/nflow-rest-api-common/src/test/java/io/nflow/rest/v1/converter/CreateWorkflowConverterTest.java +++ b/nflow-rest-api-common/src/test/java/io/nflow/rest/v1/converter/CreateWorkflowConverterTest.java @@ -27,7 +27,7 @@ public class CreateWorkflowConverterTest { @Spy - private final ObjectStringMapper objectMapper = new ObjectStringMapper(new ObjectMapper()); + private final ObjectStringMapper objectMapper = new ObjectStringMapper(ObjectMapper::new); private CreateWorkflowConverter converter; diff --git a/nflow-rest-api-jax-rs/src/test/java/io/nflow/rest/v1/config/jaxrs/RestConfigurationTest.java b/nflow-rest-api-jax-rs/src/test/java/io/nflow/rest/v1/config/jaxrs/RestConfigurationTest.java index 78e521373..e907a2b30 100644 --- a/nflow-rest-api-jax-rs/src/test/java/io/nflow/rest/v1/config/jaxrs/RestConfigurationTest.java +++ b/nflow-rest-api-jax-rs/src/test/java/io/nflow/rest/v1/config/jaxrs/RestConfigurationTest.java @@ -25,7 +25,7 @@ public void setup() { @Test public void nflowRestObjectMapperInstantiated() { - ObjectMapper restMapper = configuration.nflowRestObjectMapper(new ObjectMapper()); + ObjectMapper restMapper = configuration.nflowRestObjectMapper(ObjectMapper::new); assertThat(restMapper.getSerializationConfig().hasSerializationFeatures(WRITE_DATES_AS_TIMESTAMPS.getMask()), is(false)); } } diff --git a/nflow-rest-api-jax-rs/src/test/java/io/nflow/rest/v1/jaxrs/WorkflowInstanceResourceTest.java b/nflow-rest-api-jax-rs/src/test/java/io/nflow/rest/v1/jaxrs/WorkflowInstanceResourceTest.java index ae003d05b..7c12eeb32 100644 --- a/nflow-rest-api-jax-rs/src/test/java/io/nflow/rest/v1/jaxrs/WorkflowInstanceResourceTest.java +++ b/nflow-rest-api-jax-rs/src/test/java/io/nflow/rest/v1/jaxrs/WorkflowInstanceResourceTest.java @@ -95,7 +95,7 @@ public void setup() { resource = new WorkflowInstanceResource(workflowInstances, createWorkflowConverter, listWorkflowConverter, workflowInstanceFactory, workflowInstanceDao); lenient().when(workflowInstanceFactory.newWorkflowInstanceBuilder()) - .thenReturn(new WorkflowInstance.Builder(new ObjectStringMapper(new ObjectMapper()))); + .thenReturn(new WorkflowInstance.Builder(new ObjectStringMapper(ObjectMapper::new))); } @Test