diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c0e2b3b..ab982bf 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: maven:3.3.9-jdk-8
+image: maven:3.9-eclipse-temurin-21-alpine
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
diff --git a/pom.xml b/pom.xml
index 28880a4..6348841 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,14 +4,14 @@
uk.ac.ebi.pride.archive
pride-mongodb-repo
- 1.0.9-SNAPSHOT
+ 1.0.10-SNAPSHOT
jar
PRIDE MongoDB repository
org.springframework.boot
spring-boot-starter-parent
- 2.0.1.RELEASE
+ 3.3.3
+
+ de.flapdoodle.embed
+ de.flapdoodle.embed.mongo
+ 3.5.4
+ test
@@ -84,6 +97,13 @@
spring-boot-starter-data-mongodb
+
+
+ org.mongodb
+ mongodb-driver-sync
+ 4.9.1
+
+
com.fasterxml.jackson
jackson-base
@@ -122,7 +142,6 @@
org.hibernate.validator
hibernate-validator
- 6.1.5.Final
test
@@ -141,7 +160,6 @@
org.projectlombok
lombok
- 1.18.24
@@ -238,6 +256,35 @@
org.apache.maven.plugins
maven-source-plugin
+
+ org.openrewrite.maven
+ rewrite-maven-plugin
+ 5.39.0
+
+ true
+
+ org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3
+
+
+
+
+ org.openrewrite.recipe
+ rewrite-spring
+ 5.17.0
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ true
+
+ -parameters
+
+
+
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideProject.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideProject.java
index 53f03be..a359504 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideProject.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideProject.java
@@ -1,6 +1,9 @@
package uk.ac.ebi.pride.mongodb.archive.model.projects;
-import lombok.*;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.Getter;
import lombok.experimental.SuperBuilder;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
@@ -46,6 +49,7 @@ public MongoPrideProject() {
* Project Accession in PRIDE
**/
@Indexed(unique = true, name = PrideArchiveField.ACCESSION)
+ @Field(value = PrideArchiveField.ACCESSION)
protected String accession;
/**
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideReanalysisProject.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideReanalysisProject.java
index 2fa9c37..28873c8 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideReanalysisProject.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideReanalysisProject.java
@@ -1,6 +1,7 @@
package uk.ac.ebi.pride.mongodb.archive.model.projects;
-import lombok.*;
+import lombok.Builder;
+import lombok.Data;
import org.bson.types.ObjectId;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/files/PrideFileMongoRepositoryImpl.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/files/PrideFileMongoRepositoryImpl.java
index b1e8347..2683e4c 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/files/PrideFileMongoRepositoryImpl.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/files/PrideFileMongoRepositoryImpl.java
@@ -10,7 +10,7 @@
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.data.repository.support.PageableExecutionUtils;
+import org.springframework.data.support.PageableExecutionUtils;
import uk.ac.ebi.pride.archive.dataprovider.common.Triple;
import uk.ac.ebi.pride.mongodb.archive.model.PrideArchiveField;
import uk.ac.ebi.pride.mongodb.archive.model.files.MongoPrideFile;
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/msruns/PrideMSRunMongoRepositoryImpl.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/msruns/PrideMSRunMongoRepositoryImpl.java
index 09d5646..072b1ec 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/msruns/PrideMSRunMongoRepositoryImpl.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/msruns/PrideMSRunMongoRepositoryImpl.java
@@ -8,7 +8,7 @@
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.data.repository.support.PageableExecutionUtils;
+import org.springframework.data.support.PageableExecutionUtils;
import uk.ac.ebi.pride.archive.dataprovider.common.Triple;
import uk.ac.ebi.pride.mongodb.archive.model.PrideArchiveField;
import uk.ac.ebi.pride.mongodb.archive.model.msrun.MongoPrideMSRun;
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/ImportedProjectMongoRepositoryCustomImpl.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/ImportedProjectMongoRepositoryCustomImpl.java
index e5d5657..66ce401 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/ImportedProjectMongoRepositoryCustomImpl.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/ImportedProjectMongoRepositoryCustomImpl.java
@@ -1,13 +1,12 @@
package uk.ac.ebi.pride.mongodb.archive.repo.projects;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.data.repository.support.PageableExecutionUtils;
+import org.springframework.data.support.PageableExecutionUtils;
import uk.ac.ebi.pride.mongodb.archive.model.PrideArchiveField;
import uk.ac.ebi.pride.mongodb.archive.model.projects.MongoImportedProject;
@@ -21,7 +20,6 @@ public class ImportedProjectMongoRepositoryCustomImpl implements ImportedProject
private final MongoTemplate mongoTemplate;
- @Autowired
public ImportedProjectMongoRepositoryCustomImpl(@Qualifier("archiveMongoTemplate") MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideAnalysisMongoRepositoryImpl.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideAnalysisMongoRepositoryImpl.java
index 49c6120..f758699 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideAnalysisMongoRepositoryImpl.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideAnalysisMongoRepositoryImpl.java
@@ -7,7 +7,7 @@
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.data.repository.support.PageableExecutionUtils;
+import org.springframework.data.support.PageableExecutionUtils;
import uk.ac.ebi.pride.archive.dataprovider.common.Triple;
import uk.ac.ebi.pride.mongodb.archive.model.projects.MongoPrideAnalysis;
import uk.ac.ebi.pride.mongodb.utils.PrideMongoUtils;
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideProjectMongoRepository.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideProjectMongoRepository.java
index 9e0af97..500267a 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideProjectMongoRepository.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideProjectMongoRepository.java
@@ -3,6 +3,7 @@
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
+import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import uk.ac.ebi.pride.mongodb.archive.model.PrideArchiveField;
import uk.ac.ebi.pride.mongodb.archive.model.projects.MongoPrideProject;
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideProjectMongoRepositoryCustomImpl.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideProjectMongoRepositoryCustomImpl.java
index 28dd647..5630375 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideProjectMongoRepositoryCustomImpl.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/repo/projects/PrideProjectMongoRepositoryCustomImpl.java
@@ -1,13 +1,12 @@
package uk.ac.ebi.pride.mongodb.archive.repo.projects;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.data.repository.support.PageableExecutionUtils;
+import org.springframework.data.support.PageableExecutionUtils;
import uk.ac.ebi.pride.mongodb.archive.model.PrideArchiveField;
import uk.ac.ebi.pride.mongodb.archive.model.projects.MongoPrideProject;
@@ -21,7 +20,6 @@ public class PrideProjectMongoRepositoryCustomImpl implements PrideProjectMongoR
private final MongoTemplate mongoTemplate;
- @Autowired
public PrideProjectMongoRepositoryCustomImpl(@Qualifier("archiveMongoTemplate") MongoTemplate mongoTemplate) {
this.mongoTemplate = mongoTemplate;
}
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/assays/PrideAssayMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/assays/PrideAssayMongoService.java
index bc131d9..fe69b00 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/assays/PrideAssayMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/assays/PrideAssayMongoService.java
@@ -1,7 +1,6 @@
package uk.ac.ebi.pride.mongodb.archive.service.assays;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.stereotype.Service;
import uk.ac.ebi.pride.archive.dataprovider.common.Triple;
@@ -30,7 +29,6 @@ public class PrideAssayMongoService {
final PrideAssayMongoRepository assayRepository;
- @Autowired
public PrideAssayMongoService(PrideAssayMongoRepository assayRepository) {
this.assayRepository = assayRepository;
}
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/files/PrideFileMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/files/PrideFileMongoService.java
index c7b26c7..b99cb2e 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/files/PrideFileMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/files/PrideFileMongoService.java
@@ -43,7 +43,6 @@ public void setMongoOperations(MongoTemplate mongoTemplate) {
this.mongoOperations = mongoTemplate;
}
- @Autowired
public PrideFileMongoService(PrideFileMongoRepository fileRepository, PrideMSRunMongoRepository msRunMongoRepository) {
this.fileRepository = fileRepository;
this.msRunMongoRepository = msRunMongoRepository;
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/msruns/PrideMsRunMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/msruns/PrideMsRunMongoService.java
index 55443eb..567694a 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/msruns/PrideMsRunMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/msruns/PrideMsRunMongoService.java
@@ -41,7 +41,6 @@ public class PrideMsRunMongoService implements IMSRunService {
OntologyCacheService ontologyCacheService;
- @Autowired
public PrideMsRunMongoService(PrideMSRunMongoRepository msRunRepository) {
this.msRunRepository = msRunRepository;
try {
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/ImportedProjectMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/ImportedProjectMongoService.java
index 4dfb1b1..2985ce3 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/ImportedProjectMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/ImportedProjectMongoService.java
@@ -2,7 +2,6 @@
import lombok.extern.slf4j.Slf4j;
import org.bson.types.ObjectId;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -28,7 +27,6 @@ public class ImportedProjectMongoService {
final ImportedProjectMongoRepository repository;
final PrideAssayMongoRepository assayMongoRepository;
- @Autowired
public ImportedProjectMongoService(ImportedProjectMongoRepository repository, PrideAssayMongoRepository assayMongoRepository) {
this.repository = repository;
this.assayMongoRepository = assayMongoRepository;
@@ -41,7 +39,7 @@ public ImportedProjectMongoService(ImportedProjectMongoRepository repository, Pr
* @return MongoImportedProject
*/
public Optional insert(MongoImportedProject project) {
- if (!repository.findByAccession(project.getAccession()).isPresent()) {
+ if (repository.findByAccession(project.getAccession()).isEmpty()) {
project = repository.save(project);
log.info("A new project has been saved into MongoDB database with Accession -- " + project.getAccession());
} else
@@ -196,7 +194,7 @@ public boolean deleteByAccession(String accession) {
public void saveAssays(List mongoAssays) {
mongoAssays.forEach(x -> {
Optional currentAssay = assayMongoRepository.findPrideAssayByAccession(x.getAccession());
- if (!currentAssay.isPresent())
+ if (currentAssay.isEmpty())
assayMongoRepository.save(x);
else {
updateAssay(currentAssay.get(), x);
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideAnalysisMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideAnalysisMongoService.java
index bc14e91..6283b3c 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideAnalysisMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideAnalysisMongoService.java
@@ -1,7 +1,6 @@
package uk.ac.ebi.pride.mongodb.archive.service.projects;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import uk.ac.ebi.pride.mongodb.archive.repo.projects.PrideAnalysisMongoRepository;
@@ -18,7 +17,6 @@ public class PrideAnalysisMongoService {
// @Autowired
// private MongoOperations mongo;
- @Autowired
public PrideAnalysisMongoService(PrideAnalysisMongoRepository repository) {
this.repository = repository;
}
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideProjectMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideProjectMongoService.java
index ffc2726..fe6af8c 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideProjectMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideProjectMongoService.java
@@ -2,7 +2,6 @@
import lombok.extern.slf4j.Slf4j;
import org.bson.types.ObjectId;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -33,7 +32,6 @@ public class PrideProjectMongoService {
final PrideProjectMongoRepository repository;
final PrideAssayMongoRepository assayMongoRepository;
- @Autowired
public PrideProjectMongoService(PrideProjectMongoRepository repository, PrideAssayMongoRepository assayMongoRepository) {
this.repository = repository;
this.assayMongoRepository = assayMongoRepository;
@@ -46,7 +44,7 @@ public PrideProjectMongoService(PrideProjectMongoRepository repository, PrideAss
* @return MongoPrideProject
*/
public Optional insert(MongoPrideProject project) {
- if (!repository.findByAccession(project.getAccession()).isPresent()) {
+ if (repository.findByAccession(project.getAccession()).isEmpty()) {
project = repository.save(project);
log.info("A new project has been saved into MongoDB database with Accession -- " + project.getAccession());
} else
@@ -201,7 +199,7 @@ public boolean deleteByAccession(String accession) {
public void saveAssays(List mongoAssays) {
mongoAssays.forEach(x -> {
Optional currentAssay = assayMongoRepository.findPrideAssayByAccession(x.getAccession());
- if (!currentAssay.isPresent())
+ if (currentAssay.isEmpty())
assayMongoRepository.save(x);
else {
updateAssay(currentAssay.get(), x);
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideReanalysisMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideReanalysisMongoService.java
index efd626f..43d1a52 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideReanalysisMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/projects/PrideReanalysisMongoService.java
@@ -2,7 +2,6 @@
import lombok.extern.slf4j.Slf4j;
import org.bson.types.ObjectId;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import uk.ac.ebi.pride.mongodb.archive.model.projects.MongoPrideReanalysisProject;
import uk.ac.ebi.pride.mongodb.archive.repo.projects.PrideReanalysisMongoRepository;
@@ -25,7 +24,6 @@ public class PrideReanalysisMongoService {
final PrideReanalysisMongoRepository repository;
- @Autowired
public PrideReanalysisMongoService(PrideReanalysisMongoRepository repository) {
this.repository = repository;
}
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/samples/PrideSampleMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/samples/PrideSampleMongoService.java
index 091d637..03021c7 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/samples/PrideSampleMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/samples/PrideSampleMongoService.java
@@ -3,7 +3,6 @@
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import uk.ac.ebi.pride.archive.dataprovider.sample.ISampleMSRunRow;
import uk.ac.ebi.pride.archive.dataprovider.sample.SampleProvider;
@@ -37,7 +36,6 @@ public class PrideSampleMongoService {
/** Logger use to query and filter the data **/
private static final Logger LOGGER = LoggerFactory.getLogger(PrideSampleMongoService.class);
- @Autowired
public PrideSampleMongoService(PrideMongoExperimentalDesign prideMongoExperimentalDesign) {
this.prideMongoExperimentalDesign = prideMongoExperimentalDesign;
}
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/stats/PeptidomeStatsMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/stats/PeptidomeStatsMongoService.java
index 0aa6aba..718aaf1 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/stats/PeptidomeStatsMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/stats/PeptidomeStatsMongoService.java
@@ -1,7 +1,6 @@
package uk.ac.ebi.pride.mongodb.archive.service.stats;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import uk.ac.ebi.pride.mongodb.archive.model.stats.MongoPeptidomeStats;
import uk.ac.ebi.pride.mongodb.archive.repo.stats.PeptidomeStatsMongoRepository;
@@ -14,7 +13,6 @@ public class PeptidomeStatsMongoService {
final PeptidomeStatsMongoRepository repository;
- @Autowired
public PeptidomeStatsMongoService(PeptidomeStatsMongoRepository repository) {
this.repository = repository;
}
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/stats/PrideStatsMongoService.java b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/stats/PrideStatsMongoService.java
index d9ad736..b26d69f 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/stats/PrideStatsMongoService.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/archive/service/stats/PrideStatsMongoService.java
@@ -1,7 +1,6 @@
package uk.ac.ebi.pride.mongodb.archive.service.stats;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import uk.ac.ebi.pride.archive.dataprovider.common.Tuple;
import uk.ac.ebi.pride.mongodb.archive.model.stats.MongoPrideStats;
@@ -29,7 +28,6 @@ public class PrideStatsMongoService {
final PrideStatsMongoRepository repository;
- @Autowired
public PrideStatsMongoService(PrideStatsMongoRepository repository) {
this.repository = repository;
}
@@ -73,7 +71,7 @@ public Optional updateSubmissionCountStats(Date date, PrideStat
Optional stats = findStatsBydate(date);
MongoPrideStats currentStats;
- if(!stats.isPresent()){
+ if(stats.isEmpty()){
Map>> submissionCounts = new HashMap<>();
submissionCounts.put(prideStatsKeysConstants.statsKey, submissionCount);
MongoPrideStats mongoPrideStats = MongoPrideStats.builder()
@@ -102,7 +100,7 @@ public Optional updateSubmissionComplexStats(Date date, PrideSt
Optional stats = findStatsBydate(date);
MongoPrideStats currentStats;
- if(!stats.isPresent()){
+ if(stats.isEmpty()){
Map submissionCounts = new HashMap<>();
submissionCounts.put(prideStatsKeysConstants.statsKey, submissionCount);
MongoPrideStats mongoPrideStats = MongoPrideStats.builder()
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/configs/AbstractPrideMongoConfiguration.java b/src/main/java/uk/ac/ebi/pride/mongodb/configs/AbstractPrideMongoConfiguration.java
index b942e8d..32f8740 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/configs/AbstractPrideMongoConfiguration.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/configs/AbstractPrideMongoConfiguration.java
@@ -1,37 +1,44 @@
package uk.ac.ebi.pride.mongodb.configs;
import com.mongodb.*;
-import org.springframework.data.mongodb.MongoDbFactory;
-import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
-import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
+import com.mongodb.client.MongoClient;
+import com.mongodb.client.MongoClients;
+import org.springframework.context.annotation.Bean;
+import org.springframework.data.mongodb.MongoDatabaseFactory;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
+
/**
* This Abstract class is used to Configure all the connections to Spring.
* @author ypriverol
*/
-public abstract class AbstractPrideMongoConfiguration extends AbstractMongoConfiguration {
+public abstract class AbstractPrideMongoConfiguration {
- @Override
- public MongoClient mongoClient() {
- MongoClient mongoClient = configureMachineFromURI(getMongoURI());
- return mongoClient;
+ @Bean
+ public MongoTemplate mongoTemplate() {
+ return new MongoTemplate(mongoDbFactory());
}
- @Override
- public MongoDbFactory mongoDbFactory(){
- return new SimpleMongoDbFactory(mongoClient(), getDatabaseName());
+ @Bean
+ public MongoDatabaseFactory mongoDbFactory(){
+ return new SimpleMongoClientDatabaseFactory(mongoClient(), getDatabaseName());
}
+ @Bean
+ public MongoClient mongoClient() {
+ return configureMachineFromURI(getMongoURI());
+ }
- /**
- * This method create a connection from an URI
- * @param uri URI in String format
- * @return MongoClient
- */
- public MongoClient configureMachineFromURI(String uri){
- MongoClientURI clientURI = new MongoClientURI(uri);
- return new MongoClient(clientURI);
+ public MongoClient configureMachineFromURI(String uri) {
+ ConnectionString connectionString = new ConnectionString(uri);
+ MongoClientSettings settings = MongoClientSettings.builder()
+ .applyConnectionString(connectionString)
+ .build();
+ return MongoClients.create(settings);
}
public abstract String getMongoURI();
+
+ public abstract String getDatabaseName();
}
diff --git a/src/main/java/uk/ac/ebi/pride/mongodb/configs/ArchiveMongoConfig.java b/src/main/java/uk/ac/ebi/pride/mongodb/configs/ArchiveMongoConfig.java
index c3f0e0c..c8da4dc 100644
--- a/src/main/java/uk/ac/ebi/pride/mongodb/configs/ArchiveMongoConfig.java
+++ b/src/main/java/uk/ac/ebi/pride/mongodb/configs/ArchiveMongoConfig.java
@@ -1,9 +1,11 @@
package uk.ac.ebi.pride.mongodb.configs;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -21,41 +23,18 @@ public class ArchiveMongoConfig extends AbstractPrideMongoConfiguration {
@Value("${mongodb.project.database}")
private String mongoProjectDatabase;
- @Value("${mongodb.project.app.user}")
- private String user;
-
- @Value("${mongodb.project.app.password}")
- private String password;
-
- @Value("${mongodb.project.app.authenticationDatabase}")
- private String authenticationDatabse;
-
- @Value("${mongodb.projects.replicate.hosts}")
- private String mongoHosts;
-
- @Value("${mongodb.projects.replicate.ports}")
- private String mongoPorts;
-
- @Value("${mongodb.project.app.machine.port}")
- private String port;
-
- @Value("${mongo.single.machine}")
- private String singleMachine;
-
- @Value("${mongodb.projects.single.machine.host}")
- private String mongoHost;
-
@Value("${mongodb.projects.machine.uri}")
private String mongoURI;
- @Override
- @Bean(name = "archiveMongoTemplate")
+ @Primary
+ @Bean
+ @Qualifier("archiveMongoTemplate")
public MongoTemplate mongoTemplate() {
- return new MongoTemplate(super.mongoDbFactory());
+ return super.mongoTemplate();
}
@Override
- protected String getDatabaseName() {
+ public String getDatabaseName() {
return mongoProjectDatabase;
}
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/ArchiveOracleConfig.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/ArchiveOracleConfig.java
index 6dfffb7..b9ab980 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/ArchiveOracleConfig.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/ArchiveOracleConfig.java
@@ -5,6 +5,7 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitialization;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -14,7 +15,7 @@
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-import javax.persistence.EntityManagerFactory;
+import jakarta.persistence.EntityManagerFactory;
import javax.sql.DataSource;
/**
@@ -43,6 +44,7 @@ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManager
}
@Bean(name = "oracleTransactionManager")
+ @DependsOnDatabaseInitialization
public JpaTransactionManager jpaTransactionManager(
@Qualifier("oracleEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideMongoLocalhostConfig.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideMongoLocalhostConfig.java
index 94a1166..d72f9bb 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideMongoLocalhostConfig.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideMongoLocalhostConfig.java
@@ -1,11 +1,11 @@
package uk.ac.ebi.pride.mongodb.archive.config;
-import com.mongodb.MongoClient;
+import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
-import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
+import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+import uk.ac.ebi.pride.mongodb.configs.AbstractPrideMongoConfiguration;
/**
* This code is licensed under the Apache License, Version 2.0 (the
@@ -22,21 +22,22 @@
@ComponentScan(basePackages = {"uk.ac.ebi.pride.mongodb.archive.service", "uk.ac.ebi.pride.utilities.ols.web.service.cache"})
@EnableMongoRepositories(basePackages = {"uk.ac.ebi.pride.mongodb.archive.repo"})
@Configuration
-public class PrideMongoLocalhostConfig extends AbstractMongoConfiguration {
+public class PrideMongoLocalhostConfig extends AbstractPrideMongoConfiguration {
+
@Override
- public MongoMappingContext mongoMappingContext()
- throws ClassNotFoundException {
- return super.mongoMappingContext();
+ @Bean(name = "archiveMongoTestTemplate")
+ public MongoTemplate mongoTemplate() {
+ return super.mongoTemplate();
}
@Override
- protected String getDatabaseName() {
- return "prideDB";
+ public String getMongoURI() {
+ return "localhost" + ":" + "27017";
}
@Override
- public MongoClient mongoClient() {
- return new MongoClient("localhost" + ":" + "27017");
+ public String getDatabaseName() {
+ return "prideDB";
}
}
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideProjectFongoTestConfig.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideProjectFongoTestConfig.java
index d4d9dda..6ec6ae0 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideProjectFongoTestConfig.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideProjectFongoTestConfig.java
@@ -1,35 +1,73 @@
package uk.ac.ebi.pride.mongodb.archive.config;
+//
+//import com.github.fakemongo.Fongo;
+//import com.mongodb.MongoClient;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.ComponentScan;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
+//import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
+//
+///**
+// * Test Configuration for Mongo PRIDE Projects using the fongo {@link Fongo} library.
+// *
+// * @author ypriverol
+// */
+//
+//@ComponentScan(basePackages = "uk.ac.ebi.pride.mongodb.archive.service")
+//@EnableMongoRepositories(basePackages = {"uk.ac.ebi.pride.mongodb.archive.repo"})
+//@Configuration
+//public class PrideProjectFongoTestConfig extends AbstractMongoConfiguration{
+//
+// @Override
+// protected String getDatabaseName() {
+// return "mongo-unit-test";
+// }
+//
+// @Bean
+// @Override
+// public MongoClient mongoClient() {
+// return new Fongo("mongo-test").getMongo();
+// }
+//}
+//
+//
+//
-import com.github.fakemongo.Fongo;
-import com.mongodb.MongoClient;
+import com.mongodb.client.MongoClients;
+import com.mongodb.client.MongoClient;
+import de.flapdoodle.embed.mongo.distribution.Version;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
-import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
+import de.flapdoodle.embed.mongo.MongodExecutable;
+import de.flapdoodle.embed.mongo.MongodStarter;
+import de.flapdoodle.embed.mongo.config.MongodConfig;
+import de.flapdoodle.embed.mongo.config.Net;
+import de.flapdoodle.embed.process.runtime.Network;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
-/**
- * Test Configuration for Mongo PRIDE Projects using the fongo {@link Fongo} library.
- *
- * @author ypriverol
- */
-
@ComponentScan(basePackages = "uk.ac.ebi.pride.mongodb.archive.service")
@EnableMongoRepositories(basePackages = {"uk.ac.ebi.pride.mongodb.archive.repo"})
@Configuration
-public class PrideProjectFongoTestConfig extends AbstractMongoConfiguration{
+public class PrideProjectFongoTestConfig {
- @Override
- protected String getDatabaseName() {
- return "mongo-unit-test";
- }
+ private MongodExecutable mongodExecutable;
@Bean
- @Override
- public MongoClient mongoClient() {
- return new Fongo("mongo-test").getMongo();
- }
-}
-
+ public MongoTemplate mongoTemplate() throws Exception {
+ MongodStarter starter = MongodStarter.getDefaultInstance();
+ MongodConfig mongodConfig = MongodConfig.builder()
+ .version(Version.Main.PRODUCTION)
+ .net(new Net(27017, Network.localhostIsIPv6()))
+ .build();
+ mongodExecutable = starter.prepare(mongodConfig);
+ mongodExecutable.start();
+ MongoClient mongoClient = MongoClients.create("mongodb://localhost:27017");
+ return new MongoTemplate(new SimpleMongoClientDatabaseFactory(mongoClient, "test"));
+ }
+}
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideProjectsHttpTestConfig.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideProjectsHttpTestConfig.java
index 9e9b99f..8c9bd9a 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideProjectsHttpTestConfig.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/config/PrideProjectsHttpTestConfig.java
@@ -17,78 +17,14 @@ public class PrideProjectsHttpTestConfig extends AbstractPrideMongoConfiguration
@Value("${mongodb.project.database}")
private String mongoProjectDatabase;
- @Value("${mongodb.project.app.user}")
- private String user;
-
- @Value("${mongodb.project.app.password}")
- private String password;
-
- @Value("${mongodb.project.app.authenticationDatabase}")
- private String authenticationDatabse;
-
- @Value("${mongodb.projects.replicate.hosts}")
- private String mongoHosts;
-
- @Value("${mongodb.projects.replicate.ports}")
- private String mongoPorts;
-
- @Value("${mongodb.project.app.machine.port}")
- private String port;
-
- @Value("${mongo.single.machine}")
- private String singleMachine;
-
- @Value("${mongodb.projects.single.machine.host}")
- private String mongoHost;
-
@Value("${mongodb.projects.machine.uri}")
private String mongoURI;
@Override
- protected String getDatabaseName() {
+ public String getDatabaseName() {
return mongoProjectDatabase;
}
-// @Override
-// public String getUser() {
-// return user;
-// }
-//
-// @Override
-// public String getPassword() {
-// return password;
-// }
-//
-// @Override
-// public String getAuthenticationDatabse() {
-// return authenticationDatabse;
-// }
-//
-// @Override
-// public String getMongoHosts() {
-// return mongoHosts;
-// }
-//
-// @Override
-// public String getMongoPorts() {
-// return mongoPorts;
-// }
-//
-// @Override
-// public String getPort() {
-// return port;
-// }
-//
-// @Override
-// public String getSingleMachine() {
-// return singleMachine;
-// }
-//
-// @Override
-// public String getMongoHost() {
-// return mongoHost;
-// }
-
@Override
public String getMongoURI() {
return mongoURI;
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/PrideFieldEnumTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/PrideFieldEnumTest.java
index c943efd..887bd94 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/PrideFieldEnumTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/PrideFieldEnumTest.java
@@ -1,7 +1,7 @@
package uk.ac.ebi.pride.mongodb.archive.model;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
/**
* This code is licensed under the Apache License, Version 2.0 (the
@@ -22,6 +22,6 @@ public void prideFieldEnumTest(){
for(PrideFieldEnum prideFieldEnum: PrideFieldEnum.values())
System.out.println(prideFieldEnum.toString());
- Assert.assertTrue(PrideFieldEnum.values().length > 0);
+ Assertions.assertTrue(PrideFieldEnum.values().length > 0);
}
}
\ No newline at end of file
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/files/MongoPrideFileTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/files/MongoPrideFileTest.java
index 751d41c..58a21c0 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/files/MongoPrideFileTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/files/MongoPrideFileTest.java
@@ -1,7 +1,7 @@
package uk.ac.ebi.pride.mongodb.archive.model.files;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import uk.ac.ebi.pride.archive.dataprovider.param.CvParamProvider;
import uk.ac.ebi.pride.archive.dataprovider.param.CvParam;
import uk.ac.ebi.pride.archive.dataprovider.utils.ProjectFileCategoryConstants;
@@ -24,7 +24,7 @@
public class MongoPrideFileTest {
MongoPrideFile file;
- @Before
+ @BeforeEach
public void setUp() {
CvParamProvider cvCategory = ProjectFileCategoryConstants.RAW.getCv();
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideAnalysisTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideAnalysisTest.java
index 166f64a..8dafe33 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideAnalysisTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideAnalysisTest.java
@@ -1,8 +1,8 @@
package uk.ac.ebi.pride.mongodb.archive.model.projects;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* This code is licensed under the Apache License, Version 2.0 (the
@@ -19,7 +19,7 @@ public class MongoPrideAnalysisTest {
MongoPrideAnalysis project;
- @Before
+ @BeforeEach
public void setUp() {
project = MongoPrideAnalysis.builder().accession("RPX000001").build();
@@ -28,6 +28,6 @@ public void setUp() {
@Test
public void mongoAnalysisTest(){
System.out.println(project.toString());
- Assert.assertTrue(project.accession.equalsIgnoreCase("RPX000001"));
+ Assertions.assertTrue(project.accession.equalsIgnoreCase("RPX000001"));
}
}
\ No newline at end of file
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideProjectTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideProjectTest.java
index 3a7b3a7..59dd145 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideProjectTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/projects/MongoPrideProjectTest.java
@@ -1,7 +1,7 @@
package uk.ac.ebi.pride.mongodb.archive.model.projects;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.Collection;
import java.util.Collections;
@@ -21,7 +21,7 @@ public class MongoPrideProjectTest {
MongoPrideProject project;
- @Before
+ @BeforeEach
public void setUp() {
Collection tags = Collections.singleton("Metaproteomics");
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/reference/MongoReferenceTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/reference/MongoReferenceTest.java
index 4cee85e..1fbb71d 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/reference/MongoReferenceTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/model/reference/MongoReferenceTest.java
@@ -1,8 +1,8 @@
package uk.ac.ebi.pride.mongodb.archive.model.reference;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import uk.ac.ebi.pride.archive.dataprovider.reference.Reference;
/**
@@ -20,7 +20,7 @@ public class MongoReferenceTest {
Reference ref;
- @Before
+ @BeforeEach
public void setUp() {
ref = new Reference("Uszkoreit, Julian, et al. \"PIA: An intuitive protein inference engine with a web-based user interface.\" Journal of proteome research 14.7 (2015): 2988-2997.",25938255,"10.1021/acs.jproteome.5b00121");
@@ -29,7 +29,7 @@ public void setUp() {
@Test
public void mongReferenceTest(){
System.out.println(ref.toString());
- Assert.assertEquals(25938255, ref.getPubmedId());
+ Assertions.assertEquals(25938255, ref.getPubmedId());
}
@Test
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/fongo/projects/PrideFongoProjectServiceTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/fongo/projects/PrideFongoProjectServiceTest.java
index aef51e7..f310220 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/fongo/projects/PrideFongoProjectServiceTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/fongo/projects/PrideFongoProjectServiceTest.java
@@ -1,12 +1,10 @@
package uk.ac.ebi.pride.mongodb.archive.service.fongo.projects;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
import uk.ac.ebi.pride.archive.dataprovider.common.Triple;
import uk.ac.ebi.pride.archive.dataprovider.common.Tuple;
import uk.ac.ebi.pride.archive.dataprovider.param.CvParamProvider;
@@ -37,7 +35,6 @@
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = {PrideProjectFongoTestConfig.class})
public class PrideFongoProjectServiceTest {
@@ -50,7 +47,7 @@ public class PrideFongoProjectServiceTest {
@Autowired
PrideMsRunMongoService prideMsRunMongoService;
- @Before
+ @BeforeEach
public void setUp(){
}
@@ -79,7 +76,7 @@ private Submission readSubmission() throws SubmissionFileException, URISyntaxExc
@Test
public void importPrideProject() throws SubmissionFileException, URISyntaxException {
Optional project = prideProjectService.insert(TestUtils.parseProject(readSubmission()));
- Assert.assertTrue(project.get()
+ Assertions.assertTrue(project.get()
.getAccession().equalsIgnoreCase("PXD000003"));
}
@@ -109,7 +106,7 @@ public void importPrideProjectWithFiles() throws SubmissionFileException, URISyn
}).collect(Collectors.toList());
List> filesInserted= prideFileMongoService.insertAllFilesAndMsRuns(mongoFiles,null);
- Assert.assertEquals(mongoFiles.size(), dataFiles.size());
+ Assertions.assertEquals(mongoFiles.size(), dataFiles.size());
List> fileRelations = new ArrayList<>();
for(DataFile dataFile: dataFiles){
@@ -123,7 +120,7 @@ public void importPrideProjectWithFiles() throws SubmissionFileException, URISyn
}
project = prideProjectService.updateFileRelations(project.get().getAccession(),fileRelations);
- Assert.assertEquals(600, project.get().getSubmittedFileRelations().size());
+ Assertions.assertEquals(600, project.get().getSubmittedFileRelations().size());
@@ -148,7 +145,7 @@ public void updateTypeOfRawMSRun() throws SubmissionFileException, URISyntaxExce
}).collect(Collectors.toList());
List> filesInserted= prideFileMongoService.insertAllFilesAndMsRuns(mongoFiles,null);
- Assert.assertEquals(mongoFiles.size(), dataFiles.size());
+ Assertions.assertEquals(mongoFiles.size(), dataFiles.size());
for(MongoPrideFile prideFile: prideFileMongoService.findFilesByProjectAccession(project.get().getAccession())){
if(prideFile.getFileCategory().getAccession().equalsIgnoreCase(ProjectFileCategoryConstants.RAW.getCv().getAccession())){
@@ -158,7 +155,7 @@ public void updateTypeOfRawMSRun() throws SubmissionFileException, URISyntaxExce
}
List msRuns = prideMsRunMongoService.getMSRunsByProject(project.get().getAccession());
- Assert.assertEquals(150, msRuns.size());
+ Assertions.assertEquals(150, msRuns.size());
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/fongo/stats/PrideStatsMongoServiceTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/fongo/stats/PrideStatsMongoServiceTest.java
index b3655e4..8bb0713 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/fongo/stats/PrideStatsMongoServiceTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/fongo/stats/PrideStatsMongoServiceTest.java
@@ -1,11 +1,9 @@
package uk.ac.ebi.pride.mongodb.archive.service.fongo.stats;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
import uk.ac.ebi.pride.archive.dataprovider.common.Tuple;
import uk.ac.ebi.pride.mongodb.archive.config.PrideProjectFongoTestConfig;
import uk.ac.ebi.pride.mongodb.archive.model.stats.MongoPrideStats;
@@ -27,7 +25,6 @@
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = {PrideProjectFongoTestConfig.class})
public class PrideStatsMongoServiceTest {
@@ -66,7 +63,7 @@ public void findStatsBydate() {
insertDataset();
Optional findDatasets = service.findStatsBydate(date);
findDatasets.ifPresent(mongoPrideStats -> System.out.println(mongoPrideStats.getEstimationDate()));
- Assert.assertTrue(findDatasets.isPresent());
+ Assertions.assertTrue(findDatasets.isPresent());
}
@@ -77,7 +74,7 @@ public void updateSubmissionCountStats() {
service.updateSubmissionCountStats(date, PrideStatsKeysConstants.SUBMISSIONS_PER_YEAR, monthlySubmissions);
Optional findDatasets = service.findStatsBydate(date);
findDatasets.ifPresent(mongoPrideStats -> System.out.println(mongoPrideStats.getSubmissionsCount().size()));
- Assert.assertEquals(5, findDatasets.get().getSubmissionsCount().get(PrideStatsKeysConstants.SUBMISSIONS_PER_YEAR.getStatsKey()).size());
+ Assertions.assertEquals(5, findDatasets.get().getSubmissionsCount().get(PrideStatsKeysConstants.SUBMISSIONS_PER_YEAR.getStatsKey()).size());
}
@Test
@@ -92,7 +89,7 @@ public void findLastGeneratedStats() {
if(findDatasets != null)
System.out.println(findDatasets.getEstimationDate());
assert findDatasets != null;
- Assert.assertEquals(4, Objects.requireNonNull(findDatasets).getSubmissionsCount().get(PrideStatsKeysConstants.SUBMISSIONS_PER_YEAR.getStatsKey()).size());
+ Assertions.assertEquals(4, Objects.requireNonNull(findDatasets).getSubmissionsCount().get(PrideStatsKeysConstants.SUBMISSIONS_PER_YEAR.getStatsKey()).size());
}
}
\ No newline at end of file
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/integration/projects/PrideFileMongoServiceTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/integration/projects/PrideFileMongoServiceTest.java
index 1d7a3a1..67db7eb 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/integration/projects/PrideFileMongoServiceTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/integration/projects/PrideFileMongoServiceTest.java
@@ -1,15 +1,13 @@
package uk.ac.ebi.pride.mongodb.archive.service.integration.projects;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
import uk.ac.ebi.pride.archive.dataprovider.param.CvParam;
import uk.ac.ebi.pride.archive.dataprovider.utils.MSFileTypeConstants;
import uk.ac.ebi.pride.archive.repo.repos.file.ProjectFile;
@@ -35,7 +33,6 @@
*
* @author ypriverol
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = {PrideProjectFongoTestConfig.class, ArchiveOracleConfig.class})
@TestPropertySource(locations = "classpath:application-test.properties")
public class PrideFileMongoServiceTest {
@@ -49,7 +46,7 @@ public class PrideFileMongoServiceTest {
@Autowired
ProjectRepository oracleProjectRepository;
- @Ignore
+ @Disabled
@Test
public void save() {
MongoPrideFile file = MongoPrideFile
@@ -59,7 +56,7 @@ public void save() {
}
@Test
- @Ignore
+ @Disabled
public void searchFilesTest(){
insertFilesSave();
String filterRaw = "fileCategory.value==RESULT";
@@ -128,7 +125,7 @@ private void insertFilesSave(){
}
);
- Assert.assertEquals(400, prideFileMongoService.count());
+ Assertions.assertEquals(400, prideFileMongoService.count());
}
@@ -165,7 +162,7 @@ private void insertFilesInBatchSave(){
prideFileMongoService.insertAllFilesAndMsRuns(mongoPrideFiles,null);
});
- Assert.assertEquals(1200, prideFileMongoService.count());
+ Assertions.assertEquals(1200, prideFileMongoService.count());
}
}
\ No newline at end of file
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/localhost/projects/PrideLocalhostProjectServiceTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/localhost/projects/PrideLocalhostProjectServiceTest.java
index 578c0bc..ad4dea7 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/localhost/projects/PrideLocalhostProjectServiceTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/localhost/projects/PrideLocalhostProjectServiceTest.java
@@ -1,13 +1,11 @@
package uk.ac.ebi.pride.mongodb.archive.service.localhost.projects;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
import uk.ac.ebi.pride.archive.dataprovider.common.Triple;
import uk.ac.ebi.pride.archive.dataprovider.common.Tuple;
import uk.ac.ebi.pride.archive.dataprovider.param.CvParam;
@@ -40,7 +38,6 @@
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = {PrideMongoLocalhostConfig.class, ArchiveOracleConfig.class})
public class PrideLocalhostProjectServiceTest {
@@ -54,7 +51,7 @@ public class PrideLocalhostProjectServiceTest {
PrideMsRunMongoService prideMsRunMongoService;
- @Before
+ @BeforeEach
public void setup(){
// prideProjectService.deleteAll();
// prideFileMongoService.deleteAll();
@@ -94,7 +91,7 @@ private MSRunJson readMSrunMetadata() throws URISyntaxException, IOException {
@Test
public void importPrideProject() throws SubmissionFileException, URISyntaxException {
Optional project = prideProjectService.insert(TestUtils.parseProject(readSubmission()));
- Assert.assertTrue(project.get()
+ Assertions.assertTrue(project.get()
.getAccession().equalsIgnoreCase("PXD000003"));
}
@@ -125,7 +122,7 @@ public void importPrideProjectWithFiles() throws SubmissionFileException, URISyn
}).collect(Collectors.toList());
List> filesInserted= prideFileMongoService.insertAllFilesAndMsRuns(mongoFiles,null);
- Assert.assertEquals(mongoFiles.size(), dataFiles.size());
+ Assertions.assertEquals(mongoFiles.size(), dataFiles.size());
List> fileRelations = new ArrayList<>();
for(DataFile dataFile: dataFiles){
@@ -139,7 +136,7 @@ public void importPrideProjectWithFiles() throws SubmissionFileException, URISyn
}
project = prideProjectService.updateFileRelations(project.get().getAccession(),fileRelations);
- Assert.assertEquals(600, project.get().getSubmittedFileRelations().size());
+ Assertions.assertEquals(600, project.get().getSubmittedFileRelations().size());
@@ -164,7 +161,7 @@ public void updateTypeOfRawMSRun() throws SubmissionFileException, URISyntaxExce
}).collect(Collectors.toList());
List> filesInserted= prideFileMongoService.insertAllFilesAndMsRuns(mongoFiles,null);
- Assert.assertEquals(mongoFiles.size(), dataFiles.size());
+ Assertions.assertEquals(mongoFiles.size(), dataFiles.size());
MSRunJson msRunJson = readMSrunMetadata();
@@ -190,7 +187,7 @@ public void updateTypeOfRawMSRun() throws SubmissionFileException, URISyntaxExce
}
List msRuns = prideMsRunMongoService.getMSRunsByProject(project.get().getAccession());
- Assert.assertEquals(150, msRuns.size());
+ Assertions.assertEquals(150, msRuns.size());
}
/**
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/mockito/PridePeptideEvidenceMongoServiceTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/mockito/PridePeptideEvidenceMongoServiceTest.java
index 786817b..69689c6 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/mockito/PridePeptideEvidenceMongoServiceTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/mockito/PridePeptideEvidenceMongoServiceTest.java
@@ -1,14 +1,11 @@
package uk.ac.ebi.pride.mongodb.archive.service.mockito;
-import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
import uk.ac.ebi.pride.mongodb.archive.config.PrideProjectFongoTestConfig;
/**
* @author ypriverol
*/
-@RunWith(SpringRunner.class)
@SpringBootTest(classes = {PrideProjectFongoTestConfig.class})
public class PridePeptideEvidenceMongoServiceTest {
diff --git a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/stats/CategoryStatsTest.java b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/stats/CategoryStatsTest.java
index 03c32b6..a710990 100644
--- a/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/stats/CategoryStatsTest.java
+++ b/src/test/java/uk/ac/ebi/pride/mongodb/archive/service/stats/CategoryStatsTest.java
@@ -1,8 +1,8 @@
package uk.ac.ebi.pride.mongodb.archive.service.stats;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import uk.ac.ebi.pride.archive.dataprovider.common.Tuple;
/**
@@ -20,7 +20,7 @@ public class CategoryStatsTest {
CategoryStats stats;
- @Before
+ @BeforeEach
public void setUp() {
stats = CategoryStats
.builder()
@@ -31,7 +31,7 @@ public void setUp() {
@Test
public void CategoryTest(){
System.out.println(stats.toString());
- Assert.assertEquals(new Tuple<>("Number od Submissions", 30000), stats.getCategory());
+ Assertions.assertEquals(new Tuple<>("Number od Submissions", 30000), stats.getCategory());
}
@Test
diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties
index af9abe0..46c41e1 100644
--- a/src/test/resources/application-test.properties
+++ b/src/test/resources/application-test.properties
@@ -11,14 +11,14 @@ spring.datasource.oracle.driver.class.name=@pride.archive.repo.jdbc.driver@
# Configuration for MongoDB
mongodb.project.database=@maven.spring.pridedb.datasource.mongo.db@
-mongodb.project.app.user=@maven.spring.pridedb.datasource.mongo.user@
-mongodb.project.app.password=@maven.spring.pridedb.datasource.mongo.password@
-mongodb.project.app.authenticationDatabase=@maven.spring.pridedb.datasource.mongo.authenticationDatabase@
-mongodb.projects.replicate.hosts=@maven.spring.pridedb.datasource.mongo.replicate.hosts@
-mongodb.projects.replicate.ports=@maven.spring.pridedb.datasource.mongo.replicate.ports@
-mongodb.project.app.machine.port=@maven.spring.pridedb.datasource.mongo.single.machine.port@
-mongo.single.machine=@maven.spring.pridedb.datasource.mongo.single.machine@
-mongodb.projects.single.machine.host=@maven.spring.pridedb.datasource.mongo.single.machine.host@
+#mongodb.project.app.user=@maven.spring.pridedb.datasource.mongo.user@
+#mongodb.project.app.password=@maven.spring.pridedb.datasource.mongo.password@
+#mongodb.project.app.authenticationDatabase=@maven.spring.pridedb.datasource.mongo.authenticationDatabase@
+#mongodb.projects.replicate.hosts=@maven.spring.pridedb.datasource.mongo.replicate.hosts@
+#mongodb.projects.replicate.ports=@maven.spring.pridedb.datasource.mongo.replicate.ports@
+#mongodb.project.app.machine.port=@maven.spring.pridedb.datasource.mongo.single.machine.port@
+#mongo.single.machine=@maven.spring.pridedb.datasource.mongo.single.machine@
+#mongodb.projects.single.machine.host=@maven.spring.pridedb.datasource.mongo.single.machine.host@
mongodb.projects.machine.uri=@maven.spring.pridedb.datasource.mongo.machine.uri@
#Configure Default Database