DATAMONGO-2481 - Polishing.

Migrate more tests to JUnit 5. Rearrange methods. Reduce method visibility according to JUnit 5 requirements.

Remove Java 11 build and only use Java 8 and 13.

Original pull request: #838.
This commit is contained in:
Mark Paluch
2020-03-06 11:33:40 +01:00
parent 8029acb3fb
commit 46ab6b4c94
176 changed files with 1701 additions and 1676 deletions

36
Jenkinsfile vendored
View File

@@ -46,22 +46,6 @@ pipeline {
}
}
}
stage('Publish JDK 11 + MongoDB 4.2') {
when {
changeset "ci/openjdk11-mongodb-4.2/**"
}
agent { label 'data' }
options { timeout(time: 30, unit: 'MINUTES') }
steps {
script {
def image = docker.build("springci/spring-data-openjdk11-with-mongodb-4.2.0", "ci/openjdk11-mongodb-4.2/")
docker.withRegistry('', 'hub.docker.com-springbuildmaster') {
image.push()
}
}
}
}
stage('Publish JDK 13 + MongoDB 4.2') {
when {
changeset "ci/openjdk13-mongodb-4.2/**"
@@ -155,26 +139,6 @@ pipeline {
}
}
stage("test: baseline (jdk11)") {
agent {
docker {
image 'springci/spring-data-openjdk11-with-mongodb-4.2.0:latest'
label 'data'
args '-v $HOME:/tmp/jenkins-home'
}
}
options { timeout(time: 30, unit: 'MINUTES') }
steps {
sh 'rm -rf ?'
sh 'mkdir -p /tmp/mongodb/db /tmp/mongodb/log'
sh 'mongod --setParameter transactionLifetimeLimitSeconds=90 --setParameter maxTransactionLockRequestTimeoutMillis=10000 --dbpath /tmp/mongodb/db --replSet rs0 --fork --logpath /tmp/mongodb/log/mongod.log &'
sh 'sleep 10'
sh 'mongo --eval "rs.initiate({_id: \'rs0\', members:[{_id: 0, host: \'127.0.0.1:27017\'}]});"'
sh 'sleep 15'
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Duser.name=jenkins -Dsort -U -B'
}
}
stage("test: baseline (jdk13)") {
agent {
docker {

View File

@@ -344,12 +344,6 @@
<java.util.logging.config.file>src/test/resources/logging.properties</java.util.logging.config.file>
<reactor.trace.cancel>true</reactor.trace.cancel>
</systemPropertyVariables>
<properties>
<property>
<name>listener</name>
<value>org.springframework.data.mongodb.test.util.CleanMongoDBJunitRunListener</value>
</property>
</properties>
</configuration>
</plugin>

View File

@@ -13,7 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**

View File

@@ -16,11 +16,11 @@
package org.springframework.data.mongodb;
import static de.schauderhaft.degraph.check.JCheck.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.*;
import de.schauderhaft.degraph.configuration.NamedPattern;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Tests package dependency constraints.
@@ -28,10 +28,10 @@ import org.junit.Test;
* @author Jens Schauder
* @author Oliver Gierke
*/
public class DependencyTests {
class DependencyTests {
@Test
public void noInternalPackageCycles() {
void noInternalPackageCycles() {
assertThat(classpath() //
.noJars() //
@@ -43,7 +43,7 @@ public class DependencyTests {
}
@Test
public void onlyConfigMayUseRepository() {
void onlyConfigMayUseRepository() {
assertThat(classpath() //
.including("org.springframework.data.**") //
@@ -60,7 +60,7 @@ public class DependencyTests {
}
@Test
public void commonsInternaly() {
void commonsInternaly() {
assertThat(classpath() //
.noJars() //

View File

@@ -22,12 +22,11 @@ import static org.mockito.Mockito.*;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.jta.JtaTransactionManager;
@@ -42,8 +41,8 @@ import com.mongodb.session.ServerSession;
/**
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
public class MongoDatabaseUtilsUnitTests {
@ExtendWith(MockitoExtension.class)
class MongoDatabaseUtilsUnitTests {
@Mock ClientSession session;
@Mock ServerSession serverSession;
@@ -52,23 +51,8 @@ public class MongoDatabaseUtilsUnitTests {
@Mock UserTransaction userTransaction;
@Before
public void setUp() {
when(dbFactory.getSession(any())).thenReturn(session);
when(dbFactory.withSession(session)).thenReturn(dbFactory);
when(dbFactory.getMongoDatabase()).thenReturn(db);
when(session.getServerSession()).thenReturn(serverSession);
when(session.hasActiveTransaction()).thenReturn(true);
when(serverSession.isClosed()).thenReturn(false);
}
@After
public void verifyTransactionSynchronizationManagerState() {
@AfterEach
void verifyTransactionSynchronizationManagerState() {
assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue();
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
@@ -79,7 +63,7 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-2130
public void isTransactionActiveShouldDetectTxViaFactory() {
void isTransactionActiveShouldDetectTxViaFactory() {
when(dbFactory.isTransactionActive()).thenReturn(true);
@@ -87,7 +71,7 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-2130
public void isTransactionActiveShouldReturnFalseIfNoTxActive() {
void isTransactionActiveShouldReturnFalseIfNoTxActive() {
when(dbFactory.isTransactionActive()).thenReturn(false);
@@ -95,7 +79,12 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-2130
public void isTransactionActiveShouldLookupTxForActiveTransactionSynchronizationViaTxManager() {
void isTransactionActiveShouldLookupTxForActiveTransactionSynchronizationViaTxManager() {
when(dbFactory.getSession(any())).thenReturn(session);
when(session.getServerSession()).thenReturn(serverSession);
when(session.hasActiveTransaction()).thenReturn(true);
when(serverSession.isClosed()).thenReturn(false);
when(dbFactory.isTransactionActive()).thenReturn(false);
@@ -112,7 +101,7 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-1920
public void shouldNotStartSessionWhenNoTransactionOngoing() {
void shouldNotStartSessionWhenNoTransactionOngoing() {
MongoDatabaseUtils.getDatabase(dbFactory, SessionSynchronization.ON_ACTUAL_TRANSACTION);
@@ -121,7 +110,14 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-1920
public void shouldParticipateInOngoingJtaTransactionWithCommitWhenSessionSychronizationIsAny() throws Exception {
void shouldParticipateInOngoingJtaTransactionWithCommitWhenSessionSychronizationIsAny() throws Exception {
when(dbFactory.getSession(any())).thenReturn(session);
when(dbFactory.withSession(session)).thenReturn(dbFactory);
when(dbFactory.getMongoDatabase()).thenReturn(db);
when(session.getServerSession()).thenReturn(serverSession);
when(session.hasActiveTransaction()).thenReturn(true);
when(serverSession.isClosed()).thenReturn(false);
when(userTransaction.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE,
Status.STATUS_ACTIVE);
@@ -152,7 +148,14 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-1920
public void shouldParticipateInOngoingJtaTransactionWithRollbackWhenSessionSychronizationIsAny() throws Exception {
void shouldParticipateInOngoingJtaTransactionWithRollbackWhenSessionSychronizationIsAny() throws Exception {
when(dbFactory.getSession(any())).thenReturn(session);
when(dbFactory.withSession(session)).thenReturn(dbFactory);
when(dbFactory.getMongoDatabase()).thenReturn(db);
when(session.getServerSession()).thenReturn(serverSession);
when(session.hasActiveTransaction()).thenReturn(true);
when(serverSession.isClosed()).thenReturn(false);
when(userTransaction.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE,
Status.STATUS_ACTIVE);
@@ -185,8 +188,7 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-1920
public void shouldNotParticipateInOngoingJtaTransactionWithRollbackWhenSessionSychronizationIsNative()
throws Exception {
void shouldNotParticipateInOngoingJtaTransactionWithRollbackWhenSessionSychronizationIsNative() throws Exception {
when(userTransaction.getStatus()).thenReturn(Status.STATUS_NO_TRANSACTION, Status.STATUS_ACTIVE,
Status.STATUS_ACTIVE);
@@ -219,7 +221,13 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-1920
public void shouldParticipateInOngoingMongoTransactionWhenSessionSychronizationIsNative() {
void shouldParticipateInOngoingMongoTransactionWhenSessionSychronizationIsNative() {
when(dbFactory.getSession(any())).thenReturn(session);
when(dbFactory.withSession(session)).thenReturn(dbFactory);
when(dbFactory.getMongoDatabase()).thenReturn(db);
when(session.getServerSession()).thenReturn(serverSession);
when(serverSession.isClosed()).thenReturn(false);
MongoTransactionManager txManager = new MongoTransactionManager(dbFactory);
TransactionTemplate txTemplate = new TransactionTemplate(txManager);
@@ -245,7 +253,13 @@ public class MongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-1920
public void shouldParticipateInOngoingMongoTransactionWhenSessionSychronizationIsAny() {
void shouldParticipateInOngoingMongoTransactionWhenSessionSynchronizationIsAny() {
when(dbFactory.getSession(any())).thenReturn(session);
when(dbFactory.withSession(session)).thenReturn(dbFactory);
when(dbFactory.getMongoDatabase()).thenReturn(db);
when(session.getServerSession()).thenReturn(serverSession);
when(serverSession.isClosed()).thenReturn(false);
MongoTransactionManager txManager = new MongoTransactionManager(dbFactory);
TransactionTemplate txTemplate = new TransactionTemplate(txManager);

View File

@@ -18,12 +18,12 @@ package org.springframework.data.mongodb;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.transaction.TransactionDefinition;
@@ -41,7 +41,7 @@ import com.mongodb.session.ServerSession;
/**
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MongoTransactionManagerUnitTests {
@Mock ClientSession session;
@@ -52,24 +52,16 @@ public class MongoTransactionManagerUnitTests {
@Mock MongoDatabase db;
@Mock MongoDatabase db2;
@Before
@BeforeEach
public void setUp() {
when(dbFactory.getSession(any())).thenReturn(session, session2);
when(dbFactory.withSession(session)).thenReturn(dbFactory);
when(dbFactory.withSession(session2)).thenReturn(dbFactory2);
when(dbFactory.getMongoDatabase()).thenReturn(db);
when(dbFactory2.getMongoDatabase()).thenReturn(db2);
when(session.getServerSession()).thenReturn(serverSession);
when(session2.getServerSession()).thenReturn(serverSession);
when(serverSession.isClosed()).thenReturn(false);
}
@After
@AfterEach
public void verifyTransactionSynchronizationManager() {
assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue();
@@ -238,6 +230,11 @@ public class MongoTransactionManagerUnitTests {
@Test // DATAMONGO-1920
public void suspendTransactionWhilePropagationRequiresNew() {
when(dbFactory.withSession(session2)).thenReturn(dbFactory2);
when(dbFactory2.getMongoDatabase()).thenReturn(db2);
when(session2.getServerSession()).thenReturn(serverSession);
when(serverSession.isClosed()).thenReturn(false);
MongoTransactionManager txManager = new MongoTransactionManager(dbFactory);
TransactionStatus txStatus = txManager.getTransaction(new DefaultTransactionDefinition());

View File

@@ -22,11 +22,10 @@ import static org.mockito.Mockito.*;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.transaction.reactive.TransactionSynchronizationManager;
import org.springframework.transaction.reactive.TransactionalOperator;
@@ -42,26 +41,16 @@ import com.mongodb.session.ServerSession;
* @author Mark Paluch
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
public class ReactiveMongoDatabaseUtilsUnitTests {
@ExtendWith(MockitoExtension.class)
class ReactiveMongoDatabaseUtilsUnitTests {
@Mock ClientSession session;
@Mock ServerSession serverSession;
@Mock ReactiveMongoDatabaseFactory databaseFactory;
@Mock MongoDatabase db;
@Before
public void setUp() {
when(databaseFactory.getSession(any())).thenReturn(Mono.just(session));
when(databaseFactory.getMongoDatabase()).thenReturn(db);
when(session.getServerSession()).thenReturn(serverSession);
when(session.hasActiveTransaction()).thenReturn(true);
}
@Test // DATAMONGO-2265
public void isTransactionActiveShouldDetectTxViaFactory() {
void isTransactionActiveShouldDetectTxViaFactory() {
when(databaseFactory.isTransactionActive()).thenReturn(true);
@@ -71,7 +60,7 @@ public class ReactiveMongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-2265
public void isTransactionActiveShouldReturnFalseIfNoTxActive() {
void isTransactionActiveShouldReturnFalseIfNoTxActive() {
when(databaseFactory.isTransactionActive()).thenReturn(false);
@@ -81,8 +70,11 @@ public class ReactiveMongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-2265
public void isTransactionActiveShouldLookupTxForActiveTransactionSynchronizationViaTxManager() {
void isTransactionActiveShouldLookupTxForActiveTransactionSynchronizationViaTxManager() {
when(session.getServerSession()).thenReturn(serverSession);
when(session.hasActiveTransaction()).thenReturn(true);
when(databaseFactory.getSession(any())).thenReturn(Mono.just(session));
when(databaseFactory.isTransactionActive()).thenReturn(false);
when(session.commitTransaction()).thenReturn(Mono.empty());
@@ -96,7 +88,9 @@ public class ReactiveMongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-2265
public void shouldNotStartSessionWhenNoTransactionOngoing() {
void shouldNotStartSessionWhenNoTransactionOngoing() {
when(databaseFactory.getMongoDatabase()).thenReturn(db);
ReactiveMongoDatabaseUtils.getDatabase(databaseFactory, SessionSynchronization.ON_ACTUAL_TRANSACTION) //
.as(StepVerifier::create) //
@@ -108,7 +102,10 @@ public class ReactiveMongoDatabaseUtilsUnitTests {
}
@Test // DATAMONGO-2265
public void shouldParticipateInOngoingMongoTransactionWhenSessionSychronizationIsNative() {
void shouldParticipateInOngoingMongoTransactionWhenSessionSychronizationIsNative() {
when(session.getServerSession()).thenReturn(serverSession);
when(databaseFactory.getSession(any())).thenReturn(Mono.just(session));
ReactiveMongoTransactionManager txManager = new ReactiveMongoTransactionManager(databaseFactory);
when(session.abortTransaction()).thenReturn(Mono.empty());

View File

@@ -15,24 +15,21 @@
*/
package org.springframework.data.mongodb;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.reactive.TransactionalOperator;
import org.springframework.transaction.support.DefaultTransactionDefinition;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import com.mongodb.reactivestreams.client.ClientSession;
import com.mongodb.reactivestreams.client.MongoDatabase;
@@ -44,8 +41,8 @@ import com.mongodb.session.ServerSession;
* @author Mark Paluch
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
public class ReactiveMongoTransactionManagerUnitTests {
@ExtendWith(MockitoExtension.class)
class ReactiveMongoTransactionManagerUnitTests {
@Mock ClientSession session;
@Mock ClientSession session2;
@@ -55,30 +52,16 @@ public class ReactiveMongoTransactionManagerUnitTests {
@Mock MongoDatabase db;
@Mock MongoDatabase db2;
@Before
public void setUp() {
@BeforeEach
void setUp() {
when(databaseFactory.getSession(any())).thenReturn(Mono.just(session), Mono.just(session2));
when(databaseFactory.withSession(session)).thenReturn(databaseFactory);
when(databaseFactory.withSession(session2)).thenReturn(databaseFactory2);
when(databaseFactory.getMongoDatabase()).thenReturn(db);
when(databaseFactory2.getMongoDatabase()).thenReturn(db2);
when(session.getServerSession()).thenReturn(serverSession);
when(session2.getServerSession()).thenReturn(serverSession);
}
@After
public void verifyTransactionSynchronizationManager() {
assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue();
assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse();
}
@Test // DATAMONGO-2265
public void triggerCommitCorrectly() {
void triggerCommitCorrectly() {
ReactiveMongoTransactionManager txManager = new ReactiveMongoTransactionManager(databaseFactory);
ReactiveMongoTemplate template = new ReactiveMongoTemplate(databaseFactory);
@@ -103,7 +86,7 @@ public class ReactiveMongoTransactionManagerUnitTests {
}
@Test // DATAMONGO-2265
public void participateInOnGoingTransactionWithCommit() {
void participateInOnGoingTransactionWithCommit() {
ReactiveMongoTransactionManager txManager = new ReactiveMongoTransactionManager(databaseFactory);
ReactiveMongoTemplate template = new ReactiveMongoTemplate(databaseFactory);
@@ -131,7 +114,7 @@ public class ReactiveMongoTransactionManagerUnitTests {
}
@Test // DATAMONGO-2265
public void participateInOnGoingTransactionWithRollbackOnly() {
void participateInOnGoingTransactionWithRollbackOnly() {
ReactiveMongoTransactionManager txManager = new ReactiveMongoTransactionManager(databaseFactory);
ReactiveMongoTemplate template = new ReactiveMongoTemplate(databaseFactory);
@@ -156,7 +139,7 @@ public class ReactiveMongoTransactionManagerUnitTests {
}
@Test // DATAMONGO-2265
public void suspendTransactionWhilePropagationNotSupported() {
void suspendTransactionWhilePropagationNotSupported() {
ReactiveMongoTransactionManager txManager = new ReactiveMongoTransactionManager(databaseFactory);
ReactiveMongoTemplate template = new ReactiveMongoTemplate(databaseFactory);
@@ -195,7 +178,11 @@ public class ReactiveMongoTransactionManagerUnitTests {
}
@Test // DATAMONGO-2265
public void suspendTransactionWhilePropagationRequiresNew() {
void suspendTransactionWhilePropagationRequiresNew() {
when(databaseFactory.withSession(session2)).thenReturn(databaseFactory2);
when(databaseFactory2.getMongoDatabase()).thenReturn(db2);
when(session2.getServerSession()).thenReturn(serverSession);
ReactiveMongoTransactionManager txManager = new ReactiveMongoTransactionManager(databaseFactory);
ReactiveMongoTemplate template = new ReactiveMongoTemplate(databaseFactory);
@@ -237,7 +224,7 @@ public class ReactiveMongoTransactionManagerUnitTests {
}
@Test // DATAMONGO-2265
public void readonlyShouldInitiateASessionStartAndCommitTransaction() {
void readonlyShouldInitiateASessionStartAndCommitTransaction() {
ReactiveMongoTransactionManager txManager = new ReactiveMongoTransactionManager(databaseFactory);
ReactiveMongoTemplate template = new ReactiveMongoTemplate(databaseFactory);

View File

@@ -24,11 +24,12 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.data.mongodb.SessionAwareMethodInterceptor.MethodCache;
import org.springframework.test.util.ReflectionTestUtils;
@@ -44,7 +45,7 @@ import com.mongodb.client.MongoDatabase;
*
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class SessionAwareMethodInterceptorUnitTests {
@Mock ClientSession session;
@@ -54,7 +55,7 @@ public class SessionAwareMethodInterceptorUnitTests {
MongoCollection collection;
MongoDatabase database;
@Before
@BeforeEach
public void setUp() {
collection = createProxyInstance(session, targetCollection, MongoCollection.class);

View File

@@ -25,7 +25,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

View File

@@ -25,7 +25,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.config;
import static org.assertj.core.api.Assertions.*;
import org.joda.time.DateTime;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

View File

@@ -21,7 +21,7 @@ import java.util.Collections;
import java.util.Set;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanReference;

View File

@@ -17,10 +17,10 @@ package org.springframework.data.mongodb.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.core.type.AnnotationMetadata;
@@ -30,21 +30,21 @@ import org.springframework.core.type.AnnotationMetadata;
*
* @author Oliver Gierke
*/
@RunWith(MockitoJUnitRunner.class)
public class MongoAuditingRegistrarUnitTests {
@ExtendWith(MockitoExtension.class)
class MongoAuditingRegistrarUnitTests {
MongoAuditingRegistrar registrar = new MongoAuditingRegistrar();
private MongoAuditingRegistrar registrar = new MongoAuditingRegistrar();
@Mock AnnotationMetadata metadata;
@Mock BeanDefinitionRegistry registry;
@Test // DATAMONGO-792
public void rejectsNullAnnotationMetadata() {
void rejectsNullAnnotationMetadata() {
assertThatIllegalArgumentException().isThrownBy(() -> registrar.registerBeanDefinitions(null, registry));
}
@Test // DATAMONGO-792
public void rejectsNullBeanDefinitionRegistry() {
void rejectsNullBeanDefinitionRegistry() {
assertThatIllegalArgumentException().isThrownBy(() -> registrar.registerBeanDefinitions(metadata, null));
}
}

View File

@@ -19,8 +19,8 @@ import static org.assertj.core.api.Assertions.*;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
@@ -47,7 +47,7 @@ public class MongoClientParserIntegrationTests {
DefaultListableBeanFactory factory;
BeanDefinitionReader reader;
@Before
@BeforeEach
public void setUp() {
this.factory = new DefaultListableBeanFactory();

View File

@@ -17,8 +17,8 @@ package org.springframework.data.mongodb.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
@@ -51,7 +51,7 @@ public class MongoDbFactoryParserIntegrationTests {
DefaultListableBeanFactory factory;
BeanDefinitionReader reader;
@Before
@BeforeEach
public void setUp() {
factory = new DefaultListableBeanFactory();
reader = new XmlBeanDefinitionReader(factory);

View File

@@ -19,9 +19,9 @@ import static org.assertj.core.api.Assertions.*;
import java.util.List;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.config.BeanDefinition;
@@ -44,7 +44,7 @@ public class MongoParserIntegrationTests {
DefaultListableBeanFactory factory;
BeanDefinitionReader reader;
@Before
@BeforeEach
public void setUp() {
this.factory = new DefaultListableBeanFactory();
@@ -52,7 +52,7 @@ public class MongoParserIntegrationTests {
}
@Test
@Ignore
@Disabled
public void readsMongoAttributesCorrectly() {
reader.loadBeanDefinitions(new ClassPathResource("namespace/mongo-bean.xml"));

View File

@@ -17,8 +17,8 @@ package org.springframework.data.mongodb.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.mongodb.ReadPreference;
@@ -31,7 +31,7 @@ public class ReadPreferencePropertyEditorUnitTests {
ReadPreferencePropertyEditor editor;
@Before
@BeforeEach
public void setUp() {
editor = new ReadPreferencePropertyEditor();
}

View File

@@ -17,7 +17,7 @@ package org.springframework.data.mongodb.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import com.mongodb.WriteConcern;

View File

@@ -17,8 +17,8 @@ package org.springframework.data.mongodb.config;
import static org.assertj.core.api.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.mongodb.WriteConcern;
@@ -32,7 +32,7 @@ public class WriteConcernPropertyEditorUnitTests {
WriteConcernPropertyEditor editor;
@Before
@BeforeEach
public void setUp() {
editor = new WriteConcernPropertyEditor();
}

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.*;
import org.bson.BsonDocument;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link ChangeStreamOptions}.

View File

@@ -15,14 +15,16 @@
*/
package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.mongodb.core.MongoTemplate.CloseableIterableCursorAdapter;
import org.springframework.data.mongodb.core.MongoTemplate.DocumentCallback;
@@ -35,40 +37,39 @@ import com.mongodb.client.MongoCursor;
*
* @author Oliver Gierke
*/
@RunWith(MockitoJUnitRunner.class)
public class CloseableIterableCursorAdapterUnitTests {
@ExtendWith(MockitoExtension.class)
class CloseableIterableCursorAdapterUnitTests {
@Mock PersistenceExceptionTranslator exceptionTranslator;
@Mock DocumentCallback<Object> callback;
MongoCursor<Document> cursor;
CloseableIterator<Object> adapter;
private MongoCursor<Document> cursor;
private CloseableIterator<Object> adapter;
@Before
public void setUp() {
this.cursor = doThrow(IllegalArgumentException.class).when(mock(MongoCursor.class));
this.adapter = new CloseableIterableCursorAdapter<Object>(cursor, exceptionTranslator, callback);
@BeforeEach
void setUp() {
this.cursor = mock(MongoCursor.class);
this.adapter = new CloseableIterableCursorAdapter<>(cursor, exceptionTranslator, callback);
}
@Test(expected = IllegalArgumentException.class) // DATAMONGO-1276
public void propagatesOriginalExceptionFromAdapterDotNext() {
@Test // DATAMONGO-1276
void propagatesOriginalExceptionFromAdapterDotNext() {
cursor.next();
adapter.next();
doThrow(IllegalArgumentException.class).when(cursor).next();
assertThatIllegalArgumentException().isThrownBy(() -> adapter.next());
}
@Test(expected = IllegalArgumentException.class) // DATAMONGO-1276
public void propagatesOriginalExceptionFromAdapterDotHasNext() {
@Test // DATAMONGO-1276
void propagatesOriginalExceptionFromAdapterDotHasNext() {
cursor.hasNext();
adapter.hasNext();
doThrow(IllegalArgumentException.class).when(cursor).hasNext();
assertThatIllegalArgumentException().isThrownBy(() -> adapter.hasNext());
}
@Test(expected = IllegalArgumentException.class) // DATAMONGO-1276
public void propagatesOriginalExceptionFromAdapterDotClose() {
@Test // DATAMONGO-1276
void propagatesOriginalExceptionFromAdapterDotClose() {
cursor.close();
adapter.close();
doThrow(IllegalArgumentException.class).when(cursor).close();
assertThatIllegalArgumentException().isThrownBy(() -> adapter.close());
}
}

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Locale;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.query.Collation;
import org.springframework.data.mongodb.core.query.Collation.Alternate;
import org.springframework.data.mongodb.core.query.Collation.CaseFirst;

View File

@@ -20,8 +20,8 @@ import static org.springframework.data.mongodb.core.query.Criteria.*;
import static org.springframework.data.mongodb.core.query.Query.*;
import static org.springframework.data.mongodb.test.util.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.geo.Point;
import org.springframework.data.mongodb.MongoDatabaseFactory;
@@ -47,7 +47,7 @@ public class CountQueryUnitTests {
MongoDatabaseFactory factory = mock(MongoDatabaseFactory.class);
@Before
@BeforeEach
public void setUp() {
this.context = new MongoMappingContext();

View File

@@ -30,14 +30,15 @@ import java.util.Optional;
import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
@@ -83,22 +84,22 @@ import com.mongodb.client.model.WriteModel;
* @author Minsu Kim
* @author Jens Schauder
*/
@RunWith(MockitoJUnitRunner.class)
public class DefaultBulkOperationsUnitTests {
@ExtendWith(MockitoExtension.class)
class DefaultBulkOperationsUnitTests {
MongoTemplate template;
private MongoTemplate template;
@Mock MongoDatabase database;
@Mock(answer = Answers.RETURNS_DEEP_STUBS) MongoCollection<Document> collection;
@Mock MongoDatabaseFactory factory;
@Mock DbRefResolver dbRefResolver;
@Captor ArgumentCaptor<List<WriteModel<Document>>> captor;
MongoConverter converter;
MongoMappingContext mappingContext;
private MongoConverter converter;
private MongoMappingContext mappingContext;
DefaultBulkOperations ops;
private DefaultBulkOperations ops;
@Before
public void setUp() {
@BeforeEach
void setUp() {
when(factory.getMongoDatabase()).thenReturn(database);
when(factory.getExceptionTranslator()).thenReturn(new NullExceptionTranslator());
@@ -117,7 +118,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-1518
public void updateOneShouldUseCollationWhenPresent() {
void updateOneShouldUseCollationWhenPresent() {
ops.updateOne(new BasicQuery("{}").collation(Collation.of("de")), new Update().set("lastName", "targaryen"))
.execute();
@@ -130,7 +131,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-1518
public void updateManyShouldUseCollationWhenPresent() {
void updateManyShouldUseCollationWhenPresent() {
ops.updateMulti(new BasicQuery("{}").collation(Collation.of("de")), new Update().set("lastName", "targaryen"))
.execute();
@@ -143,7 +144,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-1518
public void removeShouldUseCollationWhenPresent() {
void removeShouldUseCollationWhenPresent() {
ops.remove(new BasicQuery("{}").collation(Collation.of("de"))).execute();
@@ -155,7 +156,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2218
public void replaceOneShouldUseCollationWhenPresent() {
void replaceOneShouldUseCollationWhenPresent() {
ops.replaceOne(new BasicQuery("{}").collation(Collation.of("de")), new SomeDomainType()).execute();
@@ -167,7 +168,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-1678
public void bulkUpdateShouldMapQueryAndUpdateCorrectly() {
void bulkUpdateShouldMapQueryAndUpdateCorrectly() {
ops.updateOne(query(where("firstName").is("danerys")), Update.update("firstName", "queen danerys")).execute();
@@ -179,7 +180,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-1678
public void bulkRemoveShouldMapQueryCorrectly() {
void bulkRemoveShouldMapQueryCorrectly() {
ops.remove(query(where("firstName").is("danerys"))).execute();
@@ -190,7 +191,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2218
public void bulkReplaceOneShouldMapQueryCorrectly() {
void bulkReplaceOneShouldMapQueryCorrectly() {
SomeDomainType replacement = new SomeDomainType();
replacement.firstName = "Minsu";
@@ -207,7 +208,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2261
public void bulkInsertInvokesEntityCallbacks() {
void bulkInsertInvokesEntityCallbacks() {
BeforeConvertPersonCallback beforeConvertCallback = spy(new BeforeConvertPersonCallback());
BeforeSavePersonCallback beforeSaveCallback = spy(new BeforeSavePersonCallback());
@@ -235,7 +236,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2290
public void bulkReplaceOneEmitsEventsCorrectly() {
void bulkReplaceOneEmitsEventsCorrectly() {
ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);
@@ -256,7 +257,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2290
public void bulkInsertEmitsEventsCorrectly() {
void bulkInsertEmitsEventsCorrectly() {
ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);
@@ -277,7 +278,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2290
public void noAfterSaveEventOnFailure() {
void noAfterSaveEventOnFailure() {
ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);
when(collection.bulkWrite(anyList(), any())).thenThrow(new MongoWriteException(
@@ -302,7 +303,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2330
public void writeConcernNotAppliedWhenNotSet() {
void writeConcernNotAppliedWhenNotSet() {
ops.updateOne(new BasicQuery("{}").collation(Collation.of("de")), new Update().set("lastName", "targaryen"))
.execute();
@@ -311,7 +312,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2330
public void writeConcernAppliedCorrectlyWhenSet() {
void writeConcernAppliedCorrectlyWhenSet() {
ops.setDefaultWriteConcern(WriteConcern.MAJORITY);
@@ -322,7 +323,7 @@ public class DefaultBulkOperationsUnitTests {
}
@Test // DATAMONGO-2450
public void appliesArrayFilterWhenPresent() {
void appliesArrayFilterWhenPresent() {
ops.updateOne(new BasicQuery("{}"), new Update().filterArray(Criteria.where("element").gte(100))).execute();

View File

@@ -21,12 +21,13 @@ import static org.mockito.Mockito.*;
import lombok.Data;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
@@ -46,21 +47,21 @@ import com.mongodb.client.model.IndexOptions;
*
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class DefaultIndexOperationsUnitTests {
MongoTemplate template;
private MongoTemplate template;
@Mock MongoDatabaseFactory factory;
@Mock MongoDatabase db;
@Mock MongoCollection<Document> collection;
MongoExceptionTranslator exceptionTranslator = new MongoExceptionTranslator();
MappingMongoConverter converter;
MongoMappingContext mappingContext;
private MongoExceptionTranslator exceptionTranslator = new MongoExceptionTranslator();
private MappingMongoConverter converter;
private MongoMappingContext mappingContext;
@Before
public void setUp() {
@BeforeEach
void setUp() {
when(factory.getMongoDatabase()).thenReturn(db);
when(factory.getExceptionTranslator()).thenReturn(exceptionTranslator);
@@ -73,7 +74,7 @@ public class DefaultIndexOperationsUnitTests {
}
@Test // DATAMONGO-1183
public void indexOperationsMapFieldNameCorrectly() {
void indexOperationsMapFieldNameCorrectly() {
indexOpsFor(Jedi.class).ensureIndex(new Index("name", Direction.DESC));
@@ -81,7 +82,7 @@ public class DefaultIndexOperationsUnitTests {
}
@Test // DATAMONGO-1854
public void ensureIndexDoesNotSetCollectionIfNoDefaultDefined() {
void ensureIndexDoesNotSetCollectionIfNoDefaultDefined() {
indexOpsFor(Jedi.class).ensureIndex(new Index("firstname", Direction.DESC));
@@ -92,7 +93,7 @@ public class DefaultIndexOperationsUnitTests {
}
@Test // DATAMONGO-1854
public void ensureIndexUsesDefaultCollationIfNoneDefinedInOptions() {
void ensureIndexUsesDefaultCollationIfNoneDefinedInOptions() {
indexOpsFor(Sith.class).ensureIndex(new Index("firstname", Direction.DESC));
@@ -104,7 +105,7 @@ public class DefaultIndexOperationsUnitTests {
}
@Test // DATAMONGO-1854
public void ensureIndexDoesNotUseDefaultCollationIfExplicitlySpecifiedInTheIndex() {
void ensureIndexDoesNotUseDefaultCollationIfExplicitlySpecifiedInTheIndex() {
indexOpsFor(Sith.class).ensureIndex(new Index("firstname", Direction.DESC).collation(Collation.of("en_US")));
@@ -116,7 +117,7 @@ public class DefaultIndexOperationsUnitTests {
}
@Test // DATAMONGO-1183
public void shouldCreateHashedIndexCorrectly() {
void shouldCreateHashedIndexCorrectly() {
indexOpsFor(Jedi.class).ensureIndex(HashedIndex.hashed("name"));

View File

@@ -21,13 +21,14 @@ import static org.mockito.Mockito.*;
import lombok.Data;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.reactivestreams.Publisher;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
@@ -45,22 +46,22 @@ import com.mongodb.reactivestreams.client.MongoDatabase;
/**
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class DefaultReactiveIndexOperationsUnitTests {
ReactiveMongoTemplate template;
private ReactiveMongoTemplate template;
@Mock ReactiveMongoDatabaseFactory factory;
@Mock MongoDatabase db;
@Mock MongoCollection<Document> collection;
@Mock Publisher publisher;
MongoExceptionTranslator exceptionTranslator = new MongoExceptionTranslator();
MappingMongoConverter converter;
MongoMappingContext mappingContext;
private MongoExceptionTranslator exceptionTranslator = new MongoExceptionTranslator();
private MappingMongoConverter converter;
private MongoMappingContext mappingContext;
@Before
public void setUp() {
@BeforeEach
void setUp() {
when(factory.getMongoDatabase()).thenReturn(db);
when(factory.getExceptionTranslator()).thenReturn(exceptionTranslator);
@@ -73,7 +74,7 @@ public class DefaultReactiveIndexOperationsUnitTests {
}
@Test // DATAMONGO-1854
public void ensureIndexDoesNotSetCollectionIfNoDefaultDefined() {
void ensureIndexDoesNotSetCollectionIfNoDefaultDefined() {
indexOpsFor(Jedi.class).ensureIndex(new Index("firstname", Direction.DESC)).subscribe();
@@ -84,7 +85,7 @@ public class DefaultReactiveIndexOperationsUnitTests {
}
@Test // DATAMONGO-1854
public void ensureIndexUsesDefaultCollationIfNoneDefinedInOptions() {
void ensureIndexUsesDefaultCollationIfNoneDefinedInOptions() {
indexOpsFor(Sith.class).ensureIndex(new Index("firstname", Direction.DESC)).subscribe();
@@ -96,7 +97,7 @@ public class DefaultReactiveIndexOperationsUnitTests {
}
@Test // DATAMONGO-1854
public void ensureIndexDoesNotUseDefaultCollationIfExplicitlySpecifiedInTheIndex() {
void ensureIndexDoesNotUseDefaultCollationIfExplicitlySpecifiedInTheIndex() {
indexOpsFor(Sith.class).ensureIndex(new Index("firstname", Direction.DESC).collation(Collation.of("en_US")))
.subscribe();

View File

@@ -18,12 +18,12 @@ package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.mongodb.core.script.ExecutableMongoScript;
import org.springframework.data.mongodb.core.script.NamedMongoScript;
@@ -35,29 +35,29 @@ import org.springframework.data.mongodb.core.script.NamedMongoScript;
* @author Oliver Gierke
* @since 1.7
*/
@RunWith(MockitoJUnitRunner.class)
public class DefaultScriptOperationsUnitTests {
@ExtendWith(MockitoExtension.class)
class DefaultScriptOperationsUnitTests {
DefaultScriptOperations scriptOps;
private DefaultScriptOperations scriptOps;
@Mock MongoOperations mongoOperations;
@Before
public void setUp() {
@BeforeEach
void setUp() {
this.scriptOps = new DefaultScriptOperations(mongoOperations);
}
@Test // DATAMONGO-479
public void rejectsNullExecutableMongoScript() {
void rejectsNullExecutableMongoScript() {
assertThatIllegalArgumentException().isThrownBy(() -> scriptOps.register((ExecutableMongoScript) null));
}
@Test // DATAMONGO-479
public void rejectsNullNamedMongoScript() {
void rejectsNullNamedMongoScript() {
assertThatIllegalArgumentException().isThrownBy(() -> scriptOps.register((NamedMongoScript) null));
}
@Test // DATAMONGO-479
public void saveShouldUseCorrectCollectionName() {
void saveShouldUseCorrectCollectionName() {
scriptOps.register(new NamedMongoScript("foo", "function..."));
@@ -65,7 +65,7 @@ public class DefaultScriptOperationsUnitTests {
}
@Test // DATAMONGO-479
public void saveShouldGenerateScriptNameForExecutableMongoScripts() {
void saveShouldGenerateScriptNameForExecutableMongoScripts() {
scriptOps.register(new ExecutableMongoScript("function..."));
@@ -76,27 +76,27 @@ public class DefaultScriptOperationsUnitTests {
}
@Test // DATAMONGO-479
public void executeShouldThrowExceptionWhenScriptIsNull() {
void executeShouldThrowExceptionWhenScriptIsNull() {
assertThatIllegalArgumentException().isThrownBy(() -> scriptOps.execute(null));
}
@Test // DATAMONGO-479
public void existsShouldThrowExceptionWhenScriptNameIsNull() {
void existsShouldThrowExceptionWhenScriptNameIsNull() {
assertThatIllegalArgumentException().isThrownBy(() -> scriptOps.exists(null));
}
@Test // DATAMONGO-479
public void existsShouldThrowExceptionWhenScriptNameIsEmpty() {
void existsShouldThrowExceptionWhenScriptNameIsEmpty() {
assertThatIllegalArgumentException().isThrownBy(() -> scriptOps.exists(""));
}
@Test // DATAMONGO-479
public void callShouldThrowExceptionWhenScriptNameIsNull() {
void callShouldThrowExceptionWhenScriptNameIsNull() {
assertThatIllegalArgumentException().isThrownBy(() -> scriptOps.call(null));
}
@Test // DATAMONGO-479
public void callShouldThrowExceptionWhenScriptNameIsEmpty() {
void callShouldThrowExceptionWhenScriptNameIsEmpty() {
assertThatIllegalArgumentException().isThrownBy(() -> scriptOps.call(""));
}
}

View File

@@ -17,8 +17,9 @@ package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.data.annotation.Id;
@@ -34,7 +35,7 @@ public class EntityOperationUnitTests {
MongoMappingContext mappingContext = new MongoMappingContext();
ConversionService conversionService = new DefaultConversionService();
@Before
@BeforeEach
public void setUp() {
ops = new EntityOperations(mappingContext);
}

View File

@@ -20,12 +20,13 @@ import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
/**
@@ -33,40 +34,40 @@ import org.springframework.data.mongodb.core.aggregation.Aggregation;
*
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ExecutableAggregationOperationSupportUnitTests {
@Mock MongoTemplate template;
ExecutableAggregationOperationSupport opSupport;
private ExecutableAggregationOperationSupport opSupport;
@Before
public void setUp() {
@BeforeEach
void setUp() {
opSupport = new ExecutableAggregationOperationSupport(template);
}
@Test // DATAMONGO-1563
public void throwsExceptionOnNullDomainType() {
void throwsExceptionOnNullDomainType() {
assertThatIllegalArgumentException().isThrownBy(() -> opSupport.aggregateAndReturn(null));
}
@Test // DATAMONGO-1563
public void throwsExceptionOnNullCollectionWhenUsed() {
void throwsExceptionOnNullCollectionWhenUsed() {
assertThatIllegalArgumentException()
.isThrownBy(() -> opSupport.aggregateAndReturn(Person.class).inCollection(null));
}
@Test // DATAMONGO-1563
public void throwsExceptionOnEmptyCollectionWhenUsed() {
void throwsExceptionOnEmptyCollectionWhenUsed() {
assertThatIllegalArgumentException().isThrownBy(() -> opSupport.aggregateAndReturn(Person.class).inCollection(""));
}
@Test // DATAMONGO-1563
public void throwsExceptionOnNullAggregation() {
void throwsExceptionOnNullAggregation() {
assertThatIllegalArgumentException().isThrownBy(() -> opSupport.aggregateAndReturn(Person.class).by(null));
}
@Test // DATAMONGO-1563
public void aggregateWithUntypedAggregationAndExplicitCollection() {
void aggregateWithUntypedAggregationAndExplicitCollection() {
opSupport.aggregateAndReturn(Person.class).inCollection("star-wars").by(newAggregation(project("foo"))).all();
@@ -76,7 +77,7 @@ public class ExecutableAggregationOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void aggregateWithUntypedAggregation() {
void aggregateWithUntypedAggregation() {
when(template.getCollectionName(any(Class.class))).thenReturn("person");
@@ -91,7 +92,7 @@ public class ExecutableAggregationOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void aggregateWithTypeAggregation() {
void aggregateWithTypeAggregation() {
when(template.getCollectionName(any(Class.class))).thenReturn("person");
@@ -106,7 +107,7 @@ public class ExecutableAggregationOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void aggregateStreamWithUntypedAggregationAndExplicitCollection() {
void aggregateStreamWithUntypedAggregationAndExplicitCollection() {
opSupport.aggregateAndReturn(Person.class).inCollection("star-wars").by(newAggregation(project("foo"))).stream();
@@ -116,7 +117,7 @@ public class ExecutableAggregationOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void aggregateStreamWithUntypedAggregation() {
void aggregateStreamWithUntypedAggregation() {
when(template.getCollectionName(any(Class.class))).thenReturn("person");
@@ -131,7 +132,7 @@ public class ExecutableAggregationOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void aggregateStreamWithTypeAggregation() {
void aggregateStreamWithTypeAggregation() {
when(template.getCollectionName(any(Class.class))).thenReturn("person");

View File

@@ -23,12 +23,13 @@ import lombok.Data;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.BulkOperations.BulkMode;
@@ -38,7 +39,7 @@ import org.springframework.data.mongodb.core.BulkOperations.BulkMode;
* @author Christoph Strobl
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ExecutableInsertOperationSupportUnitTests {
private static final String STAR_WARS = "star-wars";
@@ -46,16 +47,12 @@ public class ExecutableInsertOperationSupportUnitTests {
@Mock MongoTemplate template;
@Mock BulkOperations bulkOperations;
ExecutableInsertOperationSupport ops;
private ExecutableInsertOperationSupport ops;
Person luke, han;
private Person luke, han;
@Before
public void setUp() {
when(template.bulkOps(any(), any(), any())).thenReturn(bulkOperations);
when(template.getCollectionName(any(Class.class))).thenReturn(STAR_WARS);
when(bulkOperations.insert(anyList())).thenReturn(bulkOperations);
@BeforeEach
void setUp() {
ops = new ExecutableInsertOperationSupport(template);
@@ -69,17 +66,19 @@ public class ExecutableInsertOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void nullCollectionShouldThrowException() {
void nullCollectionShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> ops.insert(Person.class).inCollection(null));
}
@Test // DATAMONGO-1563
public void nullBulkModeShouldThrowException() {
void nullBulkModeShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> ops.insert(Person.class).withBulkMode(null));
}
@Test // DATAMONGO-1563
public void insertShouldUseDerivedCollectionName() {
void insertShouldUseDerivedCollectionName() {
when(template.getCollectionName(any(Class.class))).thenReturn(STAR_WARS);
ops.insert(Person.class).one(luke);
@@ -92,7 +91,7 @@ public class ExecutableInsertOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void insertShouldUseExplicitCollectionName() {
void insertShouldUseExplicitCollectionName() {
ops.insert(Person.class).inCollection(STAR_WARS).one(luke);
@@ -101,7 +100,9 @@ public class ExecutableInsertOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void insertCollectionShouldDelegateCorrectly() {
void insertCollectionShouldDelegateCorrectly() {
when(template.getCollectionName(any(Class.class))).thenReturn(STAR_WARS);
ops.insert(Person.class).all(Arrays.asList(luke, han));
@@ -110,7 +111,11 @@ public class ExecutableInsertOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void bulkInsertCollectionShouldDelegateCorrectly() {
void bulkInsertCollectionShouldDelegateCorrectly() {
when(template.getCollectionName(any(Class.class))).thenReturn(STAR_WARS);
when(template.bulkOps(any(), any(), any())).thenReturn(bulkOperations);
when(bulkOperations.insert(anyList())).thenReturn(bulkOperations);
ops.insert(Person.class).bulk(Arrays.asList(luke, han));
@@ -123,7 +128,11 @@ public class ExecutableInsertOperationSupportUnitTests {
}
@Test // DATAMONGO-1563
public void bulkInsertWithBulkModeShouldDelegateCorrectly() {
void bulkInsertWithBulkModeShouldDelegateCorrectly() {
when(template.getCollectionName(any(Class.class))).thenReturn(STAR_WARS);
when(template.bulkOps(any(), any(), any())).thenReturn(bulkOperations);
when(bulkOperations.insert(anyList())).thenReturn(bulkOperations);
ops.insert(Person.class).withBulkMode(BulkMode.UNORDERED).bulk(Arrays.asList(luke, han));

View File

@@ -23,11 +23,12 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions;
@@ -40,7 +41,7 @@ import org.springframework.data.mongodb.core.query.Query;
* @author Christoph Strobl
* @currentRead Beyond the Shadows - Brent Weeks
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ExecutableMapReduceOperationSupportUnitTests {
private static final String STAR_WARS = "star-wars";
@@ -49,29 +50,27 @@ public class ExecutableMapReduceOperationSupportUnitTests {
@Mock MongoTemplate template;
ExecutableMapReduceOperationSupport mapReduceOpsSupport;
@Before
public void setUp() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
private ExecutableMapReduceOperationSupport mapReduceOpsSupport;
@BeforeEach
void setUp() {
mapReduceOpsSupport = new ExecutableMapReduceOperationSupport(template);
}
@Test // DATAMONGO-1929
public void throwsExceptionOnNullTemplate() {
void throwsExceptionOnNullTemplate() {
assertThatIllegalArgumentException().isThrownBy(() -> new ExecutableMapReduceOperationSupport(null));
}
@Test // DATAMONGO-1929
public void throwsExceptionOnNullDomainType() {
void throwsExceptionOnNullDomainType() {
assertThatIllegalArgumentException().isThrownBy(() -> mapReduceOpsSupport.mapReduce(null));
}
@Test // DATAMONGO-1929
public void usesExtractedCollectionName() {
void usesExtractedCollectionName() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION).all();
verify(template).mapReduce(any(Query.class), eq(Person.class), eq(STAR_WARS), eq(MAP_FUNCTION), eq(REDUCE_FUNCTION),
@@ -79,7 +78,7 @@ public class ExecutableMapReduceOperationSupportUnitTests {
}
@Test // DATAMONGO-1929
public void usesExplicitCollectionName() {
void usesExplicitCollectionName() {
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION)
.inCollection("the-night-angel").all();
@@ -89,8 +88,9 @@ public class ExecutableMapReduceOperationSupportUnitTests {
}
@Test // DATAMONGO-1929
public void usesMapReduceOptionsWhenPresent() {
void usesMapReduceOptionsWhenPresent() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
MapReduceOptions options = MapReduceOptions.options();
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION).with(options).all();
@@ -99,8 +99,9 @@ public class ExecutableMapReduceOperationSupportUnitTests {
}
@Test // DATAMONGO-1929
public void usesQueryWhenPresent() {
void usesQueryWhenPresent() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
Query query = new BasicQuery("{ 'lastname' : 'skywalker' }");
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION).matching(query).all();
@@ -109,8 +110,9 @@ public class ExecutableMapReduceOperationSupportUnitTests {
}
@Test // DATAMONGO-1929
public void usesProjectionWhenPresent() {
void usesProjectionWhenPresent() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION).as(Jedi.class).all();
verify(template).mapReduce(any(Query.class), eq(Person.class), eq(STAR_WARS), eq(MAP_FUNCTION), eq(REDUCE_FUNCTION),

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link GeoCommandStatistics}.

View File

@@ -23,8 +23,8 @@ import java.util.List;
import java.util.Map;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.annotation.Transient;
import org.springframework.data.convert.WritingConverter;
@@ -49,7 +49,7 @@ public class MappingMongoJsonSchemaCreatorUnitTests {
MongoMappingContext mappingContext;
MappingMongoJsonSchemaCreator schemaCreator;
@Before
@BeforeEach
public void setUp() {
mappingContext = new MongoMappingContext();

View File

@@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;

View File

@@ -18,7 +18,8 @@ package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.*;
import org.bson.UuidRepresentation;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.data.mongodb.config.ReadConcernPropertyEditor;

View File

@@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.test.util.ReflectionTestUtils;

View File

@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.*;
import java.net.UnknownHostException;
import org.bson.BsonDocument;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.core.NestedRuntimeException;
import org.springframework.dao.DataAccessException;
@@ -50,7 +50,7 @@ public class MongoExceptionTranslatorUnitTests {
MongoExceptionTranslator translator;
@Before
@BeforeEach
public void setUp() {
translator = new MongoExceptionTranslator();
}

View File

@@ -43,6 +43,7 @@ import org.joda.time.DateTime;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.convert.converter.Converter;
@@ -56,7 +57,6 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.annotation.Version;
import org.springframework.data.auditing.IsNewAwareAuditingHandler;
import org.springframework.data.convert.CustomConversions;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
@@ -64,7 +64,6 @@ import org.springframework.data.mapping.MappingException;
import org.springframework.data.mongodb.InvalidMongoDbApiUsageException;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.core.convert.LazyLoadingProxy;
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
import org.springframework.data.mongodb.core.index.Index;
import org.springframework.data.mongodb.core.index.IndexField;

View File

@@ -22,11 +22,13 @@ import static org.springframework.data.mongodb.core.query.Query.*;
import java.util.concurrent.TimeUnit;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.core.MongoTemplate.QueryCursorPreparer;
@@ -44,15 +46,16 @@ import com.mongodb.client.FindIterable;
* @author Christoph Strobl
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class QueryCursorPreparerUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class QueryCursorPreparerUnitTests {
@Mock MongoDatabaseFactory factory;
@Mock MongoExceptionTranslator exceptionTranslatorMock;
@Mock FindIterable<Document> cursor;
@Before
public void setUp() {
@BeforeEach
void setUp() {
when(factory.getExceptionTranslator()).thenReturn(exceptionTranslatorMock);
when(factory.getCodecRegistry()).thenReturn(MongoClientSettings.getDefaultCodecRegistry());
@@ -65,7 +68,7 @@ public class QueryCursorPreparerUnitTests {
}
@Test // DATAMONGO-185
public void appliesHintsCorrectly() {
void appliesHintsCorrectly() {
Query query = query(where("foo").is("bar")).withHint("{ age: 1 }");
prepare(query);
@@ -74,7 +77,7 @@ public class QueryCursorPreparerUnitTests {
}
@Test // DATAMONGO-2365
public void appliesIndexNameAsHintCorrectly() {
void appliesIndexNameAsHintCorrectly() {
Query query = query(where("foo").is("bar")).withHint("idx-1");
prepare(query);
@@ -83,7 +86,7 @@ public class QueryCursorPreparerUnitTests {
}
@Test // DATAMONGO-2319
public void appliesDocumentHintsCorrectly() {
void appliesDocumentHintsCorrectly() {
Query query = query(where("foo").is("bar")).withHint(Document.parse("{ age: 1 }"));
prepare(query);
@@ -113,7 +116,7 @@ public class QueryCursorPreparerUnitTests {
// }
@Test // DATAMONGO-957
public void appliesMaxTimeCorrectly() {
void appliesMaxTimeCorrectly() {
Query query = query(where("foo").is("bar")).maxTime(1, TimeUnit.SECONDS);
prepare(query);
@@ -122,7 +125,7 @@ public class QueryCursorPreparerUnitTests {
}
@Test // DATAMONGO-957
public void appliesCommentCorrectly() {
void appliesCommentCorrectly() {
Query query = query(where("foo").is("bar")).comment("spring data");
prepare(query);
@@ -141,7 +144,7 @@ public class QueryCursorPreparerUnitTests {
// }
@Test // DATAMONGO-1480
public void appliesNoCursorTimeoutCorrectly() {
void appliesNoCursorTimeoutCorrectly() {
Query query = query(where("foo").is("bar")).noCursorTimeout();
@@ -151,7 +154,7 @@ public class QueryCursorPreparerUnitTests {
}
@Test // DATAMONGO-1518
public void appliesCollationCorrectly() {
void appliesCollationCorrectly() {
prepare(new BasicQuery("{}").collation(Collation.of("fr")));
@@ -159,7 +162,7 @@ public class QueryCursorPreparerUnitTests {
}
@Test // DATAMONGO-1311
public void appliesBatchSizeCorrectly() {
void appliesBatchSizeCorrectly() {
prepare(new BasicQuery("{}").cursorBatchSize(100));

View File

@@ -20,12 +20,12 @@ import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
@@ -34,40 +34,40 @@ import org.springframework.data.mongodb.core.aggregation.Aggregation;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ReactiveAggregationOperationSupportUnitTests {
@Mock ReactiveMongoTemplate template;
ReactiveAggregationOperationSupport opSupport;
private ReactiveAggregationOperationSupport opSupport;
@Before
public void setUp() {
@BeforeEach
void setUp() {
opSupport = new ReactiveAggregationOperationSupport(template);
}
@Test // DATAMONGO-1719
public void throwsExceptionOnNullDomainType() {
void throwsExceptionOnNullDomainType() {
assertThatIllegalArgumentException().isThrownBy(() -> opSupport.aggregateAndReturn(null));
}
@Test // DATAMONGO-1719
public void throwsExceptionOnNullCollectionWhenUsed() {
void throwsExceptionOnNullCollectionWhenUsed() {
assertThatIllegalArgumentException()
.isThrownBy(() -> opSupport.aggregateAndReturn(Person.class).inCollection(null));
}
@Test // DATAMONGO-1719
public void throwsExceptionOnEmptyCollectionWhenUsed() {
void throwsExceptionOnEmptyCollectionWhenUsed() {
assertThatIllegalArgumentException().isThrownBy(() -> opSupport.aggregateAndReturn(Person.class).inCollection(""));
}
@Test // DATAMONGO-1719
public void throwsExceptionOnNullAggregation() {
void throwsExceptionOnNullAggregation() {
assertThatIllegalArgumentException().isThrownBy(() -> opSupport.aggregateAndReturn(Person.class).by(null));
}
@Test // DATAMONGO-1719
public void aggregateWithUntypedAggregationAndExplicitCollection() {
void aggregateWithUntypedAggregationAndExplicitCollection() {
opSupport.aggregateAndReturn(Person.class).inCollection("star-wars").by(newAggregation(project("foo"))).all();
@@ -77,7 +77,7 @@ public class ReactiveAggregationOperationSupportUnitTests {
}
@Test // DATAMONGO-1719
public void aggregateWithUntypedAggregation() {
void aggregateWithUntypedAggregation() {
when(template.getCollectionName(any(Class.class))).thenReturn("person");
@@ -92,7 +92,7 @@ public class ReactiveAggregationOperationSupportUnitTests {
}
@Test // DATAMONGO-1719
public void aggregateWithTypeAggregation() {
void aggregateWithTypeAggregation() {
when(template.getCollectionName(any(Class.class))).thenReturn("person");

View File

@@ -30,12 +30,12 @@ import java.util.Collections;
import java.util.List;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.TypedAggregation;
@@ -47,20 +47,20 @@ import org.springframework.data.mongodb.core.query.Criteria;
* @author Christoph Strobl
* @currentRead Dawn Cook - The Decoy Princess
*/
@RunWith(MockitoJUnitRunner.class)
public class ReactiveChangeStreamOperationSupportUnitTests {
@ExtendWith(MockitoExtension.class)
class ReactiveChangeStreamOperationSupportUnitTests {
@Mock ReactiveMongoTemplate template;
ReactiveChangeStreamOperationSupport changeStreamSupport;
private ReactiveChangeStreamOperationSupport changeStreamSupport;
@Before
public void setUp() {
@BeforeEach
void setUp() {
when(template.changeStream(any(), any(), any())).thenReturn(Flux.empty());
changeStreamSupport = new ReactiveChangeStreamOperationSupport(template);
}
@Test // DATAMONGO-2089
public void listenWithoutDomainTypeUsesDocumentAsDefault() {
void listenWithoutDomainTypeUsesDocumentAsDefault() {
changeStreamSupport.changeStream(Document.class).listen().subscribe();
@@ -68,7 +68,7 @@ public class ReactiveChangeStreamOperationSupportUnitTests {
}
@Test // DATAMONGO-2089
public void listenWithDomainTypeUsesSourceAsTarget() {
void listenWithDomainTypeUsesSourceAsTarget() {
changeStreamSupport.changeStream(Person.class).listen().subscribe();
@@ -76,7 +76,7 @@ public class ReactiveChangeStreamOperationSupportUnitTests {
}
@Test // DATAMONGO-2089
public void collectionNameIsPassedOnCorrectly() {
void collectionNameIsPassedOnCorrectly() {
changeStreamSupport.changeStream(Person.class).watchCollection("star-wars").listen().subscribe();
@@ -84,7 +84,7 @@ public class ReactiveChangeStreamOperationSupportUnitTests {
}
@Test // DATAMONGO-2089
public void listenWithDomainTypeCreatesTypedAggregation() {
void listenWithDomainTypeCreatesTypedAggregation() {
Criteria criteria = where("operationType").is("insert");
changeStreamSupport.changeStream(Person.class).filter(criteria).listen().subscribe();
@@ -104,7 +104,7 @@ public class ReactiveChangeStreamOperationSupportUnitTests {
}
@Test // DATAMONGO-2089
public void listenWithoutDomainTypeCreatesUntypedAggregation() {
void listenWithoutDomainTypeCreatesUntypedAggregation() {
Criteria criteria = where("operationType").is("insert");
changeStreamSupport.changeStream(Document.class).filter(criteria).listen().subscribe();
@@ -125,7 +125,7 @@ public class ReactiveChangeStreamOperationSupportUnitTests {
}
@Test // DATAMONGO-2089
public void optionsShouldBePassedOnCorrectly() {
void optionsShouldBePassedOnCorrectly() {
Document filter = new Document("$match", new Document("operationType", "insert"));
@@ -142,7 +142,7 @@ public class ReactiveChangeStreamOperationSupportUnitTests {
}
@Test // DATAMONGO-2089
public void optionsShouldBeCombinedCorrectly() {
void optionsShouldBeCombinedCorrectly() {
Document filter = new Document("$match", new Document("operationType", "insert"));
Instant resumeTimestamp = Instant.now();

View File

@@ -24,12 +24,12 @@ import lombok.Data;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.annotation.Id;
@@ -38,21 +38,19 @@ import org.springframework.data.annotation.Id;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ReactiveInsertOperationSupportUnitTests {
private static final String STAR_WARS = "star-wars";
@Mock ReactiveMongoTemplate template;
ReactiveInsertOperationSupport ops;
private ReactiveInsertOperationSupport ops;
Person luke, han;
private Person luke, han;
@Before
public void setUp() {
when(template.getCollectionName(any(Class.class))).thenReturn(STAR_WARS);
@BeforeEach
void setUp() {
ops = new ReactiveInsertOperationSupport(template);
@@ -66,12 +64,14 @@ public class ReactiveInsertOperationSupportUnitTests {
}
@Test // DATAMONGO-1719
public void nullCollectionShouldThrowException() {
void nullCollectionShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> ops.insert(Person.class).inCollection(null));
}
@Test // DATAMONGO-1719
public void insertShouldUseDerivedCollectionName() {
void insertShouldUseDerivedCollectionName() {
when(template.getCollectionName(any(Class.class))).thenReturn(STAR_WARS);
ops.insert(Person.class).one(luke);
@@ -84,7 +84,7 @@ public class ReactiveInsertOperationSupportUnitTests {
}
@Test // DATAMONGO-1719
public void insertShouldUseExplicitCollectionName() {
void insertShouldUseExplicitCollectionName() {
ops.insert(Person.class).inCollection(STAR_WARS).one(luke);
@@ -93,7 +93,9 @@ public class ReactiveInsertOperationSupportUnitTests {
}
@Test // DATAMONGO-1719
public void insertCollectionShouldDelegateCorrectly() {
void insertCollectionShouldDelegateCorrectly() {
when(template.getCollectionName(any(Class.class))).thenReturn(STAR_WARS);
ops.insert(Person.class).all(Arrays.asList(luke, han));

View File

@@ -23,11 +23,11 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Field;
@@ -41,7 +41,7 @@ import org.springframework.data.mongodb.core.query.Query;
* @author Christoph Strobl
* @currentRead Beyond the Shadows - Brent Weeks
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class ReactiveMapReduceOperationSupportUnitTests {
private static final String STAR_WARS = "star-wars";
@@ -50,28 +50,27 @@ public class ReactiveMapReduceOperationSupportUnitTests {
@Mock ReactiveMongoTemplate template;
ReactiveMapReduceOperationSupport mapReduceOpsSupport;
@Before
public void setUp() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
private ReactiveMapReduceOperationSupport mapReduceOpsSupport;
@BeforeEach
void setUp() {
mapReduceOpsSupport = new ReactiveMapReduceOperationSupport(template);
}
@Test // DATAMONGO-1929
public void throwsExceptionOnNullTemplate() {
void throwsExceptionOnNullTemplate() {
assertThatIllegalArgumentException().isThrownBy(() -> new ExecutableMapReduceOperationSupport(null));
}
@Test // DATAMONGO-1929
public void throwsExceptionOnNullDomainType() {
void throwsExceptionOnNullDomainType() {
assertThatIllegalArgumentException().isThrownBy(() -> mapReduceOpsSupport.mapReduce(null));
}
@Test // DATAMONGO-1929
public void usesExtractedCollectionName() {
void usesExtractedCollectionName() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION).all();
@@ -80,7 +79,7 @@ public class ReactiveMapReduceOperationSupportUnitTests {
}
@Test // DATAMONGO-1929
public void usesExplicitCollectionName() {
void usesExplicitCollectionName() {
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION)
.inCollection("the-night-angel").all();
@@ -90,7 +89,9 @@ public class ReactiveMapReduceOperationSupportUnitTests {
}
@Test // DATAMONGO-1929
public void usesMapReduceOptionsWhenPresent() {
void usesMapReduceOptionsWhenPresent() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
MapReduceOptions options = MapReduceOptions.options();
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION).with(options).all();
@@ -100,7 +101,9 @@ public class ReactiveMapReduceOperationSupportUnitTests {
}
@Test // DATAMONGO-1929
public void usesQueryWhenPresent() {
void usesQueryWhenPresent() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
Query query = new BasicQuery("{ 'lastname' : 'skywalker' }");
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION).matching(query).all();
@@ -110,7 +113,9 @@ public class ReactiveMapReduceOperationSupportUnitTests {
}
@Test // DATAMONGO-1929
public void usesProjectionWhenPresent() {
void usesProjectionWhenPresent() {
when(template.getCollectionName(eq(Person.class))).thenReturn(STAR_WARS);
mapReduceOpsSupport.mapReduce(Person.class).map(MAP_FUNCTION).reduce(REDUCE_FUNCTION).as(Jedi.class).all();

View File

@@ -57,13 +57,13 @@ import com.mongodb.reactivestreams.client.MongoClient;
@ExtendWith(MongoClientExtension.class)
public class ReactiveMongoTemplateIndexTests {
static @Client MongoClient client;
private static @Client MongoClient client;
SimpleReactiveMongoDatabaseFactory factory;
ReactiveMongoTemplate template;
private SimpleReactiveMongoDatabaseFactory factory;
private ReactiveMongoTemplate template;
@BeforeEach
public void setUp() {
void setUp() {
factory = new SimpleReactiveMongoDatabaseFactory(client, "reactive-template-index-tests");
template = new ReactiveMongoTemplate(factory);
@@ -74,11 +74,11 @@ public class ReactiveMongoTemplateIndexTests {
}
@AfterEach
public void cleanUp() {}
void cleanUp() {}
@Test // DATAMONGO-1444
@RepeatFailedTest(3)
public void testEnsureIndexShouldCreateIndex() {
void testEnsureIndexShouldCreateIndex() {
Person p1 = new Person("Oliver");
p1.setAge(25);
@@ -114,7 +114,7 @@ public class ReactiveMongoTemplateIndexTests {
@Test // DATAMONGO-1444
@RepeatFailedTest(3)
public void getIndexInfoShouldReturnCorrectIndex() {
void getIndexInfoShouldReturnCorrectIndex() {
Person p1 = new Person("Oliver");
p1.setAge(25);
@@ -145,7 +145,7 @@ public class ReactiveMongoTemplateIndexTests {
@Test // DATAMONGO-1444, DATAMONGO-2264
@RepeatFailedTest(3)
public void testReadIndexInfoForIndicesCreatedViaMongoShellCommands() {
void testReadIndexInfoForIndicesCreatedViaMongoShellCommands() {
template.indexOps(Person.class).dropAllIndexes() //
.as(StepVerifier::create) //
@@ -197,7 +197,7 @@ public class ReactiveMongoTemplateIndexTests {
@Test // DATAMONGO-1928
@RepeatFailedTest(3)
public void shouldCreateIndexOnAccess() {
void shouldCreateIndexOnAccess() {
StepVerifier.create(template.getCollection("indexedSample").listIndexes(Document.class)).expectNextCount(0)
.verifyComplete();
@@ -213,7 +213,7 @@ public class ReactiveMongoTemplateIndexTests {
@Test // DATAMONGO-1928, DATAMONGO-2264
@RepeatFailedTest(3)
public void indexCreationShouldFail() throws InterruptedException {
void indexCreationShouldFail() throws InterruptedException {
Flux.from(factory.getMongoDatabase().getCollection("indexfail") //
.createIndex(new Document("field", 1), new IndexOptions().name("foo").unique(true).sparse(true)))

View File

@@ -47,10 +47,11 @@ import org.bson.BsonDocument;
import org.bson.BsonTimestamp;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.dao.DataIntegrityViolationException;
@@ -96,11 +97,11 @@ import com.mongodb.reactivestreams.client.MongoClient;
@ExtendWith({ MongoClientExtension.class, MongoServerCondition.class })
public class ReactiveMongoTemplateTests {
public static final String DB_NAME = "reactive-mongo-template-tests";
static @Client MongoClient client;
private static final String DB_NAME = "reactive-mongo-template-tests";
private static @Client MongoClient client;
ConfigurableApplicationContext context = new GenericApplicationContext();
ReactiveMongoTestTemplate template = new ReactiveMongoTestTemplate(cfg -> {
private ConfigurableApplicationContext context = new GenericApplicationContext();
private ReactiveMongoTestTemplate template = new ReactiveMongoTestTemplate(cfg -> {
cfg.configureDatabaseFactory(it -> {
@@ -113,19 +114,21 @@ public class ReactiveMongoTemplateTests {
});
});
ReactiveMongoDatabaseFactory factory = template.getDatabaseFactory();
@BeforeEach
void setUp() {
@AfterEach
public void setUp() {
template
.flush(Person.class, MyPerson.class, Sample.class, Venue.class, PersonWithVersionPropertyOfTypeInteger.class) //
.as(StepVerifier::create) //
.verifyComplete();
template.flush().as(StepVerifier::create).verifyComplete();
template.flush("people", "collection").as(StepVerifier::create).verifyComplete();
template.dropCollection(Person.class).as(StepVerifier::create).verifyComplete();
template.dropCollection("personX").as(StepVerifier::create).verifyComplete();
template.flush("people", "collection", "personX", "unique_person").as(StepVerifier::create).verifyComplete();
}
private ReactiveMongoDatabaseFactory factory = template.getDatabaseFactory();
@Test // DATAMONGO-1444
public void insertSetsId() {
void insertSetsId() {
PersonWithAList person = new PersonWithAList();
assert person.getId() == null;
@@ -139,7 +142,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void insertAllSetsId() {
void insertAllSetsId() {
PersonWithAList person = new PersonWithAList();
@@ -152,7 +155,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void insertCollectionSetsId() {
void insertCollectionSetsId() {
PersonWithAList person = new PersonWithAList();
@@ -165,7 +168,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void saveSetsId() {
void saveSetsId() {
PersonWithAList person = new PersonWithAList();
assert person.getId() == null;
@@ -179,7 +182,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void insertsSimpleEntityCorrectly() {
void insertsSimpleEntityCorrectly() {
Person person = new Person("Mark");
person.setAge(35);
@@ -195,7 +198,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void simpleInsertDoesNotAllowArrays() {
void simpleInsertDoesNotAllowArrays() {
Person person = new Person("Mark");
person.setAge(35);
@@ -204,7 +207,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void simpleInsertDoesNotAllowCollections() {
void simpleInsertDoesNotAllowCollections() {
Person person = new Person("Mark");
person.setAge(35);
@@ -213,7 +216,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void insertsSimpleEntityWithSuppliedCollectionNameCorrectly() {
void insertsSimpleEntityWithSuppliedCollectionNameCorrectly() {
Person person = new Person("Homer");
person.setAge(35);
@@ -229,7 +232,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void insertBatchCorrectly() {
void insertBatchCorrectly() {
List<Person> people = Arrays.asList(new Person("Dick", 22), new Person("Harry", 23), new Person("Tom", 21));
@@ -240,12 +243,12 @@ public class ReactiveMongoTemplateTests {
template.find(new Query().with(Sort.by("firstname")), Person.class) //
.as(StepVerifier::create) //
.expectNextSequence(people) //
.expectNextCount(3) ///
.verifyComplete();
}
@Test // DATAMONGO-1444
public void insertBatchWithSuppliedCollectionNameCorrectly() {
void insertBatchWithSuppliedCollectionNameCorrectly() {
List<Person> people = Arrays.asList(new Person("Dick", 22), new Person("Harry", 23), new Person("Tom", 21));
@@ -256,12 +259,12 @@ public class ReactiveMongoTemplateTests {
template.find(new Query().with(Sort.by("firstname")), Person.class, "people") //
.as(StepVerifier::create) //
.expectNextSequence(people) //
.expectNextCount(3) //
.verifyComplete();
}
@Test // DATAMONGO-1444
public void insertBatchWithSuppliedEntityTypeCorrectly() {
void insertBatchWithSuppliedEntityTypeCorrectly() {
List<Person> people = Arrays.asList(new Person("Dick", 22), new Person("Harry", 23), new Person("Tom", 21));
@@ -272,12 +275,12 @@ public class ReactiveMongoTemplateTests {
template.find(new Query().with(Sort.by("firstname")), Person.class) //
.as(StepVerifier::create) //
.expectNextSequence(people) //
.expectNextCount(3) //
.verifyComplete();
}
@Test // DATAMONGO-1444
public void testAddingToList() {
void testAddingToList() {
PersonWithAList person = createPersonWithAList("Sven", 22);
template.insert(person) //
@@ -322,7 +325,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void testFindOneWithSort() {
void testFindOneWithSort() {
PersonWithAList sven = createPersonWithAList("Sven", 22);
PersonWithAList erik = createPersonWithAList("Erik", 21);
@@ -346,7 +349,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void bogusUpdateDoesNotTriggerException() {
void bogusUpdateDoesNotTriggerException() {
ReactiveMongoTemplate mongoTemplate = new ReactiveMongoTemplate(factory);
mongoTemplate.setWriteResultChecking(WriteResultChecking.EXCEPTION);
@@ -367,7 +370,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void updateFirstByEntityTypeShouldUpdateObject() {
void updateFirstByEntityTypeShouldUpdateObject() {
Person person = new Person("Oliver2", 25);
template.insert(person) //
@@ -381,7 +384,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void updateFirstByCollectionNameShouldUpdateObjects() {
void updateFirstByCollectionNameShouldUpdateObjects() {
Person person = new Person("Oliver2", 25);
template.insert(person, "people") //
@@ -395,7 +398,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void updateMultiByEntityTypeShouldUpdateObjects() {
void updateMultiByEntityTypeShouldUpdateObjects() {
Query query = new Query(
new Criteria().orOperator(where("firstName").is("Walter Jr"), where("firstName").is("Walter")));
@@ -411,7 +414,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void updateMultiByCollectionNameShouldUpdateObject() {
void updateMultiByCollectionNameShouldUpdateObject() {
Query query = new Query(
new Criteria().orOperator(where("firstName").is("Walter Jr"), where("firstName").is("Walter")));
@@ -432,7 +435,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void throwsExceptionForDuplicateIds() {
void throwsExceptionForDuplicateIds() {
ReactiveMongoTemplate template = new ReactiveMongoTemplate(factory);
template.setWriteResultChecking(WriteResultChecking.EXCEPTION);
@@ -452,7 +455,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void throwsExceptionForUpdateWithInvalidPushOperator() {
void throwsExceptionForUpdateWithInvalidPushOperator() {
ReactiveMongoTemplate template = new ReactiveMongoTemplate(factory);
template.setWriteResultChecking(WriteResultChecking.EXCEPTION);
@@ -475,7 +478,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void rejectsDuplicateIdInInsertAll() {
void rejectsDuplicateIdInInsertAll() {
ReactiveMongoTemplate template = new ReactiveMongoTemplate(factory);
template.setWriteResultChecking(WriteResultChecking.EXCEPTION);
@@ -490,7 +493,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void testFindAndUpdate() {
void testFindAndUpdate() {
template.insertAll(Arrays.asList(new Person("Tom", 21), new Person("Dick", 22), new Person("Harry", 23))) //
.as(StepVerifier::create) //
@@ -527,7 +530,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldReplaceDocument() {
void findAndReplaceShouldReplaceDocument() {
org.bson.Document doc = new org.bson.Document("foo", "bar");
template.save(doc, "findandreplace").as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -548,7 +551,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldErrorOnIdPresent() {
void findAndReplaceShouldErrorOnIdPresent() {
template.save(new MyPerson("Walter")).as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -561,21 +564,21 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldErrorOnSkip() {
void findAndReplaceShouldErrorOnSkip() {
assertThatIllegalArgumentException().isThrownBy(() -> template
.findAndReplace(query(where("name").is("Walter")).skip(10), new MyPerson("Heisenberg")).subscribe());
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldErrorOnLimit() {
void findAndReplaceShouldErrorOnLimit() {
assertThatIllegalArgumentException().isThrownBy(() -> template
.findAndReplace(query(where("name").is("Walter")).limit(10), new MyPerson("Heisenberg")).subscribe());
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldConsiderSortAndUpdateFirstIfMultipleFound() {
void findAndReplaceShouldConsiderSortAndUpdateFirstIfMultipleFound() {
MyPerson walter1 = new MyPerson("Walter 1");
MyPerson walter2 = new MyPerson("Walter 2");
@@ -592,7 +595,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldReplaceObject() {
void findAndReplaceShouldReplaceObject() {
MyPerson person = new MyPerson("Walter");
template.save(person) //
@@ -611,7 +614,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldConsiderFields() {
void findAndReplaceShouldConsiderFields() {
MyPerson person = new MyPerson("Walter");
person.address = new Address("TX", "Austin");
@@ -633,7 +636,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceNonExistingWithUpsertFalse() {
void findAndReplaceNonExistingWithUpsertFalse() {
template.findAndReplace(query(where("name").is("Walter")), new MyPerson("Heisenberg")) //
.as(StepVerifier::create) //
@@ -643,7 +646,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceNonExistingWithUpsertTrue() {
void findAndReplaceNonExistingWithUpsertTrue() {
template
.findAndReplace(query(where("name").is("Walter")), new MyPerson("Heisenberg"),
@@ -655,7 +658,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldProjectReturnedObjectCorrectly() {
void findAndReplaceShouldProjectReturnedObjectCorrectly() {
MyPerson person = new MyPerson("Walter");
template.save(person) //
@@ -673,7 +676,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1827
public void findAndReplaceShouldReplaceObjectReturingNew() {
void findAndReplaceShouldReplaceObjectReturingNew() {
MyPerson person = new MyPerson("Walter");
template.save(person) //
@@ -691,7 +694,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void testFindAllAndRemoveFullyReturnsAndRemovesDocuments() {
void testFindAllAndRemoveFullyReturnsAndRemovesDocuments() {
Sample spring = new Sample("100", "spring");
Sample data = new Sample("200", "data");
@@ -716,7 +719,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-2219
public void testFindAllAndRemoveReturnsEmptyWithoutMatches() {
void testFindAllAndRemoveReturnsEmptyWithoutMatches() {
Query qry = query(where("field").in("spring", "mongodb"));
template.findAllAndRemove(qry, Sample.class) //
@@ -729,7 +732,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1774
public void testFindAllAndRemoveByCollectionReturnsAndRemovesDocuments() {
void testFindAllAndRemoveByCollectionReturnsAndRemovesDocuments() {
Sample spring = new Sample("100", "spring");
Sample data = new Sample("200", "data");
@@ -754,12 +757,12 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1774
public void removeWithNullShouldThrowError() {
void removeWithNullShouldThrowError() {
assertThatIllegalArgumentException().isThrownBy(() -> template.remove((Object) null).subscribe());
}
@Test // DATAMONGO-1774
public void removeWithEmptyMonoShouldDoNothing() {
void removeWithEmptyMonoShouldDoNothing() {
Sample spring = new Sample("100", "spring");
Sample data = new Sample("200", "data");
@@ -778,7 +781,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1774
public void removeWithMonoShouldDeleteElement() {
void removeWithMonoShouldDeleteElement() {
Sample spring = new Sample("100", "spring");
Sample data = new Sample("200", "data");
@@ -794,7 +797,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1774
public void removeWithMonoAndCollectionShouldDeleteElement() {
void removeWithMonoAndCollectionShouldDeleteElement() {
Sample spring = new Sample("100", "spring");
Sample data = new Sample("200", "data");
@@ -812,7 +815,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-2195
public void removeVersionedEntityConsidersVersion() {
void removeVersionedEntityConsidersVersion() {
PersonWithVersionPropertyOfTypeInteger person = new PersonWithVersionPropertyOfTypeInteger();
person.firstName = "Dave";
@@ -842,7 +845,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void optimisticLockingHandling() {
void optimisticLockingHandling() {
// Init version
PersonWithVersionPropertyOfTypeInteger person = new PersonWithVersionPropertyOfTypeInteger();
@@ -887,7 +890,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void doesNotFailOnVersionInitForUnversionedEntity() {
void doesNotFailOnVersionInitForUnversionedEntity() {
Document dbObject = new Document();
dbObject.put("firstName", "Oliver");
@@ -900,7 +903,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void removesObjectFromExplicitCollection() {
void removesObjectFromExplicitCollection() {
String collectionName = "explicit";
template.remove(new Query(), collectionName).as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -923,7 +926,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void savesMapCorrectly() {
void savesMapCorrectly() {
Map<String, String> map = new HashMap<>();
map.put("key", "value");
@@ -936,12 +939,12 @@ public class ReactiveMongoTemplateTests {
@Test
// DATAMONGO-1444, DATAMONGO-1730, DATAMONGO-2150
public void savesMongoPrimitiveObjectCorrectly() {
void savesMongoPrimitiveObjectCorrectly() {
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> template.save(new Object(), "collection"));
}
@Test // DATAMONGO-1444
public void savesPlainDbObjectCorrectly() {
void savesPlainDbObjectCorrectly() {
Document dbObject = new Document("foo", "bar");
@@ -954,7 +957,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444, DATAMONGO-1730
public void rejectsPlainObjectWithOutExplicitCollection() {
void rejectsPlainObjectWithOutExplicitCollection() {
Document dbObject = new Document("foo", "bar");
@@ -968,7 +971,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void readsPlainDbObjectById() {
void readsPlainDbObjectById() {
Document dbObject = new Document("foo", "bar");
template.save(dbObject, "collection") //
@@ -986,7 +989,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void geoNear() {
void geoNear() {
List<Venue> venues = Arrays.asList(TestEntities.geolocation().pennStation(), //
TestEntities.geolocation().tenGenOffice(), //
@@ -1017,7 +1020,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void writesPlainString() {
void writesPlainString() {
template.save("{ 'foo' : 'bar' }", "collection") //
.as(StepVerifier::create) //
@@ -1026,12 +1029,12 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444, DATAMONGO-2150
public void rejectsNonJsonStringForSave() {
void rejectsNonJsonStringForSave() {
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> template.save("Foobar!", "collection"));
}
@Test // DATAMONGO-1444
public void initializesVersionOnInsert() {
void initializesVersionOnInsert() {
PersonWithVersionPropertyOfTypeInteger person = new PersonWithVersionPropertyOfTypeInteger();
person.firstName = "Dave";
@@ -1045,7 +1048,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void initializesVersionOnBatchInsert() {
void initializesVersionOnBatchInsert() {
PersonWithVersionPropertyOfTypeInteger person = new PersonWithVersionPropertyOfTypeInteger();
person.firstName = "Dave";
@@ -1059,7 +1062,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1992
public void initializesIdAndVersionAndOfImmutableObject() {
void initializesIdAndVersionAndOfImmutableObject() {
ImmutableVersioned versioned = new ImmutableVersioned();
@@ -1078,7 +1081,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void queryCanBeNull() {
void queryCanBeNull() {
template.findAll(PersonWithIdPropertyOfTypeObjectId.class) //
.as(StepVerifier::create) //
@@ -1090,7 +1093,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void versionsObjectIntoDedicatedCollection() {
void versionsObjectIntoDedicatedCollection() {
PersonWithVersionPropertyOfTypeInteger person = new PersonWithVersionPropertyOfTypeInteger();
person.firstName = "Dave";
@@ -1109,7 +1112,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void correctlySetsLongVersionProperty() {
void correctlySetsLongVersionProperty() {
PersonWithVersionPropertyOfTypeLong person = new PersonWithVersionPropertyOfTypeLong();
person.firstName = "Dave";
@@ -1122,11 +1125,11 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void throwsExceptionForIndexViolationIfConfigured() {
void throwsExceptionForIndexViolationIfConfigured() {
ReactiveMongoTemplate template = new ReactiveMongoTemplate(factory);
template.setWriteResultChecking(WriteResultChecking.EXCEPTION);
template.indexOps(Person.class) //
template.indexOps("unique_person") //
.ensureIndex(new Index().on("firstName", Direction.DESC).unique()) //
.as(StepVerifier::create) //
.expectNextCount(1) //
@@ -1135,7 +1138,7 @@ public class ReactiveMongoTemplateTests {
Person person = new Person(new ObjectId(), "Amol");
person.setAge(28);
template.save(person) //
template.save(person, "unique_person") //
.as(StepVerifier::create) //
.expectNextCount(1) //
.verifyComplete();
@@ -1143,13 +1146,16 @@ public class ReactiveMongoTemplateTests {
person = new Person(new ObjectId(), "Amol");
person.setAge(28);
template.save(person) //
template.save(person, "unique_person") //
.as(StepVerifier::create) //
.verifyError(DataIntegrityViolationException.class);
// safeguard to clean up previous state
template.dropCollection(Person.class).as(StepVerifier::create).verifyComplete();
}
@Test // DATAMONGO-1444
public void preventsDuplicateInsert() {
void preventsDuplicateInsert() {
template.setWriteConcern(WriteConcern.MAJORITY);
@@ -1169,7 +1175,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void countAndFindWithoutTypeInformation() {
void countAndFindWithoutTypeInformation() {
Person person = new Person();
template.save(person) //
@@ -1192,7 +1198,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void nullsPropertiesForVersionObjectUpdates() {
void nullsPropertiesForVersionObjectUpdates() {
VersionedPerson person = new VersionedPerson();
person.firstname = "Dave";
@@ -1221,7 +1227,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void nullsValuesForUpdatesOfUnversionedEntity() {
void nullsValuesForUpdatesOfUnversionedEntity() {
Person person = new Person("Dave");
template.save(person). //
@@ -1245,7 +1251,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void savesJsonStringCorrectly() {
void savesJsonStringCorrectly() {
Document dbObject = new Document().append("first", "first").append("second", "second");
@@ -1264,7 +1270,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void executesExistsCorrectly() {
void executesExistsCorrectly() {
Sample sample = new Sample();
template.save(sample).as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -1287,7 +1293,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void tailStreamsData() throws InterruptedException {
void tailStreamsData() throws InterruptedException {
template.dropCollection("capped").then(template.createCollection("capped", //
CollectionOptions.empty().size(1000).maxDocuments(10).capped()))
@@ -1309,7 +1315,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1444
public void tailStreamsDataUntilCancellation() throws InterruptedException {
void tailStreamsDataUntilCancellation() throws InterruptedException {
template.dropCollection("capped").then(template.createCollection("capped", //
CollectionOptions.empty().size(1000).maxDocuments(10).capped()))
@@ -1345,7 +1351,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1761
public void testDistinct() {
void testDistinct() {
Person person1 = new Person("Christoph", 38);
Person person2 = new Person("Christine", 39);
@@ -1365,7 +1371,7 @@ public class ReactiveMongoTemplateTests {
@Test // DATAMONGO-1803
@Disabled("Heavily relying on timing assumptions. Cannot test message resumption properly. Too much race for too little time in between.")
@EnableIfReplicaSetAvailable
public void changeStreamEventsShouldBeEmittedCorrectly() throws InterruptedException {
void changeStreamEventsShouldBeEmittedCorrectly() throws InterruptedException {
template.createCollection(Person.class).as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -1397,7 +1403,7 @@ public class ReactiveMongoTemplateTests {
@Test // DATAMONGO-1803
@Disabled("Heavily relying on timing assumptions. Cannot test message resumption properly. Too much race for too little time in between.")
@EnableIfReplicaSetAvailable
public void changeStreamEventsShouldBeConvertedCorrectly() throws InterruptedException {
void changeStreamEventsShouldBeConvertedCorrectly() throws InterruptedException {
template.createCollection(Person.class).as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -1429,7 +1435,7 @@ public class ReactiveMongoTemplateTests {
@Test // DATAMONGO-1803
@Disabled("Heavily relying on timing assumptions. Cannot test message resumption properly. Too much race for too little time in between.")
@EnableIfReplicaSetAvailable
public void changeStreamEventsShouldBeFilteredCorrectly() throws InterruptedException {
void changeStreamEventsShouldBeFilteredCorrectly() throws InterruptedException {
template.createCollection(Person.class).as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -1461,8 +1467,9 @@ public class ReactiveMongoTemplateTests {
@Test // DATAMONGO-1803
@EnableIfReplicaSetAvailable
public void mapsReservedWordsCorrectly() throws InterruptedException {
void mapsReservedWordsCorrectly() throws InterruptedException {
template.dropCollection(Person.class).onErrorResume(it -> Mono.empty()).as(StepVerifier::create).verifyComplete();
template.createCollection(Person.class).as(StepVerifier::create).expectNextCount(1).verifyComplete();
BlockingQueue<ChangeStreamEvent<Person>> documents = new LinkedBlockingQueue<>(100);
@@ -1504,7 +1511,7 @@ public class ReactiveMongoTemplateTests {
@Test // DATAMONGO-1803
@Disabled("Heavily relying on timing assumptions. Cannot test message resumption properly. Too much race for too little time in between.")
@EnableIfReplicaSetAvailable
public void changeStreamEventsShouldBeResumedCorrectly() throws InterruptedException {
void changeStreamEventsShouldBeResumedCorrectly() throws InterruptedException {
template.createCollection(Person.class).as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -1545,7 +1552,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1870
public void removeShouldConsiderLimit() {
void removeShouldConsiderLimit() {
List<Sample> samples = IntStream.range(0, 100) //
.mapToObj(i -> new Sample("id-" + i, i % 2 == 0 ? "stark" : "lannister")) //
@@ -1562,7 +1569,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-1870
public void removeShouldConsiderSkipAndSort() {
void removeShouldConsiderSkipAndSort() {
List<Sample> samples = IntStream.range(0, 100) //
.mapToObj(i -> new Sample("id-" + i, i % 2 == 0 ? "stark" : "lannister")) //
@@ -1581,7 +1588,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-2189
public void afterSaveEventContainsSavedObjectUsingInsert() {
void afterSaveEventContainsSavedObjectUsingInsert() {
AtomicReference<ImmutableVersioned> saved = createAfterSaveReference();
ImmutableVersioned source = new ImmutableVersioned();
@@ -1596,7 +1603,7 @@ public class ReactiveMongoTemplateTests {
}
@Test // DATAMONGO-2189
public void afterSaveEventContainsSavedObjectUsingInsertAll() {
void afterSaveEventContainsSavedObjectUsingInsertAll() {
AtomicReference<ImmutableVersioned> saved = createAfterSaveReference();
ImmutableVersioned source = new ImmutableVersioned();
@@ -1613,8 +1620,10 @@ public class ReactiveMongoTemplateTests {
@Test // DATAMONGO-2012
@EnableIfMongoServerVersion(isGreaterThanEqual = "4.0")
@EnableIfReplicaSetAvailable
public void watchesDatabaseCorrectly() throws InterruptedException {
void watchesDatabaseCorrectly() throws InterruptedException {
template.dropCollection(Person.class).onErrorResume(it -> Mono.empty()).as(StepVerifier::create).verifyComplete();
template.dropCollection("personX").onErrorResume(it -> Mono.empty()).as(StepVerifier::create).verifyComplete();
template.createCollection(Person.class).as(StepVerifier::create).expectNextCount(1).verifyComplete();
template.createCollection("personX").as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -1654,8 +1663,9 @@ public class ReactiveMongoTemplateTests {
@Test // DATAMONGO-2012, DATAMONGO-2113
@EnableIfMongoServerVersion(isGreaterThanEqual = "4.0")
@EnableIfReplicaSetAvailable
public void resumesAtTimestampCorrectly() throws InterruptedException {
void resumesAtTimestampCorrectly() throws InterruptedException {
template.dropCollection(Person.class).onErrorResume(it -> Mono.empty()).as(StepVerifier::create).verifyComplete();
template.createCollection(Person.class).as(StepVerifier::create).expectNextCount(1).verifyComplete();
BlockingQueue<ChangeStreamEvent<Person>> documents = new LinkedBlockingQueue<>(100);
@@ -1704,7 +1714,7 @@ public class ReactiveMongoTemplateTests {
@Test // DATAMONGO-2115
@EnableIfMongoServerVersion(isGreaterThanEqual = "4.0")
@EnableIfReplicaSetAvailable
public void resumesAtBsonTimestampCorrectly() throws InterruptedException {
void resumesAtBsonTimestampCorrectly() throws InterruptedException {
template.createCollection(Person.class).as(StepVerifier::create).expectNextCount(1).verifyComplete();
@@ -1774,7 +1784,7 @@ public class ReactiveMongoTemplateTests {
final @Id String id;
final @Version Long version;
public ImmutableVersioned() {
ImmutableVersioned() {
id = null;
version = null;
}
@@ -1786,9 +1796,9 @@ public class ReactiveMongoTemplateTests {
@Id String id;
String field;
public Sample() {}
Sample() {}
public Sample(String id, String field) {
Sample(String id, String field) {
this.id = id;
this.field = field;
}
@@ -1803,7 +1813,7 @@ public class ReactiveMongoTemplateTests {
String name;
Address address;
public MyPerson(String name) {
MyPerson(String name) {
this.name = name;
}
}

View File

@@ -22,7 +22,7 @@ import java.util.Arrays;
import java.util.Map;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.query.SerializationUtils;
import com.mongodb.BasicDBList;

View File

@@ -21,10 +21,10 @@ import static org.mockito.Mockito.*;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.data.mongodb.MongoDatabaseFactory;
@@ -42,15 +42,15 @@ import com.mongodb.client.MongoDatabase;
* @author Christoph Strobl
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class SimpleMongoClientDatabaseFactoryUnitTests {
@ExtendWith(MockitoExtension.class)
class SimpleMongoClientDatabaseFactoryUnitTests {
@Mock MongoClient mongo;
@Mock ClientSession clientSession;
@Mock MongoDatabase database;
@Test // DATADOC-254, DATAMONGO-1903
public void rejectsIllegalDatabaseNames() {
void rejectsIllegalDatabaseNames() {
rejectsDatabaseName("foo.bar");
rejectsDatabaseName("foo$bar");
@@ -61,14 +61,14 @@ public class SimpleMongoClientDatabaseFactoryUnitTests {
}
@Test // DATADOC-254
public void allowsDatabaseNames() {
void allowsDatabaseNames() {
new SimpleMongoClientDatabaseFactory(mongo, "foo-bar");
new SimpleMongoClientDatabaseFactory(mongo, "foo_bar");
new SimpleMongoClientDatabaseFactory(mongo, "foo01231bar");
}
@Test // DATADOC-295
public void mongoUriConstructor() {
void mongoUriConstructor() {
ConnectionString mongoURI = new ConnectionString(
"mongodb://myUsername:myPassword@localhost/myDatabase.myCollection");
@@ -78,7 +78,7 @@ public class SimpleMongoClientDatabaseFactoryUnitTests {
}
@Test // DATAMONGO-1158
public void constructsMongoClientAccordingToMongoUri() {
void constructsMongoClientAccordingToMongoUri() {
ConnectionString uri = new ConnectionString(
"mongodb://myUserName:myPassWord@127.0.0.1:27017/myDataBase.myCollection");
@@ -88,7 +88,7 @@ public class SimpleMongoClientDatabaseFactoryUnitTests {
}
@Test // DATAMONGO-1880
public void cascadedWithSessionUsesRootFactory() {
void cascadedWithSessionUsesRootFactory() {
when(mongo.getDatabase("foo")).thenReturn(database);

View File

@@ -21,10 +21,10 @@ import static org.mockito.Mockito.*;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
@@ -39,15 +39,15 @@ import com.mongodb.reactivestreams.client.MongoDatabase;
*
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class SimpleReactiveMongoDatabaseFactoryUnitTests {
@ExtendWith(MockitoExtension.class)
class SimpleReactiveMongoDatabaseFactoryUnitTests {
@Mock MongoClient mongoClient;
@Mock ClientSession clientSession;
@Mock MongoDatabase database;
@Test // DATAMONGO-1880
public void cascadedWithSessionUsesRootFactory() {
void cascadedWithSessionUsesRootFactory() {
when(mongoClient.getDatabase("foo")).thenReturn(database);
@@ -63,7 +63,7 @@ public class SimpleReactiveMongoDatabaseFactoryUnitTests {
}
@Test // DATAMONGO-1903
public void rejectsIllegalDatabaseNames() {
void rejectsIllegalDatabaseNames() {
rejectsDatabaseName("foo.bar");
rejectsDatabaseName("foo$bar");

View File

@@ -19,8 +19,8 @@ import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link AggregationOptions}.
@@ -34,7 +34,7 @@ public class AggregationOptionsTests {
AggregationOptions aggregationOptions;
@Before
@BeforeEach
public void setup() {
aggregationOptions = newAggregationOptions().explain(true) //
.cursorBatchSize(1) //

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link AggregationUpdate}.

View File

@@ -22,7 +22,7 @@ import java.util.Arrays;
import java.util.List;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators.ArrayToObject;

View File

@@ -20,7 +20,7 @@ import static org.springframework.data.mongodb.core.DocumentTestUtils.*;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.aggregation.BucketAutoOperation.Granularities;

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link BucketOperation}.

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link ConvertOperators}.

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link CountOperation}.

View File

@@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.aggregation.ExposedFields.ExposedField;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.mongodb.core.aggregation.Fields.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.aggregation.Fields.*;

View File

@@ -22,11 +22,12 @@ import java.util.Arrays;
import java.util.List;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.core.DocumentTestUtils;
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
@@ -37,16 +38,16 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
/**
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
public class FilterExpressionUnitTests {
@ExtendWith(MockitoExtension.class)
class FilterExpressionUnitTests {
@Mock MongoDatabaseFactory mongoDbFactory;
private AggregationOperationContext aggregationContext;
private MongoMappingContext mappingContext;
@Before
public void setUp() {
@BeforeEach
void setUp() {
mappingContext = new MongoMappingContext();
aggregationContext = new TypeBasedAggregationOperationContext(Sales.class, mappingContext,
@@ -54,7 +55,7 @@ public class FilterExpressionUnitTests {
}
@Test // DATAMONGO-1491
public void shouldConstructFilterExpressionCorrectly() {
void shouldConstructFilterExpressionCorrectly() {
TypedAggregation<Sales> agg = Aggregation.newAggregation(Sales.class,
Aggregation.project()
@@ -72,7 +73,7 @@ public class FilterExpressionUnitTests {
}
@Test // DATAMONGO-1491
public void shouldConstructFilterExpressionCorrectlyWhenUsingFilterOnProjectionBuilder() {
void shouldConstructFilterExpressionCorrectlyWhenUsingFilterOnProjectionBuilder() {
TypedAggregation<Sales> agg = Aggregation.newAggregation(Sales.class, Aggregation.project().and("items")
.filter("item", AggregationFunctionExpressions.GTE.of(Fields.field("item.price"), 100)).as("items"));
@@ -88,7 +89,7 @@ public class FilterExpressionUnitTests {
}
@Test // DATAMONGO-1491
public void shouldConstructFilterExpressionCorrectlyWhenInputMapToArray() {
void shouldConstructFilterExpressionCorrectlyWhenInputMapToArray() {
TypedAggregation<Sales> agg = Aggregation.newAggregation(Sales.class,
Aggregation.project().and(filter(Arrays.<Object> asList(1, "a", 2, null, 3.1D, 4, "5")).as("num")
@@ -105,7 +106,7 @@ public class FilterExpressionUnitTests {
}
@Test // DATAMONGO-2320
public void shouldConstructFilterExpressionCorrectlyWhenConditionContainsFieldReference() {
void shouldConstructFilterExpressionCorrectlyWhenConditionContainsFieldReference() {
Aggregation agg = Aggregation.newAggregation(Aggregation.project().and((ctx) -> new Document()).as("field-1")
.and(filter("items").as("item").by(ComparisonOperators.valueOf("item.price").greaterThan("field-1")))

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.Arrays;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.annotation.Id;
import org.springframework.data.geo.Distance;
import org.springframework.data.mongodb.core.DocumentTestUtils;

View File

@@ -20,7 +20,7 @@ import static org.springframework.data.mongodb.test.util.Assertions.*;
import java.util.Arrays;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.Person;
import org.springframework.data.mongodb.core.query.Criteria;

View File

@@ -22,7 +22,7 @@ import static org.springframework.data.mongodb.core.aggregation.Fields.*;
import java.util.Arrays;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.DocumentTestUtils;
import org.springframework.data.mongodb.core.query.Criteria;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.DocumentTestUtils;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.aggregation.Aggregation.SystemVariable;
import org.springframework.data.mongodb.core.aggregation.ObjectOperators.MergeObjects;

View File

@@ -21,7 +21,7 @@ import static org.springframework.data.mongodb.test.util.Assertions.*;
import java.util.Arrays;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link OutOperation}.

View File

@@ -28,7 +28,7 @@ import java.util.Arrays;
import java.util.List;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Range;
import org.springframework.data.domain.Range.Bound;

View File

@@ -23,11 +23,13 @@ import static org.mockito.Mockito.anyList;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.data.mongodb.ReactiveMongoDatabaseFactory;
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
@@ -43,20 +45,21 @@ import com.mongodb.reactivestreams.client.MongoDatabase;
* @author Christoph Strobl
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
public class ReactiveAggregationUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class ReactiveAggregationUnitTests {
static final String INPUT_COLLECTION = "collection-1";
private static final String INPUT_COLLECTION = "collection-1";
ReactiveMongoTemplate template;
ReactiveMongoDatabaseFactory factory;
private ReactiveMongoTemplate template;
private ReactiveMongoDatabaseFactory factory;
@Mock MongoClient mongoClient;
@Mock MongoDatabase db;
@Mock MongoCollection<Document> collection;
@Mock AggregatePublisher<Document> publisher;
@Before
public void setUp() {
@BeforeEach
void setUp() {
factory = new SimpleReactiveMongoDatabaseFactory(mongoClient, "db");
template = new ReactiveMongoTemplate(factory);
@@ -69,23 +72,23 @@ public class ReactiveAggregationUnitTests {
}
@Test // DATAMONGO-1646
public void shouldHandleMissingInputCollection() {
void shouldHandleMissingInputCollection() {
assertThatIllegalArgumentException()
.isThrownBy(() -> template.aggregate(newAggregation(), (String) null, TagCount.class));
}
@Test // DATAMONGO-1646
public void shouldHandleMissingAggregationPipeline() {
void shouldHandleMissingAggregationPipeline() {
assertThatIllegalArgumentException().isThrownBy(() -> template.aggregate(null, INPUT_COLLECTION, TagCount.class));
}
@Test // DATAMONGO-1646
public void shouldHandleMissingEntityClass() {
void shouldHandleMissingEntityClass() {
assertThatIllegalArgumentException().isThrownBy(() -> template.aggregate(newAggregation(), INPUT_COLLECTION, null));
}
@Test // DATAMONGO-1646
public void errorsOnExplainUsage() {
void errorsOnExplainUsage() {
assertThatIllegalArgumentException().isThrownBy(() -> template.aggregate(newAggregation(Product.class, //
project("name", "netPrice")) //
.withOptions(AggregationOptions.builder().explain(true).build()),
@@ -93,7 +96,7 @@ public class ReactiveAggregationUnitTests {
}
@Test // DATAMONGO-1646, DATAMONGO-1311
public void appliesBatchSizeWhenPresent() {
void appliesBatchSizeWhenPresent() {
when(publisher.batchSize(anyInt())).thenReturn(publisher);
@@ -107,7 +110,7 @@ public class ReactiveAggregationUnitTests {
}
@Test // DATAMONGO-1646
public void appliesCollationCorrectlyWhenPresent() {
void appliesCollationCorrectlyWhenPresent() {
template.aggregate(newAggregation(Product.class, //
project("name", "netPrice")) //
@@ -118,7 +121,7 @@ public class ReactiveAggregationUnitTests {
}
@Test // DATAMONGO-1646
public void doesNotSetCollationWhenNotPresent() {
void doesNotSetCollationWhenNotPresent() {
template.aggregate(newAggregation(Product.class, //
project("name", "netPrice")) //
@@ -129,7 +132,7 @@ public class ReactiveAggregationUnitTests {
}
@Test // DATAMONGO-1646
public void appliesDiskUsageCorrectly() {
void appliesDiskUsageCorrectly() {
template.aggregate(newAggregation(Product.class, //
project("name", "netPrice")) //

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.aggregation.ReplaceRootOperation.ReplaceRootDocumentOperation;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link ReplaceRootOperation}.

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link SampleOperation}.

View File

@@ -20,7 +20,7 @@ import static org.assertj.core.api.Assertions.*;
import java.util.List;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver;
import org.springframework.data.mongodb.core.convert.QueryMapper;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link SkipOperation}.

View File

@@ -21,7 +21,7 @@ import static org.springframework.data.mongodb.test.util.Assertions.*;
import java.util.Arrays;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit tests for {@link SortByCountOperation}.

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import static org.springframework.data.mongodb.core.DocumentTestUtils.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Unit test for {@link StringOperators}.

View File

@@ -27,11 +27,11 @@ import java.util.List;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.support.GenericConversionService;
@@ -57,7 +57,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
* @author Mark Paluch
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class TypeBasedAggregationOperationContextUnitTests {
MongoMappingContext context;
@@ -66,7 +66,7 @@ public class TypeBasedAggregationOperationContextUnitTests {
@Mock DbRefResolver dbRefResolver;
@Before
@BeforeEach
public void setUp() {
this.context = new MongoMappingContext();
@@ -283,7 +283,7 @@ public class TypeBasedAggregationOperationContextUnitTests {
assertThat(definition.get("something_totally_different")).isEqualTo(1);
}
@Test(expected = IllegalArgumentException.class) // DATAMONGO-1326
@Test // DATAMONGO-1326
public void lookupGroupAggregationShouldFailInvalidFieldReference() {
TypeBasedAggregationOperationContext context = getContext(MeterData.class);
@@ -291,7 +291,7 @@ public class TypeBasedAggregationOperationContextUnitTests {
lookup("OtherCollection", "resourceId", "otherId", "lookup"),
group().min("lookup.otherkey").as("something_totally_different"), sort(Direction.ASC, "resourceId"));
agg.toDocument("meterData", context);
assertThatIllegalArgumentException().isThrownBy(() -> agg.toDocument("meterData", context));
}
@Test // DATAMONGO-861

View File

@@ -22,7 +22,7 @@ import java.util.Collection;
import java.util.Collections;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.aggregation;
import static org.assertj.core.api.Assertions.*;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.DocumentTestUtils;

View File

@@ -20,13 +20,13 @@ import static org.assertj.core.api.Assertions.*;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.annotation.Id;

View File

@@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.convert;
import static org.mockito.Mockito.*;
import org.bson.conversions.Bson;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.data.mapping.context.MappingContext;

View File

@@ -22,11 +22,13 @@ import java.util.Arrays;
import java.util.HashSet;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.annotation.Id;
@@ -39,20 +41,20 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
*
* @author Oliver Gierke
*/
@RunWith(MockitoJUnitRunner.class)
public class CustomConvertersUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class CustomConvertersUnitTests {
MappingMongoConverter converter;
private MappingMongoConverter converter;
@Mock BarToDocumentConverter barToDocumentConverter;
@Mock DocumentToBarConverter documentToBarConverter;
@Mock MongoDatabaseFactory mongoDbFactory;
MongoMappingContext context;
private MongoMappingContext context;
@Before
@SuppressWarnings("unchecked")
public void setUp() throws Exception {
@BeforeEach
void setUp() {
when(barToDocumentConverter.convert(any(Bar.class))).thenReturn(new Document());
when(documentToBarConverter.convert(any(Document.class))).thenReturn(new Bar());
@@ -61,7 +63,7 @@ public class CustomConvertersUnitTests {
Arrays.asList(barToDocumentConverter, documentToBarConverter));
context = new MongoMappingContext();
context.setInitialEntitySet(new HashSet<Class<?>>(Arrays.asList(Foo.class, Bar.class)));
context.setInitialEntitySet(new HashSet<>(Arrays.asList(Foo.class, Bar.class)));
context.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
context.initialize();
@@ -71,7 +73,7 @@ public class CustomConvertersUnitTests {
}
@Test // DATADOC-101
public void nestedToDocumentConverterGetsInvoked() {
void nestedToDocumentConverterGetsInvoked() {
Foo foo = new Foo();
foo.bar = new Bar();
@@ -81,7 +83,7 @@ public class CustomConvertersUnitTests {
}
@Test // DATADOC-101
public void nestedFromDocumentConverterGetsInvoked() {
void nestedFromDocumentConverterGetsInvoked() {
Document document = new Document();
document.put("bar", new Document());
@@ -91,25 +93,25 @@ public class CustomConvertersUnitTests {
}
@Test // DATADOC-101
public void toDocumentConverterGetsInvoked() {
void toDocumentConverterGetsInvoked() {
converter.write(new Bar(), new Document());
verify(barToDocumentConverter).convert(any(Bar.class));
}
@Test // DATADOC-101
public void fromDocumentConverterGetsInvoked() {
void fromDocumentConverterGetsInvoked() {
converter.read(Bar.class, new Document());
verify(documentToBarConverter).convert(any(Document.class));
}
@Test // DATADOC-101
public void foo() {
void foo() {
Document document = new Document();
document.put("foo", null);
assertThat(document.containsKey("foo")).isEqualTo(true);
assertThat(document).containsKey("foo");
}
public static class Foo {
@@ -122,11 +124,7 @@ public class CustomConvertersUnitTests {
public String foo;
}
private interface BarToDocumentConverter extends Converter<Bar, Document> {
private interface BarToDocumentConverter extends Converter<Bar, Document> {}
}
private interface DocumentToBarConverter extends Converter<Document, Bar> {
}
private interface DocumentToBarConverter extends Converter<Document, Bar> {}
}

View File

@@ -24,9 +24,9 @@ import java.util.List;
import java.util.Map;
import org.bson.Document;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
@@ -40,7 +40,7 @@ public class DataMongo273Tests {
MappingMongoConverter converter;
@Before
@BeforeEach
public void setupMongoConverter() {
MongoMappingContext mappingContext = new MongoMappingContext();
@@ -74,7 +74,7 @@ public class DataMongo273Tests {
}
@Test // DATAMONGO-294
@Ignore("TODO: Mongo3 - this is no longer supported as DBList is no Bson type :/")
@Disabled("TODO: Mongo3 - this is no longer supported as DBList is no Bson type :/")
@SuppressWarnings({ "rawtypes", "unchecked" })
public void convertListOfThings() {
Plane plane = new Plane("Boeing", 4);

View File

@@ -34,12 +34,12 @@ import java.util.Set;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.bson.types.ObjectId;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.annotation.AccessType;
import org.springframework.data.annotation.AccessType.Type;
@@ -69,7 +69,7 @@ import com.mongodb.client.MongoDatabase;
* @author Christoph Strobl
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class DbRefMappingMongoConverterUnitTests {
MappingMongoConverter converter;
@@ -78,7 +78,7 @@ public class DbRefMappingMongoConverterUnitTests {
@Mock MongoDatabaseFactory dbFactory;
DefaultDbRefResolver dbRefResolver;
@Before
@BeforeEach
public void setUp() {
when(dbFactory.getExceptionTranslator()).thenReturn(new MongoExceptionTranslator());

View File

@@ -24,13 +24,15 @@ import java.util.Collections;
import org.bson.Document;
import org.bson.types.ObjectId;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.mongodb.MongoDatabaseFactory;
@@ -47,17 +49,18 @@ import com.mongodb.client.MongoDatabase;
* @author Christoph Strobl
* @author Oliver Gierke
*/
@RunWith(MockitoJUnitRunner.class)
public class DefaultDbRefResolverUnitTests {
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class DefaultDbRefResolverUnitTests {
@Mock MongoDatabaseFactory factoryMock;
@Mock MongoDatabase dbMock;
@Mock MongoCollection<Document> collectionMock;
@Mock FindIterable<Document> cursorMock;
DefaultDbRefResolver resolver;
private DefaultDbRefResolver resolver;
@Before
public void setUp() {
@BeforeEach
void setUp() {
when(factoryMock.getMongoDatabase()).thenReturn(dbMock);
when(dbMock.getCollection(anyString(), any(Class.class))).thenReturn(collectionMock);
@@ -68,7 +71,7 @@ public class DefaultDbRefResolverUnitTests {
@Test // DATAMONGO-1194
@SuppressWarnings("unchecked")
public void bulkFetchShouldLoadDbRefsCorrectly() {
void bulkFetchShouldLoadDbRefsCorrectly() {
DBRef ref1 = new DBRef("collection-1", new ObjectId());
DBRef ref2 = new DBRef("collection-1", new ObjectId());
@@ -85,25 +88,26 @@ public class DefaultDbRefResolverUnitTests {
assertThat($in).hasSize(2);
}
@Test(expected = InvalidDataAccessApiUsageException.class) // DATAMONGO-1194
public void bulkFetchShouldThrowExceptionWhenUsingDifferntCollectionsWithinSetOfReferences() {
@Test // DATAMONGO-1194
void bulkFetchShouldThrowExceptionWhenUsingDifferntCollectionsWithinSetOfReferences() {
DBRef ref1 = new DBRef("collection-1", new ObjectId());
DBRef ref2 = new DBRef("collection-2", new ObjectId());
resolver.bulkFetch(Arrays.asList(ref1, ref2));
assertThatThrownBy(() -> resolver.bulkFetch(Arrays.asList(ref1, ref2)))
.isInstanceOf(InvalidDataAccessApiUsageException.class);
}
@Test // DATAMONGO-1194
public void bulkFetchShouldReturnEarlyForEmptyLists() {
void bulkFetchShouldReturnEarlyForEmptyLists() {
resolver.bulkFetch(Collections.<DBRef> emptyList());
resolver.bulkFetch(Collections.emptyList());
verify(collectionMock, never()).find(Mockito.any(Document.class));
}
@Test // DATAMONGO-1194
public void bulkFetchShouldRestoreOriginalOrder() {
void bulkFetchShouldRestoreOriginalOrder() {
Document o1 = new Document("_id", new ObjectId());
Document o2 = new Document("_id", new ObjectId());
@@ -117,7 +121,7 @@ public class DefaultDbRefResolverUnitTests {
}
@Test // DATAMONGO-1765
public void bulkFetchContainsDuplicates() {
void bulkFetchContainsDuplicates() {
Document document = new Document("_id", new ObjectId());

View File

@@ -22,8 +22,8 @@ import java.util.Collections;
import java.util.List;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.convert.ConfigurableTypeInformationMapper;
import org.springframework.data.convert.SimpleTypeInformationMapper;
@@ -42,7 +42,7 @@ public class DefaultMongoTypeMapperUnitTests {
DefaultMongoTypeMapper typeMapper;
@Before
@BeforeEach
public void setUp() {
configurableTypeInformationMapper = new ConfigurableTypeInformationMapper(

View File

@@ -19,7 +19,7 @@ import static org.assertj.core.api.Assertions.*;
import org.bson.BsonDocument;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.DocumentTestUtils;
import org.springframework.data.mongodb.core.mapping.Field;

View File

@@ -21,7 +21,7 @@ import java.util.Arrays;
import java.util.List;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.geo.Box;
import org.springframework.data.geo.Circle;

View File

@@ -20,7 +20,7 @@ import static org.springframework.data.mongodb.test.util.Assertions.*;
import java.util.Arrays;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

View File

@@ -18,10 +18,10 @@ package org.springframework.data.mongodb.core.convert;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
@@ -36,7 +36,7 @@ import com.mongodb.DBRef;
*
* @author Christoph Strobl
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class LazyLoadingInterceptorUnitTests {
@Mock MongoPersistentProperty propertyMock;

View File

@@ -28,7 +28,8 @@ import java.util.concurrent.atomic.AtomicLong;
import org.assertj.core.data.TemporalUnitLessThanOffset;
import org.bson.BsonTimestamp;
import org.bson.Document;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.data.geo.Box;

View File

@@ -21,7 +21,8 @@ import java.time.ZonedDateTime;
import java.util.Collections;
import java.util.Date;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.core.convert.converter.Converter;
/**
@@ -29,10 +30,10 @@ import org.springframework.core.convert.converter.Converter;
*
* @author Christoph Strobl
*/
public class MongoCustomConversionsUnitTests {
class MongoCustomConversionsUnitTests {
@Test // DATAMONGO-2349
public void nonAnnotatedConverterForJavaTimeTypeShouldOnlyBeRegisteredAsReadingConverter() {
void nonAnnotatedConverterForJavaTimeTypeShouldOnlyBeRegisteredAsReadingConverter() {
MongoCustomConversions conversions = new MongoCustomConversions(
Collections.singletonList(new DateToZonedDateTimeConverter()));

View File

@@ -27,11 +27,11 @@ import java.util.Set;
import java.util.regex.Pattern;
import org.bson.conversions.Bson;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.data.annotation.Id;
import org.springframework.data.domain.Example;
@@ -52,7 +52,7 @@ import org.springframework.data.util.TypeInformation;
* @author Christoph Strobl
* @author Mark Paluch
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class MongoExampleMapperUnitTests {
MongoExampleMapper mapper;
@@ -61,7 +61,7 @@ public class MongoExampleMapperUnitTests {
@Mock MongoDatabaseFactory factory;
@Before
@BeforeEach
public void setUp() {
this.context = new MongoMappingContext();

View File

@@ -23,8 +23,8 @@ import java.util.Arrays;
import java.util.List;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
@@ -105,7 +105,7 @@ public class MongoJsonSchemaMapperUnitTests {
" }" + //
" } }";
@Before
@BeforeEach
public void setUp() {
mapper = new MongoJsonSchemaMapper(new MappingMongoConverter(mock(DbRefResolver.class), new MongoMappingContext()));
}

View File

@@ -19,7 +19,7 @@ import static org.springframework.data.mongodb.test.util.Assertions.*;
import org.bson.Document;
import org.bson.types.Code;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

View File

@@ -18,8 +18,8 @@ package org.springframework.data.mongodb.core.convert;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.mapping.BasicMongoPersistentEntity;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
@@ -36,7 +36,7 @@ public class ObjectPathUnitTests {
MongoPersistentEntity<EntityTwo> two;
MongoPersistentEntity<EntityThree> three;
@Before
@BeforeEach
public void setUp() {
one = new BasicMongoPersistentEntity<>(ClassTypeInformation.from(EntityOne.class));

View File

@@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core.convert;
import static org.mockito.Mockito.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.springframework.data.mongodb.core.convert.MongoConverters.TermToStringConverter;
import org.springframework.data.mongodb.core.query.Term;
import org.springframework.data.mongodb.core.query.Term.Type;

View File

@@ -31,12 +31,12 @@ import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.bson.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.annotation.Id;
@@ -66,19 +66,19 @@ import com.mongodb.DBRef;
* @author Mark Paluch
* @author Pavel Vodrazka
*/
@RunWith(MockitoJUnitRunner.class)
public class UpdateMapperUnitTests {
@ExtendWith(MockitoExtension.class)
class UpdateMapperUnitTests {
@Mock MongoDatabaseFactory factory;
MappingMongoConverter converter;
MongoMappingContext context;
UpdateMapper mapper;
private MappingMongoConverter converter;
private MongoMappingContext context;
private UpdateMapper mapper;
private Converter<NestedEntity, Document> writingConverterSpy;
@Before
@BeforeEach
@SuppressWarnings("unchecked")
public void setUp() {
void setUp() {
this.writingConverterSpy = Mockito.spy(new NestedEntityWriteConverter());
CustomConversions conversions = new MongoCustomConversions(Collections.singletonList(writingConverterSpy));
@@ -95,7 +95,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-721
public void updateMapperRetainsTypeInformationForCollectionField() {
void updateMapperRetainsTypeInformationForCollectionField() {
Update update = new Update().push("list", new ConcreteChildClass("2", "BAR"));
@@ -109,7 +109,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-807
public void updateMapperShouldRetainTypeInformationForNestedEntities() {
void updateMapperShouldRetainTypeInformationForNestedEntities() {
Update update = Update.update("model", new ModelImpl(1));
UpdateMapper mapper = new UpdateMapper(converter);
@@ -123,7 +123,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-807
public void updateMapperShouldNotPersistTypeInformationForKnownSimpleTypes() {
void updateMapperShouldNotPersistTypeInformationForKnownSimpleTypes() {
Update update = Update.update("model.value", 1);
UpdateMapper mapper = new UpdateMapper(converter);
@@ -136,7 +136,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-807
public void updateMapperShouldNotPersistTypeInformationForNullValues() {
void updateMapperShouldNotPersistTypeInformationForNullValues() {
Update update = Update.update("model", null);
UpdateMapper mapper = new UpdateMapper(converter);
@@ -149,7 +149,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-407
public void updateMapperShouldRetainTypeInformationForNestedCollectionElements() {
void updateMapperShouldRetainTypeInformationForNestedCollectionElements() {
Update update = Update.update("list.$", new ConcreteChildClass("42", "bubu"));
@@ -163,7 +163,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-407
public void updateMapperShouldSupportNestedCollectionElementUpdates() {
void updateMapperShouldSupportNestedCollectionElementUpdates() {
Update update = Update.update("list.$.value", "foo").set("list.$.otherValue", "bar");
@@ -177,7 +177,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-407
public void updateMapperShouldWriteTypeInformationForComplexNestedCollectionElementUpdates() {
void updateMapperShouldWriteTypeInformationForComplexNestedCollectionElementUpdates() {
Update update = Update.update("list.$.value", "foo").set("list.$.someObject", new ConcreteChildClass("42", "bubu"));
@@ -195,7 +195,7 @@ public class UpdateMapperUnitTests {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test // DATAMONGO-812
public void updateMapperShouldConvertPushCorrectlyWhenCalledWithEachUsingSimpleTypes() {
void updateMapperShouldConvertPushCorrectlyWhenCalledWithEachUsingSimpleTypes() {
Update update = new Update().push("values").each("spring", "data", "mongodb");
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(Model.class));
@@ -211,7 +211,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-812
public void updateMapperShouldConvertPushWhithoutAddingClassInformationWhenUsedWithEvery() {
void updateMapperShouldConvertPushWhithoutAddingClassInformationWhenUsedWithEvery() {
Update update = new Update().push("values").each("spring", "data", "mongodb");
@@ -225,7 +225,7 @@ public class UpdateMapperUnitTests {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test // DATAMONGO-812
public void updateMapperShouldConvertPushCorrectlyWhenCalledWithEachUsingCustomTypes() {
void updateMapperShouldConvertPushCorrectlyWhenCalledWithEachUsingCustomTypes() {
Update update = new Update().push("models").each(new ListModel("spring", "data", "mongodb"));
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(),
@@ -240,7 +240,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-812
public void updateMapperShouldRetainClassInformationForPushCorrectlyWhenCalledWithEachUsingCustomTypes() {
void updateMapperShouldRetainClassInformationForPushCorrectlyWhenCalledWithEachUsingCustomTypes() {
Update update = new Update().push("models").each(new ListModel("spring", "data", "mongodb"));
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(),
@@ -254,7 +254,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-812
public void testUpdateShouldAllowMultiplePushEachForDifferentFields() {
void testUpdateShouldAllowMultiplePushEachForDifferentFields() {
Update update = new Update().push("category").each("spring", "data").push("type").each("mongodb");
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(Object.class));
@@ -265,7 +265,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-943
public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositiveIndexParameter() {
void updatePushEachAtPositionWorksCorrectlyWhenGivenPositiveIndexParameter() {
Update update = new Update().push("key").atPosition(2).each(Arrays.asList("Arya", "Arry", "Weasel"));
@@ -280,7 +280,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-943, DATAMONGO-2055
public void updatePushEachAtNegativePositionWorksCorrectly() {
void updatePushEachAtNegativePositionWorksCorrectly() {
Update update = new Update().push("key").atPosition(-2).each(Arrays.asList("Arya", "Arry", "Weasel"));
@@ -294,7 +294,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-943
public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionFirst() {
void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionFirst() {
Update update = new Update().push("key").atPosition(Position.FIRST).each(Arrays.asList("Arya", "Arry", "Weasel"));
@@ -309,7 +309,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-943
public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionLast() {
void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionLast() {
Update update = new Update().push("key").atPosition(Position.LAST).each(Arrays.asList("Arya", "Arry", "Weasel"));
@@ -323,7 +323,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-943
public void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionNull() {
void updatePushEachAtPositionWorksCorrectlyWhenGivenPositionNull() {
Update update = new Update().push("key").atPosition(null).each(Arrays.asList("Arya", "Arry", "Weasel"));
@@ -337,7 +337,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-832
public void updatePushEachWithSliceShouldRenderCorrectly() {
void updatePushEachWithSliceShouldRenderCorrectly() {
Update update = new Update().push("key").slice(5).each(Arrays.asList("Arya", "Arry", "Weasel"));
@@ -351,7 +351,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-832
public void updatePushEachWithSliceShouldRenderWhenUsingMultiplePushCorrectly() {
void updatePushEachWithSliceShouldRenderWhenUsingMultiplePushCorrectly() {
Update update = new Update().push("key").slice(5).each(Arrays.asList("Arya", "Arry", "Weasel")).push("key-2")
.slice(-2).each("The Beggar King", "Viserys III Targaryen");
@@ -371,7 +371,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1141
public void updatePushEachWithValueSortShouldRenderCorrectly() {
void updatePushEachWithValueSortShouldRenderCorrectly() {
Update update = new Update().push("scores").sort(Direction.DESC).each(42, 23, 68);
@@ -387,7 +387,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1141
public void updatePushEachWithDocumentSortShouldRenderCorrectly() {
void updatePushEachWithDocumentSortShouldRenderCorrectly() {
Update update = new Update().push("list")
.sort(Sort.by(new Order(Direction.ASC, "value"), new Order(Direction.ASC, "field")))
@@ -405,7 +405,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1141
public void updatePushEachWithSortShouldRenderCorrectlyWhenUsingMultiplePush() {
void updatePushEachWithSortShouldRenderCorrectlyWhenUsingMultiplePush() {
Update update = new Update().push("authors").sort(Direction.ASC).each("Harry").push("chapters")
.sort(Sort.by(Direction.ASC, "order")).each(Collections.emptyList());
@@ -427,7 +427,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-410
public void testUpdateMapperShouldConsiderCustomWriteTarget() {
void testUpdateMapperShouldConsiderCustomWriteTarget() {
List<NestedEntity> someValues = Arrays.asList(new NestedEntity("spring"), new NestedEntity("data"),
new NestedEntity("mongodb"));
@@ -440,7 +440,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-404
public void createsDbRefForEntityIdOnPulls() {
void createsDbRefForEntityIdOnPulls() {
Update update = new Update().pull("dbRefAnnotatedList.id", "2");
@@ -452,7 +452,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-404
public void createsDbRefForEntityOnPulls() {
void createsDbRefForEntityOnPulls() {
Entity entity = new Entity();
entity.id = "5";
@@ -465,15 +465,16 @@ public class UpdateMapperUnitTests {
assertThat(pullClause.get("dbRefAnnotatedList")).isEqualTo(new DBRef("entity", entity.id));
}
@Test(expected = MappingException.class) // DATAMONGO-404
public void rejectsInvalidFieldReferenceForDbRef() {
@Test // DATAMONGO-404
void rejectsInvalidFieldReferenceForDbRef() {
Update update = new Update().pull("dbRefAnnotatedList.name", "NAME");
mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(DocumentWithDBRefCollection.class));
assertThatThrownBy(() -> mapper.getMappedObject(update.getUpdateObject(),
context.getPersistentEntity(DocumentWithDBRefCollection.class))).isInstanceOf(MappingException.class);
}
@Test // DATAMONGO-404
public void rendersNestedDbRefCorrectly() {
void rendersNestedDbRefCorrectly() {
Update update = new Update().pull("nested.dbRefAnnotatedList.id", "2");
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(),
@@ -484,7 +485,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-468
public void rendersUpdateOfDbRefPropertyWithDomainObjectCorrectly() {
void rendersUpdateOfDbRefPropertyWithDomainObjectCorrectly() {
Entity entity = new Entity();
entity.id = "5";
@@ -498,7 +499,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-862
public void rendersUpdateAndPreservesKeyForPathsNotPointingToProperty() {
void rendersUpdateAndPreservesKeyForPathsNotPointingToProperty() {
Update update = new Update().set("listOfInterface.$.value", "expected-value");
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(),
@@ -509,7 +510,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-863
public void doesNotConvertRawDocuments() {
void doesNotConvertRawDocuments() {
Update update = new Update();
update.pull("options",
@@ -528,7 +529,7 @@ public class UpdateMapperUnitTests {
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test // DATAMONG0-471
public void testUpdateShouldApply$addToSetCorrectlyWhenUsedWith$each() {
void testUpdateShouldApply$addToSetCorrectlyWhenUsedWith$each() {
Update update = new Update().addToSet("values").each("spring", "data", "mongodb");
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(),
@@ -542,7 +543,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONG0-471
public void testUpdateShouldRetainClassTypeInformationWhenUsing$addToSetWith$eachForCustomTypes() {
void testUpdateShouldRetainClassTypeInformationWhenUsing$addToSetWith$eachForCustomTypes() {
Update update = new Update().addToSet("models").each(new ModelImpl(2014), new ModelImpl(1), new ModelImpl(28));
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(),
@@ -559,7 +560,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-897
public void updateOnDbrefPropertyOfInterfaceTypeWithoutExplicitGetterForIdShouldBeMappedCorrectly() {
void updateOnDbrefPropertyOfInterfaceTypeWithoutExplicitGetterForIdShouldBeMappedCorrectly() {
Update update = new Update().set("referencedDocument", new InterfaceDocumentDefinitionImpl("1", "Foo"));
Document mappedObject = mapper.getMappedObject(update.getUpdateObject(),
@@ -573,7 +574,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-847
public void updateMapperConvertsNestedQueryCorrectly() {
void updateMapperConvertsNestedQueryCorrectly() {
Update update = new Update().pull("list", Query.query(Criteria.where("value").in("foo", "bar")));
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -588,7 +589,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-847
public void updateMapperConvertsPullWithNestedQuerfyOnDBRefCorrectly() {
void updateMapperConvertsPullWithNestedQuerfyOnDBRefCorrectly() {
Update update = new Update().pull("dbRefAnnotatedList", Query.query(Criteria.where("id").is("1")));
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -601,7 +602,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1077
public void shouldNotRemovePositionalParameter() {
void shouldNotRemovePositionalParameter() {
Update update = new Update();
update.unset("dbRefAnnotatedList.$");
@@ -615,7 +616,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1210
public void mappingEachOperatorShouldNotAddTypeInfoForNonInterfaceNonAbstractTypes() {
void mappingEachOperatorShouldNotAddTypeInfoForNonInterfaceNonAbstractTypes() {
Update update = new Update().addToSet("nestedDocs").each(new NestedDocument("nested-1"),
new NestedDocument("nested-2"));
@@ -628,7 +629,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1210
public void mappingEachOperatorShouldAddTypeHintForInterfaceTypes() {
void mappingEachOperatorShouldAddTypeHintForInterfaceTypes() {
Update update = new Update().addToSet("models").each(new ModelImpl(1), new ModelImpl(2));
@@ -640,7 +641,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1210
public void mappingEachOperatorShouldAddTypeHintForAbstractTypes() {
void mappingEachOperatorShouldAddTypeHintForAbstractTypes() {
Update update = new Update().addToSet("list").each(new ConcreteChildClass("foo", "one"),
new ConcreteChildClass("bar", "two"));
@@ -653,7 +654,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1210
public void mappingShouldOnlyRemoveTypeHintFromTopLevelTypeInCaseOfNestedDocument() {
void mappingShouldOnlyRemoveTypeHintFromTopLevelTypeInCaseOfNestedDocument() {
WrapperAroundInterfaceType wait = new WrapperAroundInterfaceType();
wait.interfaceType = new ModelImpl(1);
@@ -670,7 +671,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1210
public void mappingShouldRetainTypeInformationOfNestedListWhenUpdatingConcreteyParentType() {
void mappingShouldRetainTypeInformationOfNestedListWhenUpdatingConcreteyParentType() {
ListModelWrapper lmw = new ListModelWrapper();
lmw.models = Collections.singletonList(new ModelImpl(1));
@@ -685,7 +686,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1809
public void pathShouldIdentifyPositionalParameterWithMoreThanOneDigit() {
void pathShouldIdentifyPositionalParameterWithMoreThanOneDigit() {
Document at2digitPosition = mapper.getMappedObject(new Update()
.addToSet("concreteInnerList.10.concreteTypeList", new SomeInterfaceImpl("szeth")).getUpdateObject(),
@@ -702,7 +703,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1236
public void mappingShouldRetainTypeInformationForObjectValues() {
void mappingShouldRetainTypeInformationForObjectValues() {
Update update = new Update().set("value", new NestedDocument("kaladin"));
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -713,7 +714,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1236
public void mappingShouldNotRetainTypeInformationForConcreteValues() {
void mappingShouldNotRetainTypeInformationForConcreteValues() {
Update update = new Update().set("concreteValue", new NestedDocument("shallan"));
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -724,7 +725,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1236
public void mappingShouldRetainTypeInformationForObjectValuesWithAlias() {
void mappingShouldRetainTypeInformationForObjectValuesWithAlias() {
Update update = new Update().set("value", new NestedDocument("adolin"));
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -735,7 +736,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1236
public void mappingShouldRetrainTypeInformationWhenValueTypeOfMapDoesNotMatchItsDeclaration() {
void mappingShouldRetrainTypeInformationWhenValueTypeOfMapDoesNotMatchItsDeclaration() {
Map<Object, Object> map = Collections.singletonMap("szeth", new NestedDocument("son-son-vallano"));
@@ -748,7 +749,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1236
public void mappingShouldNotContainTypeInformationWhenValueTypeOfMapMatchesDeclaration() {
void mappingShouldNotContainTypeInformationWhenValueTypeOfMapMatchesDeclaration() {
Map<Object, NestedDocument> map = Collections.singletonMap("jasnah", new NestedDocument("kholin"));
@@ -762,7 +763,7 @@ public class UpdateMapperUnitTests {
@Test // DATAMONGO-1250
@SuppressWarnings("unchecked")
public void mapsUpdateWithBothReadingAndWritingConverterRegistered() {
void mapsUpdateWithBothReadingAndWritingConverterRegistered() {
CustomConversions conversions = new MongoCustomConversions(Arrays.asList(
ClassWithEnum.AllocationToStringConverter.INSTANCE, ClassWithEnum.StringToAllocationConverter.INSTANCE));
@@ -785,7 +786,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1251
public void mapsNullValueCorrectlyForSimpleTypes() {
void mapsNullValueCorrectlyForSimpleTypes() {
Update update = new Update().set("value", null);
@@ -797,7 +798,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1251
public void mapsNullValueCorrectlyForJava8Date() {
void mapsNullValueCorrectlyForJava8Date() {
Update update = new Update().set("date", null);
@@ -809,7 +810,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1251
public void mapsNullValueCorrectlyForCollectionTypes() {
void mapsNullValueCorrectlyForCollectionTypes() {
Update update = new Update().set("values", null);
@@ -821,7 +822,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1251
public void mapsNullValueCorrectlyForPropertyOfNestedDocument() {
void mapsNullValueCorrectlyForPropertyOfNestedDocument() {
Update update = new Update().set("concreteValue.name", null);
@@ -834,7 +835,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1288
public void mapsAtomicIntegerToIntegerCorrectly() {
void mapsAtomicIntegerToIntegerCorrectly() {
Update update = new Update().set("intValue", new AtomicInteger(10));
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -845,7 +846,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1288
public void mapsAtomicIntegerToPrimitiveIntegerCorrectly() {
void mapsAtomicIntegerToPrimitiveIntegerCorrectly() {
Update update = new Update().set("primIntValue", new AtomicInteger(10));
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -856,7 +857,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1404
public void mapsMinCorrectly() {
void mapsMinCorrectly() {
Update update = new Update().min("minfield", 10);
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -866,7 +867,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1404
public void mapsMaxCorrectly() {
void mapsMaxCorrectly() {
Update update = new Update().max("maxfield", 999);
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -877,7 +878,7 @@ public class UpdateMapperUnitTests {
@Test // DATAMONGO-1423, DATAMONGO-2155
@SuppressWarnings("unchecked")
public void mappingShouldConsiderCustomConvertersForEnumMapKeys() {
void mappingShouldConsiderCustomConvertersForEnumMapKeys() {
CustomConversions conversions = new MongoCustomConversions(Arrays.asList(
ClassWithEnum.AllocationToStringConverter.INSTANCE, ClassWithEnum.StringToAllocationConverter.INSTANCE));
@@ -904,7 +905,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1176
public void mappingShouldPrepareUpdateObjectForMixedOperatorsAndFields() {
void mappingShouldPrepareUpdateObjectForMixedOperatorsAndFields() {
Document document = new Document("key", "value").append("$set", new Document("a", "b").append("x", "y"));
@@ -915,7 +916,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1176
public void mappingShouldReturnReplaceObject() {
void mappingShouldReturnReplaceObject() {
Document document = new Document("key", "value").append("a", "b").append("x", "y");
@@ -928,7 +929,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1176
public void mappingShouldReturnUpdateObject() {
void mappingShouldReturnUpdateObject() {
Document document = new Document("$push", new Document("x", "y")).append("$set", new Document("a", "b"));
@@ -940,7 +941,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1486, DATAMONGO-2155
public void mappingShouldConvertMapKeysToString() {
void mappingShouldConvertMapKeysToString() {
Update update = new Update().set("map", Collections.singletonMap(25, "#StarTrek50"));
Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
@@ -956,7 +957,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1772
public void mappingShouldAddTypeKeyInListOfInterfaceTypeContainedInConcreteObjectCorrectly() {
void mappingShouldAddTypeKeyInListOfInterfaceTypeContainedInConcreteObjectCorrectly() {
ConcreteInner inner = new ConcreteInner();
inner.interfaceTypeList = Collections.singletonList(new SomeInterfaceImpl());
@@ -970,7 +971,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-1772
public void mappingShouldAddTypeKeyInListOfAbstractTypeContainedInConcreteObjectCorrectly() {
void mappingShouldAddTypeKeyInListOfAbstractTypeContainedInConcreteObjectCorrectly() {
ConcreteInner inner = new ConcreteInner();
inner.abstractTypeList = Collections.singletonList(new SomeInterfaceImpl());
@@ -984,7 +985,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2155
public void shouldPreserveFieldNamesOfMapProperties() {
void shouldPreserveFieldNamesOfMapProperties() {
Update update = Update
.fromDocument(new Document("concreteMap", new Document("Name", new Document("name", "fooo"))));
@@ -996,7 +997,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2155
public void shouldPreserveExplicitFieldNamesInsideMapProperties() {
void shouldPreserveExplicitFieldNamesInsideMapProperties() {
Update update = Update
.fromDocument(new Document("map", new Document("Value", new Document("renamed-value", "fooo"))));
@@ -1009,7 +1010,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2155
public void shouldMapAliasedFieldNamesInMapsCorrectly() {
void shouldMapAliasedFieldNamesInMapsCorrectly() {
Update update = Update
.fromDocument(new Document("map", Collections.singletonMap("Value", new Document("value", "fooo"))));
@@ -1022,7 +1023,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2174
public void mappingUpdateDocumentWithExplicitFieldNameShouldBePossible() {
void mappingUpdateDocumentWithExplicitFieldNameShouldBePossible() {
Document mappedUpdate = mapper.getMappedObject(new Document("AValue", "a value"),
context.getPersistentEntity(TypeWithFieldNameThatCannotBeDecapitalized.class));
@@ -1031,7 +1032,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2054
public void mappingShouldAllowPositionAllParameter() {
void mappingShouldAllowPositionAllParameter() {
Update update = new Update().inc("grades.$[]", 10);
@@ -1042,7 +1043,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2054
public void mappingShouldAllowPositionAllParameterWhenPropertyHasExplicitFieldName() {
void mappingShouldAllowPositionAllParameterWhenPropertyHasExplicitFieldName() {
Update update = new Update().inc("list.$[]", 10);
@@ -1053,7 +1054,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2215
public void mappingShouldAllowPositionParameterWithIdentifier() {
void mappingShouldAllowPositionParameterWithIdentifier() {
Update update = new Update().set("grades.$[element]", 10) //
.filterArray(Criteria.where("element").gte(100));
@@ -1065,7 +1066,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2215
public void mappingShouldAllowPositionParameterWithIdentifierWhenFieldHasExplicitFieldName() {
void mappingShouldAllowPositionParameterWithIdentifierWhenFieldHasExplicitFieldName() {
Update update = new Update().set("list.$[element]", 10) //
.filterArray(Criteria.where("element").gte(100));
@@ -1077,7 +1078,7 @@ public class UpdateMapperUnitTests {
}
@Test // DATAMONGO-2215
public void mappingShouldAllowNestedPositionParameterWithIdentifierWhenFieldHasExplicitFieldName() {
void mappingShouldAllowNestedPositionParameterWithIdentifierWhenFieldHasExplicitFieldName() {
Update update = new Update().set("list.$[element].value", 10) //
.filterArray(Criteria.where("element").gte(100));
@@ -1119,7 +1120,7 @@ public class UpdateMapperUnitTests {
@Id String id;
String value;
public InterfaceDocumentDefinitionImpl(String id, String value) {
InterfaceDocumentDefinitionImpl(String id, String value) {
this.id = id;
this.value = value;
@@ -1163,7 +1164,7 @@ public class UpdateMapperUnitTests {
static class ModelImpl implements Model {
public int value;
public ModelImpl(int value) {
ModelImpl(int value) {
this.value = value;
}
@@ -1188,7 +1189,7 @@ public class UpdateMapperUnitTests {
List<String> values;
public ListModel(String... values) {
ListModel(String... values) {
this.values = Arrays.asList(values);
}
}
@@ -1217,7 +1218,7 @@ public class UpdateMapperUnitTests {
String otherValue;
AbstractChildClass someObject;
public AbstractChildClass(String id, String value) {
AbstractChildClass(String id, String value) {
this.id = id;
this.value = value;
this.otherValue = "other_" + value;
@@ -1226,7 +1227,7 @@ public class UpdateMapperUnitTests {
static class ConcreteChildClass extends AbstractChildClass {
public ConcreteChildClass(String id, String value) {
ConcreteChildClass(String id, String value) {
super(id, value);
}
}
@@ -1242,7 +1243,7 @@ public class UpdateMapperUnitTests {
static class NestedEntity {
String name;
public NestedEntity(String name) {
NestedEntity(String name) {
super();
this.name = name;
}
@@ -1288,7 +1289,7 @@ public class UpdateMapperUnitTests {
String name;
public NestedDocument(String name) {
NestedDocument(String name) {
super();
this.name = name;
}

View File

@@ -28,6 +28,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.geo.Box;
@@ -41,7 +42,6 @@ import org.springframework.data.mongodb.core.BulkOperations.BulkMode;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.TestEntities;
import org.springframework.data.mongodb.core.Venue;
import org.springframework.data.mongodb.core.geo.GeoJsonTests.Venue2DSphere;
import org.springframework.data.mongodb.core.query.NearQuery;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.test.util.MongoTestUtils;

View File

@@ -20,8 +20,8 @@ import static org.assertj.core.api.Assertions.*;
import java.io.IOException;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.data.geo.Point;
@@ -36,7 +36,7 @@ public class GeoJsonModuleUnitTests {
ObjectMapper mapper;
@Before
@BeforeEach
public void setUp() {
mapper = new ObjectMapper();

Some files were not shown because too many files have changed in this diff Show More