Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 35 additions & 14 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.8.RELEASE</version>
<version>2.5.5</version>
<relativePath /> <!-- .. lookup parent from repository -->
</parent>

Expand All @@ -25,12 +25,12 @@
<skipTests>false</skipTests>
<skipITs>${skipTests}</skipITs>
<skipUTs>${skipTests}</skipUTs>
<springBootVersion>${project.parent.version}</springBootVersion>
<springLdapVersion>2.3.2.RELEASE</springLdapVersion>
<springSecurityVersion>5.0.6.RELEASE</springSecurityVersion>
<springSessionVersion>2.0.2.RELEASE</springSessionVersion>
<springBootVersion>2.5.5</springBootVersion>
<springLdapVersion>2.3.4.RELEASE</springLdapVersion>
<springSecurityVersion>5.5.2</springSecurityVersion>
<springSessionVersion>2.5.0</springSessionVersion>
<forkCountTests>1</forkCountTests>
<jackson.version>2.12.1</jackson.version>
<jackson.version>2.12.5</jackson.version>
</properties>

<!-- Reporting Plugins -->
Expand Down Expand Up @@ -111,7 +111,7 @@
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>2.1.2</version>
<version>3.0.4</version>
</dependency>

<dependency>
Expand All @@ -136,6 +136,10 @@
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</exclusion>
</exclusions>
</dependency>

Expand All @@ -145,6 +149,23 @@
<version>${springBootVersion}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>4.3.2</version><!--$NO-MVN-MAN-VER$-->
</dependency>

<dependency>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need of mongodb-driver-core dependency explicitly. sync will download the same.

