Browse Source

DATAMONGO-1602 - Remove references to Assert single-arg methods.

Replace references to Assert single-arg methods with references to methods accepting the test object and message.

Related ticket: SPR-15196.
pull/440/head
Mark Paluch 9 years ago
parent
commit
54acc4934c
  1. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MappingMongoConverterParser.java
  2. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java
  3. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAdmin.java
  4. 33
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java
  5. 43
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java
  6. 7
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationResults.java
  7. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ConverterRegistration.java
  8. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java
  9. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java
  10. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java
  11. 7
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java
  12. 17
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexField.java
  13. 9
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexInfo.java
  14. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoMappingEventPublisher.java
  15. 10
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexCreator.java
  16. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/BasicMongoPersistentEntity.java
  17. 11
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapreduce/GroupByResults.java
  18. 9
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapreduce/MapReduceResults.java
  19. 22
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java
  20. 19
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java
  21. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/spel/ExpressionNode.java
  22. 7
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/gridfs/AntPath.java
  23. 9
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/gridfs/GridFsTemplate.java
  24. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/cdi/MongoRepositoryBean.java
  25. 31
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/ConvertingParameterAccessor.java
  26. 2
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoQueryCreator.java
  27. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/IndexEnsuringQueryCreationListener.java
  28. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MongoRepositoryFactory.java
  29. 5
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepository.java
  30. 13
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QuerydslRepositorySupport.java
  31. 4
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/ReactiveMongoRepositoryFactory.java
  32. 6
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java
  33. 8
      spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java
  34. 4
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/monitor/MongoMonitorIntegrationTests.java
  35. 7
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/performance/PerformanceTests.java
  36. 4
      spring-data-mongodb/src/test/java/org/springframework/data/mongodb/performance/ReactivePerformanceTests.java

