diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/mongo/MongoDatabaseCFG.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/mongo/MongoDatabaseCFG.java index d284dc1..f54e188 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/mongo/MongoDatabaseCFG.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/mongo/MongoDatabaseCFG.java @@ -23,6 +23,10 @@ import org.springframework.data.mongodb.core.convert.MappingMongoConverter; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; +import com.mongodb.ConnectionString; +import com.mongodb.MongoClientSettings; +import com.mongodb.client.MongoClients; + import net.javacrumbs.shedlock.core.LockProvider; import net.javacrumbs.shedlock.provider.mongo.MongoLockProvider; @@ -34,7 +38,11 @@ public class MongoDatabaseCFG { @Bean public MongoDatabaseFactory mongoDatabaseFactory(final MongoPropertiesCFG mongoPropertiesCFG){ - return new SimpleMongoClientDatabaseFactory(mongoPropertiesCFG.getUri()); + ConnectionString connectionString = new ConnectionString(mongoPropertiesCFG.getUri()); + MongoClientSettings mongoClientSettings = MongoClientSettings.builder() + .applyConnectionString(connectionString) + .build(); + return new SimpleMongoClientDatabaseFactory(MongoClients.create(mongoClientSettings), mongoPropertiesCFG.getSchemaName()); } @Bean diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/mongo/MongoPropertiesCFG.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/mongo/MongoPropertiesCFG.java index 3e05a2b..227cded 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/mongo/MongoPropertiesCFG.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/config/mongo/MongoPropertiesCFG.java @@ -28,4 +28,7 @@ public class MongoPropertiesCFG { @Value("${data.mongodb.uri}") private String uri; + + @Value("${data.mongodb.schema-name}") + private String schemaName; } diff --git a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/scheduler/executors/base/LExecutor.java b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/scheduler/executors/base/LExecutor.java index 4f10b85..f3efd8a 100644 --- a/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/scheduler/executors/base/LExecutor.java +++ b/src/main/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/scheduler/executors/base/LExecutor.java @@ -15,11 +15,9 @@ import it.finanze.sanita.fse2.ms.gtw.statusmanager.scheduler.actions.ActionBuilderEDS; import it.finanze.sanita.fse2.ms.gtw.statusmanager.scheduler.actions.base.IActionStepEDS; import it.finanze.sanita.fse2.ms.gtw.statusmanager.scheduler.actions.base.IExecutableEDS; -import lombok.extern.slf4j.Slf4j; import java.util.LinkedHashMap; -@Slf4j public abstract class LExecutor implements IExecutableEDS { @Override diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties index 5a6a937..17caded 100644 --- a/src/main/resources/application-dev.properties +++ b/src/main/resources/application-dev.properties @@ -5,6 +5,7 @@ management.server.port=8013 # Database ####################################### data.mongodb.uri=mongodb://mongoadmin:secret@localhost:27888/fse +data.mongodb.schema-name=FSE_GTW ####################################### # KAFKA diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties index 62f1f49..3560c13 100644 --- a/src/main/resources/application-docker.properties +++ b/src/main/resources/application-docker.properties @@ -5,6 +5,7 @@ management.server.port=8013 # Database ####################################### data.mongodb.uri=mongodb://mongoadmin:secret@host.docker.internal:27888/fse +data.mongodb.schema-name=FSE_GTW ####################################### # KAFKA diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 15e5e59..f0fae07 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -33,6 +33,7 @@ log.level=trace # DATASOURCE DB ####################################### data.mongodb.uri=mongodb://${MONGO_USER}:${MONGO_PASSWORD}@:/ +data.mongodb.schema-name=${MONGO_DBNAME} ####################################### # KAFKA diff --git a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/RepoTest.java b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/RepoTest.java index a40c025..06deddd 100644 --- a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/RepoTest.java +++ b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/RepoTest.java @@ -12,7 +12,6 @@ package it.finanze.sanita.fse2.ms.gtw.statusmanager; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.BDDMockito.given; import org.junit.jupiter.api.DisplayName; diff --git a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/TxExecutorTest.java b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/TxExecutorTest.java index 9cc8f4a..8e69eea 100644 --- a/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/TxExecutorTest.java +++ b/src/test/java/it/finanze/sanita/fse2/ms/gtw/statusmanager/TxExecutorTest.java @@ -11,15 +11,12 @@ */ package it.finanze.sanita.fse2.ms.gtw.statusmanager; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.client.IConfigClient; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.client.IProcessorClient; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.dto.client.processor.res.tx.DeleteTxResDTO; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.dto.client.processor.res.tx.GetTxResDTO; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.enums.ActionRes; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.repository.entity.FhirEvent; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.repository.mongo.ITransactionEventsRepo; -import it.finanze.sanita.fse2.ms.gtw.statusmanager.scheduler.executors.impl.TxExecutor; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.springframework.http.HttpMethod.DELETE; + +import java.util.ArrayList; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,11 +32,13 @@ import org.springframework.web.client.ResourceAccessException; import org.springframework.web.client.RestTemplate; -import java.util.ArrayList; - -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.springframework.http.HttpMethod.DELETE; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.client.IConfigClient; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.dto.client.processor.res.tx.DeleteTxResDTO; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.dto.client.processor.res.tx.GetTxResDTO; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.enums.ActionRes; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.repository.entity.FhirEvent; +import it.finanze.sanita.fse2.ms.gtw.statusmanager.scheduler.executors.impl.TxExecutor; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles(Constants.Profile.TEST) @@ -48,15 +47,9 @@ class TxExecutorTest { @Autowired private TxExecutor txExecutor; - @Autowired - private IProcessorClient processorClient; - @MockBean private IConfigClient configClient; - @Autowired - private ITransactionEventsRepo transaction; - @Autowired private MongoTemplate mongoTemplate; @@ -121,7 +114,6 @@ void executorFailureTestOnProcess() { void executorFailureTestOnDelete() { GetTxResDTO first = TestUtility.createFirstTxLinksMock(); GetTxResDTO last = TestUtility.createLastTxLinksMock(); - DeleteTxResDTO deleted = TestUtility.createDeletedTransactionMock(); Mockito.when(configClient.getExpirationDate()).thenReturn(5); diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties index 9d87fbb..417ab5b 100644 --- a/src/test/resources/application-test.properties +++ b/src/test/resources/application-test.properties @@ -17,6 +17,7 @@ kafka.enablessl=false # Database ####################################### data.mongodb.uri=mongodb://mongoadmin:secret@localhost:27888/fse +data.mongodb.schema-name=FSE_GTW ####### LOGGING OUTPUT FORMAT ############ # Must be one of console, json