<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-core</artifactId>
<version>4.3.2</version><!--$NO-MVN-MAN-VER$-->
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -204,15 +225,15 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.9.0</version>
<version>3.9.0</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -246,13 +267,13 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
<version>3.12.0</version>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.9</version>
<version>4.4.14</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -285,7 +306,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.6</version>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -335,7 +356,7 @@
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>2.0.0</version>
<version>3.0.0</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -524,7 +545,7 @@
<skipTests>${skipUTs}</skipTests>
<forkCount>${forkCountTests}</forkCount>
<reuseForks>true</reuseForks>
<parallel>classes</parallel>
<parallel>methods</parallel>
<threadCount>5</threadCount>
<includes>
<include>${someModule.test.includes}</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void connect_to_message_bus() throws Exception {
RabbitTemplate rabbitTemplate = rabbitAdmin.getRabbitTemplate();

rmqHandler.setRabbitTemplate(rabbitTemplate);
rmqHandler.getContainer().setRabbitAdmin(rabbitAdmin);
rmqHandler.getContainer().setAmqpAdmin(rabbitAdmin);
rmqHandler.getContainer().setConnectionFactory(rmqHandler.getCachingConnectionFactory());
rmqHandler.getContainer().setQueueNames(rmqHandler.getRmqProperties().getQueueName());
assertEquals("Expected message bus to be up", true, amqpBroker.isRunning);
Expand Down Expand Up @@ -131,7 +131,7 @@ private RabbitAdmin createExchange(final RMQHandler rmqHandler) {
admin.getQueueProperties(queueName);
RabbitTemplate rabbitTemplate = admin.getRabbitTemplate();
rabbitTemplate.setExchange(exchangeName);
rabbitTemplate.setQueue(queueName);
rabbitTemplate.setDefaultReceiveQueue(queueName);
rabbitTemplate.setRoutingKey(ROUTING_KEY_1);
return admin;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -98,7 +98,7 @@ public void connect_to_message_bus() throws Exception {
RabbitTemplate rabbitTemplate = rabbitAdmin.getRabbitTemplate();

rmqHandler.setRabbitTemplate(rabbitTemplate);
rmqHandler.getContainer().setRabbitAdmin(rabbitAdmin);
rmqHandler.getContainer().setAmqpAdmin(rabbitAdmin);
rmqHandler.getContainer().setConnectionFactory(rmqHandler.getCachingConnectionFactory());
rmqHandler.getContainer().setQueueNames(rmqProperties.getQueueName());
assertEquals("Expected message bus to be up", true, amqpBroker.isRunning);
Expand Down Expand Up @@ -172,7 +172,7 @@ private RabbitAdmin createExchange(final RMQHandler rmqHandler) {
RabbitTemplate rabbitTemplate = admin.getRabbitTemplate();
rabbitTemplate.setExchange(exchangeName);
rabbitTemplate.setRoutingKey(DEFAULT_ROUTING_KEY);
rabbitTemplate.setQueue(queueName);
rabbitTemplate.setDefaultReceiveQueue(queueName);
return admin;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.springframework.boot.autoconfigure.mongo.MongoProperties;
import org.springframework.stereotype.Component;

import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
import com.mongodb.client.model.Filters;
Expand Down Expand Up @@ -195,8 +195,7 @@ private List<Document> getDocumentsFromCollection(String collectionName) {
}

private MongoCollection<Document> getCollection(String collectionName) {
MongoClientURI uri = new MongoClientURI(mongoProperties.getUri());
mongoClient = new MongoClient(uri);
mongoClient = MongoClients.create(mongoProperties.getUri());
MongoDatabase db = mongoClient.getDatabase(database);
MongoCollection<Document> collection = db.getCollection(collectionName);
return collection;
Expand Down
11 changes: 7 additions & 4 deletions src/functionaltests/java/com/ericsson/ei/utils/TestConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@

import org.apache.tomcat.util.codec.binary.Base64;
import org.apache.tomcat.util.codec.binary.StringUtils;
import org.bson.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.SocketUtils;

import com.mongodb.MongoClient;
import com.mongodb.client.ListDatabasesIterable;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoCursor;

import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
Expand Down Expand Up @@ -51,9 +54,9 @@ protected static void startUpMongoClient() throws IOException {
}

try {
MongodForTestsFactory testsFactory = MongodForTestsFactory.with(Version.V3_4_1);
mongoClient = testsFactory.newMongo();
String port = "" + mongoClient.getAddress().getPort();
final ListDatabasesIterable<Document> list = mongoClient.listDatabases();
final MongoCursor<Document> iter = list.iterator();
final String port = "" + iter.getServerAddress().getPort();
System.setProperty("spring.data.mongodb.port", port);
LOGGER.debug("Started embedded Mongo DB for tests on port: " + port);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;

import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
Expand Down Expand Up @@ -404,8 +404,7 @@ private JsonNode getNewestMailFromDatabase() throws Exception {
}

private void setupMailhogMongoDBHandler() {
MongoClientURI uri = new MongoClientURI(mailHogUri);
MongoClient mongoClient = new MongoClient(uri);
MongoClient mongoClient = MongoClients.create(mailHogUri);
mailhogMongoDBHandler = new MongoDBHandler();
mailhogMongoDBHandler.setMongoClient(mongoClient);
}
Expand Down
5 changes: 1 addition & 4 deletions src/integrationtests/java/util/IntegrationTestBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,17 @@
*/
package util;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.annotation.PostConstruct;

Expand All @@ -52,6 +48,7 @@
import com.ericsson.ei.utils.HttpRequest.HttpMethod;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.Setter;

public abstract class IntegrationTestBase extends AbstractTestExecutionListener {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/ericsson/ei/config/HttpSessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.springframework.context.annotation.Primary;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.session.data.mongo.MongoOperationsSessionRepository;
import org.springframework.session.data.mongo.MongoIndexedSessionRepository;
import org.springframework.session.data.mongo.config.annotation.web.http.EnableMongoHttpSession;
import org.springframework.session.web.http.HttpSessionIdResolver;

Expand All @@ -20,8 +20,8 @@ public class HttpSessionConfig {

@Primary
@Bean
public MongoOperationsSessionRepository mongoSessionRepository(MongoOperations mongoOperations) {
MongoOperationsSessionRepository repository = new MongoOperationsSessionRepository(mongoOperations);
public MongoIndexedSessionRepository mongoIndexedSessionRepository(MongoOperations mongoOperations) {
MongoIndexedSessionRepository repository = new MongoIndexedSessionRepository(mongoOperations);
repository.setMaxInactiveIntervalInSeconds(maxInactiveIntervalInSeconds);
return repository;
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/com/ericsson/ei/handlers/ObjectHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mongodb.BasicDBObject;
import com.mongodb.MongoClientException;
import com.mongodb.util.JSON;

import lombok.Getter;
import lombok.Setter;
Expand Down Expand Up @@ -118,7 +117,6 @@ public String insertObject(String aggregatedObject, RulesObject rulesObject, Str
BasicDBObject document = prepareDocumentForInsertion(id, aggregatedObject);
LOGGER.debug("ObjectHandler: Aggregated Object document to be inserted: {}",
document.toString());

mongoDbHandler.insertDocument(databaseName, aggregationsCollectionName, document.toString());
postInsertActions(aggregatedObject, rulesObject, event, id);
return aggregatedObject;
Expand Down Expand Up @@ -272,7 +270,7 @@ public String lockDocument(String id) {
if (result != null) {
LOGGER.debug("DB locked by {} thread", Thread.currentThread().getId());
documentLocked = false;
return JSON.serialize(result);
return new BasicDBObject(result).toString();
}
// To Remove
LOGGER.debug("Waiting by {} thread", Thread.currentThread().getId());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ericsson/ei/handlers/RMQHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
Expand Down Expand Up @@ -150,7 +150,7 @@ public RabbitTemplate rabbitMqTemplate() {
rabbitTemplate = new RabbitTemplate(connectionFactory());
}

rabbitTemplate.setQueue(rmqProperties.getWaitlistQueueName());
rabbitTemplate.setDefaultReceiveQueue(rmqProperties.getWaitlistQueueName());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the format properly

rabbitTemplate.setExchange(rmqProperties.getExchangeName());
rabbitTemplate.setRoutingKey(WAITLIST_BINDING_KEY);
rabbitTemplate.setConfirmCallback(new ConfirmCallback() {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/ericsson/ei/jsonmerge/MergeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String mergeObject(String id, String mergeId, RulesObject rules, String e
LOGGER.debug("AGGREGATED OBJECT : " + aggregatedObject);
if(aggregatedObject == null) {
return null;
}
}
String mergeRule = getMergeRules(rules);
if (mergeRule != null && !mergeRule.isEmpty()) {
String updatedRule = replaceIdMarkerInRules(mergeRule, mergeId);
Expand All @@ -110,7 +110,6 @@ public String mergeObject(String id, String mergeId, RulesObject rules, String e
}
objectHandler.updateObject(mergedObject, rules, event, id);
}

return mergedObject;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/ericsson/ei/jsonmerge/MergePrepare.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public String getMergePath(String originObject, String mergeRule, boolean skipPa
Object ruleJSONObject;

// condition to avoid un-necessary exception to print in the log
if(mergeRule.startsWith("{")) {
if (mergeRule.startsWith("{")) {
ruleJSONObject = new JSONObject(mergeRule);
} else {
return getMergePathFromArrayMergeRules(originObject, mergeRule, stringObject);
Expand Down
Loading