6
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/config/MappingMongoConverterParser.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -369,7 +369,9 @@ public class MappingMongoConverterParser implements BeanDefinitionParser {
* @param filters * @param filters
*/ */
public NegatingFilter(TypeFilter... filters) { public NegatingFilter(TypeFilter... filters) {
Assert.notNull(filters);
Assert.notNull(filters, "TypeFilters must not be null");
this.delegates = new HashSet<TypeFilter>(Arrays.asList(filters)); this.delegates = new HashSet<TypeFilter>(Arrays.asList(filters));
} }

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/DefaultIndexOperations.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,7 +18,6 @@ package org.springframework.data.mongodb.core;
import static org.springframework.data.mongodb.core.MongoTemplate.*; import static org.springframework.data.mongodb.core.MongoTemplate.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -189,7 +188,7 @@ public class DefaultIndexOperations implements IndexOperations {
public <T> T execute(CollectionCallback<T> callback) { public <T> T execute(CollectionCallback<T> callback) {
Assert.notNull(callback); Assert.notNull(callback, "CollectionCallback must not be null!");
try { try {
MongoCollection<Document> collection = mongoDbFactory.getDb().getCollection(collectionName); MongoCollection<Document> collection = mongoDbFactory.getDb().getCollection(collectionName);

6
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoAdmin.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2013 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,6 +28,7 @@ import com.mongodb.Mongo;
* *
* @author Mark Pollack * @author Mark Pollack
* @author Thomas Darimont * @author Thomas Darimont
* @author Mark Paluch
*/ */
@ManagedResource(description = "Mongo Admin Operations") @ManagedResource(description = "Mongo Admin Operations")
public class MongoAdmin implements MongoAdminOperations { public class MongoAdmin implements MongoAdminOperations {
@ -38,7 +39,8 @@ public class MongoAdmin implements MongoAdminOperations {
private String authenticationDatabaseName; private String authenticationDatabaseName;
public MongoAdmin(Mongo mongo) { public MongoAdmin(Mongo mongo) {
Assert.notNull(mongo);
Assert.notNull(mongo, "Mongo must not be null!");
this.mongo = mongo; this.mongo = mongo;
} }

33
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java

@ -218,7 +218,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
*/ */
public MongoTemplate(MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) { public MongoTemplate(MongoDbFactory mongoDbFactory, MongoConverter mongoConverter) {
Assert.notNull(mongoDbFactory); Assert.notNull(mongoDbFactory, "MongoDbFactory must not be null!");
this.mongoDbFactory = mongoDbFactory; this.mongoDbFactory = mongoDbFactory;
this.exceptionTranslator = mongoDbFactory.getExceptionTranslator(); this.exceptionTranslator = mongoDbFactory.getExceptionTranslator();
@ -438,7 +438,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected void executeQuery(Query query, String collectionName, DocumentCallbackHandler dch, protected void executeQuery(Query query, String collectionName, DocumentCallbackHandler dch,
CursorPreparer preparer) { CursorPreparer preparer) {
Assert.notNull(query); Assert.notNull(query, "Query must not be null!");
Document queryObject = queryMapper.getMappedObject(query.getQueryObject(), null); Document queryObject = queryMapper.getMappedObject(query.getQueryObject(), null);
Document sortObject = query.getSortObject(); Document sortObject = query.getSortObject();
@ -454,7 +454,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <T> T execute(DbCallback<T> action) { public <T> T execute(DbCallback<T> action) {
Assert.notNull(action); Assert.notNull(action, "DbCallbackmust not be null!");
try { try {
MongoDatabase db = this.getDb(); MongoDatabase db = this.getDb();
@ -470,7 +470,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public <T> T execute(String collectionName, CollectionCallback<T> callback) { public <T> T execute(String collectionName, CollectionCallback<T> callback) {
Assert.notNull(callback); Assert.notNull(callback, "CollectionCallback must not be null!");
try { try {
MongoCollection<Document> collection = getAndPrepareCollection(getDb(), collectionName); MongoCollection<Document> collection = getAndPrepareCollection(getDb(), collectionName);
@ -735,7 +735,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
} }
public long count(Query query, Class<?> entityClass) { public long count(Query query, Class<?> entityClass) {
Assert.notNull(entityClass);
Assert.notNull(entityClass, "Entity class must not be null!");
return count(query, entityClass, determineCollectionName(entityClass)); return count(query, entityClass, determineCollectionName(entityClass));
} }
@ -749,7 +750,8 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
*/ */
public long count(Query query, Class<?> entityClass, String collectionName) { public long count(Query query, Class<?> entityClass, String collectionName) {
Assert.hasText(collectionName); Assert.hasText(collectionName, "Collection name must not be null or empty!");
final Document document = query == null ? null final Document document = query == null ? null
: queryMapper.getMappedObject(query.getQueryObject(), : queryMapper.getMappedObject(query.getQueryObject(),
entityClass == null ? null : mappingContext.getPersistentEntity(entityClass)); entityClass == null ? null : mappingContext.getPersistentEntity(entityClass));
@ -932,7 +934,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
protected <T> void doInsertBatch(String collectionName, Collection<? extends T> batchToSave, MongoWriter<T> writer) { protected <T> void doInsertBatch(String collectionName, Collection<? extends T> batchToSave, MongoWriter<T> writer) {
Assert.notNull(writer); Assert.notNull(writer, "MongoWriter must not be null!");
List<Document> documentList = new ArrayList<Document>(); List<Document> documentList = new ArrayList<Document>();
for (T o : batchToSave) { for (T o : batchToSave) {
@ -960,14 +962,14 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public void save(Object objectToSave) { public void save(Object objectToSave) {
Assert.notNull(objectToSave); Assert.notNull(objectToSave, "Object to save must not be null!");
save(objectToSave, determineEntityCollectionName(objectToSave)); save(objectToSave, determineEntityCollectionName(objectToSave));
} }
public void save(Object objectToSave, String collectionName) { public void save(Object objectToSave, String collectionName) {
Assert.notNull(objectToSave); Assert.notNull(objectToSave, "Object to save must not be null!");
Assert.hasText(collectionName); Assert.hasText(collectionName, "Collection name must not be null or empty!");
MongoPersistentEntity<?> mongoPersistentEntity = getPersistentEntity(objectToSave.getClass()); MongoPersistentEntity<?> mongoPersistentEntity = getPersistentEntity(objectToSave.getClass());
@ -1240,7 +1242,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public DeleteResult remove(Object object, String collection) { public DeleteResult remove(Object object, String collection) {
Assert.hasText(collection); Assert.hasText(collection, "Collection name must not be null or empty!");
if (object == null) { if (object == null) {
return null; return null;
@ -2348,8 +2350,9 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
public ReadDocumentCallback(EntityReader<? super T, Bson> reader, Class<T> type, String collectionName) { public ReadDocumentCallback(EntityReader<? super T, Bson> reader, Class<T> type, String collectionName) {
Assert.notNull(reader); Assert.notNull(reader, "EntityReader must not be null!");
Assert.notNull(type); Assert.notNull(type, "Entity type must not be null!");
this.reader = reader; this.reader = reader;
this.type = type; this.type = type;
this.collectionName = collectionName; this.collectionName = collectionName;
@ -2491,7 +2494,9 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware,
* @param delegate must not be {@literal null}. * @param delegate must not be {@literal null}.
*/ */
public GeoNearResultDocumentCallback(DocumentCallback<T> delegate, Metric metric) { public GeoNearResultDocumentCallback(DocumentCallback<T> delegate, Metric metric) {
Assert.notNull(delegate);
Assert.notNull(delegate, "DocumentCallback must not be null!");
this.delegate = delegate; this.delegate = delegate;
this.metric = metric; this.metric = metric;
} }

43
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoTemplate.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2016 the original author or authors. * Copyright 2016-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -373,7 +373,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org.springframework.data.mongodb.core.ReactiveMongoOperations#execute(java.lang.String, org.springframework.data.mongodb.core.ReactiveCollectionCallback) * @see org.springframework.data.mongodb.core.ReactiveMongoOperations#execute(java.lang.String, org.springframework.data.mongodb.core.ReactiveCollectionCallback)
*/ */
public <T> Flux<T> execute(String collectionName, ReactiveCollectionCallback<T> callback) { public <T> Flux<T> execute(String collectionName, ReactiveCollectionCallback<T> callback) {
Assert.notNull(callback);
Assert.notNull(callback, "ReactiveCollectionCallback must not be null!");
return createFlux(collectionName, callback); return createFlux(collectionName, callback);
} }
@ -386,7 +387,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Flux<T> createFlux(ReactiveDatabaseCallback<T> callback) { public <T> Flux<T> createFlux(ReactiveDatabaseCallback<T> callback) {
Assert.notNull(callback); Assert.notNull(callback, "ReactiveDatabaseCallback must not be null!");
return Flux.defer(() -> callback.doInDB(getMongoDatabase())).onErrorResumeWith(translateFluxException()); return Flux.defer(() -> callback.doInDB(getMongoDatabase())).onErrorResumeWith(translateFluxException());
} }
@ -400,7 +401,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Mono<T> createMono(final ReactiveDatabaseCallback<T> callback) { public <T> Mono<T> createMono(final ReactiveDatabaseCallback<T> callback) {
Assert.notNull(callback); Assert.notNull(callback, "ReactiveDatabaseCallback must not be null!");
return Mono.defer(() -> Mono.from(callback.doInDB(getMongoDatabase()))).otherwise(translateMonoException()); return Mono.defer(() -> Mono.from(callback.doInDB(getMongoDatabase()))).otherwise(translateMonoException());
} }
@ -414,8 +415,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Flux<T> createFlux(String collectionName, ReactiveCollectionCallback<T> callback) { public <T> Flux<T> createFlux(String collectionName, ReactiveCollectionCallback<T> callback) {
Assert.hasText(collectionName); Assert.hasText(collectionName, "Collection name must not be null or empty!");
Assert.notNull(callback); Assert.notNull(callback, "ReactiveDatabaseCallback must not be null!");
Mono<MongoCollection<Document>> collectionPublisher = Mono Mono<MongoCollection<Document>> collectionPublisher = Mono
.fromCallable(() -> getAndPrepareCollection(getMongoDatabase(), collectionName)); .fromCallable(() -> getAndPrepareCollection(getMongoDatabase(), collectionName));
@ -433,8 +434,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Mono<T> createMono(String collectionName, ReactiveCollectionCallback<T> callback) { public <T> Mono<T> createMono(String collectionName, ReactiveCollectionCallback<T> callback) {
Assert.hasText(collectionName); Assert.hasText(collectionName, "Collection name must not be null or empty!");
Assert.notNull(callback); Assert.notNull(callback, "ReactiveCollectionCallback must not be null!");
Mono<MongoCollection<Document>> collectionPublisher = Mono Mono<MongoCollection<Document>> collectionPublisher = Mono
.fromCallable(() -> getAndPrepareCollection(getMongoDatabase(), collectionName)); .fromCallable(() -> getAndPrepareCollection(getMongoDatabase(), collectionName));
@ -729,7 +730,9 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
* @see org.springframework.data.mongodb.core.ReactiveMongoOperations#count(org.springframework.data.mongodb.core.query.Query, java.lang.Class) * @see org.springframework.data.mongodb.core.ReactiveMongoOperations#count(org.springframework.data.mongodb.core.query.Query, java.lang.Class)
*/ */
public Mono<Long> count(Query query, Class<?> entityClass) { public Mono<Long> count(Query query, Class<?> entityClass) {
Assert.notNull(entityClass);
Assert.notNull(entityClass, "Entity class must not be null!");
return count(query, entityClass, determineCollectionName(entityClass)); return count(query, entityClass, determineCollectionName(entityClass));
} }
@ -745,7 +748,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public Mono<Long> count(final Query query, final Class<?> entityClass, String collectionName) { public Mono<Long> count(final Query query, final Class<?> entityClass, String collectionName) {
Assert.hasText(collectionName); Assert.hasText(collectionName, "Collection name must not be null or empty!");
return createMono(collectionName, collection -> { return createMono(collectionName, collection -> {
@ -880,7 +883,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
protected <T> Flux<T> doInsertBatch(final String collectionName, final Collection<? extends T> batchToSave, protected <T> Flux<T> doInsertBatch(final String collectionName, final Collection<? extends T> batchToSave,
final MongoWriter<Object> writer) { final MongoWriter<Object> writer) {
Assert.notNull(writer); Assert.notNull(writer, "MongoWriter must not be null!");
Mono<List<Tuple2<T, Document>>> prepareDocuments = Flux.fromIterable(batchToSave) Mono<List<Tuple2<T, Document>>> prepareDocuments = Flux.fromIterable(batchToSave)
.flatMap(new Function<T, Flux<Tuple2<T, Document>>>() { .flatMap(new Function<T, Flux<Tuple2<T, Document>>>() {
@ -933,7 +936,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Mono<T> save(T objectToSave) { public <T> Mono<T> save(T objectToSave) {
Assert.notNull(objectToSave); Assert.notNull(objectToSave, "Object to save must not be null!");
return save(objectToSave, determineEntityCollectionName(objectToSave)); return save(objectToSave, determineEntityCollectionName(objectToSave));
} }
@ -942,8 +945,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public <T> Mono<T> save(T objectToSave, String collectionName) { public <T> Mono<T> save(T objectToSave, String collectionName) {
Assert.notNull(objectToSave); Assert.notNull(objectToSave, "Object to save must not be null!");
Assert.hasText(collectionName); Assert.hasText(collectionName, "Collection name must not be null or empty!");
MongoPersistentEntity<?> mongoPersistentEntity = getPersistentEntity(objectToSave.getClass()); MongoPersistentEntity<?> mongoPersistentEntity = getPersistentEntity(objectToSave.getClass());
@ -1275,7 +1278,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
public Mono<DeleteResult> remove(Object object, String collection) { public Mono<DeleteResult> remove(Object object, String collection) {
Assert.hasText(collection); Assert.hasText(collection, "Collection name must not be null or empty!");
if (object == null) { if (object == null) {
return null; return null;
@ -1839,7 +1842,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
private <T> T execute(MongoDatabaseCallback<T> action) { private <T> T execute(MongoDatabaseCallback<T> action) {
Assert.notNull(action); Assert.notNull(action, "MongoDatabaseCallback must not be null!");
try { try {
MongoDatabase db = this.getMongoDatabase(); MongoDatabase db = this.getMongoDatabase();
@ -2202,8 +2205,9 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
ReadDocumentCallback(EntityReader<? super T, Bson> reader, Class<T> type, String collectionName) { ReadDocumentCallback(EntityReader<? super T, Bson> reader, Class<T> type, String collectionName) {
Assert.notNull(reader); Assert.notNull(reader, "EntityReader must not be null!");
Assert.notNull(type); Assert.notNull(type, "Entity type must not be null!");
this.reader = reader; this.reader = reader;
this.type = type; this.type = type;
this.collectionName = collectionName; this.collectionName = collectionName;
@ -2240,7 +2244,8 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
*/ */
GeoNearResultDbObjectCallback(DocumentCallback<T> delegate, Metric metric) { GeoNearResultDbObjectCallback(DocumentCallback<T> delegate, Metric metric) {
Assert.notNull(delegate); Assert.notNull(delegate, "DocumentCallback must not be null!");
this.delegate = delegate; this.delegate = delegate;
this.metric = metric; this.metric = metric;
} }

7
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/aggregation/AggregationResults.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2013-2016 the original author or authors. * Copyright 2013-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,6 +29,7 @@ import org.springframework.util.Assert;
* @author Oliver Gierke * @author Oliver Gierke
* @author Thomas Darimont * @author Thomas Darimont
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
* @param <T> The class in which the results are mapped onto. * @param <T> The class in which the results are mapped onto.
* @since 1.3 * @since 1.3
*/ */
@ -46,8 +47,8 @@ public class AggregationResults<T> implements Iterable<T> {
*/ */
public AggregationResults(List<T> mappedResults, Document rawResults) { public AggregationResults(List<T> mappedResults, Document rawResults) {
Assert.notNull(mappedResults); Assert.notNull(mappedResults, "List of mapped results must not be null!");
Assert.notNull(rawResults); Assert.notNull(rawResults, "Raw results must not be null!");
this.mappedResults = Collections.unmodifiableList(mappedResults); this.mappedResults = Collections.unmodifiableList(mappedResults);
this.rawResults = rawResults; this.rawResults = rawResults;

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/ConverterRegistration.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,6 +23,7 @@ import org.springframework.util.Assert;
* Conversion registration information. * Conversion registration information.
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author Mark Paluch
*/ */
class ConverterRegistration { class ConverterRegistration {
@ -39,7 +40,7 @@ class ConverterRegistration {
*/ */
public ConverterRegistration(ConvertiblePair convertiblePair, boolean isReading, boolean isWriting) { public ConverterRegistration(ConvertiblePair convertiblePair, boolean isReading, boolean isWriting) {
Assert.notNull(convertiblePair); Assert.notNull(convertiblePair, "ConvertiblePair must not be null!");
this.convertiblePair = convertiblePair; this.convertiblePair = convertiblePair;
this.reading = isReading; this.reading = isReading;

6
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/CustomConversions.java

@ -89,7 +89,7 @@ public class CustomConversions {
*/ */
public CustomConversions(List<?> converters) { public CustomConversions(List<?> converters) {
Assert.notNull(converters); Assert.notNull(converters, "List of converters must not be null!");
this.readingPairs = new LinkedHashSet<ConvertiblePair>(); this.readingPairs = new LinkedHashSet<ConvertiblePair>();
this.writingPairs = new LinkedHashSet<ConvertiblePair>(); this.writingPairs = new LinkedHashSet<ConvertiblePair>();
@ -346,8 +346,8 @@ public class CustomConversions {
private static Class<?> getCustomTarget(Class<?> sourceType, Class<?> requestedTargetType, private static Class<?> getCustomTarget(Class<?> sourceType, Class<?> requestedTargetType,
Collection<ConvertiblePair> pairs) { Collection<ConvertiblePair> pairs) {
Assert.notNull(sourceType); Assert.notNull(sourceType, "Source Class must not be null!");
Assert.notNull(pairs); Assert.notNull(pairs, "Collection of ConvertiblePair must not be null!");
if (requestedTargetType != null && pairs.contains(new ConvertiblePair(sourceType, requestedTargetType))) { if (requestedTargetType != null && pairs.contains(new ConvertiblePair(sourceType, requestedTargetType))) {
return requestedTargetType; return requestedTargetType;

10
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java

@ -1,11 +1,11 @@
/* /*
* Copyright 2011-2017 by the original author(s). * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -851,7 +851,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
protected DBRef createDBRef(Object target, MongoPersistentProperty property) { protected DBRef createDBRef(Object target, MongoPersistentProperty property) {
Assert.notNull(target); Assert.notNull(target, "Target object must not be null!");
if (target instanceof DBRef) { if (target instanceof DBRef) {
return (DBRef) target; return (DBRef) target;
@ -1244,8 +1244,8 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
*/ */
public MongoDbPropertyValueProvider(Bson source, SpELExpressionEvaluator evaluator, ObjectPath path) { public MongoDbPropertyValueProvider(Bson source, SpELExpressionEvaluator evaluator, ObjectPath path) {
Assert.notNull(source); Assert.notNull(source, "Bson source must not be null!");
Assert.notNull(evaluator); Assert.notNull(evaluator, "SpELExpressionEvaluator must not be null!");
this.source = new DocumentAccessor(source); this.source = new DocumentAccessor(source);
this.evaluator = evaluator; this.evaluator = evaluator;

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/QueryMapper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -86,7 +86,7 @@ public class QueryMapper {
*/ */
public QueryMapper(MongoConverter converter) { public QueryMapper(MongoConverter converter) {
Assert.notNull(converter); Assert.notNull(converter, "MongoConverter must not be null!");
this.conversionService = converter.getConversionService(); this.conversionService = converter.getConversionService();
this.converter = converter; this.converter = converter;

7
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2014 the original author or authors. * Copyright 2014-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,6 +29,7 @@ import org.springframework.util.Assert;
* Represents a geospatial sphere value. * Represents a geospatial sphere value.
* *
* @author Thomas Darimont * @author Thomas Darimont
* @author Mark Paluch
* @since 1.5 * @since 1.5
*/ */
public class Sphere implements Shape { public class Sphere implements Shape {
@ -46,8 +47,8 @@ public class Sphere implements Shape {
@PersistenceConstructor @PersistenceConstructor
public Sphere(Point center, Distance radius) { public Sphere(Point center, Distance radius) {
Assert.notNull(center); Assert.notNull(center, "Center point must not be null!");
Assert.notNull(radius); Assert.notNull(radius, "Radius must not be null!");
Assert.isTrue(radius.getValue() >= 0, "Radius must not be negative!"); Assert.isTrue(radius.getValue() >= 0, "Radius must not be negative!");
this.center = center; this.center = center;

17
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexField.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -43,8 +43,13 @@ public final class IndexField {
private IndexField(String key, Direction direction, Type type, Float weight) { private IndexField(String key, Direction direction, Type type, Float weight) {
Assert.hasText(key); Assert.hasText(key, "Key must not be null or empty");
Assert.isTrue(direction != null ^ (Type.GEO.equals(type) || Type.TEXT.equals(type)));
if (Type.GEO.equals(type) || Type.TEXT.equals(type)) {
Assert.isTrue(direction == null, "Geo/Text indexes must not have a direction!");
} else {
Assert.notNull(direction, "Default indexes require a direction");
}
this.key = key; this.key = key;
this.direction = direction; this.direction = direction;
@ -53,7 +58,9 @@ public final class IndexField {
} }
public static IndexField create(String key, Direction order) { public static IndexField create(String key, Direction order) {
Assert.notNull(order);
Assert.notNull(order, "Direction must not be null!");
return new IndexField(key, order, Type.DEFAULT); return new IndexField(key, order, Type.DEFAULT);
} }
@ -102,7 +109,7 @@ public final class IndexField {
} }
/** /**
* Returns wheter the {@link IndexField} is a text index field. * Returns whether the {@link IndexField} is a text index field.
* *
* @return true if type is {@link Type#TEXT} * @return true if type is {@link Type#TEXT}
* @since 1.6 * @since 1.6

9
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/IndexInfo.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,17 +23,15 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.mongodb.DBObject;
import org.bson.Document; import org.bson.Document;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import com.mongodb.DBObject;
/** /**
* @author Mark Pollack * @author Mark Pollack
* @author Oliver Gierke * @author Oliver Gierke
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
*/ */
public class IndexInfo { public class IndexInfo {
@ -132,7 +130,8 @@ public class IndexInfo {
*/ */
public boolean isIndexForFields(Collection<String> keys) { public boolean isIndexForFields(Collection<String> keys) {
Assert.notNull(keys); Assert.notNull(keys, "Collection of keys must not be null!");
List<String> indexKeys = new ArrayList<String>(indexFields.size()); List<String> indexKeys = new ArrayList<String>(indexFields.size());
for (IndexField field : indexFields) { for (IndexField field : indexFields) {

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoMappingEventPublisher.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2015 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,6 +34,7 @@ import org.springframework.util.Assert;
* *
* @author Jon Brisbin * @author Jon Brisbin
* @author Oliver Gierke * @author Oliver Gierke
* @author Mark Paluch
*/ */
public class MongoMappingEventPublisher implements ApplicationEventPublisher { public class MongoMappingEventPublisher implements ApplicationEventPublisher {
@ -46,7 +47,7 @@ public class MongoMappingEventPublisher implements ApplicationEventPublisher {
*/ */
public MongoMappingEventPublisher(MongoPersistentEntityIndexCreator indexCreator) { public MongoMappingEventPublisher(MongoPersistentEntityIndexCreator indexCreator) {
Assert.notNull(indexCreator); Assert.notNull(indexCreator, "MongoPersistentEntityIndexCreator must not be null!");
this.indexCreator = indexCreator; this.indexCreator = indexCreator;
} }

10
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexCreator.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.support.PersistenceExceptionTranslator;
import org.springframework.data.mapping.PersistentEntity; import org.springframework.data.mapping.PersistentEntity;
import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.context.MappingContextEvent; import org.springframework.data.mapping.context.MappingContextEvent;
@ -82,9 +81,10 @@ public class MongoPersistentEntityIndexCreator implements ApplicationListener<Ma
*/ */
public MongoPersistentEntityIndexCreator(MongoMappingContext mappingContext, IndexOperationsProvider indexOperationsProvider, public MongoPersistentEntityIndexCreator(MongoMappingContext mappingContext, IndexOperationsProvider indexOperationsProvider,
IndexResolver indexResolver) { IndexResolver indexResolver) {
Assert.notNull(indexOperationsProvider);
Assert.notNull(mappingContext); Assert.notNull(mappingContext, "MongoMappingContext must not be null!");
Assert.notNull(indexResolver); Assert.notNull(indexOperationsProvider, "IndexOperationsProvider must not be null!");
Assert.notNull(indexResolver, "IndexResolver must not be null!");
this.indexOperationsProvider = indexOperationsProvider; this.indexOperationsProvider = indexOperationsProvider;
this.mappingContext = mappingContext; this.mappingContext = mappingContext;

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/BasicMongoPersistentEntity.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2014 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,6 +51,7 @@ import org.springframework.util.StringUtils;
* @author Oliver Gierke * @author Oliver Gierke
* @author Thomas Darimont * @author Thomas Darimont
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
*/ */
public class BasicMongoPersistentEntity<T> extends BasicPersistentEntity<T, MongoPersistentProperty> implements public class BasicMongoPersistentEntity<T> extends BasicPersistentEntity<T, MongoPersistentProperty> implements
MongoPersistentEntity<T>, ApplicationContextAware { MongoPersistentEntity<T>, ApplicationContextAware {
@ -200,7 +201,7 @@ public class BasicMongoPersistentEntity<T> extends BasicPersistentEntity<T, Mong
@Override @Override
protected MongoPersistentProperty returnPropertyIfBetterIdPropertyCandidateOrNull(MongoPersistentProperty property) { protected MongoPersistentProperty returnPropertyIfBetterIdPropertyCandidateOrNull(MongoPersistentProperty property) {
Assert.notNull(property); Assert.notNull(property, "MongoPersistentProperty must not be null!");
if (!property.isIdProperty()) { if (!property.isIdProperty()) {
return null; return null;

11
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapreduce/GroupByResults.java

@ -1,11 +1,11 @@
/* /*
* Copyright 2011 - 2016O the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -26,6 +26,7 @@ import org.springframework.util.Assert;
* *
* @author Mark Pollack * @author Mark Pollack
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
* @param <T> The class in which the results are mapped onto, accessible via an {@link Iterator}. * @param <T> The class in which the results are mapped onto, accessible via an {@link Iterator}.
*/ */
public class GroupByResults<T> implements Iterable<T> { public class GroupByResults<T> implements Iterable<T> {
@ -39,10 +40,12 @@ public class GroupByResults<T> implements Iterable<T> {
public GroupByResults(List<T> mappedResults, Document rawResults) { public GroupByResults(List<T> mappedResults, Document rawResults) {
Assert.notNull(mappedResults); Assert.notNull(mappedResults, "List of mapped results must not be null!");
Assert.notNull(rawResults); Assert.notNull(rawResults, "Raw results must not be null!");
this.mappedResults = mappedResults; this.mappedResults = mappedResults;
this.rawResults = rawResults; this.rawResults = rawResults;
parseKeys(); parseKeys();
parseCount(); parseCount();
parseServerUsed(); parseServerUsed();

9
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapreduce/MapReduceResults.java

@ -1,11 +1,11 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -29,6 +29,7 @@ import com.mongodb.MapReduceOutput;
* @author Mark Pollack * @author Mark Pollack
* @author Oliver Gierke * @author Oliver Gierke
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
* @param <T> The class in which the results are mapped onto, accessible via an iterator. * @param <T> The class in which the results are mapped onto, accessible via an iterator.
*/ */
public class MapReduceResults<T> implements Iterable<T> { public class MapReduceResults<T> implements Iterable<T> {
@ -49,8 +50,8 @@ public class MapReduceResults<T> implements Iterable<T> {
@Deprecated @Deprecated
public MapReduceResults(List<T> mappedResults, Document rawResults) { public MapReduceResults(List<T> mappedResults, Document rawResults) {
Assert.notNull(mappedResults); Assert.notNull(mappedResults, "List of mapped results must not be null!");
Assert.notNull(rawResults); Assert.notNull(rawResults, "Raw results must not be null!");
this.mappedResults = mappedResults; this.mappedResults = mappedResults;
this.rawResults = rawResults; this.rawResults = rawResults;

22
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java

@ -50,6 +50,7 @@ import com.mongodb.BasicDBList;
* @author Oliver Gierke * @author Oliver Gierke
* @author Thomas Darimont * @author Thomas Darimont
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
*/ */
public class Criteria implements CriteriaDefinition { public class Criteria implements CriteriaDefinition {
@ -386,7 +387,7 @@ public class Criteria implements CriteriaDefinition {
*/ */
public Criteria regex(Pattern pattern) { public Criteria regex(Pattern pattern) {
Assert.notNull(pattern); Assert.notNull(pattern, "Pattern must not be null!");
if (lastOperatorWasNot()) { if (lastOperatorWasNot()) {
return not(pattern); return not(pattern);
@ -407,7 +408,9 @@ public class Criteria implements CriteriaDefinition {
} }
private Pattern toPattern(String regex, String options) { private Pattern toPattern(String regex, String options) {
Assert.notNull(regex);
Assert.notNull(regex, "Regex string must not be null!");
return Pattern.compile(regex, options == null ? 0 : BSON.regexFlags(options)); return Pattern.compile(regex, options == null ? 0 : BSON.regexFlags(options));
} }
@ -421,7 +424,9 @@ public class Criteria implements CriteriaDefinition {
* @see <a href="https://docs.mongodb.com/manual/reference/operator/query/centerSphere/">MongoDB Query operator: $centerSphere</a> * @see <a href="https://docs.mongodb.com/manual/reference/operator/query/centerSphere/">MongoDB Query operator: $centerSphere</a>
*/ */
public Criteria withinSphere(Circle circle) { public Criteria withinSphere(Circle circle) {
Assert.notNull(circle);
Assert.notNull(circle, "Circle must not be null!");
criteria.put("$geoWithin", new GeoCommand(new Sphere(circle))); criteria.put("$geoWithin", new GeoCommand(new Sphere(circle)));
return this; return this;
} }
@ -435,7 +440,8 @@ public class Criteria implements CriteriaDefinition {
*/ */
public Criteria within(Shape shape) { public Criteria within(Shape shape) {
Assert.notNull(shape); Assert.notNull(shape, "Shape must not be null!");
criteria.put("$geoWithin", new GeoCommand(shape)); criteria.put("$geoWithin", new GeoCommand(shape));
return this; return this;
} }
@ -448,7 +454,9 @@ public class Criteria implements CriteriaDefinition {
* @see <a href="https://docs.mongodb.com/manual/reference/operator/query/near/">MongoDB Query operator: $near</a> * @see <a href="https://docs.mongodb.com/manual/reference/operator/query/near/">MongoDB Query operator: $near</a>
*/ */
public Criteria near(Point point) { public Criteria near(Point point) {
Assert.notNull(point);
Assert.notNull(point, "Point must not be null!");
criteria.put("$near", point); criteria.put("$near", point);
return this; return this;
} }
@ -462,7 +470,9 @@ public class Criteria implements CriteriaDefinition {
* @see <a href="https://docs.mongodb.com/manual/reference/operator/query/nearSphere/">MongoDB Query operator: $nearSphere</a> * @see <a href="https://docs.mongodb.com/manual/reference/operator/query/nearSphere/">MongoDB Query operator: $nearSphere</a>
*/ */
public Criteria nearSphere(Point point) { public Criteria nearSphere(Point point) {
Assert.notNull(point);
Assert.notNull(point, "Point must not be null!");
criteria.put("$nearSphere", point); criteria.put("$nearSphere", point);
return this; return this;
} }

19
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/NearQuery.java

@ -1,11 +1,11 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
@ -47,11 +47,11 @@ public final class NearQuery {
/** /**
* Creates a new {@link NearQuery}. * Creates a new {@link NearQuery}.
* *
* @param point * @param point must not be {@literal null}.
*/ */
private NearQuery(Point point, Metric metric) { private NearQuery(Point point, Metric metric) {
Assert.notNull(point); Assert.notNull(point, "Point must not be null!");
this.point = point; this.point = point;
this.spherical = false; this.spherical = false;
@ -106,7 +106,6 @@ public final class NearQuery {
* @return * @return
*/ */
public static NearQuery near(Point point, Metric metric) { public static NearQuery near(Point point, Metric metric) {
Assert.notNull(point);
return new NearQuery(point, metric); return new NearQuery(point, metric);
} }
@ -183,7 +182,8 @@ public final class NearQuery {
*/ */
public NearQuery maxDistance(double maxDistance, Metric metric) { public NearQuery maxDistance(double maxDistance, Metric metric) {
Assert.notNull(metric); Assert.notNull(metric, "Metric must not be null!");
return maxDistance(new Distance(maxDistance, metric)); return maxDistance(new Distance(maxDistance, metric));
} }
@ -196,7 +196,7 @@ public final class NearQuery {
*/ */
public NearQuery maxDistance(Distance distance) { public NearQuery maxDistance(Distance distance) {
Assert.notNull(distance); Assert.notNull(distance, "Distance must not be null!");
if (distance.getMetric() != Metrics.NEUTRAL) { if (distance.getMetric() != Metrics.NEUTRAL) {
this.spherical(true); this.spherical(true);
@ -239,7 +239,8 @@ public final class NearQuery {
*/ */
public NearQuery minDistance(double minDistance, Metric metric) { public NearQuery minDistance(double minDistance, Metric metric) {
Assert.notNull(metric); Assert.notNull(metric, "Metric must not be null!");
return minDistance(new Distance(minDistance, metric)); return minDistance(new Distance(minDistance, metric));
} }
@ -253,7 +254,7 @@ public final class NearQuery {
*/ */
public NearQuery minDistance(Distance distance) { public NearQuery minDistance(Distance distance) {
Assert.notNull(distance); Assert.notNull(distance, "Distance must not be null!");
if (distance.getMetric() != Metrics.NEUTRAL) { if (distance.getMetric() != Metrics.NEUTRAL) {
this.spherical(true); this.spherical(true);

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/spel/ExpressionNode.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2013-2016 the original author or authors. * Copyright 2013-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -31,6 +31,7 @@ import org.springframework.util.Assert;
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
*/ */
public class ExpressionNode implements Iterable<ExpressionNode> { public class ExpressionNode implements Iterable<ExpressionNode> {
@ -173,7 +174,7 @@ public class ExpressionNode implements Iterable<ExpressionNode> {
*/ */
public ExpressionNode getChild(int index) { public ExpressionNode getChild(int index) {
Assert.isTrue(index >= 0); Assert.isTrue(index >= 0, "Index must be greater or equal to zero!");
return from(node.getChild(index), state); return from(node.getChild(index), state);
} }

7
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/gridfs/AntPath.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,6 +24,7 @@ import org.springframework.util.Assert;
* Value object to abstract Ant paths. * Value object to abstract Ant paths.
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author Mark Paluch
*/ */
class AntPath { class AntPath {
@ -38,7 +39,9 @@ class AntPath {
* @param path must not be {@literal null}. * @param path must not be {@literal null}.
*/ */
public AntPath(String path) { public AntPath(String path) {
Assert.notNull(path);
Assert.notNull(path, "Path must not be null!");
this.path = path; this.path = path;
} }

9
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/gridfs/GridFsTemplate.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -48,6 +48,7 @@ import com.mongodb.client.gridfs.model.GridFSUploadOptions;
* @author Thomas Darimont * @author Thomas Darimont
* @author Martin Baumgartner * @author Martin Baumgartner
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
*/ */
public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver { public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver {
@ -75,8 +76,8 @@ public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver
*/ */
public GridFsTemplate(MongoDbFactory dbFactory, MongoConverter converter, String bucket) { public GridFsTemplate(MongoDbFactory dbFactory, MongoConverter converter, String bucket) {
Assert.notNull(dbFactory); Assert.notNull(dbFactory, "MongoDbFactory must not be null!");
Assert.notNull(converter); Assert.notNull(converter, "MongoConverter must not be null!");
this.dbFactory = dbFactory; this.dbFactory = dbFactory;
this.converter = converter; this.converter = converter;
@ -158,7 +159,7 @@ public class GridFsTemplate implements GridFsOperations, ResourcePatternResolver
*/ */
public ObjectId store(InputStream content, String filename, String contentType, Document metadata) { public ObjectId store(InputStream content, String filename, String contentType, Document metadata) {
Assert.notNull(content); Assert.notNull(content, "InputStream must not be null!");
GridFSUploadOptions opts = new GridFSUploadOptions(); GridFSUploadOptions opts = new GridFSUploadOptions();

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/cdi/MongoRepositoryBean.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -53,7 +53,7 @@ public class MongoRepositoryBean<T> extends CdiRepositoryBean<T> {
super(qualifiers, repositoryType, beanManager, detector); super(qualifiers, repositoryType, beanManager, detector);
Assert.notNull(operations); Assert.notNull(operations, "MongoOperations bean must not be null!");
this.operations = operations; this.operations = operations;
} }

31
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/ConvertingParameterAccessor.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2015 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -42,6 +42,7 @@ import com.mongodb.DBRef;
* @author Oliver Gierke * @author Oliver Gierke
* @author Christoph Strobl * @author Christoph Strobl
* @author Thomas Darimont * @author Thomas Darimont
* @author Mark Paluch
*/ */
public class ConvertingParameterAccessor implements MongoParameterAccessor { public class ConvertingParameterAccessor implements MongoParameterAccessor {
@ -56,36 +57,36 @@ public class ConvertingParameterAccessor implements MongoParameterAccessor {
*/ */
public ConvertingParameterAccessor(MongoWriter<?> writer, MongoParameterAccessor delegate) { public ConvertingParameterAccessor(MongoWriter<?> writer, MongoParameterAccessor delegate) {
Assert.notNull(writer); Assert.notNull(writer, "MongoWriter must not be null!");
Assert.notNull(delegate); Assert.notNull(delegate, "MongoParameterAccessor must not be null!");
this.writer = writer; this.writer = writer;
this.delegate = delegate; this.delegate = delegate;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see java.lang.Iterable#iterator() * @see java.lang.Iterable#iterator()
*/ */
public PotentiallyConvertingIterator iterator() { public PotentiallyConvertingIterator iterator() {
return new ConvertingIterator(delegate.iterator()); return new ConvertingIterator(delegate.iterator());
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.springframework.data.repository.query.ParameterAccessor#getPageable() * @see org.springframework.data.repository.query.ParameterAccessor#getPageable()
*/ */
public Pageable getPageable() { public Pageable getPageable() {
return delegate.getPageable(); return delegate.getPageable();
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
* @see org.springframework.data.repository.query.ParameterAccessor#getSort() * @see org.springframework.data.repository.query.ParameterAccessor#getSort()
*/ */
public Sort getSort() { public Sort getSort() {
return delegate.getSort(); return delegate.getSort();
} }

2
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoQueryCreator.java

@ -92,7 +92,7 @@ class MongoQueryCreator extends AbstractQueryCreator<Query, Criteria> {
super(tree, accessor); super(tree, accessor);
Assert.notNull(context); Assert.notNull(context, "MappingContext must not be null!");
this.accessor = accessor; this.accessor = accessor;
this.isGeoNearQuery = isGeoNearQuery; this.isGeoNearQuery = isGeoNearQuery;

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/IndexEnsuringQueryCreationListener.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2013 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -57,7 +57,7 @@ class IndexEnsuringQueryCreationListener implements QueryCreationListener<PartTr
*/ */
public IndexEnsuringQueryCreationListener(IndexOperationsProvider indexOperationsProvider) { public IndexEnsuringQueryCreationListener(IndexOperationsProvider indexOperationsProvider) {
Assert.notNull(indexOperationsProvider); Assert.notNull(indexOperationsProvider, "IndexOperationsProvider must not be null!");
this.indexOperationsProvider = indexOperationsProvider; this.indexOperationsProvider = indexOperationsProvider;
} }

6
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/MongoRepositoryFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2015 the original author or authors. * Copyright 2010-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,7 +21,6 @@ import java.io.Serializable;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.domain.Persistable;
import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.MappingException; import org.springframework.data.mapping.model.MappingException;
import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.MongoOperations;
@ -56,6 +55,7 @@ import org.springframework.util.ClassUtils;
* @author Oliver Gierke * @author Oliver Gierke
* @author Thomas Darimont * @author Thomas Darimont
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
*/ */
public class MongoRepositoryFactory extends RepositoryFactorySupport { public class MongoRepositoryFactory extends RepositoryFactorySupport {
@ -77,7 +77,7 @@ public class MongoRepositoryFactory extends RepositoryFactorySupport {
*/ */
public MongoRepositoryFactory(MongoOperations mongoOperations) { public MongoRepositoryFactory(MongoOperations mongoOperations) {
Assert.notNull(mongoOperations); Assert.notNull(mongoOperations, "MongoOperations must not be null!");
this.operations = mongoOperations; this.operations = mongoOperations;
this.mappingContext = mongoOperations.getConverter().getMappingContext(); this.mappingContext = mongoOperations.getConverter().getMappingContext();

5
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QueryDslMongoRepository.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -80,7 +80,8 @@ public class QueryDslMongoRepository<T, ID extends Serializable> extends SimpleM
super(entityInformation, mongoOperations); super(entityInformation, mongoOperations);
Assert.notNull(resolver); Assert.notNull(resolver, "EntityPathResolver must not be null!");
EntityPath<T> path = resolver.createPath(entityInformation.getJavaType()); EntityPath<T> path = resolver.createPath(entityInformation.getJavaType());
this.builder = new PathBuilder<T>(path.getType(), path.getMetadata()); this.builder = new PathBuilder<T>(path.getType(), path.getMetadata());

13
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/QuerydslRepositorySupport.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2015 the original author or authors. * Copyright 2011-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,6 +27,7 @@ import com.querydsl.mongodb.AbstractMongodbQuery;
* Base class to create repository implementations based on Querydsl. * Base class to create repository implementations based on Querydsl.
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author Mark Paluch
*/ */
public abstract class QuerydslRepositorySupport { public abstract class QuerydslRepositorySupport {
@ -40,7 +41,7 @@ public abstract class QuerydslRepositorySupport {
*/ */
public QuerydslRepositorySupport(MongoOperations operations) { public QuerydslRepositorySupport(MongoOperations operations) {
Assert.notNull(operations); Assert.notNull(operations, "MongoOperations must not be null!");
this.template = operations; this.template = operations;
this.context = operations.getConverter().getMappingContext(); this.context = operations.getConverter().getMappingContext();
@ -54,7 +55,9 @@ public abstract class QuerydslRepositorySupport {
* @return * @return
*/ */
protected <T> AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> from(final EntityPath<T> path) { protected <T> AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> from(final EntityPath<T> path) {
Assert.notNull(path);
Assert.notNull(path, "EntityPath must not be null!");
MongoPersistentEntity<?> entity = context.getPersistentEntity(path.getType()); MongoPersistentEntity<?> entity = context.getPersistentEntity(path.getType());
return from(path, entity.getCollection()); return from(path, entity.getCollection());
} }
@ -68,8 +71,8 @@ public abstract class QuerydslRepositorySupport {
*/ */
protected <T> AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> from(final EntityPath<T> path, String collection) { protected <T> AbstractMongodbQuery<T, SpringDataMongodbQuery<T>> from(final EntityPath<T> path, String collection) {
Assert.notNull(path); Assert.notNull(path, "EntityPath must not be null!");
Assert.hasText(collection); Assert.hasText(collection, "Collection name must not be null or empty!");
return new SpringDataMongodbQuery<T>(template, path.getType(), collection); return new SpringDataMongodbQuery<T>(template, path.getType(), collection);
} }

4
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/ReactiveMongoRepositoryFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2016 the original author or authors. * Copyright 2016-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -65,7 +65,7 @@ public class ReactiveMongoRepositoryFactory extends ReactiveRepositoryFactorySup
*/ */
public ReactiveMongoRepositoryFactory(ReactiveMongoOperations mongoOperations) { public ReactiveMongoRepositoryFactory(ReactiveMongoOperations mongoOperations) {
Assert.notNull(mongoOperations); Assert.notNull(mongoOperations, "ReactiveMongoOperations must not be null!");
this.operations = mongoOperations; this.operations = mongoOperations;
this.mappingContext = mongoOperations.getConverter().getMappingContext(); this.mappingContext = mongoOperations.getConverter().getMappingContext();

6
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2010-2016 the original author or authors. * Copyright 2010-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -61,8 +61,8 @@ public class SimpleMongoRepository<T, ID extends Serializable> implements MongoR
*/ */
public SimpleMongoRepository(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) { public SimpleMongoRepository(MongoEntityInformation<T, ID> metadata, MongoOperations mongoOperations) {
Assert.notNull(mongoOperations); Assert.notNull(metadata, "MongoEntityInformation must not be null!");
Assert.notNull(metadata); Assert.notNull(mongoOperations, "MongoOperations must not be null!");
this.entityInformation = metadata; this.entityInformation = metadata;
this.mongoOperations = mongoOperations; this.mongoOperations = mongoOperations;

8
spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/support/SimpleReactiveMongoRepository.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2016 the original author or authors. * Copyright 2016-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,8 +27,6 @@ import java.util.Set;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import org.springframework.data.domain.Example; import org.springframework.data.domain.Example;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.ReactiveMongoOperations; import org.springframework.data.mongodb.core.ReactiveMongoOperations;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
@ -61,8 +59,8 @@ public class SimpleReactiveMongoRepository<T, ID extends Serializable> implement
public SimpleReactiveMongoRepository(MongoEntityInformation<T, ID> metadata, public SimpleReactiveMongoRepository(MongoEntityInformation<T, ID> metadata,
ReactiveMongoOperations mongoOperations) { ReactiveMongoOperations mongoOperations) {
Assert.notNull(mongoOperations); Assert.notNull(metadata, "MongoEntityInformation must not be null!");
Assert.notNull(metadata); Assert.notNull(mongoOperations, "ReactiveMongoOperations must not be null!");
this.entityInformation = metadata; this.entityInformation = metadata;
this.mongoOperations = mongoOperations; this.mongoOperations = mongoOperations;

4
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/monitor/MongoMonitorIntegrationTests.java

@ -25,8 +25,6 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import com.mongodb.Mongo; import com.mongodb.Mongo;
@ -35,6 +33,7 @@ import com.mongodb.Mongo;
* *
* @author Mark Pollack * @author Mark Pollack
* @author Thomas Darimont * @author Thomas Darimont
* @author Mark Paluch
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:infrastructure.xml") @ContextConfiguration("classpath:infrastructure.xml")
@ -46,7 +45,6 @@ public class MongoMonitorIntegrationTests {
public void serverInfo() { public void serverInfo() {
ServerInfo serverInfo = new ServerInfo(mongo); ServerInfo serverInfo = new ServerInfo(mongo);
serverInfo.getVersion(); serverInfo.getVersion();
Assert.isTrue(StringUtils.hasText("1."));
} }
@Test // DATAMONGO-685 @Test // DATAMONGO-685

7
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/performance/PerformanceTests.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2016 the original author or authors. * Copyright 2012-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,7 +17,6 @@ package org.springframework.data.mongodb.performance;
import static org.springframework.data.mongodb.core.query.Criteria.*; import static org.springframework.data.mongodb.core.query.Criteria.*;
import static org.springframework.data.mongodb.core.query.Query.*; import static org.springframework.data.mongodb.core.query.Query.*;
import static org.springframework.util.Assert.*;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
@ -48,6 +47,7 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean; import org.springframework.data.mongodb.repository.support.MongoRepositoryFactoryBean;
import org.springframework.util.Assert;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -67,6 +67,7 @@ import com.mongodb.WriteConcern;
* *
* @author Oliver Gierke * @author Oliver Gierke
* @author Christoph Strobl * @author Christoph Strobl
* @author Mark Paluch
*/ */
public class PerformanceTests { public class PerformanceTests {
@ -623,7 +624,7 @@ public class PerformanceTests {
private static <T> List<T> pickRandomNumerOfItemsFrom(List<T> source) { private static <T> List<T> pickRandomNumerOfItemsFrom(List<T> source) {
isTrue(!source.isEmpty()); Assert.isTrue(!source.isEmpty(), "Source must not be empty!");
Random random = new Random(); Random random = new Random();
int numberOfItems = random.nextInt(source.size()); int numberOfItems = random.nextInt(source.size());

4
spring-data-mongodb/src/test/java/org/springframework/data/mongodb/performance/ReactivePerformanceTests.java

@ -17,8 +17,8 @@ package org.springframework.data.mongodb.performance;
import static org.springframework.data.mongodb.core.query.Criteria.*; import static org.springframework.data.mongodb.core.query.Criteria.*;
import static org.springframework.data.mongodb.core.query.Query.*; import static org.springframework.data.mongodb.core.query.Query.*;
import static org.springframework.util.Assert.*;
import org.springframework.util.Assert;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
@ -670,7 +670,7 @@ public class ReactivePerformanceTests {
private static <T> List<T> pickRandomNumerOfItemsFrom(List<T> source) { private static <T> List<T> pickRandomNumerOfItemsFrom(List<T> source) {
isTrue(!source.isEmpty()); Assert.isTrue(!source.isEmpty(), "Source must not be empty!");
Random random = new Random(); Random random = new Random();
int numberOfItems = random.nextInt(source.size()); int numberOfItems = random.nextInt(source.size());

Loading…
Cancel
Save