Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ecc71299f | ||
|
|
0a97fb92af | ||
|
|
423efcf33e | ||
|
|
9dbea7c120 | ||
|
|
69ba8b5ba9 | ||
|
|
91815a68c4 | ||
|
|
6949e4ad70 | ||
|
|
f53f6b9308 | ||
|
|
fb3bda9e94 | ||
|
|
c9ad0884ec | ||
|
|
eba0a66e1c | ||
|
|
92ace88cac | ||
|
|
24a5fcd5f5 | ||
|
|
4fff480e17 | ||
|
|
51160571fd | ||
|
|
b5c40e7427 | ||
|
|
ee712f67db | ||
|
|
de2a0373bb | ||
|
|
baa897ff2b |
6
pom.xml
6
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.4.3</version>
|
||||
<version>3.4.5</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Spring Data MongoDB</name>
|
||||
@@ -15,7 +15,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data.build</groupId>
|
||||
<artifactId>spring-data-parent</artifactId>
|
||||
<version>2.7.3</version>
|
||||
<version>2.7.5</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
@@ -26,7 +26,7 @@
|
||||
<properties>
|
||||
<project.type>multi</project.type>
|
||||
<dist.id>spring-data-mongodb</dist.id>
|
||||
<springdata.commons>2.7.3</springdata.commons>
|
||||
<springdata.commons>2.7.5</springdata.commons>
|
||||
<mongo>4.6.1</mongo>
|
||||
<mongo.reactivestreams>${mongo}</mongo.reactivestreams>
|
||||
<jmh.version>1.19</jmh.version>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.4.3</version>
|
||||
<version>3.4.5</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.4.3</version>
|
||||
<version>3.4.5</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-mongodb-parent</artifactId>
|
||||
<version>3.4.3</version>
|
||||
<version>3.4.5</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bson.Document;
|
||||
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.core.query.MetricConversion;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*/
|
||||
class CountQuery {
|
||||
|
||||
private Document source;
|
||||
private final Document source;
|
||||
|
||||
private CountQuery(Document source) {
|
||||
this.source = source;
|
||||
@@ -101,7 +101,7 @@ class CountQuery {
|
||||
}
|
||||
|
||||
if (valueToInspect instanceof Collection) {
|
||||
return requiresRewrite((Collection) valueToInspect);
|
||||
return requiresRewrite((Collection<?>) valueToInspect);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -157,12 +157,14 @@ class CountQuery {
|
||||
* @param $and potentially existing {@code $and} condition.
|
||||
* @return the rewritten query {@link Document}.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Document createGeoWithin(String key, Document source, @Nullable Object $and) {
|
||||
|
||||
boolean spheric = source.containsKey("$nearSphere");
|
||||
Object $near = spheric ? source.get("$nearSphere") : source.get("$near");
|
||||
|
||||
Number maxDistance = source.containsKey("$maxDistance") ? (Number) source.get("$maxDistance") : Double.MAX_VALUE;
|
||||
Number maxDistance = getMaxDistance(source, $near, spheric);
|
||||
|
||||
List<Object> $centerMax = Arrays.asList(toCenterCoordinates($near), maxDistance);
|
||||
Document $geoWithinMax = new Document("$geoWithin",
|
||||
new Document(spheric ? "$centerSphere" : "$center", $centerMax));
|
||||
@@ -180,7 +182,7 @@ class CountQuery {
|
||||
|
||||
if ($and != null) {
|
||||
if ($and instanceof Collection) {
|
||||
Collection andElements = (Collection) $and;
|
||||
Collection<Document> andElements = (Collection<Document>) $and;
|
||||
criteria = new ArrayList<>(andElements.size() + 2);
|
||||
criteria.addAll(andElements);
|
||||
} else {
|
||||
@@ -194,9 +196,35 @@ class CountQuery {
|
||||
|
||||
criteria.add(new Document("$nor", Collections.singletonList(new Document(key, $geoWithinMin))));
|
||||
criteria.add(new Document(key, $geoWithinMax));
|
||||
|
||||
return new Document("$and", criteria);
|
||||
}
|
||||
|
||||
private static Number getMaxDistance(Document source, Object $near, boolean spheric) {
|
||||
|
||||
Number maxDistance = Double.MAX_VALUE;
|
||||
|
||||
if (source.containsKey("$maxDistance")) { // legacy coordinate pair
|
||||
return (Number) source.get("$maxDistance");
|
||||
}
|
||||
|
||||
if ($near instanceof Document) {
|
||||
|
||||
Document nearDoc = (Document) $near;
|
||||
|
||||
if (nearDoc.containsKey("$maxDistance")) {
|
||||
|
||||
maxDistance = (Number) nearDoc.get("$maxDistance");
|
||||
// geojson is in Meters but we need radians x/(6378.1*1000)
|
||||
if (spheric && nearDoc.containsKey("$geometry")) {
|
||||
maxDistance = MetricConversion.metersToRadians(maxDistance.doubleValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maxDistance;
|
||||
}
|
||||
|
||||
private static boolean containsNear(Document source) {
|
||||
return source.containsKey("$near") || source.containsKey("$nearSphere");
|
||||
}
|
||||
@@ -220,10 +248,17 @@ class CountQuery {
|
||||
return Arrays.asList(((Point) value).getX(), ((Point) value).getY());
|
||||
}
|
||||
|
||||
if (value instanceof Document && ((Document) value).containsKey("x")) {
|
||||
if (value instanceof Document) {
|
||||
Document document = (Document) value;
|
||||
|
||||
Document point = (Document) value;
|
||||
return Arrays.asList(point.get("x"), point.get("y"));
|
||||
if (document.containsKey("x")) {
|
||||
return Arrays.asList(document.get("x"), document.get("y"));
|
||||
}
|
||||
|
||||
if (document.containsKey("$geometry")) {
|
||||
Document geoJsonPoint = document.get("$geometry", Document.class);
|
||||
return geoJsonPoint.get("coordinates");
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
@@ -1303,9 +1303,10 @@ public interface MongoOperations extends FluentMongoOperations {
|
||||
/**
|
||||
* Insert the object into the collection for the entity type of the object to save. <br />
|
||||
* The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}. <br />
|
||||
* If your object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
|
||||
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
|
||||
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
|
||||
* If your object has an {@literal Id} property which holds a {@literal null} value, it will be set with the generated
|
||||
* Id from MongoDB. If your Id property is a String then MongoDB ObjectId will be used to populate that string.
|
||||
* Otherwise, the conversion from ObjectId to your property type will be handled by Spring's BeanWrapper class that
|
||||
* leverages Type Conversion API. See
|
||||
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
|
||||
* Type Conversion"</a> for more details. <br />
|
||||
* Insert is used to initially store the object into the database. To update an existing object use the save method.
|
||||
|
||||
@@ -272,7 +272,7 @@ class QueryOperations {
|
||||
*/
|
||||
<T> MappedDocument prepareId(@Nullable MongoPersistentEntity<T> entity) {
|
||||
|
||||
if (entity == null) {
|
||||
if (entity == null || source.hasId()) {
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
@@ -1110,9 +1110,10 @@ public interface ReactiveMongoOperations extends ReactiveFluentMongoOperations {
|
||||
* <br />
|
||||
* The object is converted to the MongoDB native representation using an instance of {@see MongoConverter}.
|
||||
* <br />
|
||||
* If your object has an "Id' property, it will be set with the generated Id from MongoDB. If your Id property is a
|
||||
* String then MongoDB ObjectId will be used to populate that string. Otherwise, the conversion from ObjectId to your
|
||||
* property type will be handled by Spring's BeanWrapper class that leverages Type Conversion API. See
|
||||
* If your object has an {@literal Id} property which holds a {@literal null} value, it will be set with the generated
|
||||
* Id from MongoDB. If your Id property is a String then MongoDB ObjectId will be used to populate that string.
|
||||
* Otherwise, the conversion from ObjectId to your property type will be handled by Spring's BeanWrapper class that
|
||||
* leverages Type Conversion API. See
|
||||
* <a href="https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#validation" > Spring's
|
||||
* Type Conversion"</a> for more details.
|
||||
* <br />
|
||||
|
||||
@@ -446,7 +446,7 @@ public class ScriptOperators {
|
||||
/**
|
||||
* Define the optional {@code initArgs} for the {@link #init(String)} function.
|
||||
*
|
||||
* @param function must not be {@literal null}.
|
||||
* @param args must not be {@literal null}.
|
||||
* @return this.
|
||||
*/
|
||||
@Override
|
||||
|
||||
@@ -73,7 +73,7 @@ public class BasicQuery extends Query {
|
||||
*
|
||||
* @param queryObject must not be {@literal null}.
|
||||
* @param fieldsObject must not be {@literal null}.
|
||||
* @throws IllegalArgumentException when {@code sortObject} or {@code fieldsObject} is {@literal null}.
|
||||
* @throws IllegalArgumentException when {@code queryObject} or {@code fieldsObject} is {@literal null}.
|
||||
*/
|
||||
public BasicQuery(Document queryObject, Document fieldsObject) {
|
||||
|
||||
|
||||
@@ -624,9 +624,13 @@ public class Criteria implements CriteriaDefinition {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a geo-spatial criterion using a {@literal $maxDistance} operation, for use with $near
|
||||
* Creates a geo-spatial criterion using a {@literal $maxDistance} operation, for use with {@literal $near} or
|
||||
* {@literal $nearSphere}.
|
||||
* <p>
|
||||
* <strong>NOTE:</strong> The unit of measure for distance may depends on the used coordinate representation
|
||||
* (legacy vs. geoJson) as well as the target operation.
|
||||
*
|
||||
* @param maxDistance
|
||||
* @param maxDistance radians or meters
|
||||
* @return this.
|
||||
* @see <a href="https://docs.mongodb.com/manual/reference/operator/query/maxDistance/">MongoDB Query operator:
|
||||
* $maxDistance</a>
|
||||
@@ -645,8 +649,11 @@ public class Criteria implements CriteriaDefinition {
|
||||
/**
|
||||
* Creates a geospatial criterion using a {@literal $minDistance} operation, for use with {@literal $near} or
|
||||
* {@literal $nearSphere}.
|
||||
* <p>
|
||||
* <strong>NOTE:</strong> The unit of measure for distance may depends on the used coordinate representation
|
||||
* (legacy vs. geoJson) as well as the target operation.
|
||||
*
|
||||
* @param minDistance
|
||||
* @param minDistance radians or meters
|
||||
* @return this.
|
||||
* @since 1.7
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.data.mongodb.core.query;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
|
||||
import org.springframework.data.geo.Distance;
|
||||
@@ -27,6 +28,7 @@ import org.springframework.data.geo.Metrics;
|
||||
* {@link Metric} and {@link Distance} conversions using the metric system.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @since 2.2
|
||||
*/
|
||||
public class MetricConversion {
|
||||
@@ -61,6 +63,28 @@ public class MetricConversion {
|
||||
.doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code distance} in radians (on an earth like sphere).
|
||||
*
|
||||
* @param distance must not be {@literal null}.
|
||||
* @return distance in radians.
|
||||
* @since 3.4.4
|
||||
*/
|
||||
public static double toRadians(Distance distance) {
|
||||
return metersToRadians(getDistanceInMeters(distance));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code distance} in radians (on an earth like sphere).
|
||||
*
|
||||
* @param meters
|
||||
* @return distance in radians.
|
||||
* @since 3.4.4
|
||||
*/
|
||||
public static double metersToRadians(double meters) {
|
||||
return BigDecimal.valueOf(meters).divide(METERS_MULTIPLIER, MathContext.DECIMAL64).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code metric} to meters multiplier.
|
||||
*
|
||||
|
||||
@@ -295,7 +295,7 @@ public interface JsonSchemaObject {
|
||||
Type OBJECT = jsonTypeOf("object");
|
||||
Type ARRAY = jsonTypeOf("array");
|
||||
Type NUMBER = jsonTypeOf("number");
|
||||
Type BOOLEAN = jsonTypeOf("boolean");
|
||||
Type BOOLEAN = jsonTypeOf("bool");
|
||||
Type STRING = jsonTypeOf("string");
|
||||
Type NULL = jsonTypeOf("null");
|
||||
|
||||
|
||||
@@ -15,20 +15,17 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.core;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
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.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
|
||||
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
|
||||
import org.springframework.data.mongodb.core.convert.NoOpDbRefResolver;
|
||||
import org.springframework.data.mongodb.core.convert.QueryMapper;
|
||||
import org.springframework.data.mongodb.core.geo.GeoJsonPoint;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
|
||||
import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity;
|
||||
import org.springframework.data.mongodb.core.query.Criteria;
|
||||
@@ -155,6 +152,39 @@ class CountQueryUnitTests {
|
||||
"{\"$or\" : [ { \"name\": \"food\" }, {\"location\": {\"$geoWithin\": {\"$center\": [[-73.99171, 40.738868], 10.0]}}} ]}"));
|
||||
}
|
||||
|
||||
@Test // GH-4004
|
||||
void nearToGeoWithinWithMaxDistanceUsingGeoJsonSource() {
|
||||
|
||||
Query source = query(new Criteria().orOperator(where("name").is("food"),
|
||||
where("location").near(new GeoJsonPoint(-73.99171, 40.738868)).maxDistance(10)));
|
||||
|
||||
org.bson.Document target = postProcessQueryForCount(source);
|
||||
assertThat(target).isEqualTo(org.bson.Document.parse(
|
||||
"{\"$or\" : [ { \"name\": \"food\" }, {\"location\": {\"$geoWithin\": {\"$center\": [[-73.99171, 40.738868], 10.0]}}} ]}"));
|
||||
}
|
||||
|
||||
@Test // GH-4004
|
||||
void nearSphereToGeoWithinWithoutMaxDistanceUsingGeoJsonSource() {
|
||||
|
||||
Query source = query(new Criteria().orOperator(where("name").is("food"),
|
||||
where("location").nearSphere(new GeoJsonPoint(-73.99171, 40.738868))));
|
||||
|
||||
org.bson.Document target = postProcessQueryForCount(source);
|
||||
assertThat(target).isEqualTo(org.bson.Document.parse(
|
||||
"{\"$or\" : [ { \"name\": \"food\" }, {\"location\": {\"$geoWithin\": {\"$centerSphere\": [[-73.99171, 40.738868], 1.7976931348623157E308]}}} ]}"));
|
||||
}
|
||||
|
||||
@Test // GH-4004
|
||||
void nearSphereToGeoWithinWithMaxDistanceUsingGeoJsonSource() {
|
||||
|
||||
Query source = query(new Criteria().orOperator(where("name").is("food"), where("location")
|
||||
.nearSphere(new GeoJsonPoint(-73.99171, 40.738868)).maxDistance/*in meters for geojson*/(10d)));
|
||||
|
||||
org.bson.Document target = postProcessQueryForCount(source);
|
||||
assertThat(target).isEqualTo(org.bson.Document.parse(
|
||||
"{\"$or\" : [ { \"name\": \"food\" }, {\"location\": {\"$geoWithin\": {\"$centerSphere\": [[-73.99171, 40.738868], 1.567855942887398E-6]}}} ]}"));
|
||||
}
|
||||
|
||||
private org.bson.Document postProcessQueryForCount(Query source) {
|
||||
|
||||
org.bson.Document intermediate = mapper.getMappedObject(source.getQueryObject(), (MongoPersistentEntity<?>) null);
|
||||
|
||||
@@ -292,7 +292,7 @@ class MappingMongoJsonSchemaCreatorUnitTests {
|
||||
" 're-named-property' : { 'type' : 'string' }," + //
|
||||
" 'retypedProperty' : { 'bsonType' : 'javascript' }," + //
|
||||
" 'primitiveInt' : { 'bsonType' : 'int' }," + //
|
||||
" 'booleanProperty' : { 'type' : 'boolean' }," + //
|
||||
" 'booleanProperty' : { 'type' : 'bool' }," + //
|
||||
" 'longProperty' : { 'bsonType' : 'long' }," + //
|
||||
" 'intProperty' : { 'bsonType' : 'int' }," + //
|
||||
" 'dateProperty' : { 'bsonType' : 'date' }," + //
|
||||
|
||||
@@ -3659,6 +3659,26 @@ public class MongoTemplateTests {
|
||||
assertThat(target).isEqualTo(source);
|
||||
}
|
||||
|
||||
@Test // GH-4184
|
||||
void insertHonorsExistingRawId() {
|
||||
|
||||
RawStringId source = new RawStringId();
|
||||
source.id = "abc";
|
||||
source.value = "new value";
|
||||
|
||||
template.insert(source);
|
||||
|
||||
org.bson.Document result = template
|
||||
.execute(db -> db.getCollection(template.getCollectionName(RawStringId.class))
|
||||
.find().limit(1).cursor().next());
|
||||
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.get("_id")).isEqualTo("abc");
|
||||
|
||||
RawStringId target = template.findOne(query(where("id").is(source.id)), RawStringId.class);
|
||||
assertThat(target).isEqualTo(source);
|
||||
}
|
||||
|
||||
@Test // GH-4026
|
||||
void saveShouldGenerateNewIdOfTypeIfExplicitlyDefined() {
|
||||
|
||||
|
||||
@@ -205,6 +205,15 @@ class QueryOperationsUnitTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test // GH-4184
|
||||
void insertContextDoesNotOverrideExistingId() {
|
||||
|
||||
assertThat(queryOperations.createInsertContext(new Document("_id", "abc")).prepareId(Person.class).getDocument())//
|
||||
.satisfies(result -> {
|
||||
assertThat(result).isEqualTo(new Document("_id", "abc"));
|
||||
});
|
||||
}
|
||||
|
||||
static class Person {
|
||||
|
||||
}
|
||||
|
||||
@@ -219,6 +219,23 @@ public class ReactiveMongoTemplateTests {
|
||||
}).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // GH-4184
|
||||
void insertHonorsExistingRawId() {
|
||||
|
||||
MongoTemplateTests.RawStringId source = new MongoTemplateTests.RawStringId();
|
||||
source.id = "abc";
|
||||
source.value = "new value";
|
||||
|
||||
template.insert(source)
|
||||
.then(template.execute(db -> Flux.from(
|
||||
db.getCollection(template.getCollectionName(MongoTemplateTests.RawStringId.class)).find().limit(1).first()))
|
||||
.next())
|
||||
.as(StepVerifier::create).consumeNextWith(result -> {
|
||||
assertThat(result).isNotNull();
|
||||
assertThat(result.get("_id")).isEqualTo("abc");
|
||||
});
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1444
|
||||
void insertsSimpleEntityCorrectly() {
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
|
||||
import org.springframework.data.mongodb.core.query.NearQuery;
|
||||
import org.springframework.data.mongodb.core.query.Query;
|
||||
import org.springframework.data.mongodb.repository.Person;
|
||||
import org.springframework.data.mongodb.test.util.EnableIfMongoServerVersion;
|
||||
import org.springframework.data.mongodb.test.util.MongoTemplateExtension;
|
||||
import org.springframework.data.mongodb.test.util.MongoTestTemplate;
|
||||
import org.springframework.data.mongodb.test.util.MongoVersion;
|
||||
@@ -312,6 +313,7 @@ public class AggregationTests {
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1391
|
||||
@EnableIfMongoServerVersion(isLessThan = "6.0")
|
||||
void shouldUnwindPreserveEmpty() {
|
||||
|
||||
MongoCollection<Document> coll = mongoTemplate.getCollection(INPUT_COLLECTION);
|
||||
|
||||
@@ -117,8 +117,8 @@ public class GeoSpatialIndexTests extends AbstractIntegrationTests {
|
||||
/**
|
||||
* Returns whether an index with the given name exists for the given entity type.
|
||||
*
|
||||
* @param indexName
|
||||
* @param entityType
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
private boolean hasIndexOfType(Class<?> entityType, final String type) {
|
||||
|
||||
@@ -45,7 +45,7 @@ class SubscriptionUtils {
|
||||
* Wait for all {@link Subscription Subscriptions} to {@link Subscription#isActive() become active} but not longer
|
||||
* than {@link #DEFAULT_TIMEOUT}.
|
||||
*
|
||||
* @param subscription
|
||||
* @param subscriptions
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
static void awaitSubscriptions(Subscription... subscriptions) throws InterruptedException {
|
||||
@@ -131,7 +131,8 @@ class SubscriptionUtils {
|
||||
/**
|
||||
* {@link MessageListener} implementation collecting received {@link Message messages}.
|
||||
*
|
||||
* @param <M>
|
||||
* @param <S> source message type.
|
||||
* @param <T> target message type.
|
||||
*/
|
||||
static class CollectingMessageListener<S, T> implements MessageListener<S, T> {
|
||||
|
||||
|
||||
@@ -65,4 +65,18 @@ public class MetricConversionUnitTests {
|
||||
assertThat(multiplier).isCloseTo(0.00062137, offset(0.000000001));
|
||||
}
|
||||
|
||||
@Test // GH-4004
|
||||
void shouldConvertMetersToRadians/* on an earth like sphere with r=6378.137km */() {
|
||||
assertThat(MetricConversion.metersToRadians(1000)).isCloseTo(0.000156785594d, offset(0.000000001));
|
||||
}
|
||||
|
||||
@Test // GH-4004
|
||||
void shouldConvertKilometersToRadians/* on an earth like sphere with r=6378.137km */() {
|
||||
assertThat(MetricConversion.toRadians(new Distance(1, Metrics.KILOMETERS))).isCloseTo(0.000156785594d, offset(0.000000001));
|
||||
}
|
||||
|
||||
@Test // GH-4004
|
||||
void shouldConvertMilesToRadians/* on an earth like sphere with r=6378.137km */() {
|
||||
assertThat(MetricConversion.toRadians(new Distance(1, Metrics.MILES))).isCloseTo(0.000252321328d, offset(0.000000001));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class JsonSchemaObjectUnitTests {
|
||||
.append("description", "Must be an object defining restrictions for name, active.").append("properties",
|
||||
new Document("name", new Document("type", "string")
|
||||
.append("description", "Must be a string with length unbounded-10].").append("maxLength", 10))
|
||||
.append("active", new Document("type", "boolean")));
|
||||
.append("active", new Document("type", "bool")));
|
||||
|
||||
assertThat(object().generatedDescription()
|
||||
.properties(JsonSchemaProperty.string("name").maxLength(10).generatedDescription(),
|
||||
@@ -266,7 +266,7 @@ class JsonSchemaObjectUnitTests {
|
||||
void arrayObjectShouldRenderItemsCorrectly() {
|
||||
|
||||
assertThat(array().items(Arrays.asList(string(), bool())).toDocument()).isEqualTo(new Document("type", "array")
|
||||
.append("items", Arrays.asList(new Document("type", "string"), new Document("type", "boolean"))));
|
||||
.append("items", Arrays.asList(new Document("type", "string"), new Document("type", "bool"))));
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-2613
|
||||
@@ -316,7 +316,7 @@ class JsonSchemaObjectUnitTests {
|
||||
void booleanShouldRenderCorrectly() {
|
||||
|
||||
assertThat(bool().generatedDescription().toDocument())
|
||||
.isEqualTo(new Document("type", "boolean").append("description", "Must be a boolean."));
|
||||
.isEqualTo(new Document("type", "bool").append("description", "Must be a boolean."));
|
||||
}
|
||||
|
||||
// -----------------
|
||||
|
||||
@@ -32,7 +32,7 @@ public abstract class Assertions extends org.assertj.core.api.Assertions {
|
||||
/**
|
||||
* Create assertion for {@link Document}.
|
||||
*
|
||||
* @param actual the actual value.
|
||||
* @param document the actual value.
|
||||
* @return the created assertion object.
|
||||
*/
|
||||
public static DocumentAssert assertThat(Document document) {
|
||||
|
||||
@@ -302,10 +302,10 @@ The following example shows how to create and use transactions with a `ReactiveM
|
||||
[source,java]
|
||||
----
|
||||
@Configuration
|
||||
static class Config extends AbstractMongoClientConfiguration {
|
||||
public class Config extends AbstractReactiveMongoConfiguration {
|
||||
|
||||
@Bean
|
||||
ReactiveMongoTransactionManager transactionManager(ReactiveDatabaseFactory factory) { <1>
|
||||
ReactiveMongoTransactionManager transactionManager(ReactiveMongoDatabaseFactory factory) { <1>
|
||||
return new ReactiveMongoTransactionManager(factory);
|
||||
}
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ static class Patient {
|
||||
|
||||
[TIP]
|
||||
====
|
||||
The `@Encrypted` Annoation supports resolving keyIds via SpEL Expressions.
|
||||
The `@Encrypted` Annotation supports resolving keyIds via SpEL Expressions.
|
||||
To do so additional environment metadata (via the `MappingContext`) is required and must be provided.
|
||||
|
||||
[source,java]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Spring Data MongoDB 3.4.3 (2021.2.3)
|
||||
Spring Data MongoDB 3.4.5 (2021.2.5)
|
||||
Copyright (c) [2010-2019] Pivotal Software, Inc.
|
||||
|
||||
This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
||||
@@ -38,6 +38,8 @@ conditions of the subcomponent's license, as noted in the LICENSE file.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user