diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/DBObjectTestUtils.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/DocumentTestUtils.java similarity index 94% rename from spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/DBObjectTestUtils.java rename to spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/DocumentTestUtils.java index 15b566e7a..533146753 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/DBObjectTestUtils.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/DocumentTestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2012 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,12 +28,11 @@ import com.mongodb.BasicDBList; * Helper classes to ease assertions on {@link Document}s. * * @author Oliver Gierke + * @author Mark Paluch */ -public abstract class DBObjectTestUtils { +public abstract class DocumentTestUtils { - private DBObjectTestUtils() { - - } + private DocumentTestUtils() {} /** * Expects the field with the given key to be not {@literal null} and a {@link Document} in turn and returns it. diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java index 7e36593f6..9bcd66747 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateTests.java @@ -1493,10 +1493,10 @@ public class MongoTemplateTests { @Test public void doesNotFailOnVersionInitForUnversionedEntity() { - org.bson.Document dbObject = new org.bson.Document(); - dbObject.put("firstName", "Oliver"); + org.bson.Document document = new org.bson.Document(); + document.put("firstName", "Oliver"); - template.insert(dbObject, template.determineCollectionName(PersonWithVersionPropertyOfTypeInteger.class)); + template.insert(document, template.determineCollectionName(PersonWithVersionPropertyOfTypeInteger.class)); } /** @@ -1548,12 +1548,12 @@ public class MongoTemplateTests { * @see DATAMONGO-550 */ @Test - public void savesPlainDbObjectCorrectly() { + public void savesPlainDocumentCorrectly() { - org.bson.Document dbObject = new org.bson.Document("foo", "bar"); - template.save(dbObject, "collection"); + org.bson.Document document = new org.bson.Document("foo", "bar"); + template.save(document, "collection"); - assertThat(dbObject.containsKey("_id"), is(true)); + assertThat(document.containsKey("_id"), is(true)); } /** @@ -1562,24 +1562,24 @@ public class MongoTemplateTests { @Test(expected = InvalidDataAccessApiUsageException.class) public void rejectsPlainObjectWithOutExplicitCollection() { - org.bson.Document dbObject = new org.bson.Document("foo", "bar"); - template.save(dbObject, "collection"); + org.bson.Document document = new org.bson.Document("foo", "bar"); + template.save(document, "collection"); - template.findById(dbObject.get("_id"), org.bson.Document.class); + template.findById(document.get("_id"), org.bson.Document.class); } /** * @see DATAMONGO-550 */ @Test - public void readsPlainDbObjectById() { + public void readsPlainDocumentById() { - org.bson.Document dbObject = new org.bson.Document("foo", "bar"); - template.save(dbObject, "collection"); + org.bson.Document document = new org.bson.Document("foo", "bar"); + template.save(document, "collection"); - org.bson.Document result = template.findById(dbObject.get("_id"), org.bson.Document.class, "collection"); - assertThat(result.get("foo"), is(dbObject.get("foo"))); - assertThat(result.get("_id"), is(dbObject.get("_id"))); + org.bson.Document result = template.findById(document.get("_id"), org.bson.Document.class, "collection"); + assertThat(result.get("foo"), is(document.get("foo"))); + assertThat(result.get("_id"), is(document.get("_id"))); } /** @@ -1741,9 +1741,9 @@ public class MongoTemplateTests { @Test public void savesJsonStringCorrectly() { - org.bson.Document dbObject = new org.bson.Document().append("first", "first").append("second", "second"); + org.bson.Document document = new org.bson.Document().append("first", "first").append("second", "second"); - template.save(dbObject, "collection"); + template.save(document, "collection"); List result = template.findAll(org.bson.Document.class, "collection"); assertThat(result.size(), is(1)); @@ -2998,7 +2998,7 @@ public class MongoTemplateTests { * @see DATAMONGO-970 */ @Test - public void insertsAndRemovesBasicDbObjectCorrectly() { + public void insertsAndRemovesBasicDocumentCorrectly() { org.bson.Document object = new org.bson.Document("key", "value"); template.insert(object, "collection"); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateUnitTests.java index e6ef278ab..84bca0031 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/MongoTemplateUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 the original author or authors. + * Copyright 2010-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -340,7 +340,7 @@ public class MongoTemplateUnitTests extends MongoOperationsUnitTests { verify(collection, times(1)).deleteMany(queryCaptor.capture()); - Document idField = DBObjectTestUtils.getAsDocument(queryCaptor.getValue(), "_id"); + Document idField = DocumentTestUtils.getAsDocument(queryCaptor.getValue(), "_id"); assertThat((List) idField.get("$in"), IsIterableContainingInOrder. contains(Integer.valueOf(0), Integer.valueOf(1))); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/PersonWriteConverter.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/PersonWriteConverter.java index 67a77c978..ae211425c 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/PersonWriteConverter.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/PersonWriteConverter.java @@ -1,16 +1,36 @@ +/* + * Copyright 2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.data.mongodb.core; import org.bson.Document; import org.springframework.core.convert.converter.Converter; +/** + * @author Thomas Risberg + * @author Oliver Gierke + * @author Christoph Strobl + * @author Mark Paluch + */ public class PersonWriteConverter implements Converter { public Document convert(Person source) { - Document dbo = new Document(); - dbo.put("_id", source.getId()); - dbo.put("name", source.getFirstName()); - dbo.put("age", source.getAge()); - return dbo; + Document document = new Document(); + document.put("_id", source.getId()); + document.put("name", source.getFirstName()); + document.put("age", source.getAge()); + return document; } - } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/SerializationUtilsUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/SerializationUtilsUnitTests.java index b8f67a9f0..56a452fcf 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/SerializationUtilsUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/SerializationUtilsUnitTests.java @@ -40,27 +40,27 @@ public class SerializationUtilsUnitTests { @Test public void writesSimpleDocument() { - Document dbObject = new Document("foo", "bar"); - assertThat(serializeToJsonSafely(dbObject), is("{ \"foo\" : \"bar\"}")); + Document document = new Document("foo", "bar"); + assertThat(serializeToJsonSafely(document), is("{ \"foo\" : \"bar\"}")); } @Test public void writesComplexObjectAsPlainToString() { - Document dbObject = new Document("foo", new Complex()); - assertThat(serializeToJsonSafely(dbObject), + Document document = new Document("foo", new Complex()); + assertThat(serializeToJsonSafely(document), startsWith("{ \"foo\" : { $java : org.springframework.data.mongodb.core.SerializationUtilsUnitTests$Complex")); } @Test public void writesCollection() { - Document dbObject = new Document("foo", Arrays.asList("bar", new Complex())); + Document document = new Document("foo", Arrays.asList("bar", new Complex())); Matcher expectedOutput = allOf( startsWith( "{ \"foo\" : [ \"bar\", { $java : org.springframework.data.mongodb.core.SerializationUtilsUnitTests$Complex"), endsWith(" } ] }")); - assertThat(serializeToJsonSafely(dbObject), is(expectedOutput)); + assertThat(serializeToJsonSafely(document), is(expectedOutput)); } /** @@ -69,12 +69,12 @@ public class SerializationUtilsUnitTests { @Test public void flattenMapShouldFlatOutNestedStructureCorrectly() { - Document dbo = new Document(); - dbo.put("_id", 1); - dbo.put("nested", new Document("value", "conflux")); + Document document = new Document(); + document.put("_id", 1); + document.put("nested", new Document("value", "conflux")); - assertThat(flattenMap(dbo), hasEntry("_id", (Object) 1)); - assertThat(flattenMap(dbo), hasEntry("nested.value", (Object) "conflux")); + assertThat(flattenMap(document), hasEntry("_id", (Object) 1)); + assertThat(flattenMap(document), hasEntry("nested.value", (Object) "conflux")); } /** @@ -86,12 +86,12 @@ public class SerializationUtilsUnitTests { BasicDBList dbl = new BasicDBList(); dbl.addAll(Arrays.asList("nightwielder", "calamity")); - Document dbo = new Document(); - dbo.put("_id", 1); - dbo.put("nested", new Document("value", dbl)); + Document document = new Document(); + document.put("_id", 1); + document.put("nested", new Document("value", dbl)); - assertThat(flattenMap(dbo), hasEntry("_id", (Object) 1)); - assertThat(flattenMap(dbo), hasEntry("nested.value", (Object) dbl)); + assertThat(flattenMap(document), hasEntry("_id", (Object) 1)); + assertThat(flattenMap(document), hasEntry("nested.value", (Object) dbl)); } /** @@ -100,11 +100,11 @@ public class SerializationUtilsUnitTests { @Test public void flattenMapShouldLeaveKeywordsUntouched() { - Document dbo = new Document(); - dbo.put("_id", 1); - dbo.put("nested", new Document("$regex", "^conflux$")); + Document document = new Document(); + document.put("_id", 1); + document.put("nested", new Document("$regex", "^conflux$")); - Map map = flattenMap(dbo); + Map map = flattenMap(document); assertThat(map, hasEntry("_id", (Object) 1)); assertThat(map.get("nested"), notNullValue()); @@ -117,14 +117,14 @@ public class SerializationUtilsUnitTests { @Test public void flattenMapShouldAppendCommandsCorrectly() { - Document dbo = new Document(); + Document document = new Document(); Document nested = new Document(); nested.put("$regex", "^conflux$"); nested.put("$options", "i"); - dbo.put("_id", 1); - dbo.put("nested", nested); + document.put("_id", 1); + document.put("nested", nested); - Map map = flattenMap(dbo); + Map map = flattenMap(document); assertThat(map, hasEntry("_id", (Object) 1)); assertThat(map.get("nested"), notNullValue()); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/UnwrapAndReadDbObjectCallbackUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/UnwrapAndReadDocumentCallbackUnitTests.java similarity index 93% rename from spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/UnwrapAndReadDbObjectCallbackUnitTests.java rename to spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/UnwrapAndReadDocumentCallbackUnitTests.java index e184cd410..c0cf0dcd2 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/UnwrapAndReadDbObjectCallbackUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/UnwrapAndReadDocumentCallbackUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,9 +34,10 @@ import org.springframework.data.mongodb.core.mapping.MongoMappingContext; * Unit tests for {@link UnwrapAndReadDocumentCallback}. * * @author Oliver Gierke + * @author Mark Paluch */ @RunWith(MockitoJUnitRunner.class) -public class UnwrapAndReadDbObjectCallbackUnitTests { +public class UnwrapAndReadDocumentCallbackUnitTests { @Mock MongoDbFactory factory; @@ -62,7 +63,7 @@ public class UnwrapAndReadDbObjectCallbackUnitTests { } @Test - public void unwrapsUnderscoreIdIfBasicDocument() { + public void unwrapsUnderscoreIdIfDocument() { Target target = callback.doWith(new Document("_id", new Document("foo", "bar"))); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationTests.java index b44b54edd..9d94cfb5f 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationTests.java @@ -986,14 +986,14 @@ public class AggregationTests { ); AggregationResults results = mongoTemplate.aggregate(agg, Document.class); - Document dbo = results.getUniqueMappedResult(); + Document document = results.getUniqueMappedResult(); - assertThat(dbo, is(notNullValue())); - assertThat((String) dbo.get("concat"), is("ABCDE")); - assertThat((Integer) dbo.get("strcasecmp"), is(-1)); - assertThat((String) dbo.get("substr"), is("B")); - assertThat((String) dbo.get("toLower"), is("abc")); - assertThat((String) dbo.get("toUpper"), is("ABC")); + assertThat(document, is(notNullValue())); + assertThat((String) document.get("concat"), is("ABCDE")); + assertThat((Integer) document.get("strcasecmp"), is(-1)); + assertThat((String) document.get("substr"), is("B")); + assertThat((String) document.get("toLower"), is("abc")); + assertThat((String) document.get("toUpper"), is("ABC")); } /** @@ -1023,19 +1023,19 @@ public class AggregationTests { ); AggregationResults results = mongoTemplate.aggregate(agg, Document.class); - Document dbo = results.getUniqueMappedResult(); + Document document = results.getUniqueMappedResult(); - assertThat(dbo, is(notNullValue())); - assertThat((Integer) dbo.get("dayOfYear"), is(241)); - assertThat((Integer) dbo.get("dayOfMonth"), is(29)); - assertThat((Integer) dbo.get("dayOfWeek"), is(2)); - assertThat((Integer) dbo.get("year"), is(1983)); - assertThat((Integer) dbo.get("month"), is(8)); - assertThat((Integer) dbo.get("week"), is(35)); - assertThat((Integer) dbo.get("hour"), is(12)); - assertThat((Integer) dbo.get("minute"), is(34)); - assertThat((Integer) dbo.get("second"), is(56)); - assertThat((Integer) dbo.get("millisecond"), is(789)); + assertThat(document, is(notNullValue())); + assertThat((Integer) document.get("dayOfYear"), is(241)); + assertThat((Integer) document.get("dayOfMonth"), is(29)); + assertThat((Integer) document.get("dayOfWeek"), is(2)); + assertThat((Integer) document.get("year"), is(1983)); + assertThat((Integer) document.get("month"), is(8)); + assertThat((Integer) document.get("week"), is(35)); + assertThat((Integer) document.get("hour"), is(12)); + assertThat((Integer) document.get("minute"), is(34)); + assertThat((Integer) document.get("second"), is(56)); + assertThat((Integer) document.get("millisecond"), is(789)); } /** @@ -1316,23 +1316,23 @@ public class AggregationTests { AggregationResults result = mongoTemplate.aggregate(agg, ObjectWithDate.class, Document.class); assertThat(result.getMappedResults(), hasSize(1)); - Document dbo = result.getMappedResults().get(0); + Document document = result.getMappedResults().get(0); - assertThat(dbo.get("hour"), is((Object) dateTime.getHourOfDay())); - assertThat(dbo.get("min"), is((Object) dateTime.getMinuteOfHour())); - assertThat(dbo.get("second"), is((Object) dateTime.getSecondOfMinute())); - assertThat(dbo.get("millis"), is((Object) dateTime.getMillisOfSecond())); - assertThat(dbo.get("year"), is((Object) dateTime.getYear())); - assertThat(dbo.get("month"), is((Object) dateTime.getMonthOfYear())); + assertThat(document.get("hour"), is((Object) dateTime.getHourOfDay())); + assertThat(document.get("min"), is((Object) dateTime.getMinuteOfHour())); + assertThat(document.get("second"), is((Object) dateTime.getSecondOfMinute())); + assertThat(document.get("millis"), is((Object) dateTime.getMillisOfSecond())); + assertThat(document.get("year"), is((Object) dateTime.getYear())); + assertThat(document.get("month"), is((Object) dateTime.getMonthOfYear())); // dateTime.getWeekOfWeekyear()) returns 6 since for MongoDB the week starts on sunday and not on monday. - assertThat(dbo.get("week"), is((Object) 5)); - assertThat(dbo.get("dayOfYear"), is((Object) dateTime.getDayOfYear())); - assertThat(dbo.get("dayOfMonth"), is((Object) dateTime.getDayOfMonth())); + assertThat(document.get("week"), is((Object) 5)); + assertThat(document.get("dayOfYear"), is((Object) dateTime.getDayOfYear())); + assertThat(document.get("dayOfMonth"), is((Object) dateTime.getDayOfMonth())); // dateTime.getDayOfWeek() - assertThat(dbo.get("dayOfWeek"), is((Object) 6)); - assertThat(dbo.get("dayOfYearPlus1Day"), is((Object) dateTime.plusDays(1).getDayOfYear())); - assertThat(dbo.get("dayOfYearPlus1DayManually"), is((Object) dateTime.plusDays(1).getDayOfYear())); + assertThat(document.get("dayOfWeek"), is((Object) 6)); + assertThat(document.get("dayOfYearPlus1Day"), is((Object) dateTime.plusDays(1).getDayOfYear())); + assertThat(document.get("dayOfYearPlus1DayManually"), is((Object) dateTime.plusDays(1).getDayOfYear())); } /** diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationUnitTests.java index bb6037b08..2a9f3263d 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/AggregationUnitTests.java @@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core.aggregation; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; -import static org.springframework.data.mongodb.core.DBObjectTestUtils.*; +import static org.springframework.data.mongodb.core.DocumentTestUtils.*; import static org.springframework.data.mongodb.core.aggregation.Aggregation.*; import static org.springframework.data.mongodb.core.aggregation.Fields.*; import static org.springframework.data.mongodb.core.query.Criteria.*; diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ConditionalOperatorUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ConditionalOperatorUnitTests.java index 165a16c8f..f7a7c3098 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ConditionalOperatorUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ConditionalOperatorUnitTests.java @@ -25,8 +25,6 @@ import org.bson.Document; import org.junit.Test; import org.springframework.data.mongodb.core.query.Criteria; -import com.mongodb.DBObject; - /** * Unit tests for {@link ConditionalOperator}. * @@ -98,14 +96,14 @@ public class ConditionalOperatorUnitTests { public void simpleBuilderShouldRenderCorrectly() { ConditionalOperator operator = newBuilder().when("isYellow").then("bright").otherwise("dark"); - Document dbObject = operator.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operator.toDocument(Aggregation.DEFAULT_CONTEXT); Document expectedCondition = new Document() // .append("if", "$isYellow") // .append("then", "bright") // .append("else", "dark"); - assertThat(dbObject, isBsonObject().containing("$cond", expectedCondition)); + assertThat(document, isBsonObject().containing("$cond", expectedCondition)); } /** @@ -116,14 +114,14 @@ public class ConditionalOperatorUnitTests { ConditionalOperator operator = newBuilder().when(Criteria.where("luminosity").gte(100)).then("bright") .otherwise("dark"); - Document dbObject = operator.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operator.toDocument(Aggregation.DEFAULT_CONTEXT); - Document expectedCondition = new Document () // - .append("if", new Document ("$gte", Arrays. asList("$luminosity", 100))) // + Document expectedCondition = new Document() // + .append("if", new Document("$gte", Arrays. asList("$luminosity", 100))) // .append("then", "bright") // .append("else", "dark"); - assertThat(dbObject, isBsonObject().containing("$cond", expectedCondition)); + assertThat(document, isBsonObject().containing("$cond", expectedCondition)); } /** @@ -138,18 +136,18 @@ public class ConditionalOperatorUnitTests { Criteria.where("saturation").lt(11))) .then("bright").otherwise("dark"); - Document dbObject = operator.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operator.toDocument(Aggregation.DEFAULT_CONTEXT); - Document luminosity = new Document ("$gte", Arrays. asList("$luminosity", 100)); - Document hue = new Document ("$eq", Arrays. asList("$hue", 50)); - Document saturation = new Document ("$lt", Arrays. asList("$saturation", 11)); + Document luminosity = new Document("$gte", Arrays. asList("$luminosity", 100)); + Document hue = new Document("$eq", Arrays. asList("$hue", 50)); + Document saturation = new Document("$lt", Arrays. asList("$saturation", 11)); - Document expectedCondition = new Document () // - .append("if", Arrays. asList(luminosity, new Document ("$and", Arrays.asList(hue, saturation)))) // + Document expectedCondition = new Document() // + .append("if", Arrays. asList(luminosity, new Document("$and", Arrays.asList(hue, saturation)))) // .append("then", "bright") // .append("else", "dark"); - assertThat(dbObject, isBsonObject().containing("$cond", expectedCondition)); + assertThat(document, isBsonObject().containing("$cond", expectedCondition)); } /** @@ -162,17 +160,17 @@ public class ConditionalOperatorUnitTests { .and("saturation").and("chroma").is(200); ConditionalOperator operator = newBuilder().when(criteria).then("bright").otherwise("dark"); - Document dbObject = operator.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operator.toDocument(Aggregation.DEFAULT_CONTEXT); - Document gte = new Document ("$gte", Arrays. asList("$luminosity", 100)); - Document is = new Document ("$eq", Arrays. asList("$chroma", 200)); + Document gte = new Document("$gte", Arrays. asList("$luminosity", 100)); + Document is = new Document("$eq", Arrays. asList("$chroma", 200)); - Document expectedCondition = new Document () // + Document expectedCondition = new Document() // .append("if", Arrays.asList(gte, is)) // .append("then", "bright") // .append("else", "dark"); - assertThat(dbObject, isBsonObject().containing("$cond", expectedCondition)); + assertThat(document, isBsonObject().containing("$cond", expectedCondition)); } /** @@ -192,19 +190,19 @@ public class ConditionalOperatorUnitTests { .then("very-dark") // .otherwise("not-so-dark")); - Document dbObject = operator.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operator.toDocument(Aggregation.DEFAULT_CONTEXT); - Document trueCondition = new Document () // - .append("if", new Document ("$gte", Arrays. asList("$luminosity", 200))) // + Document trueCondition = new Document() // + .append("if", new Document("$gte", Arrays. asList("$luminosity", 200))) // .append("then", "verybright") // .append("else", "not-so-bright"); - Document falseCondition = new Document () // - .append("if", new Document ("$lt", Arrays. asList("$luminosity", 50))) // + Document falseCondition = new Document() // + .append("if", new Document("$lt", Arrays. asList("$luminosity", 50))) // .append("then", "very-dark") // .append("else", "not-so-dark"); - assertThat(dbObject, isBsonObject().containing("$cond.then.$cond", trueCondition)); - assertThat(dbObject, isBsonObject().containing("$cond.else.$cond", falseCondition)); + assertThat(document, isBsonObject().containing("$cond.then.$cond", trueCondition)); + assertThat(document, isBsonObject().containing("$cond.else.$cond", falseCondition)); } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/GeoNearOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/GeoNearOperationUnitTests.java index 6160e0737..a4f2a5eb9 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/GeoNearOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/GeoNearOperationUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import static org.junit.Assert.*; import org.bson.Document; import org.junit.Test; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.mongodb.core.query.NearQuery; /** @@ -39,9 +39,9 @@ public class GeoNearOperationUnitTests { NearQuery query = NearQuery.near(10.0, 10.0); GeoNearOperation operation = new GeoNearOperation(query, "distance"); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document nearClause = DBObjectTestUtils.getAsDocument(dbObject, "$geoNear"); + Document nearClause = DocumentTestUtils.getAsDocument(document, "$geoNear"); Document expected = new Document(query.toDocument()).append("distanceField", "distance"); assertThat(nearClause, is(expected)); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/GroupOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/GroupOperationUnitTests.java index 0d400dc2a..29fb62700 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/GroupOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/GroupOperationUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2015 the original author or authors. + * Copyright 2013-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import java.util.Arrays; import org.bson.Document; import org.junit.Test; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; /** * Unit tests for {@link GroupOperation}. @@ -47,7 +47,7 @@ public class GroupOperationUnitTests { GroupOperation operation = new GroupOperation(Fields.from()); ExposedFields fields = operation.getFields(); - Document groupClause = extractDbObjectFromGroupOperation(operation); + Document groupClause = extractDocumentFromGroupOperation(operation); assertThat(fields.exposesSingleFieldOnly(), is(true)); assertThat(fields.exposesNoFields(), is(false)); @@ -62,7 +62,7 @@ public class GroupOperationUnitTests { GroupOperation operation = new GroupOperation(Fields.from()).count().as("cnt").last("foo").as("foo"); ExposedFields fields = operation.getFields(); - Document groupClause = extractDbObjectFromGroupOperation(operation); + Document groupClause = extractDocumentFromGroupOperation(operation); assertThat(fields.exposesSingleFieldOnly(), is(false)); assertThat(fields.exposesNoFields(), is(false)); @@ -76,7 +76,7 @@ public class GroupOperationUnitTests { GroupOperation operation = new GroupOperation(fields("a")); - Document groupClause = extractDbObjectFromGroupOperation(operation); + Document groupClause = extractDocumentFromGroupOperation(operation); assertThat(groupClause.get(UNDERSCORE_ID), is((Object) "$a")); } @@ -86,8 +86,8 @@ public class GroupOperationUnitTests { GroupOperation operation = new GroupOperation(fields("a").and("b", "c")); - Document groupClause = extractDbObjectFromGroupOperation(operation); - Document idClause = DBObjectTestUtils.getAsDocument(groupClause, UNDERSCORE_ID); + Document groupClause = extractDocumentFromGroupOperation(operation); + Document idClause = DocumentTestUtils.getAsDocument(groupClause, UNDERSCORE_ID); assertThat(idClause.get("a"), is((Object) "$a")); assertThat(idClause.get("b"), is((Object) "$c")); @@ -99,8 +99,8 @@ public class GroupOperationUnitTests { GroupOperation groupOperation = Aggregation.group(fields("a", "b").and("c")) // .sum("e").as("e"); - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document eOp = DBObjectTestUtils.getAsDocument(groupClause, "e"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document eOp = DocumentTestUtils.getAsDocument(groupClause, "e"); assertThat(eOp, is((Document) new Document("$sum", "$e"))); } @@ -110,8 +110,8 @@ public class GroupOperationUnitTests { GroupOperation groupOperation = Aggregation.group(fields("a", "b").and("c")) // .sum("e").as("ee"); - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document eOp = DBObjectTestUtils.getAsDocument(groupClause, "ee"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document eOp = DocumentTestUtils.getAsDocument(groupClause, "ee"); assertThat(eOp, is((Document) new Document("$sum", "$e"))); } @@ -121,8 +121,8 @@ public class GroupOperationUnitTests { GroupOperation groupOperation = Aggregation.group(fields("a", "b").and("c")) // .count().as("count"); - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document eOp = DBObjectTestUtils.getAsDocument(groupClause, "count"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document eOp = DocumentTestUtils.getAsDocument(groupClause, "count"); assertThat(eOp, is((Document) new Document("$sum", 1))); } @@ -133,11 +133,11 @@ public class GroupOperationUnitTests { .sum("e").as("sum") // .min("e").as("min"); // - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document sum = DBObjectTestUtils.getAsDocument(groupClause, "sum"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document sum = DocumentTestUtils.getAsDocument(groupClause, "sum"); assertThat(sum, is((Document) new Document("$sum", "$e"))); - Document min = DBObjectTestUtils.getAsDocument(groupClause, "min"); + Document min = DocumentTestUtils.getAsDocument(groupClause, "min"); assertThat(min, is((Document) new Document("$min", "$e"))); } @@ -146,8 +146,8 @@ public class GroupOperationUnitTests { GroupOperation groupOperation = Aggregation.group("a", "b").push(1).as("x"); - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document push = DBObjectTestUtils.getAsDocument(groupClause, "x"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document push = DocumentTestUtils.getAsDocument(groupClause, "x"); assertThat(push, is((Document) new Document("$push", 1))); } @@ -157,8 +157,8 @@ public class GroupOperationUnitTests { GroupOperation groupOperation = Aggregation.group("a", "b").push("ref").as("x"); - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document push = DBObjectTestUtils.getAsDocument(groupClause, "x"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document push = DocumentTestUtils.getAsDocument(groupClause, "x"); assertThat(push, is((Document) new Document("$push", "$ref"))); } @@ -168,8 +168,8 @@ public class GroupOperationUnitTests { GroupOperation groupOperation = Aggregation.group("a", "b").addToSet("ref").as("x"); - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document push = DBObjectTestUtils.getAsDocument(groupClause, "x"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document push = DocumentTestUtils.getAsDocument(groupClause, "x"); assertThat(push, is((Document) new Document("$addToSet", "$ref"))); } @@ -179,8 +179,8 @@ public class GroupOperationUnitTests { GroupOperation groupOperation = Aggregation.group("a", "b").addToSet(42).as("x"); - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document push = DBObjectTestUtils.getAsDocument(groupClause, "x"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document push = DocumentTestUtils.getAsDocument(groupClause, "x"); assertThat(push, is((Document) new Document("$addToSet", 42))); } @@ -196,15 +196,15 @@ public class GroupOperationUnitTests { .first(SIZE.of(field("tags"))) // .as("tags_count"); - Document groupClause = extractDbObjectFromGroupOperation(groupOperation); - Document tagsCount = DBObjectTestUtils.getAsDocument(groupClause, "tags_count"); + Document groupClause = extractDocumentFromGroupOperation(groupOperation); + Document tagsCount = DocumentTestUtils.getAsDocument(groupClause, "tags_count"); assertThat(tagsCount.get("$first"), is((Object) new Document("$size", Arrays.asList("$tags")))); } - private Document extractDbObjectFromGroupOperation(GroupOperation groupOperation) { - Document dbObject = groupOperation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document groupClause = DBObjectTestUtils.getAsDocument(dbObject, "$group"); + private Document extractDocumentFromGroupOperation(GroupOperation groupOperation) { + Document document = groupOperation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document groupClause = DocumentTestUtils.getAsDocument(document, "$group"); return groupClause; } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/IfNullOperatorUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/IfNullOperatorUnitTests.java index 660a1e27f..5a72d977c 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/IfNullOperatorUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/IfNullOperatorUnitTests.java @@ -58,9 +58,9 @@ public class IfNullOperatorUnitTests { .ifNull("optional") // .thenReplaceWith("a more sophisticated value"); - Document dbObject = operator.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operator.toDocument(Aggregation.DEFAULT_CONTEXT); - assertThat(dbObject, + assertThat(document, isBsonObject().containing("$ifNull", Arrays. asList("$optional", "a more sophisticated value"))); } @@ -74,8 +74,8 @@ public class IfNullOperatorUnitTests { .ifNull(Fields.field("optional")) // .thenReplaceWith(Fields.field("never-null")); - Document dbObject = operator.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operator.toDocument(Aggregation.DEFAULT_CONTEXT); - assertThat(dbObject, isBsonObject().containing("$ifNull", Arrays. asList("$optional", "$never-null"))); + assertThat(document, isBsonObject().containing("$ifNull", Arrays. asList("$optional", "$never-null"))); } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/LookupOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/LookupOperationUnitTests.java index 1037d3efa..0e423935a 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/LookupOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/LookupOperationUnitTests.java @@ -21,7 +21,7 @@ import static org.springframework.data.mongodb.test.util.IsBsonObject.*; import org.bson.Document; import org.junit.Test; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; /** * Unit tests for {@link LookupOperation}. @@ -72,7 +72,7 @@ public class LookupOperationUnitTests { LookupOperation lookupOperation = Aggregation.lookup("a", "b", "c", "d"); - Document lookupClause = extractDbObjectFromLookupOperation(lookupOperation); + Document lookupClause = extractDocumentFromLookupOperation(lookupOperation); assertThat(lookupClause, isBsonObject().containing("from", "a") // @@ -94,10 +94,10 @@ public class LookupOperationUnitTests { assertThat(lookupOperation.getFields().getField("d"), notNullValue()); } - private Document extractDbObjectFromLookupOperation(LookupOperation lookupOperation) { + private Document extractDocumentFromLookupOperation(LookupOperation lookupOperation) { - Document dbObject = lookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document lookupClause = DBObjectTestUtils.getAsDocument(dbObject, "$lookup"); + Document document = lookupOperation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document lookupClause = DocumentTestUtils.getAsDocument(document, "$lookup"); return lookupClause; } @@ -141,7 +141,7 @@ public class LookupOperationUnitTests { LookupOperation lookupOperation = LookupOperation.newLookup().from("a").localField("b").foreignField("c").as("d"); - Document lookupClause = extractDbObjectFromLookupOperation(lookupOperation); + Document lookupClause = extractDocumentFromLookupOperation(lookupOperation); assertThat(lookupClause, isBsonObject().containing("from", "a") // diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ProjectionOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ProjectionOperationUnitTests.java index ae4563458..3425cbf9b 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ProjectionOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/ProjectionOperationUnitTests.java @@ -25,7 +25,7 @@ import java.util.List; import org.bson.Document; import org.junit.Test; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.mongodb.core.aggregation.ProjectionOperation.ProjectionOperationBuilder; /** @@ -55,8 +55,8 @@ public class ProjectionOperationUnitTests { ProjectionOperation operation = new ProjectionOperation(); operation = operation.and("prop").previousOperation(); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); assertThat(projectClause.get("prop"), is((Object) Fields.UNDERSCORE_ID_REF)); } @@ -65,8 +65,8 @@ public class ProjectionOperationUnitTests { ProjectionOperation operation = new ProjectionOperation(Fields.fields("foo").and("bar", "foobar")); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); assertThat(projectClause.get("foo"), is((Object) 1)); assertThat(projectClause.get("bar"), is((Object) "$foobar")); @@ -77,8 +77,8 @@ public class ProjectionOperationUnitTests { ProjectionOperation operation = new ProjectionOperation(); - Document dbObject = operation.and("foo").as("bar").toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.and("foo").as("bar").toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); assertThat(projectClause.get("bar"), is((Object) "$foo")); } @@ -88,9 +88,9 @@ public class ProjectionOperationUnitTests { ProjectionOperation operation = new ProjectionOperation(); - Document dbObject = operation.and("foo").plus(41).as("bar").toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); - Document barClause = DBObjectTestUtils.getAsDocument(projectClause, "bar"); + Document document = operation.and("foo").plus(41).as("bar").toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); + Document barClause = DocumentTestUtils.getAsDocument(projectClause, "bar"); List addClause = (List) barClause.get("$add"); assertThat(addClause, hasSize(2)); @@ -102,8 +102,8 @@ public class ProjectionOperationUnitTests { String fieldName = "a"; ProjectionOperationBuilder operation = new ProjectionOperation().and(fieldName).plus(1); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); Document oper = exctractOperation(fieldName, projectClause); assertThat(oper.containsKey(ADD), is(true)); @@ -116,8 +116,8 @@ public class ProjectionOperationUnitTests { String fieldName = "a"; String fieldAlias = "b"; ProjectionOperation operation = new ProjectionOperation().and(fieldName).plus(1).as(fieldAlias); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); Document oper = exctractOperation(fieldAlias, projectClause); assertThat(oper.containsKey(ADD), is(true)); @@ -130,8 +130,8 @@ public class ProjectionOperationUnitTests { String fieldName = "a"; String fieldAlias = "b"; ProjectionOperation operation = new ProjectionOperation().and(fieldName).minus(1).as(fieldAlias); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); Document oper = exctractOperation(fieldAlias, projectClause); assertThat(oper.containsKey(SUBTRACT), is(true)); @@ -144,8 +144,8 @@ public class ProjectionOperationUnitTests { String fieldName = "a"; String fieldAlias = "b"; ProjectionOperation operation = new ProjectionOperation().and(fieldName).multiply(1).as(fieldAlias); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); Document oper = exctractOperation(fieldAlias, projectClause); assertThat(oper.containsKey(MULTIPLY), is(true)); @@ -158,8 +158,8 @@ public class ProjectionOperationUnitTests { String fieldName = "a"; String fieldAlias = "b"; ProjectionOperation operation = new ProjectionOperation().and(fieldName).divide(1).as(fieldAlias); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); Document oper = exctractOperation(fieldAlias, projectClause); assertThat(oper.containsKey(DIVIDE), is(true)); @@ -178,8 +178,8 @@ public class ProjectionOperationUnitTests { String fieldName = "a"; String fieldAlias = "b"; ProjectionOperation operation = new ProjectionOperation().and(fieldName).mod(3).as(fieldAlias); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); Document oper = exctractOperation(fieldAlias, projectClause); assertThat(oper.containsKey(MOD), is(true)); @@ -202,8 +202,8 @@ public class ProjectionOperationUnitTests { public void excludeShouldAllowExclusionOfUnderscoreId() { ProjectionOperation projectionOp = new ProjectionOperation().andExclude(Fields.UNDERSCORE_ID); - Document dbObject = projectionOp.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = projectionOp.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); assertThat((Integer) projectClause.get(Fields.UNDERSCORE_ID), is(0)); } @@ -216,8 +216,8 @@ public class ProjectionOperationUnitTests { ProjectionOperation operation = Aggregation.project("foo").and("foobar").as("bar").andInclude("inc1", "inc2") .andExclude("_id"); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); assertThat(projectClause.get("foo"), is((Object) 1)); // implicit assertThat(projectClause.get("bar"), is((Object) "$foobar")); // explicit @@ -245,8 +245,8 @@ public class ProjectionOperationUnitTests { .and("foo").divide("bar").as("fooDivideBar") // .and("foo").mod("bar").as("fooModBar"); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projectClause = DBObjectTestUtils.getAsDocument(dbObject, PROJECT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projectClause = DocumentTestUtils.getAsDocument(document, PROJECT); assertThat((Document) projectClause.get("fooPlusBar"), // is(new Document("$add", Arrays.asList("$foo", "$bar")))); @@ -270,8 +270,8 @@ public class ProjectionOperationUnitTests { .andExpression("(netPrice + surCharge) * taxrate * [0]", 2).as("grossSalesPrice") // .and("foo").as("bar"); // - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - assertThat(dbObject, is(Document.parse( + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + assertThat(document, is(Document.parse( "{ \"$project\" : { \"grossSalesPrice\" : { \"$multiply\" : [ { \"$add\" : [ \"$netPrice\" , \"$surCharge\"]} , \"$taxrate\" , 2]} , \"bar\" : \"$foo\"}}"))); } @@ -294,10 +294,10 @@ public class ProjectionOperationUnitTests { .and("date").extractDayOfWeek().as("dayOfWeek") // ; - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - assertThat(dbObject, is(notNullValue())); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + assertThat(document, is(notNullValue())); - Document projected = exctractOperation("$project", dbObject); + Document projected = exctractOperation("$project", document); assertThat(projected.get("hour"), is((Object) new Document("$hour", Arrays.asList("$date")))); assertThat(projected.get("min"), is((Object) new Document("$minute", Arrays.asList("$date")))); @@ -323,10 +323,10 @@ public class ProjectionOperationUnitTests { .as("dayOfYearPlus1Day") // ; - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - assertThat(dbObject, is(notNullValue())); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + assertThat(document, is(notNullValue())); - Document projected = exctractOperation("$project", dbObject); + Document projected = exctractOperation("$project", document); assertThat(projected.get("dayOfYearPlus1Day"), is((Object) new Document("$dayOfYear", Arrays.asList(new Document("$add", Arrays. asList("$date", 86400000)))))); } @@ -343,9 +343,9 @@ public class ProjectionOperationUnitTests { .size()// .as("tags_count"); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projected = exctractOperation("$project", dbObject); + Document projected = exctractOperation("$project", document); assertThat(projected.get("tags_count"), is((Object) new Document("$size", Arrays.asList("$tags")))); } @@ -360,9 +360,9 @@ public class ProjectionOperationUnitTests { .and(SIZE.of(field("tags"))) // .as("tags_count"); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projected = exctractOperation("$project", dbObject); + Document projected = exctractOperation("$project", document); assertThat(projected.get("tags_count"), is((Object) new Document("$size", Arrays.asList("$tags")))); } @@ -374,8 +374,8 @@ public class ProjectionOperationUnitTests { ProjectionOperation operation = Aggregation.project().and("field").slice(10).as("renamed"); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projected = exctractOperation("$project", dbObject); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projected = exctractOperation("$project", document); assertThat(projected.get("renamed"), is((Object) new Document("$slice", Arrays. asList("$field", 10)))); @@ -389,8 +389,8 @@ public class ProjectionOperationUnitTests { ProjectionOperation operation = Aggregation.project().and("field").slice(10, 5).as("renamed"); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document projected = exctractOperation("$project", dbObject); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document projected = exctractOperation("$project", document); assertThat(projected.get("renamed"), is((Object) new Document("$slice", Arrays. asList("$field", 5, 10)))); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/SkipOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/SkipOperationUnitTests.java index c0bd54364..397ec472d 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/SkipOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/SkipOperationUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,8 +39,8 @@ public class SkipOperationUnitTests { public void rendersSkipOperation() { SkipOperation operation = new SkipOperation(10L); - Document dbObject = operation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document document = operation.toDocument(Aggregation.DEFAULT_CONTEXT); - assertThat(dbObject.get(OP), is((Object) 10L)); + assertThat(document.get(OP), is((Object) 10L)); } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/SortOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/SortOperationUnitTests.java index 3c449a49f..7abaf7aca 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/SortOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/SortOperationUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core.aggregation; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; -import static org.springframework.data.mongodb.core.DBObjectTestUtils.*; +import static org.springframework.data.mongodb.core.DocumentTestUtils.*; import org.bson.Document; import org.junit.Test; diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java index 4f6b483d3..a05260300 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/TypeBasedAggregationOperationContextUnitTests.java @@ -160,16 +160,16 @@ public class TypeBasedAggregationOperationContextUnitTests { .withOptions( newAggregationOptions().allowDiskUse(true).explain(true).cursor(new org.bson.Document("foo", 1)).build()); - org.bson.Document dbo = agg.toDocument("person", context); + org.bson.Document document = agg.toDocument("person", context); - org.bson.Document projection = getPipelineElementFromAggregationAt(dbo, 0); + org.bson.Document projection = getPipelineElementFromAggregationAt(document, 0); assertThat(projection.containsKey("$project"), is(true)); assertThat(projection.get("$project"), is((Object) new org.bson.Document("name", 1).append("age", 1))); - assertThat(dbo.get("allowDiskUse"), is((Object) true)); - assertThat(dbo.get("explain"), is((Object) true)); - assertThat(dbo.get("cursor"), is((Object) new org.bson.Document("foo", 1))); + assertThat(document.get("allowDiskUse"), is((Object) true)); + assertThat(document.get("explain"), is((Object) true)); + assertThat(document.get("cursor"), is((Object) new org.bson.Document("foo", 1))); } /** @@ -182,8 +182,8 @@ public class TypeBasedAggregationOperationContextUnitTests { TypedAggregation agg = newAggregation(MeterData.class, group("counterName").sum("counterVolume").as("totalCounterVolume")); - org.bson.Document dbo = agg.toDocument("meterData", context); - org.bson.Document group = getPipelineElementFromAggregationAt(dbo, 0); + org.bson.Document document = agg.toDocument("meterData", context); + org.bson.Document group = getPipelineElementFromAggregationAt(document, 0); org.bson.Document definition = (org.bson.Document) group.get("$group"); @@ -200,8 +200,8 @@ public class TypeBasedAggregationOperationContextUnitTests { TypedAggregation agg = newAggregation(MeterData.class, lookup("OtherCollection", "resourceId", "otherId", "lookup"), sort(Direction.ASC, "resourceId")); - org.bson.Document dbo = agg.toDocument("meterData", context); - org.bson.Document sort = getPipelineElementFromAggregationAt(dbo, 1); + org.bson.Document document = agg.toDocument("meterData", context); + org.bson.Document sort = getPipelineElementFromAggregationAt(document, 1); org.bson.Document definition = (org.bson.Document) sort.get("$sort"); @@ -218,8 +218,8 @@ public class TypeBasedAggregationOperationContextUnitTests { TypedAggregation agg = newAggregation(MeterData.class, group().min("resourceId").as("foreignKey"), lookup("OtherCollection", "foreignKey", "otherId", "lookup"), sort(Direction.ASC, "foreignKey")); - org.bson.Document dbo = agg.toDocument("meterData", context); - org.bson.Document sort = getPipelineElementFromAggregationAt(dbo, 2); + org.bson.Document document = agg.toDocument("meterData", context); + org.bson.Document sort = getPipelineElementFromAggregationAt(document, 2); org.bson.Document definition = (org.bson.Document) sort.get("$sort"); @@ -237,8 +237,8 @@ public class TypeBasedAggregationOperationContextUnitTests { lookup("OtherCollection", "resourceId", "otherId", "lookup"), group().min("lookup.otherkey").as("something_totally_different")); - org.bson.Document dbo = agg.toDocument("meterData", context); - org.bson.Document group = getPipelineElementFromAggregationAt(dbo, 1); + org.bson.Document document = agg.toDocument("meterData", context); + org.bson.Document group = getPipelineElementFromAggregationAt(document, 1); org.bson.Document definition = (org.bson.Document) group.get("$group"); org.bson.Document field = (org.bson.Document) definition.get("something_totally_different"); @@ -258,8 +258,8 @@ public class TypeBasedAggregationOperationContextUnitTests { group().min("lookup.otherkey").as("something_totally_different"), sort(Direction.ASC, "something_totally_different")); - org.bson.Document dbo = agg.toDocument("meterData", context); - org.bson.Document sort = getPipelineElementFromAggregationAt(dbo, 2); + org.bson.Document document = agg.toDocument("meterData", context); + org.bson.Document sort = getPipelineElementFromAggregationAt(document, 2); org.bson.Document definition = (org.bson.Document) sort.get("$sort"); @@ -293,9 +293,9 @@ public class TypeBasedAggregationOperationContextUnitTests { .applyCondition(conditional(Criteria.where("age.value").lt(10), new Age(0), field("age"))) // ); - Document dbo = agg.toDocument("person", context); + Document document = agg.toDocument("person", context); - Document projection = getPipelineElementFromAggregationAt(dbo, 0); + Document projection = getPipelineElementFromAggregationAt(document, 0); assertThat(projection.containsKey("$project"), is(true)); Document project = getValue(projection, "$project"); @@ -319,9 +319,9 @@ public class TypeBasedAggregationOperationContextUnitTests { .applyCondition(ifNull("age", new Age(0))) // ); - Document dbo = agg.toDocument("person", context); + Document document = agg.toDocument("person", context); - Document projection = getPipelineElementFromAggregationAt(dbo, 0); + Document projection = getPipelineElementFromAggregationAt(document, 0); assertThat(projection.containsKey("$project"), is(true)); Document project = getValue(projection, "$project"); @@ -372,8 +372,8 @@ public class TypeBasedAggregationOperationContextUnitTests { Converter ageReadConverter() { return new Converter() { @Override - public Age convert(org.bson.Document dbObject) { - return new Age(((Integer) dbObject.get("v"))); + public Age convert(org.bson.Document document) { + return new Age(((Integer) document.get("v"))); } }; } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/UnwindOperationUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/UnwindOperationUnitTests.java index 74c7ac01e..952d2d954 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/UnwindOperationUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/aggregation/UnwindOperationUnitTests.java @@ -21,7 +21,7 @@ import static org.springframework.data.mongodb.test.util.IsBsonObject.*; import org.bson.Document; import org.junit.Test; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; /** * Unit tests for {@link UnwindOperation}. @@ -52,7 +52,7 @@ public class UnwindOperationUnitTests { UnwindOperation unwindOperation = Aggregation.unwind("a", "index"); - Document unwindClause = extractDbObjectFromUnwindOperation(unwindOperation); + Document unwindClause = extractDocumentFromUnwindOperation(unwindOperation); assertThat(unwindClause, isBsonObject().containing("path", "$a").// @@ -90,7 +90,7 @@ public class UnwindOperationUnitTests { UnwindOperation unwindOperation = Aggregation.unwind("a", true); - Document unwindClause = extractDbObjectFromUnwindOperation(unwindOperation); + Document unwindClause = extractDocumentFromUnwindOperation(unwindOperation); assertThat(unwindClause, isBsonObject().containing("path", "$a").// @@ -119,7 +119,7 @@ public class UnwindOperationUnitTests { UnwindOperation unwindOperation = UnwindOperation.newUnwind().path("$foo").arrayIndex("myindex") .preserveNullAndEmptyArrays(); - Document unwindClause = extractDbObjectFromUnwindOperation(unwindOperation); + Document unwindClause = extractDocumentFromUnwindOperation(unwindOperation); assertThat(unwindClause, isBsonObject().containing("path", "$foo").// @@ -127,10 +127,10 @@ public class UnwindOperationUnitTests { containing("includeArrayIndex", "myindex")); } - private Document extractDbObjectFromUnwindOperation(UnwindOperation unwindOperation) { + private Document extractDocumentFromUnwindOperation(UnwindOperation unwindOperation) { - Document dbObject = unwindOperation.toDocument(Aggregation.DEFAULT_CONTEXT); - Document unwindClause = DBObjectTestUtils.getAsDocument(dbObject, "$unwind"); + Document document = unwindOperation.toDocument(Aggregation.DEFAULT_CONTEXT); + Document unwindClause = DocumentTestUtils.getAsDocument(document, "$unwind"); return unwindClause; } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/CustomConvertersUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/CustomConvertersUnitTests.java index bf734b43b..0692e30a9 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/CustomConvertersUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/CustomConvertersUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 by the original author(s). + * Copyright (c) 2011-2016 by the original author(s). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ public class CustomConvertersUnitTests { MappingMongoConverter converter; @Mock BarToDocumentConverter barToDocumentConverter; - @Mock DocumentToBarConverter dbObjectToBarConverter; + @Mock DocumentToBarConverter documentToBarConverter; @Mock MongoDbFactory mongoDbFactory; MongoMappingContext context; @@ -59,10 +59,10 @@ public class CustomConvertersUnitTests { public void setUp() throws Exception { when(barToDocumentConverter.convert(any(Bar.class))).thenReturn(new Document()); - when(dbObjectToBarConverter.convert(any(Document.class))).thenReturn(new Bar()); + when(documentToBarConverter.convert(any(Document.class))).thenReturn(new Bar()); CustomConversions conversions = new CustomConversions( - Arrays.asList(barToDocumentConverter, dbObjectToBarConverter)); + Arrays.asList(barToDocumentConverter, documentToBarConverter)); context = new MongoMappingContext(); context.setInitialEntitySet(new HashSet>(Arrays.asList(Foo.class, Bar.class))); @@ -87,11 +87,11 @@ public class CustomConvertersUnitTests { @Test public void nestedFromDocumentConverterGetsInvoked() { - Document dbObject = new Document(); - dbObject.put("bar", new Document()); + Document document = new Document(); + document.put("bar", new Document()); - converter.read(Foo.class, dbObject); - verify(dbObjectToBarConverter).convert(any(Document.class)); + converter.read(Foo.class, document); + verify(documentToBarConverter).convert(any(Document.class)); } @Test @@ -105,15 +105,15 @@ public class CustomConvertersUnitTests { public void fromDocumentConverterGetsInvoked() { converter.read(Bar.class, new Document()); - verify(dbObjectToBarConverter).convert(any(Document.class)); + verify(documentToBarConverter).convert(any(Document.class)); } @Test public void foo() { - Document dbObject = new Document(); - dbObject.put("foo", null); + Document document = new Document(); + document.put("foo", null); - Assert.assertThat(dbObject.containsKey("foo"), CoreMatchers.is(true)); + Assert.assertThat(document.containsKey("foo"), CoreMatchers.is(true)); } public static class Foo { diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DbRefMappingMongoConverterUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DbRefMappingMongoConverterUnitTests.java index 776fab996..ace2e4a9f 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DbRefMappingMongoConverterUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DbRefMappingMongoConverterUnitTests.java @@ -137,16 +137,16 @@ public class DbRefMappingMongoConverterUnitTests { mapDBRef.map = mapVal; - Document dbObject = new Document(); - converter.write(mapDBRef, dbObject); + Document document = new Document(); + converter.write(mapDBRef, document); - Document map = (Document) dbObject.get("map"); + Document map = (Document) document.get("map"); assertThat(map.get("test"), instanceOf(DBRef.class)); - ((Document) dbObject.get("map")).put("test", dbRef); + ((Document) document.get("map")).put("test", dbRef); - MapDBRef read = converter.read(MapDBRef.class, dbObject); + MapDBRef read = converter.read(MapDBRef.class, document); assertThat(read.map.get("test").id, is(BigInteger.ONE)); } @@ -179,12 +179,12 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs(); lazyDbRefs.dbRefToInterface = new LinkedList(Arrays.asList(new LazyDbRefTarget("1"))); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, dbo); + ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document); assertProxyIsResolved(result.dbRefToInterface, false); assertThat(result.dbRefToInterface.get(0).getId(), is(id)); @@ -203,13 +203,13 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs(); lazyDbRefs.dbRefToConcreteCollection = new ArrayList( Arrays.asList(new LazyDbRefTarget(id, value))); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, dbo); + ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document); assertProxyIsResolved(result.dbRefToConcreteCollection, false); assertThat(result.dbRefToConcreteCollection.get(0).getId(), is(id)); @@ -228,12 +228,12 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs(); lazyDbRefs.dbRefToConcreteType = new LazyDbRefTarget(id, value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, dbo); + ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document); assertProxyIsResolved(result.dbRefToConcreteType, false); assertThat(result.dbRefToConcreteType.getId(), is(id)); @@ -252,13 +252,13 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs(); lazyDbRefs.dbRefToConcreteTypeWithPersistenceConstructor = new LazyDbRefTargetWithPeristenceConstructor((Object) id, (Object) value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, dbo); + ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document); assertProxyIsResolved(result.dbRefToConcreteTypeWithPersistenceConstructor, false); assertThat(result.dbRefToConcreteTypeWithPersistenceConstructor.getId(), is(id)); @@ -277,13 +277,13 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs(); lazyDbRefs.dbRefToConcreteTypeWithPersistenceConstructorWithoutDefaultConstructor = new LazyDbRefTargetWithPeristenceConstructorWithoutDefaultConstructor( (Object) id, (Object) value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, dbo); + ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document); assertProxyIsResolved(result.dbRefToConcreteTypeWithPersistenceConstructorWithoutDefaultConstructor, false); assertThat(result.dbRefToConcreteTypeWithPersistenceConstructorWithoutDefaultConstructor.getId(), is(id)); @@ -302,12 +302,12 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); SerializableClassWithLazyDbRefs lazyDbRefs = new SerializableClassWithLazyDbRefs(); lazyDbRefs.dbRefToSerializableTarget = new SerializableLazyDbRefTarget(id, value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - SerializableClassWithLazyDbRefs result = converterSpy.read(SerializableClassWithLazyDbRefs.class, dbo); + SerializableClassWithLazyDbRefs result = converterSpy.read(SerializableClassWithLazyDbRefs.class, document); SerializableClassWithLazyDbRefs deserializedResult = (SerializableClassWithLazyDbRefs) transport(result); @@ -327,12 +327,12 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); WithObjectMethodOverrideLazyDbRefs lazyDbRefs = new WithObjectMethodOverrideLazyDbRefs(); lazyDbRefs.dbRefToToStringObjectMethodOverride = new ToStringObjectMethodOverrideLazyDbRefTarget(id, value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, dbo); + WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, document); assertThat(result.dbRefToToStringObjectMethodOverride, is(notNullValue())); assertProxyIsResolved(result.dbRefToToStringObjectMethodOverride, false); @@ -351,12 +351,12 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); WithObjectMethodOverrideLazyDbRefs lazyDbRefs = new WithObjectMethodOverrideLazyDbRefs(); lazyDbRefs.dbRefToPlainObject = new LazyDbRefTarget(id, value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, dbo); + WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, document); assertThat(result.dbRefToPlainObject, is(notNullValue())); assertProxyIsResolved(result.dbRefToPlainObject, false); @@ -382,13 +382,13 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); WithObjectMethodOverrideLazyDbRefs lazyDbRefs = new WithObjectMethodOverrideLazyDbRefs(); lazyDbRefs.dbRefToPlainObject = new LazyDbRefTarget(id, value); lazyDbRefs.dbRefToToStringObjectMethodOverride = new ToStringObjectMethodOverrideLazyDbRefTarget(id, value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, dbo); + WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, document); assertThat(result.dbRefToPlainObject, is(notNullValue())); assertProxyIsResolved(result.dbRefToPlainObject, false); @@ -411,13 +411,13 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); WithObjectMethodOverrideLazyDbRefs lazyDbRefs = new WithObjectMethodOverrideLazyDbRefs(); lazyDbRefs.dbRefToPlainObject = new LazyDbRefTarget(id, value); lazyDbRefs.dbRefToToStringObjectMethodOverride = new ToStringObjectMethodOverrideLazyDbRefTarget(id, value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, dbo); + WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, document); assertThat(result.dbRefToPlainObject, is(notNullValue())); assertProxyIsResolved(result.dbRefToPlainObject, false); @@ -438,15 +438,15 @@ public class DbRefMappingMongoConverterUnitTests { MappingMongoConverter converterSpy = spy(converter); doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef((DBRef) any()); - Document dbo = new Document(); + Document document = new Document(); WithObjectMethodOverrideLazyDbRefs lazyDbRefs = new WithObjectMethodOverrideLazyDbRefs(); lazyDbRefs.dbRefEqualsAndHashcodeObjectMethodOverride1 = new EqualsAndHashCodeObjectMethodOverrideLazyDbRefTarget( id, value); lazyDbRefs.dbRefEqualsAndHashcodeObjectMethodOverride2 = new EqualsAndHashCodeObjectMethodOverrideLazyDbRefTarget( id, value); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, dbo); + WithObjectMethodOverrideLazyDbRefs result = converterSpy.read(WithObjectMethodOverrideLazyDbRefs.class, document); assertProxyIsResolved(result.dbRefEqualsAndHashcodeObjectMethodOverride1, false); assertThat(result.dbRefEqualsAndHashcodeObjectMethodOverride1, is(notNullValue())); @@ -465,12 +465,12 @@ public class DbRefMappingMongoConverterUnitTests { @Test public void shouldNotGenerateLazyLoadingProxyForNullValues() { - Document dbo = new Document(); + Document document = new Document(); ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs(); lazyDbRefs.id = "42"; - converter.write(lazyDbRefs, dbo); + converter.write(lazyDbRefs, document); - ClassWithLazyDbRefs result = converter.read(ClassWithLazyDbRefs.class, dbo); + ClassWithLazyDbRefs result = converter.read(ClassWithLazyDbRefs.class, document); assertThat(result.id, is(lazyDbRefs.id)); assertThat(result.dbRefToInterface, is(nullValue())); @@ -486,14 +486,14 @@ public class DbRefMappingMongoConverterUnitTests { @Test public void shouldBeAbleToStoreDirectReferencesToSelf() { - Document dbo = new Document(); + Document document = new Document(); ClassWithDbRefField o = new ClassWithDbRefField(); o.id = "123"; o.reference = o; - converter.write(o, dbo); + converter.write(o, document); - ClassWithDbRefField found = converter.read(ClassWithDbRefField.class, dbo); + ClassWithDbRefField found = converter.read(ClassWithDbRefField.class, document); assertThat(found, is(notNullValue())); assertThat(found.reference, is(found)); @@ -505,16 +505,16 @@ public class DbRefMappingMongoConverterUnitTests { @Test public void shouldBeAbleToStoreNestedReferencesToSelf() { - Document dbo = new Document(); + Document document = new Document(); ClassWithNestedDbRefField o = new ClassWithNestedDbRefField(); o.id = "123"; o.nested = new NestedReferenceHolder(); o.nested.reference = o; - converter.write(o, dbo); + converter.write(o, document); - ClassWithNestedDbRefField found = converter.read(ClassWithNestedDbRefField.class, dbo); + ClassWithNestedDbRefField found = converter.read(ClassWithNestedDbRefField.class, document); assertThat(found, is(notNullValue())); assertThat(found.nested, is(notNullValue())); @@ -600,13 +600,13 @@ public class DbRefMappingMongoConverterUnitTests { doReturn(Arrays.asList(new Document("_id", id1).append("value", value), new Document("_id", id2).append("value", value))).when(converterSpy).bulkReadRefs(anyListOf(DBRef.class)); - Document dbo = new Document(); + Document document = new Document(); ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs(); lazyDbRefs.dbRefToConcreteCollection = new ArrayList( Arrays.asList(new LazyDbRefTarget(id1, value), new LazyDbRefTarget(id2, value))); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, dbo); + ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document); assertProxyIsResolved(result.dbRefToConcreteCollection, false); assertThat(result.dbRefToConcreteCollection.get(0).getId(), is(id1)); @@ -631,13 +631,13 @@ public class DbRefMappingMongoConverterUnitTests { .doReturn(new Document("_id", id2).append("value", value)).when(converterSpy) .readRef(Mockito.any(DBRef.class)); - Document dbo = new Document(); + Document document = new Document(); ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs(); lazyDbRefs.dbRefToConcreteCollection = new ArrayList( Arrays.asList(new LazyDbRefTarget(id1, value), new SerializableLazyDbRefTarget(id2, value))); - converterSpy.write(lazyDbRefs, dbo); + converterSpy.write(lazyDbRefs, document); - ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, dbo); + ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document); assertProxyIsResolved(result.dbRefToConcreteCollection, false); assertThat(result.dbRefToConcreteCollection.get(0).getId(), is(id1)); @@ -664,15 +664,15 @@ public class DbRefMappingMongoConverterUnitTests { doReturn(Arrays.asList(new Document("_id", val1.id), new Document("_id", val2.id))).when(converterSpy) .bulkReadRefs(anyListOf(DBRef.class)); - Document dbo = new Document(); + Document document = new Document(); MapDBRef mapDBRef = new MapDBRef(); mapDBRef.map = new LinkedHashMap(); mapDBRef.map.put("one", val1); mapDBRef.map.put("two", val2); - converterSpy.write(mapDBRef, dbo); + converterSpy.write(mapDBRef, document); - MapDBRef result = converterSpy.read(MapDBRef.class, dbo); + MapDBRef result = converterSpy.read(MapDBRef.class, document); // assertProxyIsResolved(result.map, false); assertThat(result.map.get("one").id, is(val1.id)); @@ -699,15 +699,15 @@ public class DbRefMappingMongoConverterUnitTests { doReturn(Arrays.asList(new Document("_id", val1.id), new Document("_id", val2.id))).when(converterSpy) .bulkReadRefs(anyListOf(DBRef.class)); - Document dbo = new Document(); + Document document = new Document(); MapDBRef mapDBRef = new MapDBRef(); mapDBRef.lazyMap = new LinkedHashMap(); mapDBRef.lazyMap.put("one", val1); mapDBRef.lazyMap.put("two", val2); - converterSpy.write(mapDBRef, dbo); + converterSpy.write(mapDBRef, document); - MapDBRef result = converterSpy.read(MapDBRef.class, dbo); + MapDBRef result = converterSpy.read(MapDBRef.class, document); assertProxyIsResolved(result.lazyMap, false); assertThat(result.lazyMap.get("one").id, is(val1.id)); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultDbRefResolverUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultDbRefResolverUnitTests.java index 074ba0ea7..1ff255e90 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultDbRefResolverUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultDbRefResolverUnitTests.java @@ -24,7 +24,6 @@ import static org.mockito.Mockito.*; import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.List; import com.mongodb.client.FindIterable; import com.mongodb.client.MongoCollection; @@ -42,13 +41,8 @@ import org.mockito.runners.MockitoJUnitRunner; import org.mockito.stubbing.Answer; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.mongodb.MongoDbFactory; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; -import com.mongodb.BasicDBObject; -import com.mongodb.DB; -import com.mongodb.DBCollection; -import com.mongodb.DBCursor; -import com.mongodb.DBObject; import com.mongodb.DBRef; /** @@ -92,8 +86,8 @@ public class DefaultDbRefResolverUnitTests { verify(collectionMock, times(1)).find(captor.capture()); - Document _id = DBObjectTestUtils.getAsDocument(captor.getValue(), "_id"); - Iterable $in = DBObjectTestUtils.getTypedValue(_id, "$in", Iterable.class); + Document _id = DocumentTestUtils.getAsDocument(captor.getValue(), "_id"); + Iterable $in = DocumentTestUtils.getTypedValue(_id, "$in", Iterable.class); assertThat($in, iterableWithSize(2)); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapperUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapperUnitTests.java index c74c1cba0..2cfbfda81 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapperUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DefaultMongoTypeMapperUnitTests.java @@ -27,7 +27,7 @@ import org.junit.Before; import org.junit.Test; import org.springframework.data.convert.ConfigurableTypeInformationMapper; import org.springframework.data.convert.SimpleTypeInformationMapper; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.util.TypeInformation; /** @@ -61,8 +61,8 @@ public class DefaultMongoTypeMapperUnitTests { @Test public void defaultInstanceReadsClasses() { - Document dbObject = new Document(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, String.class.getName()); - readsTypeFromField(dbObject, String.class); + Document document = new Document(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, String.class.getName()); + readsTypeFromField(document, String.class); } @Test @@ -116,8 +116,8 @@ public class DefaultMongoTypeMapperUnitTests { typeMapper = new DefaultMongoTypeMapper(); typeMapper.writeTypeRestrictions(result, Collections.> singleton(String.class)); - Document typeInfo = DBObjectTestUtils.getAsDocument(result, DefaultMongoTypeMapper.DEFAULT_TYPE_KEY); - List aliases = DBObjectTestUtils.getAsDBList(typeInfo, "$in"); + Document typeInfo = DocumentTestUtils.getAsDocument(result, DefaultMongoTypeMapper.DEFAULT_TYPE_KEY); + List aliases = DocumentTestUtils.getAsDBList(typeInfo, "$in"); assertThat(aliases, hasSize(1)); assertThat(aliases.get(0), is((Object) String.class.getName())); } @@ -187,9 +187,9 @@ public class DefaultMongoTypeMapperUnitTests { assertThat(typeMapper.isTypeKey(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY), is(false)); } - private void readsTypeFromField(Document dbObject, Class type) { + private void readsTypeFromField(Document document, Class type) { - TypeInformation typeInfo = typeMapper.readType(dbObject); + TypeInformation typeInfo = typeMapper.readType(document); if (type != null) { assertThat(typeInfo, is(notNullValue())); @@ -199,27 +199,27 @@ public class DefaultMongoTypeMapperUnitTests { } } - private void writesTypeToField(String field, Document dbObject, Class type) { + private void writesTypeToField(String field, Document document, Class type) { - typeMapper.writeType(type, dbObject); + typeMapper.writeType(type, document); if (field == null) { - assertThat(dbObject.keySet().isEmpty(), is(true)); + assertThat(document.keySet().isEmpty(), is(true)); } else { - assertThat(dbObject.containsKey(field), is(true)); - assertThat(dbObject.get(field), is((Object) type.getName())); + assertThat(document.containsKey(field), is(true)); + assertThat(document.get(field), is((Object) type.getName())); } } - private void writesTypeToField(Document dbObject, Class type, Object value) { + private void writesTypeToField(Document document, Class type, Object value) { - typeMapper.writeType(type, dbObject); + typeMapper.writeType(type, document); if (value == null) { - assertThat(dbObject.keySet().isEmpty(), is(true)); + assertThat(document.keySet().isEmpty(), is(true)); } else { - assertThat(dbObject.containsKey(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY), is(true)); - assertThat(dbObject.get(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY), is(value)); + assertThat(document.containsKey(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY), is(true)); + assertThat(document.get(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY), is(value)); } } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DocumentAccessorUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DocumentAccessorUnitTests.java index b95f5d70a..2a36ee223 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DocumentAccessorUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/DocumentAccessorUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013 the original author or authors. + * Copyright 2013-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import com.mongodb.BasicDBObject; import org.bson.BsonDocument; import org.bson.Document; import org.junit.Test; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.mongodb.core.mapping.Field; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; import org.springframework.data.mongodb.core.mapping.MongoPersistentEntity; @@ -43,13 +43,13 @@ public class DocumentAccessorUnitTests { @Test public void putsNestedFieldCorrectly() { - Document dbObject = new Document(); + Document document = new Document(); - DocumentAccessor accessor = new DocumentAccessor(dbObject); + DocumentAccessor accessor = new DocumentAccessor(document); accessor.put(fooProperty, "FooBar"); - Document aDbObject = DBObjectTestUtils.getAsDocument(dbObject, "a"); - assertThat(aDbObject.get("b"), is((Object) "FooBar")); + Document aDocument = DocumentTestUtils.getAsDocument(document, "a"); + assertThat(aDocument.get("b"), is((Object) "FooBar")); } @Test @@ -69,7 +69,7 @@ public class DocumentAccessorUnitTests { } @Test(expected = IllegalArgumentException.class) - public void rejectsNonBasicDocuments() { + public void rejectsNonDocuments() { new DocumentAccessor(new BsonDocument()); } @@ -93,7 +93,7 @@ public class DocumentAccessorUnitTests { accessor.put(entity.getPersistentProperty("b"), "b"); accessor.put(entity.getPersistentProperty("c"), "c"); - Document nestedA = DBObjectTestUtils.getAsDocument(target, "a"); + Document nestedA = DocumentTestUtils.getAsDocument(target, "a"); assertThat(nestedA, is(notNullValue())); assertThat(nestedA.get("b"), is((Object) "b")); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/GeoConvertersUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/GeoConvertersUnitTests.java index da37beb9d..49f29aae5 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/GeoConvertersUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/GeoConvertersUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,12 +56,12 @@ public class GeoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsBoxToDbObjectAndBackCorrectly() { + public void convertsBoxToDocumentAndBackCorrectly() { Box box = new Box(new Point(1, 2), new Point(3, 4)); - Document dbo = BoxToDocumentConverter.INSTANCE.convert(box); - Box result = DocumentToBoxConverter.INSTANCE.convert(dbo); + Document document = BoxToDocumentConverter.INSTANCE.convert(box); + Box result = DocumentToBoxConverter.INSTANCE.convert(document); assertThat(result, is(box)); assertThat(result.getClass().equals(Box.class), is(true)); @@ -71,12 +71,12 @@ public class GeoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsCircleToDbObjectAndBackCorrectlyNeutralDistance() { + public void convertsCircleToDocumentAndBackCorrectlyNeutralDistance() { Circle circle = new Circle(new Point(1, 2), 3); - Document dbo = CircleToDocumentConverter.INSTANCE.convert(circle); - Circle result = DocumentToCircleConverter.INSTANCE.convert(dbo); + Document document = CircleToDocumentConverter.INSTANCE.convert(circle); + Circle result = DocumentToCircleConverter.INSTANCE.convert(document); assertThat(result, is(circle)); } @@ -85,13 +85,13 @@ public class GeoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsCircleToDbObjectAndBackCorrectlyMilesDistance() { + public void convertsCircleToDocumentAndBackCorrectlyMilesDistance() { Distance radius = new Distance(3, Metrics.MILES); Circle circle = new Circle(new Point(1, 2), radius); - Document dbo = CircleToDocumentConverter.INSTANCE.convert(circle); - Circle result = DocumentToCircleConverter.INSTANCE.convert(dbo); + Document document = CircleToDocumentConverter.INSTANCE.convert(circle); + Circle result = DocumentToCircleConverter.INSTANCE.convert(document); assertThat(result, is(circle)); assertThat(result.getRadius(), is(radius)); @@ -101,12 +101,12 @@ public class GeoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsPolygonToDbObjectAndBackCorrectly() { + public void convertsPolygonToDocumentAndBackCorrectly() { Polygon polygon = new Polygon(new Point(1, 2), new Point(2, 3), new Point(3, 4), new Point(5, 6)); - Document dbo = PolygonToDocumentConverter.INSTANCE.convert(polygon); - Polygon result = DocumentToPolygonConverter.INSTANCE.convert(dbo); + Document document = PolygonToDocumentConverter.INSTANCE.convert(polygon); + Polygon result = DocumentToPolygonConverter.INSTANCE.convert(document); assertThat(result, is(polygon)); assertThat(result.getClass().equals(Polygon.class), is(true)); @@ -116,12 +116,12 @@ public class GeoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsSphereToDbObjectAndBackCorrectlyWithNeutralDistance() { + public void convertsSphereToDocumentAndBackCorrectlyWithNeutralDistance() { Sphere sphere = new Sphere(new Point(1, 2), 3); - Document dbo = SphereToDocumentConverter.INSTANCE.convert(sphere); - Sphere result = DocumentToSphereConverter.INSTANCE.convert(dbo); + Document document = SphereToDocumentConverter.INSTANCE.convert(sphere); + Sphere result = DocumentToSphereConverter.INSTANCE.convert(document); assertThat(result, is(sphere)); assertThat(result.getClass().equals(Sphere.class), is(true)); @@ -131,13 +131,13 @@ public class GeoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsSphereToDbObjectAndBackCorrectlyWithKilometerDistance() { + public void convertsSphereToDocumentAndBackCorrectlyWithKilometerDistance() { Distance radius = new Distance(3, Metrics.KILOMETERS); Sphere sphere = new Sphere(new Point(1, 2), radius); - Document dbo = SphereToDocumentConverter.INSTANCE.convert(sphere); - Sphere result = DocumentToSphereConverter.INSTANCE.convert(dbo); + Document document = SphereToDocumentConverter.INSTANCE.convert(sphere); + Sphere result = DocumentToSphereConverter.INSTANCE.convert(document); assertThat(result, is(sphere)); assertThat(result.getRadius(), is(radius)); @@ -152,8 +152,8 @@ public class GeoConvertersUnitTests { Point point = new Point(1, 2); - Document dbo = PointToDocumentConverter.INSTANCE.convert(point); - Point result = DocumentToPointConverter.INSTANCE.convert(dbo); + Document document = PointToDocumentConverter.INSTANCE.convert(point); + Point result = DocumentToPointConverter.INSTANCE.convert(document); assertThat(result, is(point)); assertThat(result.getClass().equals(Point.class), is(true)); @@ -163,16 +163,16 @@ public class GeoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsGeoCommandToDbObjectCorrectly() { + public void convertsGeoCommandToDocumentCorrectly() { Box box = new Box(new double[] { 1, 2 }, new double[] { 3, 4 }); GeoCommand cmd = new GeoCommand(box); - Document dbo = GeoCommandToDocumentConverter.INSTANCE.convert(cmd); + Document document = GeoCommandToDocumentConverter.INSTANCE.convert(cmd); - assertThat(dbo, is(notNullValue())); + assertThat(document, is(notNullValue())); - List boxObject = (List) dbo.get("$box"); + List boxObject = (List) document.get("$box"); assertThat(boxObject, is((Object) Arrays.asList(GeoConverters.toList(box.getFirst()), GeoConverters.toList(box.getSecond())))); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/GeoJsonConverterUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/GeoJsonConverterUnitTests.java index 275146681..9507b9b37 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/GeoJsonConverterUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/GeoJsonConverterUnitTests.java @@ -52,13 +52,13 @@ import com.mongodb.BasicDBList; * @author Christoph Strobl */ @RunWith(Suite.class) -@SuiteClasses({ GeoJsonConverterUnitTests.GeoJsonToDbObjectConverterUnitTests.class, - GeoJsonConverterUnitTests.DbObjectToGeoJsonPointConverterUnitTests.class, - GeoJsonConverterUnitTests.DbObjectToGeoJsonPolygonConverterUnitTests.class, - GeoJsonConverterUnitTests.DbObjectToGeoJsonLineStringConverterUnitTests.class, - GeoJsonConverterUnitTests.DbObjectToGeoJsonMultiPolygonConverterUnitTests.class, - GeoJsonConverterUnitTests.DbObjectToGeoJsonMultiLineStringConverterUnitTests.class, - GeoJsonConverterUnitTests.DbObjectToGeoJsonMultiPointConverterUnitTests.class }) +@SuiteClasses({ GeoJsonConverterUnitTests.GeoJsonToDocumentConverterUnitTests.class, + GeoJsonConverterUnitTests.DocumentToGeoJsonPointConverterUnitTests.class, + GeoJsonConverterUnitTests.DocumentToGeoJsonPolygonConverterUnitTests.class, + GeoJsonConverterUnitTests.DocumentToGeoJsonLineStringConverterUnitTests.class, + GeoJsonConverterUnitTests.DocumentToGeoJsonMultiPolygonConverterUnitTests.class, + GeoJsonConverterUnitTests.DocumentToGeoJsonMultiLineStringConverterUnitTests.class, + GeoJsonConverterUnitTests.DocumentToGeoJsonMultiPointConverterUnitTests.class }) public class GeoJsonConverterUnitTests { /* @@ -95,7 +95,7 @@ public class GeoJsonConverterUnitTests { .add(SINGLE_POINT.getX()) // .add(SINGLE_POINT.getY()) // .get(); // - static final Document SINGLE_POINT_DBO = new Document() // + static final Document SINGLE_POINT_DOC = new Document() // .append("type", "Point") // .append("coordinates", SINGE_POINT_CORDS);// @@ -105,7 +105,7 @@ public class GeoJsonConverterUnitTests { .add(new BasicDbListBuilder().add(POINT_2.getX()).add(POINT_2.getY()).get()) // .add(new BasicDbListBuilder().add(POINT_3.getX()).add(POINT_3.getY()).get()) // .get(); - static final Document MULTI_POINT_DBO = new Document() // + static final Document MULTI_POINT_DOC = new Document() // .append("type", "MultiPoint")// .append("coordinates", MULTI_POINT_CORDS);// @@ -127,13 +127,13 @@ public class GeoJsonConverterUnitTests { .get(); static final BasicDBList POLYGON_CORDS = new BasicDbListBuilder().add(POLYGON_OUTER_CORDS).get(); - static final Document POLYGON_DBO = new Document() // + static final Document POLYGON_DOC = new Document() // .append("type", "Polygon") // .append("coordinates", POLYGON_CORDS); // static final BasicDBList POLYGON_WITH_2_RINGS_CORDS = new BasicDbListBuilder().add(POLYGON_OUTER_CORDS) .add(POLYGON_INNER_CORDS).get(); - static final Document POLYGON_WITH_2_RINGS_DBO = new Document() // + static final Document POLYGON_WITH_2_RINGS_DOC = new Document() // .append("type", "Polygon") // .append("coordinates", POLYGON_WITH_2_RINGS_CORDS); @@ -147,7 +147,7 @@ public class GeoJsonConverterUnitTests { .add(new BasicDbListBuilder().add(POINT_3.getX()).add(POINT_3.getY()).get()) // .add(new BasicDbListBuilder().add(POINT_0.getX()).add(POINT_0.getY()).get()) // .get(); - static final Document LINE_STRING_DBO = new Document().append("type", "LineString").append("coordinates", + static final Document LINE_STRING_DOC = new Document().append("type", "LineString").append("coordinates", LINE_STRING_CORDS_0); // MultiLineString @@ -155,26 +155,26 @@ public class GeoJsonConverterUnitTests { .add(LINE_STRING_CORDS_0) // .add(LINE_STRING_CORDS_1) // .get(); - static final Document MULTI_LINE_STRING_DBO = new Document().append("type", "MultiLineString").append("coordinates", + static final Document MULTI_LINE_STRING_DOC = new Document().append("type", "MultiLineString").append("coordinates", MUILT_LINE_STRING_CORDS); // MultiPolygoin static final BasicDBList MULTI_POLYGON_CORDS = new BasicDbListBuilder().add(POLYGON_CORDS).get(); - static final Document MULTI_POLYGON_DBO = new Document().append("type", "MultiPolygon").append("coordinates", + static final Document MULTI_POLYGON_DOC = new Document().append("type", "MultiPolygon").append("coordinates", MULTI_POLYGON_CORDS); // GeometryCollection static final BasicDBList GEOMETRY_COLLECTION_GEOMETRIES = new BasicDbListBuilder() // - .add(SINGLE_POINT_DBO)// - .add(POLYGON_DBO)// + .add(SINGLE_POINT_DOC)// + .add(POLYGON_DOC)// .get(); - static final Document GEOMETRY_COLLECTION_DBO = new Document().append("type", "GeometryCollection") + static final Document GEOMETRY_COLLECTION_DOC = new Document().append("type", "GeometryCollection") .append("geometries", GEOMETRY_COLLECTION_GEOMETRIES); /** * @author Christoph Strobl */ - public static class DbObjectToGeoJsonPolygonConverterUnitTests { + public static class DocumentToGeoJsonPolygonConverterUnitTests { DocumentToGeoJsonPolygonConverter converter = DocumentToGeoJsonPolygonConverter.INSTANCE; public @Rule ExpectedException expectedException = ExpectedException.none(); @@ -184,7 +184,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertDboCorrectly() { - assertThat(converter.convert(POLYGON_DBO), equalTo(POLYGON)); + assertThat(converter.convert(POLYGON_DOC), equalTo(POLYGON)); } /** @@ -212,7 +212,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertDboWithMultipleRingsCorrectly() { - assertThat(converter.convert(POLYGON_WITH_2_RINGS_DBO), equalTo(POLYGON_WITH_2_RINGS)); + assertThat(converter.convert(POLYGON_WITH_2_RINGS_DOC), equalTo(POLYGON_WITH_2_RINGS)); } } @@ -220,7 +220,7 @@ public class GeoJsonConverterUnitTests { /** * @author Christoph Strobl */ - public static class DbObjectToGeoJsonPointConverterUnitTests { + public static class DocumentToGeoJsonPointConverterUnitTests { DocumentToGeoJsonPointConverter converter = DocumentToGeoJsonPointConverter.INSTANCE; public @Rule ExpectedException expectedException = ExpectedException.none(); @@ -230,7 +230,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertDboCorrectly() { - assertThat(converter.convert(SINGLE_POINT_DBO), equalTo(SINGLE_POINT)); + assertThat(converter.convert(SINGLE_POINT_DOC), equalTo(SINGLE_POINT)); } /** @@ -257,7 +257,7 @@ public class GeoJsonConverterUnitTests { /** * @author Christoph Strobl */ - public static class DbObjectToGeoJsonLineStringConverterUnitTests { + public static class DocumentToGeoJsonLineStringConverterUnitTests { DocumentToGeoJsonLineStringConverter converter = DocumentToGeoJsonLineStringConverter.INSTANCE; public @Rule ExpectedException expectedException = ExpectedException.none(); @@ -267,7 +267,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertDboCorrectly() { - assertThat(converter.convert(LINE_STRING_DBO), equalTo(LINE_STRING)); + assertThat(converter.convert(LINE_STRING_DOC), equalTo(LINE_STRING)); } /** @@ -294,7 +294,7 @@ public class GeoJsonConverterUnitTests { /** * @author Christoph Strobl */ - public static class DbObjectToGeoJsonMultiLineStringConverterUnitTests { + public static class DocumentToGeoJsonMultiLineStringConverterUnitTests { DocumentToGeoJsonMultiLineStringConverter converter = DocumentToGeoJsonMultiLineStringConverter.INSTANCE; public @Rule ExpectedException expectedException = ExpectedException.none(); @@ -304,7 +304,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertDboCorrectly() { - assertThat(converter.convert(MULTI_LINE_STRING_DBO), equalTo(MULTI_LINE_STRING)); + assertThat(converter.convert(MULTI_LINE_STRING_DOC), equalTo(MULTI_LINE_STRING)); } /** @@ -331,7 +331,7 @@ public class GeoJsonConverterUnitTests { /** * @author Christoph Strobl */ - public static class DbObjectToGeoJsonMultiPointConverterUnitTests { + public static class DocumentToGeoJsonMultiPointConverterUnitTests { DocumentToGeoJsonMultiPointConverter converter = DocumentToGeoJsonMultiPointConverter.INSTANCE; public @Rule ExpectedException expectedException = ExpectedException.none(); @@ -341,7 +341,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertDboCorrectly() { - assertThat(converter.convert(MULTI_POINT_DBO), equalTo(MULTI_POINT)); + assertThat(converter.convert(MULTI_POINT_DOC), equalTo(MULTI_POINT)); } /** @@ -368,7 +368,7 @@ public class GeoJsonConverterUnitTests { /** * @author Christoph Strobl */ - public static class DbObjectToGeoJsonMultiPolygonConverterUnitTests { + public static class DocumentToGeoJsonMultiPolygonConverterUnitTests { DocumentToGeoJsonMultiPolygonConverter converter = DocumentToGeoJsonMultiPolygonConverter.INSTANCE; public @Rule ExpectedException expectedException = ExpectedException.none(); @@ -378,7 +378,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertDboCorrectly() { - assertThat(converter.convert(MULTI_POLYGON_DBO), equalTo(MULTI_POLYGON)); + assertThat(converter.convert(MULTI_POLYGON_DOC), equalTo(MULTI_POLYGON)); } /** @@ -405,7 +405,7 @@ public class GeoJsonConverterUnitTests { /** * @author Christoph Strobl */ - public static class GeoJsonToDbObjectConverterUnitTests { + public static class GeoJsonToDocumentConverterUnitTests { GeoJsonToDocumentConverter converter = GeoJsonToDocumentConverter.INSTANCE; @@ -421,7 +421,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertGeoJsonPointCorrectly() { - assertThat(converter.convert(SINGLE_POINT), equalTo(SINGLE_POINT_DBO)); + assertThat(converter.convert(SINGLE_POINT), equalTo(SINGLE_POINT_DOC)); } /** @@ -429,7 +429,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertGeoJsonPolygonCorrectly() { - assertThat(converter.convert(POLYGON), equalTo(POLYGON_DBO)); + assertThat(converter.convert(POLYGON), equalTo(POLYGON_DOC)); } /** @@ -437,7 +437,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertGeoJsonLineStringCorrectly() { - assertThat(converter.convert(LINE_STRING), equalTo(LINE_STRING_DBO)); + assertThat(converter.convert(LINE_STRING), equalTo(LINE_STRING_DOC)); } /** @@ -445,7 +445,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertGeoJsonMultiLineStringCorrectly() { - assertThat(converter.convert(MULTI_LINE_STRING), equalTo(MULTI_LINE_STRING_DBO)); + assertThat(converter.convert(MULTI_LINE_STRING), equalTo(MULTI_LINE_STRING_DOC)); } /** @@ -453,7 +453,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertGeoJsonMultiPointCorrectly() { - assertThat(converter.convert(MULTI_POINT), equalTo(MULTI_POINT_DBO)); + assertThat(converter.convert(MULTI_POINT), equalTo(MULTI_POINT_DOC)); } /** @@ -461,7 +461,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertGeoJsonMultiPolygonCorrectly() { - assertThat(converter.convert(MULTI_POLYGON), equalTo(MULTI_POLYGON_DBO)); + assertThat(converter.convert(MULTI_POLYGON), equalTo(MULTI_POLYGON_DOC)); } /** @@ -469,7 +469,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertGeometryCollectionCorrectly() { - assertThat(converter.convert(GEOMETRY_COLLECTION), equalTo(GEOMETRY_COLLECTION_DBO)); + assertThat(converter.convert(GEOMETRY_COLLECTION), equalTo(GEOMETRY_COLLECTION_DOC)); } /** @@ -477,7 +477,7 @@ public class GeoJsonConverterUnitTests { */ @Test public void shouldConvertGeoJsonPolygonWithMultipleRingsCorrectly() { - assertThat(converter.convert(POLYGON_WITH_2_RINGS), equalTo(POLYGON_WITH_2_RINGS_DBO)); + assertThat(converter.convert(POLYGON_WITH_2_RINGS), equalTo(POLYGON_WITH_2_RINGS_DOC)); } } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java index d63caf642..566a446c3 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2015 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ import static java.time.ZoneId.*; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.mockito.Mockito.*; -import static org.springframework.data.mongodb.core.DBObjectTestUtils.*; +import static org.springframework.data.mongodb.core.DocumentTestUtils.*; import java.math.BigDecimal; import java.math.BigInteger; @@ -74,7 +74,7 @@ import org.springframework.data.geo.Polygon; import org.springframework.data.geo.Shape; import org.springframework.data.mapping.model.MappingException; import org.springframework.data.mapping.model.MappingInstantiationException; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.mongodb.core.convert.DocumentAccessorUnitTests.NestedType; import org.springframework.data.mongodb.core.convert.DocumentAccessorUnitTests.ProjectingType; import org.springframework.data.mongodb.core.convert.MappingMongoConverterUnitTests.ClassWithMapUsingEnumAsKey.FooBarEnum; @@ -126,12 +126,12 @@ public class MappingMongoConverterUnitTests { address.city = "New York"; address.street = "Broadway"; - org.bson.Document dbObject = new org.bson.Document(); + org.bson.Document document = new org.bson.Document(); - converter.write(address, dbObject); + converter.write(address, document); - assertThat(dbObject.get("city").toString(), is("New York")); - assertThat(dbObject.get("street").toString(), is("Broadway")); + assertThat(document.get("city").toString(), is("New York")); + assertThat(document.get("street").toString(), is("Broadway")); } @Test @@ -143,12 +143,12 @@ public class MappingMongoConverterUnitTests { Person person = new Person(); person.birthDate = new LocalDate(); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(person, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(person, document); - assertThat(dbObject.get("birthDate"), is(instanceOf(Date.class))); + assertThat(document.get("birthDate"), is(instanceOf(Date.class))); - Person result = converter.read(Person.class, dbObject); + Person result = converter.read(Person.class, document); assertThat(result.birthDate, is(notNullValue())); } @@ -170,10 +170,10 @@ public class MappingMongoConverterUnitTests { Map map = Collections.singletonMap(Locale.US, "Foo"); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(map, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(map, document); - assertThat(dbObject.get(Locale.US.toString()).toString(), is("Foo")); + assertThat(document.get(Locale.US.toString()).toString(), is("Foo")); } /** @@ -183,9 +183,9 @@ public class MappingMongoConverterUnitTests { public void readsMapWithCustomKeyTypeCorrectly() { org.bson.Document mapObject = new org.bson.Document(Locale.US.toString(), "Value"); - org.bson.Document dbObject = new org.bson.Document("map", mapObject); + org.bson.Document document = new org.bson.Document("map", mapObject); - ClassWithMapProperty result = converter.read(ClassWithMapProperty.class, dbObject); + ClassWithMapProperty result = converter.read(ClassWithMapProperty.class, document); assertThat(result.map.get(Locale.US), is("Value")); } @@ -195,11 +195,11 @@ public class MappingMongoConverterUnitTests { @Test public void usesDocumentsStoredTypeIfSubtypeOfRequest() { - org.bson.Document dbObject = new org.bson.Document(); - dbObject.put("birthDate", new LocalDate()); - dbObject.put(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, Person.class.getName()); + org.bson.Document document = new org.bson.Document(); + document.put("birthDate", new LocalDate()); + document.put(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, Person.class.getName()); - assertThat(converter.read(Contact.class, dbObject), is(instanceOf(Person.class))); + assertThat(converter.read(Contact.class, document), is(instanceOf(Person.class))); } /** @@ -208,11 +208,11 @@ public class MappingMongoConverterUnitTests { @Test public void ignoresDocumentsStoredTypeIfCompletelyDifferentTypeRequested() { - org.bson.Document dbObject = new org.bson.Document(); - dbObject.put("birthDate", new LocalDate()); - dbObject.put(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, Person.class.getName()); + org.bson.Document document = new org.bson.Document(); + document.put("birthDate", new LocalDate()); + document.put(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY, Person.class.getName()); - assertThat(converter.read(BirthDateContainer.class, dbObject), is(instanceOf(BirthDateContainer.class))); + assertThat(converter.read(BirthDateContainer.class, document), is(instanceOf(BirthDateContainer.class))); } @Test @@ -267,8 +267,8 @@ public class MappingMongoConverterUnitTests { */ @Test public void readsEnumsCorrectly() { - org.bson.Document dbObject = new org.bson.Document("sampleEnum", "FIRST"); - ClassWithEnumProperty result = converter.read(ClassWithEnumProperty.class, dbObject); + org.bson.Document document = new org.bson.Document("sampleEnum", "FIRST"); + ClassWithEnumProperty result = converter.read(ClassWithEnumProperty.class, document); assertThat(result.sampleEnum, is(SampleEnum.FIRST)); } @@ -281,9 +281,9 @@ public class MappingMongoConverterUnitTests { BasicDBList enums = new BasicDBList(); enums.add("FIRST"); - org.bson.Document dbObject = new org.bson.Document("enums", enums); + org.bson.Document document = new org.bson.Document("enums", enums); - ClassWithEnumProperty result = converter.read(ClassWithEnumProperty.class, dbObject); + ClassWithEnumProperty result = converter.read(ClassWithEnumProperty.class, document); assertThat(result.enums, is(instanceOf(List.class))); assertThat(result.enums.size(), is(1)); @@ -312,8 +312,8 @@ public class MappingMongoConverterUnitTests { @Test public void considersFieldNameWhenReading() { - org.bson.Document dbObject = new org.bson.Document("foo", "Oliver"); - Person result = converter.read(Person.class, dbObject); + org.bson.Document document = new org.bson.Document("foo", "Oliver"); + Person result = converter.read(Person.class, document); assertThat(result.firstname, is("Oliver")); } @@ -346,15 +346,15 @@ public class MappingMongoConverterUnitTests { CollectionWrapper wrapper = new CollectionWrapper(); wrapper.contacts = Arrays.asList((Contact) person); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(wrapper, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(wrapper, document); - Object result = dbObject.get("contacts"); + Object result = document.get("contacts"); assertThat(result, is(instanceOf(List.class))); List contacts = (List) result; - org.bson.Document personDbObject = (org.bson.Document) contacts.get(0); - assertThat(personDbObject.get("foo").toString(), is("Oliver")); - assertThat((String) personDbObject.get(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY), is(Person.class.getName())); + org.bson.Document personDocument = (org.bson.Document) contacts.get(0); + assertThat(personDocument.get("foo").toString(), is("Oliver")); + assertThat((String) personDocument.get(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY), is(Person.class.getName())); } /** @@ -382,14 +382,14 @@ public class MappingMongoConverterUnitTests { LocaleWrapper wrapper = new LocaleWrapper(); wrapper.locale = Locale.US; - org.bson.Document dbObject = new org.bson.Document(); - converter.write(wrapper, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(wrapper, document); - Object localeField = dbObject.get("locale"); + Object localeField = document.get("locale"); assertThat(localeField, is(instanceOf(String.class))); assertThat((String) localeField, is("en_US")); - LocaleWrapper read = converter.read(LocaleWrapper.class, dbObject); + LocaleWrapper read = converter.read(LocaleWrapper.class, document); assertThat(read.locale, is(Locale.US)); } @@ -411,10 +411,10 @@ public class MappingMongoConverterUnitTests { maps.nestedMaps = new LinkedHashMap>>(); maps.nestedMaps.put("afield", firstLevel); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(maps, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(maps, document); - ClassWithNestedMaps result = converter.read(ClassWithNestedMaps.class, dbObject); + ClassWithNestedMaps result = converter.read(ClassWithNestedMaps.class, document); Map>> nestedMap = result.nestedMaps; assertThat(nestedMap, is(notNullValue())); assertThat(nestedMap.get("afield"), is(firstLevel)); @@ -430,12 +430,12 @@ public class MappingMongoConverterUnitTests { container.value = BigDecimal.valueOf(2.5d); container.map = Collections.singletonMap("foo", container.value); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(container, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(container, document); - assertThat(dbObject.get("value"), is(instanceOf(String.class))); - assertThat((String) dbObject.get("value"), is("2.5")); - assertThat(((org.bson.Document) dbObject.get("map")).get("foo"), is(instanceOf(String.class))); + assertThat(document.get("value"), is(instanceOf(String.class))); + assertThat((String) document.get("value"), is("2.5")); + assertThat(((org.bson.Document) document.get("map")).get("foo"), is(instanceOf(String.class))); } /** @@ -444,13 +444,13 @@ public class MappingMongoConverterUnitTests { @Test public void readsClassWithBigDecimal() { - org.bson.Document dbObject = new org.bson.Document("value", "2.5"); - dbObject.put("map", new org.bson.Document("foo", "2.5")); + org.bson.Document document = new org.bson.Document("value", "2.5"); + document.put("map", new org.bson.Document("foo", "2.5")); BasicDBList list = new BasicDBList(); list.add("2.5"); - dbObject.put("collection", list); - BigDecimalContainer result = converter.read(BigDecimalContainer.class, dbObject); + document.put("collection", list); + BigDecimalContainer result = converter.read(BigDecimalContainer.class, document); assertThat(result.value, is(BigDecimal.valueOf(2.5d))); assertThat(result.map.get("foo"), is(BigDecimal.valueOf(2.5d))); @@ -464,10 +464,10 @@ public class MappingMongoConverterUnitTests { CollectionWrapper wrapper = new CollectionWrapper(); wrapper.strings = Arrays.asList(Arrays.asList("Foo")); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(wrapper, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(wrapper, document); - Object outerStrings = dbObject.get("strings"); + Object outerStrings = document.get("strings"); assertThat(outerStrings, is(instanceOf(List.class))); List typedOuterString = (List) outerStrings; @@ -483,24 +483,24 @@ public class MappingMongoConverterUnitTests { Person person = new Person(); person.addresses = Collections.emptySet(); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(person, dbObject); - converter.read(Person.class, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(person, document); + converter.read(Person.class, document); } @Test public void convertsObjectIdStringsToObjectIdCorrectly() { PersonPojoStringId p1 = new PersonPojoStringId("1234567890", "Text-1"); - org.bson.Document dbo1 = new org.bson.Document(); + org.bson.Document doc1 = new org.bson.Document(); - converter.write(p1, dbo1); - assertThat(dbo1.get("_id"), is(instanceOf(String.class))); + converter.write(p1, doc1); + assertThat(doc1.get("_id"), is(instanceOf(String.class))); PersonPojoStringId p2 = new PersonPojoStringId(new ObjectId().toString(), "Text-1"); - org.bson.Document dbo2 = new org.bson.Document(); + org.bson.Document doc2 = new org.bson.Document(); - converter.write(p2, dbo2); - assertThat(dbo2.get("_id"), is(instanceOf(ObjectId.class))); + converter.write(p2, doc2); + assertThat(doc2.get("_id"), is(instanceOf(ObjectId.class))); } /** @@ -741,9 +741,9 @@ public class MappingMongoConverterUnitTests { assertThat(list, is(notNullValue())); assertThat(list.size(), is(1)); - org.bson.Document dbObject = (org.bson.Document) list.get(0); - assertThat(dbObject.containsKey("Foo"), is(true)); - assertThat((String) dbObject.get("Foo"), is(Locale.ENGLISH.toString())); + org.bson.Document document = (org.bson.Document) list.get(0); + assertThat(document.containsKey("Foo"), is(true)); + assertThat((String) document.get("Foo"), is(Locale.ENGLISH.toString())); } /** @@ -801,10 +801,10 @@ public class MappingMongoConverterUnitTests { list.add("pong"); keyValues.put("list", list); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(keyValues, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(keyValues, document); - Map keyValuesFromMongo = converter.read(Map.class, dbObject); + Map keyValuesFromMongo = converter.read(Map.class, document); assertEquals(keyValues.size(), keyValuesFromMongo.size()); assertEquals(keyValues.get("string"), keyValuesFromMongo.get("string")); @@ -845,31 +845,31 @@ public class MappingMongoConverterUnitTests { * @see DATAMONGO-324 */ @Test - public void writesDbObjectCorrectly() { + public void writesDocumentCorrectly() { - org.bson.Document dbObject = new org.bson.Document(); - dbObject.put("foo", "bar"); + org.bson.Document document = new org.bson.Document(); + document.put("foo", "bar"); org.bson.Document result = new org.bson.Document(); - converter.write(dbObject, result); + converter.write(document, result); result.remove(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY); - assertThat(dbObject, is(result)); + assertThat(document, is(result)); } /** * @see DATAMONGO-324 */ @Test - public void readsDbObjectCorrectly() { + public void readsDocumentCorrectly() { - org.bson.Document dbObject = new org.bson.Document(); - dbObject.put("foo", "bar"); + org.bson.Document document = new org.bson.Document(); + document.put("foo", "bar"); - org.bson.Document result = converter.read(org.bson.Document.class, dbObject); + org.bson.Document result = converter.read(org.bson.Document.class, document); - assertThat(result, is(dbObject)); + assertThat(result, is(document)); } /** @@ -936,10 +936,10 @@ public class MappingMongoConverterUnitTests { @Test public void considersDefaultingExpressionsAtConstructorArguments() { - org.bson.Document dbObject = new org.bson.Document("foo", "bar"); - dbObject.put("foobar", 2.5); + org.bson.Document document = new org.bson.Document("foo", "bar"); + document.put("foobar", 2.5); - DefaultedConstructorArgument result = converter.read(DefaultedConstructorArgument.class, dbObject); + DefaultedConstructorArgument result = converter.read(DefaultedConstructorArgument.class, document); assertThat(result.bar, is(-1)); } @@ -949,11 +949,11 @@ public class MappingMongoConverterUnitTests { @Test public void usesDocumentFieldIfReferencedInAtValue() { - org.bson.Document dbObject = new org.bson.Document("foo", "bar"); - dbObject.put("something", 37); - dbObject.put("foobar", 2.5); + org.bson.Document document = new org.bson.Document("foo", "bar"); + document.put("something", 37); + document.put("foobar", 2.5); - DefaultedConstructorArgument result = converter.read(DefaultedConstructorArgument.class, dbObject); + DefaultedConstructorArgument result = converter.read(DefaultedConstructorArgument.class, document); assertThat(result.bar, is(37)); } @@ -963,9 +963,9 @@ public class MappingMongoConverterUnitTests { @Test(expected = MappingInstantiationException.class) public void rejectsNotFoundConstructorParameterForPrimitiveType() { - org.bson.Document dbObject = new org.bson.Document("foo", "bar"); + org.bson.Document document = new org.bson.Document("foo", "bar"); - converter.read(DefaultedConstructorArgument.class, dbObject); + converter.read(DefaultedConstructorArgument.class, document); } /** @@ -1013,11 +1013,11 @@ public class MappingMongoConverterUnitTests { converter.setMapKeyDotReplacement("~"); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(Collections.singletonMap("foo.bar", "foobar"), dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(Collections.singletonMap("foo.bar", "foobar"), document); - assertThat((String) dbObject.get("foo~bar"), is("foobar")); - assertThat(dbObject.containsKey("foo.bar"), is(false)); + assertThat((String) document.get("foo~bar"), is("foobar")); + assertThat(document.containsKey("foo.bar"), is(false)); } /** @@ -1029,8 +1029,8 @@ public class MappingMongoConverterUnitTests { converter.setMapKeyDotReplacement("~"); - org.bson.Document dbObject = new org.bson.Document("foo~bar", "foobar"); - Map result = converter.read(Map.class, dbObject); + org.bson.Document document = new org.bson.Document("foo~bar", "foobar"); + Map result = converter.read(Map.class, document); assertThat(result.get("foo.bar"), is("foobar")); assertThat(result.containsKey("foobar"), is(false)); @@ -1061,9 +1061,9 @@ public class MappingMongoConverterUnitTests { @Test public void readsMemberClassCorrectly() { - org.bson.Document dbObject = new org.bson.Document("inner", new org.bson.Document("value", "FOO!")); + org.bson.Document document = new org.bson.Document("inner", new org.bson.Document("value", "FOO!")); - Outer outer = converter.read(Outer.class, dbObject); + Outer outer = converter.read(Outer.class, document); assertThat(outer.inner, is(notNullValue())); assertThat(outer.inner.value, is("FOO!")); assertSyntheticFieldValueOf(outer.inner, outer); @@ -1075,8 +1075,8 @@ public class MappingMongoConverterUnitTests { @Test public void readEmptyCollectionIsModifiable() { - org.bson.Document dbObject = new org.bson.Document("contactsSet", new BasicDBList()); - CollectionWrapper wrapper = converter.read(CollectionWrapper.class, dbObject); + org.bson.Document document = new org.bson.Document("contactsSet", new BasicDBList()); + CollectionWrapper wrapper = converter.read(CollectionWrapper.class, document); assertThat(wrapper.contactsSet, is(notNullValue())); wrapper.contactsSet.add(new Contact() {}); @@ -1089,9 +1089,9 @@ public class MappingMongoConverterUnitTests { public void readsPlainDBRefObject() { DBRef dbRef = new DBRef("foo", 2); - org.bson.Document dbObject = new org.bson.Document("ref", dbRef); + org.bson.Document document = new org.bson.Document("ref", dbRef); - DBRefWrapper result = converter.read(DBRefWrapper.class, dbObject); + DBRefWrapper result = converter.read(DBRefWrapper.class, document); assertThat(result.ref, is(dbRef)); } @@ -1105,9 +1105,9 @@ public class MappingMongoConverterUnitTests { BasicDBList refs = new BasicDBList(); refs.add(dbRef); - org.bson.Document dbObject = new org.bson.Document("refs", refs); + org.bson.Document document = new org.bson.Document("refs", refs); - DBRefWrapper result = converter.read(DBRefWrapper.class, dbObject); + DBRefWrapper result = converter.read(DBRefWrapper.class, document); assertThat(result.refs, hasSize(1)); assertThat(result.refs, hasItem(dbRef)); } @@ -1120,9 +1120,9 @@ public class MappingMongoConverterUnitTests { DBRef dbRef = mock(DBRef.class); org.bson.Document refMap = new org.bson.Document("foo", dbRef); - org.bson.Document dbObject = new org.bson.Document("refMap", refMap); + org.bson.Document document = new org.bson.Document("refMap", refMap); - DBRefWrapper result = converter.read(DBRefWrapper.class, dbObject); + DBRefWrapper result = converter.read(DBRefWrapper.class, document); assertThat(result.refMap.entrySet(), hasSize(1)); assertThat(result.refMap.values(), hasItem(dbRef)); @@ -1139,9 +1139,9 @@ public class MappingMongoConverterUnitTests { DBRef dbRef = mock(DBRef.class); org.bson.Document refMap = new org.bson.Document("foo", dbRef); - org.bson.Document dbObject = new org.bson.Document("personMap", refMap); + org.bson.Document document = new org.bson.Document("personMap", refMap); - DBRefWrapper result = converter.read(DBRefWrapper.class, dbObject); + DBRefWrapper result = converter.read(DBRefWrapper.class, document); Matcher isPerson = instanceOf(Person.class); @@ -1169,8 +1169,8 @@ public class MappingMongoConverterUnitTests { */ @Test public void readsURLFromStringOutOfTheBox() throws Exception { - org.bson.Document dbObject = new org.bson.Document("url", "http://springsource.org"); - URLWrapper result = converter.read(URLWrapper.class, dbObject); + org.bson.Document document = new org.bson.Document("url", "http://springsource.org"); + URLWrapper result = converter.read(URLWrapper.class, document); assertThat(result.url, is(new URL("http://springsource.org"))); } @@ -1186,10 +1186,10 @@ public class MappingMongoConverterUnitTests { ClassWithComplexId entity = new ClassWithComplexId(); entity.complexId = id; - org.bson.Document dbObject = new org.bson.Document(); - converter.write(entity, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(entity, document); - Object idField = dbObject.get("_id"); + Object idField = document.get("_id"); assertThat(idField, is(notNullValue())); assertThat(idField, is(instanceOf(org.bson.Document.class))); assertThat(((org.bson.Document) idField).get("innerId"), is((Object) 4711L)); @@ -1296,8 +1296,8 @@ public class MappingMongoConverterUnitTests { ThrowableWrapper wrapper = new ThrowableWrapper(); wrapper.throwable = new Exception(); - org.bson.Document dbObject = new org.bson.Document(); - converter.write(wrapper, dbObject); + org.bson.Document document = new org.bson.Document(); + converter.write(wrapper, document); } /** @@ -1355,10 +1355,10 @@ public class MappingMongoConverterUnitTests { mongoConverter.setCustomConversions(conversions); mongoConverter.afterPropertiesSet(); - org.bson.Document dbObject = new org.bson.Document(); - mongoConverter.write(entity, dbObject); + org.bson.Document document = new org.bson.Document(); + mongoConverter.write(entity, document); - ClassWithMapProperty result = mongoConverter.read(ClassWithMapProperty.class, dbObject); + ClassWithMapProperty result = mongoConverter.read(ClassWithMapProperty.class, document); assertThat(result.mapOfPersons, is(notNullValue())); Person personCandidate = result.mapOfPersons.get("foo"); @@ -1379,8 +1379,8 @@ public class MappingMongoConverterUnitTests { @Test public void readsIntoStringsOutOfTheBox() { - org.bson.Document dbObject = new org.bson.Document("firstname", "Dave"); - assertThat(converter.read(String.class, dbObject), is("{ \"firstname\" : \"Dave\" }")); + org.bson.Document document = new org.bson.Document("firstname", "Dave"); + assertThat(converter.read(String.class, document), is("{ \"firstname\" : \"Dave\" }")); } /** @@ -1401,7 +1401,7 @@ public class MappingMongoConverterUnitTests { converter.write(type, result); assertThat(result.get("name"), is((Object) "name")); - org.bson.Document aValue = DBObjectTestUtils.getAsDocument(result, "a"); + org.bson.Document aValue = DocumentTestUtils.getAsDocument(result, "a"); assertThat(aValue.get("b"), is((Object) "bar")); assertThat(aValue.get("c"), is((Object) "C")); } @@ -1484,9 +1484,9 @@ public class MappingMongoConverterUnitTests { BasicDBList enumSet = new BasicDBList(); enumSet.add("SECOND"); - org.bson.Document dbObject = new org.bson.Document("enumSet", enumSet); + org.bson.Document document = new org.bson.Document("enumSet", enumSet); - ClassWithEnumProperty result = converter.read(ClassWithEnumProperty.class, dbObject); + ClassWithEnumProperty result = converter.read(ClassWithEnumProperty.class, document); assertThat(result.enumSet, is(instanceOf(EnumSet.class))); assertThat(result.enumSet.size(), is(1)); @@ -1556,16 +1556,16 @@ public class MappingMongoConverterUnitTests { ClassWithGeoBox object = new ClassWithGeoBox(); object.box = new Box(new Point(1, 2), new Point(3, 4)); - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - assertThat(dbo, is(notNullValue())); - assertThat(dbo.get("box"), is(instanceOf(org.bson.Document.class))); - assertThat(dbo.get("box"), is((Object) new org.bson.Document().append("first", toDbObject(object.box.getFirst())) - .append("second", toDbObject(object.box.getSecond())))); + assertThat(document, is(notNullValue())); + assertThat(document.get("box"), is(instanceOf(org.bson.Document.class))); + assertThat(document.get("box"), is((Object) new org.bson.Document().append("first", toDocument(object.box.getFirst())) + .append("second", toDocument(object.box.getSecond())))); } - private static org.bson.Document toDbObject(Point point) { + private static org.bson.Document toDocument(Point point) { return new org.bson.Document("x", point.getX()).append("y", point.getY()); } @@ -1578,10 +1578,10 @@ public class MappingMongoConverterUnitTests { ClassWithGeoBox object = new ClassWithGeoBox(); object.box = new Box(new Point(1, 2), new Point(3, 4)); - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - ClassWithGeoBox result = converter.read(ClassWithGeoBox.class, dbo); + ClassWithGeoBox result = converter.read(ClassWithGeoBox.class, document); assertThat(result, is(notNullValue())); assertThat(result.box, is(object.box)); @@ -1596,20 +1596,20 @@ public class MappingMongoConverterUnitTests { ClassWithGeoPolygon object = new ClassWithGeoPolygon(); object.polygon = new Polygon(new Point(1, 2), new Point(3, 4), new Point(4, 5)); - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - assertThat(dbo, is(notNullValue())); + assertThat(document, is(notNullValue())); - assertThat(dbo.get("polygon"), is(instanceOf(org.bson.Document.class))); - org.bson.Document polygonDbo = (org.bson.Document) dbo.get("polygon"); + assertThat(document.get("polygon"), is(instanceOf(org.bson.Document.class))); + org.bson.Document polygonDoc = (org.bson.Document) document.get("polygon"); @SuppressWarnings("unchecked") - List points = (List) polygonDbo.get("points"); + List points = (List) polygonDoc.get("points"); assertThat(points, hasSize(3)); - assertThat(points, Matchers. hasItems(toDbObject(object.polygon.getPoints().get(0)), - toDbObject(object.polygon.getPoints().get(1)), toDbObject(object.polygon.getPoints().get(2)))); + assertThat(points, Matchers. hasItems(toDocument(object.polygon.getPoints().get(0)), + toDocument(object.polygon.getPoints().get(1)), toDocument(object.polygon.getPoints().get(2)))); } /** @@ -1621,10 +1621,10 @@ public class MappingMongoConverterUnitTests { ClassWithGeoPolygon object = new ClassWithGeoPolygon(); object.polygon = new Polygon(new Point(1, 2), new Point(3, 4), new Point(4, 5)); - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - ClassWithGeoPolygon result = converter.read(ClassWithGeoPolygon.class, dbo); + ClassWithGeoPolygon result = converter.read(ClassWithGeoPolygon.class, document); assertThat(result, is(notNullValue())); assertThat(result.polygon, is(object.polygon)); @@ -1641,12 +1641,12 @@ public class MappingMongoConverterUnitTests { Distance radius = circle.getRadius(); object.circle = circle; - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - assertThat(dbo, is(notNullValue())); - assertThat(dbo.get("circle"), is(instanceOf(org.bson.Document.class))); - assertThat(dbo.get("circle"), + assertThat(document, is(notNullValue())); + assertThat(document.get("circle"), is(instanceOf(org.bson.Document.class))); + assertThat(document.get("circle"), is((Object) new org.bson.Document("center", new org.bson.Document("x", circle.getCenter().getX()).append("y", circle.getCenter().getY())) .append("radius", radius.getNormalizedValue()).append("metric", radius.getMetric().toString()))); @@ -1661,10 +1661,10 @@ public class MappingMongoConverterUnitTests { ClassWithGeoCircle object = new ClassWithGeoCircle(); object.circle = new Circle(new Point(1, 2), 3); - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - ClassWithGeoCircle result = converter.read(ClassWithGeoCircle.class, dbo); + ClassWithGeoCircle result = converter.read(ClassWithGeoCircle.class, document); assertThat(result, is(notNullValue())); assertThat(result.circle, is(result.circle)); @@ -1681,12 +1681,12 @@ public class MappingMongoConverterUnitTests { Distance radius = sphere.getRadius(); object.sphere = sphere; - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - assertThat(dbo, is(notNullValue())); - assertThat(dbo.get("sphere"), is(instanceOf(org.bson.Document.class))); - assertThat(dbo.get("sphere"), + assertThat(document, is(notNullValue())); + assertThat(document.get("sphere"), is(instanceOf(org.bson.Document.class))); + assertThat(document.get("sphere"), is((Object) new org.bson.Document("center", new org.bson.Document("x", sphere.getCenter().getX()).append("y", sphere.getCenter().getY())) .append("radius", radius.getNormalizedValue()).append("metric", radius.getMetric().toString()))); @@ -1703,12 +1703,12 @@ public class MappingMongoConverterUnitTests { Distance radius = sphere.getRadius(); object.sphere = sphere; - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - assertThat(dbo, is(notNullValue())); - assertThat(dbo.get("sphere"), is(instanceOf(org.bson.Document.class))); - assertThat(dbo.get("sphere"), + assertThat(document, is(notNullValue())); + assertThat(document.get("sphere"), is(instanceOf(org.bson.Document.class))); + assertThat(document.get("sphere"), is((Object) new org.bson.Document("center", new org.bson.Document("x", sphere.getCenter().getX()).append("y", sphere.getCenter().getY())) .append("radius", radius.getNormalizedValue()).append("metric", radius.getMetric().toString()))); @@ -1723,10 +1723,10 @@ public class MappingMongoConverterUnitTests { ClassWithGeoSphere object = new ClassWithGeoSphere(); object.sphere = new Sphere(new Point(1, 2), 3); - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - ClassWithGeoSphere result = converter.read(ClassWithGeoSphere.class, dbo); + ClassWithGeoSphere result = converter.read(ClassWithGeoSphere.class, document); assertThat(result, is(notNullValue())); assertThat(result.sphere, is(object.sphere)); @@ -1743,12 +1743,12 @@ public class MappingMongoConverterUnitTests { Distance radius = sphere.getRadius(); object.shape = sphere; - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - assertThat(dbo, is(notNullValue())); - assertThat(dbo.get("shape"), is(instanceOf(org.bson.Document.class))); - assertThat(dbo.get("shape"), + assertThat(document, is(notNullValue())); + assertThat(document.get("shape"), is(instanceOf(org.bson.Document.class))); + assertThat(document.get("shape"), is((Object) new org.bson.Document("center", new org.bson.Document("x", sphere.getCenter().getX()).append("y", sphere.getCenter().getY())) .append("radius", radius.getNormalizedValue()).append("metric", radius.getMetric().toString()))); @@ -1765,10 +1765,10 @@ public class MappingMongoConverterUnitTests { Sphere sphere = new Sphere(new Point(1, 2), 3); object.shape = sphere; - org.bson.Document dbo = new org.bson.Document(); - converter.write(object, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(object, document); - ClassWithGeoShape result = converter.read(ClassWithGeoShape.class, dbo); + ClassWithGeoShape result = converter.read(ClassWithGeoShape.class, document); assertThat(result, is(notNullValue())); assertThat(result.shape, is((Shape) sphere)); @@ -1783,10 +1783,10 @@ public class MappingMongoConverterUnitTests { ClassWithTextScoreProperty source = new ClassWithTextScoreProperty(); source.score = Float.MAX_VALUE; - org.bson.Document dbo = new org.bson.Document(); - converter.write(source, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(source, document); - assertThat(dbo.get("score"), nullValue()); + assertThat(document.get("score"), nullValue()); } /** @@ -1811,10 +1811,10 @@ public class MappingMongoConverterUnitTests { factory.setProxyTargetClass(true); GenericType proxied = (GenericType) factory.getProxy(); - org.bson.Document dbo = new org.bson.Document(); - converter.write(proxied, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(proxied, document); - assertThat(dbo.get("_class"), is((Object) GenericType.class.getName())); + assertThat(document.get("_class"), is((Object) GenericType.class.getName())); } /** @@ -1825,8 +1825,8 @@ public class MappingMongoConverterUnitTests { LazyLoadingProxy mock = mock(LazyLoadingProxy.class); - org.bson.Document dbo = new org.bson.Document(); - converter.write(mock, dbo); + org.bson.Document document = new org.bson.Document(); + converter.write(mock, document); verify(mock, times(1)).getTarget(); } @@ -1910,9 +1910,9 @@ public class MappingMongoConverterUnitTests { @Test public void namedIdFieldShouldExtractValueFromUnderscoreIdField() { - org.bson.Document dbo = new org.bson.Document().append("_id", "A").append("id", "B"); + org.bson.Document document = new org.bson.Document().append("_id", "A").append("id", "B"); - ClassWithNamedIdField withNamedIdField = converter.read(ClassWithNamedIdField.class, dbo); + ClassWithNamedIdField withNamedIdField = converter.read(ClassWithNamedIdField.class, document); assertThat(withNamedIdField.id, is("A")); } @@ -1923,10 +1923,10 @@ public class MappingMongoConverterUnitTests { @Test public void explicitlyRenamedIfFieldShouldExtractValueFromIdField() { - org.bson.Document dbo = new org.bson.Document().append("_id", "A").append("id", "B"); + org.bson.Document document = new org.bson.Document().append("_id", "A").append("id", "B"); ClassWithExplicitlyRenamedField withExplicitlyRenamedField = converter.read(ClassWithExplicitlyRenamedField.class, - dbo); + document); assertThat(withExplicitlyRenamedField.id, is("B")); } @@ -1937,9 +1937,9 @@ public class MappingMongoConverterUnitTests { @Test public void annotatedIdFieldShouldExtractValueFromUnderscoreIdField() { - org.bson.Document dbo = new org.bson.Document().append("_id", "A").append("id", "B"); + org.bson.Document document = new org.bson.Document().append("_id", "A").append("id", "B"); - ClassWithAnnotatedIdField withAnnotatedIdField = converter.read(ClassWithAnnotatedIdField.class, dbo); + ClassWithAnnotatedIdField withAnnotatedIdField = converter.read(ClassWithAnnotatedIdField.class, document); assertThat(withAnnotatedIdField.key, is("A")); } @@ -2037,7 +2037,7 @@ public class MappingMongoConverterUnitTests { org.bson.Document target = new org.bson.Document(); converter.write(source, target); - org.bson.Document map = DBObjectTestUtils.getAsDocument(target, "map"); + org.bson.Document map = DocumentTestUtils.getAsDocument(target, "map"); assertThat(map.containsKey("foo-enum-value"), is(true)); assertThat(map.containsKey("bar-enum-value"), is(true)); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoConvertersUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoConvertersUnitTests.java index 3e311ff0f..c9d09b4be 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoConvertersUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoConvertersUnitTests.java @@ -65,12 +65,12 @@ public class MongoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsBoxToDbObjectAndBackCorrectly() { + public void convertsBoxToDocumentAndBackCorrectly() { Box box = new Box(new Point(1, 2), new Point(3, 4)); - Document dbo = GeoConverters.BoxToDocumentConverter.INSTANCE.convert(box); - Shape shape = GeoConverters.DocumentToBoxConverter.INSTANCE.convert(dbo); + Document document = GeoConverters.BoxToDocumentConverter.INSTANCE.convert(box); + Shape shape = GeoConverters.DocumentToBoxConverter.INSTANCE.convert(document); assertThat(shape, is((org.springframework.data.geo.Shape) box)); } @@ -79,12 +79,12 @@ public class MongoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsCircleToDbObjectAndBackCorrectly() { + public void convertsCircleToDocumentAndBackCorrectly() { Circle circle = new Circle(new Point(1, 2), 3); - Document dbo = GeoConverters.CircleToDocumentConverter.INSTANCE.convert(circle); - Shape shape = GeoConverters.DocumentToCircleConverter.INSTANCE.convert(dbo); + Document document = GeoConverters.CircleToDocumentConverter.INSTANCE.convert(circle); + Shape shape = GeoConverters.DocumentToCircleConverter.INSTANCE.convert(document); assertThat(shape, is((org.springframework.data.geo.Shape) circle)); } @@ -93,12 +93,12 @@ public class MongoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsPolygonToDbObjectAndBackCorrectly() { + public void convertsPolygonToDocumentAndBackCorrectly() { Polygon polygon = new Polygon(new Point(1, 2), new Point(2, 3), new Point(3, 4), new Point(5, 6)); - Document dbo = GeoConverters.PolygonToDocumentConverter.INSTANCE.convert(polygon); - Shape shape = GeoConverters.DocumentToPolygonConverter.INSTANCE.convert(dbo); + Document document = GeoConverters.PolygonToDocumentConverter.INSTANCE.convert(polygon); + Shape shape = GeoConverters.DocumentToPolygonConverter.INSTANCE.convert(document); assertThat(shape, is((org.springframework.data.geo.Shape) polygon)); } @@ -107,12 +107,12 @@ public class MongoConvertersUnitTests { * @see DATAMONGO-858 */ @Test - public void convertsSphereToDbObjectAndBackCorrectly() { + public void convertsSphereToDocumentAndBackCorrectly() { Sphere sphere = new Sphere(new Point(1, 2), 3); - Document dbo = GeoConverters.SphereToDocumentConverter.INSTANCE.convert(sphere); - org.springframework.data.geo.Shape shape = GeoConverters.DocumentToSphereConverter.INSTANCE.convert(dbo); + Document document = GeoConverters.SphereToDocumentConverter.INSTANCE.convert(sphere); + org.springframework.data.geo.Shape shape = GeoConverters.DocumentToSphereConverter.INSTANCE.convert(document); assertThat(shape, is((org.springframework.data.geo.Shape) sphere)); } @@ -125,8 +125,8 @@ public class MongoConvertersUnitTests { Point point = new Point(1, 2); - Document dbo = GeoConverters.PointToDocumentConverter.INSTANCE.convert(point); - org.springframework.data.geo.Point converted = GeoConverters.DocumentToPointConverter.INSTANCE.convert(dbo); + Document document = GeoConverters.PointToDocumentConverter.INSTANCE.convert(point); + org.springframework.data.geo.Point converted = GeoConverters.DocumentToPointConverter.INSTANCE.convert(document); assertThat(converted, is((org.springframework.data.geo.Point) point)); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoExampleMapperUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoExampleMapperUnitTests.java index 24b0141c7..c1f33ca41 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoExampleMapperUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MongoExampleMapperUnitTests.java @@ -19,7 +19,7 @@ import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.springframework.data.domain.Example.*; import static org.springframework.data.domain.ExampleMatcher.*; -import static org.springframework.data.mongodb.core.DBObjectTestUtils.*; +import static org.springframework.data.mongodb.core.DocumentTestUtils.*; import static org.springframework.data.mongodb.test.util.IsBsonObject.*; import java.util.Arrays; @@ -163,10 +163,10 @@ public class MongoExampleMapperUnitTests { probe.flatDoc = new FlatDocument(); probe.flatDoc.stringValue = "conflux"; - org.bson.Document dbo = mapper.getMappedExample(Example.of(probe), + org.bson.Document document = mapper.getMappedExample(Example.of(probe), context.getPersistentEntity(WrapperDocument.class)); - assertThat(dbo, + assertThat(document, isBsonObject().containing("_class", new org.bson.Document("$in", new String[] { probe.getClass().getName() }))); } @@ -326,8 +326,8 @@ public class MongoExampleMapperUnitTests { probe.referenceDocument = new ReferenceDocument(); probe.referenceDocument.id = "200"; - org.bson.Document dbo = mapper.getMappedExample(of(probe), context.getPersistentEntity(WithDBRef.class)); - com.mongodb.DBRef reference = getTypedValue(dbo, "referenceDocument", com.mongodb.DBRef.class); + org.bson.Document document = mapper.getMappedExample(of(probe), context.getPersistentEntity(WithDBRef.class)); + com.mongodb.DBRef reference = getTypedValue(document, "referenceDocument", com.mongodb.DBRef.class); assertThat(reference.getId(), Is.is("200")); assertThat(reference.getCollectionName(), is("refDoc")); @@ -342,9 +342,9 @@ public class MongoExampleMapperUnitTests { FlatDocument probe = new FlatDocument(); probe.stringValue = "steelheart"; - org.bson.Document dbo = mapper.getMappedExample(of(probe), context.getPersistentEntity(FlatDocument.class)); + org.bson.Document document = mapper.getMappedExample(of(probe), context.getPersistentEntity(FlatDocument.class)); - assertThat(dbo, isBsonObject().containing("stringValue", "steelheart")); + assertThat(document, isBsonObject().containing("stringValue", "steelheart")); } /** @@ -356,10 +356,10 @@ public class MongoExampleMapperUnitTests { ClassWithGeoTypes probe = new ClassWithGeoTypes(); probe.legacyPoint = new Point(10D, 20D); - org.bson.Document dbo = mapper.getMappedExample(of(probe), context.getPersistentEntity(WithDBRef.class)); + org.bson.Document document = mapper.getMappedExample(of(probe), context.getPersistentEntity(WithDBRef.class)); - assertThat(dbo.get("legacyPoint.x"), Is.is(10D)); - assertThat(dbo.get("legacyPoint.y"), Is.is(20D)); + assertThat(document.get("legacyPoint.x"), Is.is(10D)); + assertThat(document.get("legacyPoint.y"), Is.is(20D)); } /** @@ -474,9 +474,9 @@ public class MongoExampleMapperUnitTests { probe.customNamedField = "steelheart"; probe.anotherStringValue = "calamity"; - org.bson.Document dbo = mapper.getMappedExample(of(probe), context.getPersistentEntity(FlatDocument.class)); + org.bson.Document document = mapper.getMappedExample(of(probe), context.getPersistentEntity(FlatDocument.class)); - assertThat(dbo, isBsonObject().containing("anotherStringValue", "calamity")); + assertThat(document, isBsonObject().containing("anotherStringValue", "calamity")); } /** diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/NamedMongoScriptConvertsUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/NamedMongoScriptConvertsUnitTests.java index 04404ff56..fab3bbe85 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/NamedMongoScriptConvertsUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/NamedMongoScriptConvertsUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2015 the original author or authors. + * Copyright 2014-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,8 @@ import org.junit.runners.Suite.SuiteClasses; import org.springframework.core.convert.converter.Converter; import org.springframework.data.mongodb.core.convert.MongoConverters.DocumentToNamedMongoScriptConverter; import org.springframework.data.mongodb.core.convert.MongoConverters.NamedMongoScriptToDocumentConverter; -import org.springframework.data.mongodb.core.convert.NamedMongoScriptConvertsUnitTests.DboToNamedMongoScriptConverterUnitTests; -import org.springframework.data.mongodb.core.convert.NamedMongoScriptConvertsUnitTests.NamedMongoScriptToDboConverterUnitTests; +import org.springframework.data.mongodb.core.convert.NamedMongoScriptConvertsUnitTests.DocumentToNamedMongoScriptConverterUnitTests; +import org.springframework.data.mongodb.core.convert.NamedMongoScriptConvertsUnitTests.NamedMongoScriptToDocumentConverterUnitTests; import org.springframework.data.mongodb.core.script.NamedMongoScript; /** @@ -39,7 +39,7 @@ import org.springframework.data.mongodb.core.script.NamedMongoScript; * @since 1.7 */ @RunWith(Suite.class) -@SuiteClasses({ NamedMongoScriptToDboConverterUnitTests.class, DboToNamedMongoScriptConverterUnitTests.class }) +@SuiteClasses({ NamedMongoScriptToDocumentConverterUnitTests.class, DocumentToNamedMongoScriptConverterUnitTests.class }) public class NamedMongoScriptConvertsUnitTests { static final String FUNCTION_NAME = "echo"; @@ -51,7 +51,7 @@ public class NamedMongoScriptConvertsUnitTests { /** * @author Christoph Strobl */ - public static class NamedMongoScriptToDboConverterUnitTests { + public static class NamedMongoScriptToDocumentConverterUnitTests { NamedMongoScriptToDocumentConverter converter = NamedMongoScriptToDocumentConverter.INSTANCE; @@ -59,7 +59,7 @@ public class NamedMongoScriptConvertsUnitTests { * @see DATAMONGO-479 */ @Test - public void convertShouldReturnEmptyDboWhenScriptIsNull() { + public void convertShouldReturnEmptyDocWhenScriptIsNull() { assertThat(converter.convert(null), is((Document) new Document())); } @@ -69,9 +69,9 @@ public class NamedMongoScriptConvertsUnitTests { @Test public void convertShouldConvertScriptNameCorreclty() { - Document dbo = converter.convert(ECHO_SCRIPT); + Document document = converter.convert(ECHO_SCRIPT); - Object id = dbo.get("_id"); + Object id = document.get("_id"); assertThat(id, is(instanceOf(String.class))); assertThat(id, is((Object) FUNCTION_NAME)); } @@ -82,9 +82,9 @@ public class NamedMongoScriptConvertsUnitTests { @Test public void convertShouldConvertScriptCodeCorreclty() { - Document dbo = converter.convert(ECHO_SCRIPT); + Document document = converter.convert(ECHO_SCRIPT); - Object code = dbo.get("value"); + Object code = document.get("value"); assertThat(code, is(instanceOf(Code.class))); assertThat(code, is((Object) new Code(JS_FUNCTION))); } @@ -93,7 +93,7 @@ public class NamedMongoScriptConvertsUnitTests { /** * @author Christoph Strobl */ - public static class DboToNamedMongoScriptConverterUnitTests { + public static class DocumentToNamedMongoScriptConverterUnitTests { DocumentToNamedMongoScriptConverter converter = DocumentToNamedMongoScriptConverter.INSTANCE; diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/QueryMapperUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/QueryMapperUnitTests.java index d399f0c46..c98eec26f 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/QueryMapperUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/QueryMapperUnitTests.java @@ -17,7 +17,7 @@ package org.springframework.data.mongodb.core.convert; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; -import static org.springframework.data.mongodb.core.DBObjectTestUtils.*; +import static org.springframework.data.mongodb.core.DocumentTestUtils.*; 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.IsBsonObject.*; @@ -41,7 +41,7 @@ import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.geo.Point; import org.springframework.data.mongodb.MongoDbFactory; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.mongodb.core.Person; import org.springframework.data.mongodb.core.geo.GeoJsonPoint; import org.springframework.data.mongodb.core.geo.GeoJsonPolygon; @@ -112,8 +112,8 @@ public class QueryMapperUnitTests { @Test public void handlesBigIntegerIdsCorrectly() { - org.bson.Document dbObject = new org.bson.Document("id", new BigInteger("1")); - org.bson.Document result = mapper.getMappedObject(dbObject, context.getPersistentEntity(IdWrapper.class)); + org.bson.Document document = new org.bson.Document("id", new BigInteger("1")); + org.bson.Document result = mapper.getMappedObject(document, context.getPersistentEntity(IdWrapper.class)); assertThat(result.get("_id"), is((Object) "1")); } @@ -121,8 +121,8 @@ public class QueryMapperUnitTests { public void handlesObjectIdCapableBigIntegerIdsCorrectly() { ObjectId id = new ObjectId(); - org.bson.Document dbObject = new org.bson.Document("id", new BigInteger(id.toString(), 16)); - org.bson.Document result = mapper.getMappedObject(dbObject, context.getPersistentEntity(IdWrapper.class)); + org.bson.Document document = new org.bson.Document("id", new BigInteger(id.toString(), 16)); + org.bson.Document result = mapper.getMappedObject(document, context.getPersistentEntity(IdWrapper.class)); assertThat(result.get("_id"), is((Object) id)); } @@ -138,8 +138,8 @@ public class QueryMapperUnitTests { context.getPersistentEntity(Sample.class)); Object object = result.get("_id"); assertThat(object, is(instanceOf(org.bson.Document.class))); - org.bson.Document dbObject = (org.bson.Document) object; - assertThat(dbObject.get("$ne"), is(instanceOf(ObjectId.class))); + org.bson.Document document = (org.bson.Document) object; + assertThat(document.get("$ne"), is(instanceOf(ObjectId.class))); } /** @@ -224,12 +224,12 @@ public class QueryMapperUnitTests { @Test public void doesHandleNestedFieldsWithDefaultIdNames() { - org.bson.Document dbObject = new org.bson.Document("id", new ObjectId().toString()); - dbObject.put("nested", new org.bson.Document("id", new ObjectId().toString())); + org.bson.Document document = new org.bson.Document("id", new ObjectId().toString()); + document.put("nested", new org.bson.Document("id", new ObjectId().toString())); MongoPersistentEntity entity = context.getPersistentEntity(ClassWithDefaultId.class); - org.bson.Document result = mapper.getMappedObject(dbObject, entity); + org.bson.Document result = mapper.getMappedObject(document, entity); assertThat(result.get("_id"), is(instanceOf(ObjectId.class))); assertThat(((org.bson.Document) result.get("nested")).get("_id"), is(instanceOf(ObjectId.class))); } @@ -245,11 +245,11 @@ public class QueryMapperUnitTests { Query query = Query .query(Criteria.where("id").is("id_value").and("publishers").ne(accidentallyAnObjectId.toString())); - org.bson.Document dbObject = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(UserEntity.class)); - assertThat(dbObject.get("publishers"), is(instanceOf(org.bson.Document.class))); + assertThat(document.get("publishers"), is(instanceOf(org.bson.Document.class))); - org.bson.Document publishers = (org.bson.Document) dbObject.get("publishers"); + org.bson.Document publishers = (org.bson.Document) document.get("publishers"); assertThat(publishers.containsKey("$ne"), is(true)); assertThat(publishers.get("$ne"), is(instanceOf(String.class))); } @@ -351,7 +351,7 @@ public class QueryMapperUnitTests { org.bson.Document result = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(WithDBRef.class)); - org.bson.Document reference = DBObjectTestUtils.getAsDocument(result, "reference"); + org.bson.Document reference = DocumentTestUtils.getAsDocument(result, "reference"); List inClause = getAsDBList(reference, "$in"); assertThat(inClause, hasSize(2)); @@ -394,12 +394,12 @@ public class QueryMapperUnitTests { @Test public void handleMapWithDBRefCorrectly() { - org.bson.Document mapDbObject = new org.bson.Document(); - mapDbObject.put("test", new com.mongodb.DBRef("test", "test")); - org.bson.Document dbObject = new org.bson.Document(); - dbObject.put("mapWithDBRef", mapDbObject); + org.bson.Document mapDocument = new org.bson.Document(); + mapDocument.put("test", new com.mongodb.DBRef("test", "test")); + org.bson.Document document = new org.bson.Document(); + document.put("mapWithDBRef", mapDocument); - org.bson.Document mapped = mapper.getMappedObject(dbObject, context.getPersistentEntity(WithMapDBRef.class)); + org.bson.Document mapped = mapper.getMappedObject(document, context.getPersistentEntity(WithMapDBRef.class)); assertThat(mapped.containsKey("mapWithDBRef"), is(true)); assertThat(mapped.get("mapWithDBRef"), instanceOf(org.bson.Document.class)); @@ -410,9 +410,9 @@ public class QueryMapperUnitTests { @Test public void convertsUnderscoreIdValueWithoutMetadata() { - org.bson.Document dbObject = new org.bson.Document().append("_id", new ObjectId().toString()); + org.bson.Document document = new org.bson.Document().append("_id", new ObjectId().toString()); - org.bson.Document mapped = mapper.getMappedObject(dbObject, null); + org.bson.Document mapped = mapper.getMappedObject(document, null); assertThat(mapped.containsKey("_id"), is(true)); assertThat(mapped.get("_id"), is(instanceOf(ObjectId.class))); } @@ -600,8 +600,8 @@ public class QueryMapperUnitTests { embedded2.id = "2"; Query query = query(where("embedded").in(Arrays.asList(embedded, embedded2))); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Foo.class)); - assertThat(dbo, + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Foo.class)); + assertThat(document, equalTo(org.bson.Document.parse("{ \"embedded\" : { \"$in\" : [ { \"_id\" : \"1\"} , { \"_id\" : \"2\"}]}}"))); } @@ -621,9 +621,9 @@ public class QueryMapperUnitTests { .elemMatch(new Criteria(). // andOperator(Criteria.where("customizedField").is(embeddedClass.customizedField)))); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Foo.class)); + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Foo.class)); - assertThat(dbo, isBsonObject().containing("my_items.$elemMatch.$and", + assertThat(document, isBsonObject().containing("my_items.$elemMatch.$and", new BasicDbListBuilder().add(new BasicDBObject("fancy_custom_name", embeddedClass.customizedField)).get())); } @@ -634,9 +634,9 @@ public class QueryMapperUnitTests { public void customizedFieldNameShouldBeMappedCorrectlyWhenApplyingSort() { Query query = query(where("field").is("bar")).with(new Sort(Direction.DESC, "field")); - org.bson.Document dbo = mapper.getMappedObject(query.getSortObject(), + org.bson.Document document = mapper.getMappedObject(query.getSortObject(), context.getPersistentEntity(CustomizedField.class)); - assertThat(dbo, equalTo(new org.bson.Document().append("foo", -1))); + assertThat(document, equalTo(new org.bson.Document().append("foo", -1))); } /** @@ -647,10 +647,10 @@ public class QueryMapperUnitTests { Query query = new Query(); - org.bson.Document dbo = mapper.getMappedFields(query.getFieldsObject(), + org.bson.Document document = mapper.getMappedFields(query.getFieldsObject(), context.getPersistentEntity(WithTextScoreProperty.class)); - assertThat(dbo, equalTo(new org.bson.Document().append("score", new org.bson.Document("$meta", "textScore")))); + assertThat(document, equalTo(new org.bson.Document().append("score", new org.bson.Document("$meta", "textScore")))); } /** @@ -662,10 +662,10 @@ public class QueryMapperUnitTests { Query query = new Query(); query.fields().include("textScore"); - org.bson.Document dbo = mapper.getMappedFields(query.getFieldsObject(), + org.bson.Document document = mapper.getMappedFields(query.getFieldsObject(), context.getPersistentEntity(WithTextScoreProperty.class)); - assertThat(dbo, equalTo(new org.bson.Document().append("score", new org.bson.Document("$meta", "textScore")))); + assertThat(document, equalTo(new org.bson.Document().append("score", new org.bson.Document("$meta", "textScore")))); } /** @@ -676,10 +676,10 @@ public class QueryMapperUnitTests { Query query = new Query().with(new Sort("textScore")); - org.bson.Document dbo = mapper.getMappedSort(query.getSortObject(), + org.bson.Document document = mapper.getMappedSort(query.getSortObject(), context.getPersistentEntity(WithTextScoreProperty.class)); - assertThat(dbo, equalTo(new org.bson.Document().append("score", new org.bson.Document("$meta", "textScore")))); + assertThat(document, equalTo(new org.bson.Document().append("score", new org.bson.Document("$meta", "textScore")))); } /** @@ -690,10 +690,10 @@ public class QueryMapperUnitTests { Query query = new Query().with(new Sort("id")); - org.bson.Document dbo = mapper.getMappedSort(query.getSortObject(), + org.bson.Document document = mapper.getMappedSort(query.getSortObject(), context.getPersistentEntity(WithTextScoreProperty.class)); - assertThat(dbo, equalTo(new org.bson.Document().append("_id", 1))); + assertThat(document, equalTo(new org.bson.Document().append("_id", 1))); } /** @@ -720,10 +720,10 @@ public class QueryMapperUnitTests { Query query = query(where("nested.id").is("bar")); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(RootForClassWithExplicitlyRenamedIdField.class)); - assertThat(dbo, equalTo(new org.bson.Document().append("nested.id", "bar"))); + assertThat(document, equalTo(new org.bson.Document().append("nested.id", "bar"))); } /** @@ -734,10 +734,10 @@ public class QueryMapperUnitTests { Query query = new Query().with(new Sort("nested.id")); - org.bson.Document dbo = mapper.getMappedSort(query.getSortObject(), + org.bson.Document document = mapper.getMappedSort(query.getSortObject(), context.getPersistentEntity(RootForClassWithExplicitlyRenamedIdField.class)); - assertThat(dbo, equalTo(new org.bson.Document().append("nested.id", 1))); + assertThat(document, equalTo(new org.bson.Document().append("nested.id", 1))); } /** @@ -748,12 +748,12 @@ public class QueryMapperUnitTests { Query query = query(where("foo").near(new GeoJsonPoint(100, 50))); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(ClassWithGeoTypes.class)); - assertThat(dbo, isBsonObject().containing("foo.$near.$geometry.type", "Point")); - assertThat(dbo, isBsonObject().containing("foo.$near.$geometry.coordinates.[0]", 100D)); - assertThat(dbo, isBsonObject().containing("foo.$near.$geometry.coordinates.[1]", 50D)); + assertThat(document, isBsonObject().containing("foo.$near.$geometry.type", "Point")); + assertThat(document, isBsonObject().containing("foo.$near.$geometry.coordinates.[0]", 100D)); + assertThat(document, isBsonObject().containing("foo.$near.$geometry.coordinates.[1]", 50D)); } /** @@ -764,10 +764,10 @@ public class QueryMapperUnitTests { Query query = query(where("geoJsonPoint").near(new GeoJsonPoint(100, 50))); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(ClassWithGeoTypes.class)); - assertThat(dbo, isBsonObject().containing("geoJsonPoint.$near.$geometry.type", "Point")); + assertThat(document, isBsonObject().containing("geoJsonPoint.$near.$geometry.type", "Point")); } /** @@ -778,10 +778,10 @@ public class QueryMapperUnitTests { Query query = query(where("geoJsonPoint").nearSphere(new GeoJsonPoint(100, 50))); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(ClassWithGeoTypes.class)); - assertThat(dbo, isBsonObject().containing("geoJsonPoint.$nearSphere.$geometry.type", "Point")); + assertThat(document, isBsonObject().containing("geoJsonPoint.$nearSphere.$geometry.type", "Point")); } /** @@ -792,10 +792,10 @@ public class QueryMapperUnitTests { Query query = query(where("namedGeoJsonPoint").nearSphere(new GeoJsonPoint(100, 50))); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(ClassWithGeoTypes.class)); - assertThat(dbo, + assertThat(document, isBsonObject().containing("geoJsonPointWithNameViaFieldAnnotation.$nearSphere.$geometry.type", "Point")); } @@ -808,10 +808,10 @@ public class QueryMapperUnitTests { Query query = query(where("geoJsonPoint") .within(new GeoJsonPolygon(new Point(0, 0), new Point(100, 100), new Point(100, 0), new Point(0, 0)))); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(ClassWithGeoTypes.class)); - assertThat(dbo, isBsonObject().containing("geoJsonPoint.$geoWithin.$geometry.type", "Polygon")); + assertThat(document, isBsonObject().containing("geoJsonPoint.$geoWithin.$geometry.type", "Polygon")); } /** @@ -823,11 +823,11 @@ public class QueryMapperUnitTests { Query query = query(where("geoJsonPoint") .intersects(new GeoJsonPolygon(new Point(0, 0), new Point(100, 100), new Point(100, 0), new Point(0, 0)))); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(ClassWithGeoTypes.class)); - assertThat(dbo, isBsonObject().containing("geoJsonPoint.$geoIntersects.$geometry.type", "Polygon")); - assertThat(dbo, isBsonObject().containing("geoJsonPoint.$geoIntersects.$geometry.coordinates")); + assertThat(document, isBsonObject().containing("geoJsonPoint.$geoIntersects.$geometry.type", "Polygon")); + assertThat(document, isBsonObject().containing("geoJsonPoint.$geoIntersects.$geometry.coordinates")); } /** @@ -838,10 +838,10 @@ public class QueryMapperUnitTests { Query query = query(where("map.1.stringProperty").is("ba'alzamon")); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(EntityWithComplexValueTypeMap.class)); - assertThat(dbo.containsKey("map.1.stringProperty"), is(true)); + assertThat(document.containsKey("map.1.stringProperty"), is(true)); } /** @@ -852,10 +852,10 @@ public class QueryMapperUnitTests { Query query = query(where("list.1.stringProperty").is("ba'alzamon")); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(EntityWithComplexValueTypeList.class)); - assertThat(dbo.containsKey("list.1.stringProperty"), is(true)); + assertThat(document.containsKey("list.1.stringProperty"), is(true)); } /** @@ -870,9 +870,9 @@ public class QueryMapperUnitTests { Query query = query(byExample(probe)); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Foo.class)); + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(Foo.class)); - assertThat(dbo, isBsonObject().containing("embedded\\._id", "conflux")); + assertThat(document, isBsonObject().containing("embedded\\._id", "conflux")); } /** @@ -886,11 +886,11 @@ public class QueryMapperUnitTests { Query query = query(byExample(probe)); - org.bson.Document dbo = mapper.getMappedObject(query.getQueryObject(), + org.bson.Document document = mapper.getMappedObject(query.getQueryObject(), context.getPersistentEntity(WithDBRef.class)); - assertThat(dbo.get("legacyPoint.x"), Is. is(10D)); - assertThat(dbo.get("legacyPoint.y"), Is. is(20D)); + assertThat(document.get("legacyPoint.x"), Is. is(10D)); + assertThat(document.get("legacyPoint.y"), Is. is(20D)); } @Document diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/UpdateMapperUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/UpdateMapperUnitTests.java index 8d94dc943..a566bd10a 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/UpdateMapperUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/UpdateMapperUnitTests.java @@ -18,7 +18,7 @@ package org.springframework.data.mongodb.core.convert; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import static org.mockito.Mockito.*; -import static org.springframework.data.mongodb.core.DBObjectTestUtils.*; +import static org.springframework.data.mongodb.core.DocumentTestUtils.*; import static org.springframework.data.mongodb.test.util.IsBsonObject.*; import java.time.LocalDate; @@ -43,7 +43,7 @@ import org.springframework.data.annotation.Id; import org.springframework.data.convert.WritingConverter; import org.springframework.data.mapping.model.MappingException; import org.springframework.data.mongodb.MongoDbFactory; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.mongodb.core.mapping.Field; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; import org.springframework.data.mongodb.core.query.Criteria; @@ -118,8 +118,8 @@ public class UpdateMapperUnitTests { context.getPersistentEntity(ModelWrapper.class)); Document set = getAsDocument(mappedObject, "$set"); - Document modelDbObject = (Document) set.get("model"); - assertThat(modelDbObject.get("_class"), not(nullValue())); + Document modelDocument = (Document) set.get("model"); + assertThat(modelDocument.get("_class"), not(nullValue())); } /** @@ -167,8 +167,8 @@ public class UpdateMapperUnitTests { context.getPersistentEntity(ParentClass.class)); Document set = getAsDocument(mappedObject, "$set"); - Document modelDbObject = getAsDocument(set, "aliased.$"); - assertThat(modelDbObject.get("_class"), is(ConcreteChildClass.class.getName())); + Document modelDocument = getAsDocument(set, "aliased.$"); + assertThat(modelDocument.get("_class"), is(ConcreteChildClass.class.getName())); } /** @@ -200,10 +200,10 @@ public class UpdateMapperUnitTests { Document mappedObject = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(ParentClass.class)); - Document dbo = getAsDocument(mappedObject, "$set"); - assertThat(dbo.get("aliased.$.value"), is("foo")); + Document document = getAsDocument(mappedObject, "$set"); + assertThat(document.get("aliased.$.value"), is("foo")); - Document someObject = getAsDocument(dbo, "aliased.$.someObject"); + Document someObject = getAsDocument(document, "aliased.$.someObject"); assertThat(someObject, is(notNullValue())); assertThat(someObject.get("_class"), is(ConcreteChildClass.class.getName())); assertThat(someObject.get("value"), is("bubu")); @@ -515,7 +515,7 @@ public class UpdateMapperUnitTests { * @see DATAMONGO-863 */ @Test - public void doesNotConvertRawDbObjects() { + public void doesNotConvertRawDocuments() { Update update = new Update(); update.pull("options", @@ -581,7 +581,7 @@ public class UpdateMapperUnitTests { Document mappedObject = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(DocumentWithReferenceToInterfaceImpl.class)); - Document $set = DBObjectTestUtils.getAsDocument(mappedObject, "$set"); + Document $set = DocumentTestUtils.getAsDocument(mappedObject, "$set"); Object model = $set.get("referencedDocument"); DBRef expectedDBRef = new DBRef("interfaceDocumentDefinitionImpl", "1"); @@ -598,10 +598,10 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(ParentClass.class)); - Document $pull = DBObjectTestUtils.getAsDocument(mappedUpdate, "$pull"); - Document list = DBObjectTestUtils.getAsDocument($pull, "aliased"); - Document value = DBObjectTestUtils.getAsDocument(list, "value"); - List $in = DBObjectTestUtils.getAsDBList(value, "$in"); + Document $pull = DocumentTestUtils.getAsDocument(mappedUpdate, "$pull"); + Document list = DocumentTestUtils.getAsDocument($pull, "aliased"); + Document value = DocumentTestUtils.getAsDocument(list, "value"); + List $in = DocumentTestUtils.getAsDBList(value, "$in"); assertThat($in, IsIterableContainingInOrder.contains("foo", "bar")); } @@ -616,8 +616,8 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(DocumentWithDBRefCollection.class)); - Document $pull = DBObjectTestUtils.getAsDocument(mappedUpdate, "$pull"); - Document list = DBObjectTestUtils.getAsDocument($pull, "dbRefAnnotatedList"); + Document $pull = DocumentTestUtils.getAsDocument(mappedUpdate, "$pull"); + Document list = DocumentTestUtils.getAsDocument($pull, "dbRefAnnotatedList"); assertThat(list, equalTo(new org.bson.Document().append("_id", "1"))); } @@ -634,7 +634,7 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(DocumentWithDBRefCollection.class)); - Document $unset = DBObjectTestUtils.getAsDocument(mappedUpdate, "$unset"); + Document $unset = DocumentTestUtils.getAsDocument(mappedUpdate, "$unset"); assertThat($unset, equalTo(new org.bson.Document().append("dbRefAnnotatedList.$", 1))); } @@ -840,7 +840,7 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(ConcreteChildClass.class)); - Document $set = DBObjectTestUtils.getAsDocument(mappedUpdate, "$set"); + Document $set = DocumentTestUtils.getAsDocument(mappedUpdate, "$set"); assertThat($set.containsKey("value"), is(true)); assertThat($set.get("value"), nullValue()); } @@ -856,7 +856,7 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(ClassWithJava8Date.class)); - Document $set = DBObjectTestUtils.getAsDocument(mappedUpdate, "$set"); + Document $set = DocumentTestUtils.getAsDocument(mappedUpdate, "$set"); assertThat($set.containsKey("date"), is(true)); assertThat($set.get("value"), nullValue()); } @@ -872,7 +872,7 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(ListModel.class)); - Document $set = DBObjectTestUtils.getAsDocument(mappedUpdate, "$set"); + Document $set = DocumentTestUtils.getAsDocument(mappedUpdate, "$set"); assertThat($set.containsKey("values"), is(true)); assertThat($set.get("value"), nullValue()); } @@ -888,7 +888,7 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(EntityWithObject.class)); - Document $set = DBObjectTestUtils.getAsDocument(mappedUpdate, "$set"); + Document $set = DocumentTestUtils.getAsDocument(mappedUpdate, "$set"); assertThat($set.containsKey("concreteValue.name"), is(true)); assertThat($set.get("concreteValue.name"), nullValue()); } @@ -903,7 +903,7 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(SimpleValueHolder.class)); - Document $set = DBObjectTestUtils.getAsDocument(mappedUpdate, "$set"); + Document $set = DocumentTestUtils.getAsDocument(mappedUpdate, "$set"); assertThat($set.get("intValue"), Is.is(10)); } @@ -917,7 +917,7 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), context.getPersistentEntity(SimpleValueHolder.class)); - Document $set = DBObjectTestUtils.getAsDocument(mappedUpdate, "$set"); + Document $set = DocumentTestUtils.getAsDocument(mappedUpdate, "$set"); assertThat($set.get("primIntValue"), Is.is(10)); } @@ -971,7 +971,7 @@ public class UpdateMapperUnitTests { Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), mappingContext.getPersistentEntity(ClassWithEnum.class)); - Document $set = DBObjectTestUtils.getAsDocument(mappedUpdate, "$set"); + Document $set = DocumentTestUtils.getAsDocument(mappedUpdate, "$set"); assertThat($set.containsKey("enumAsMapKey"), is(true)); Document enumAsMapKey = $set.get("enumAsMapKey", Document.class); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoJsonTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoJsonTests.java index 4ca120816..0be527d31 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoJsonTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoJsonTests.java @@ -49,14 +49,10 @@ import org.springframework.data.mongodb.test.util.BasicDbListBuilder; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.bson.Document; -import com.mongodb.BasicDBObject; -import com.mongodb.DBCollection; import com.mongodb.Mongo; import com.mongodb.MongoClient; import com.mongodb.MongoException; import com.mongodb.WriteConcern; -import com.mongodb.client.MongoCollection; /** * @author Christoph Strobl diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java index 05ef3436e..51ef334a3 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/index/MongoPersistentEntityIndexResolverUnitTests.java @@ -34,7 +34,7 @@ import org.junit.runners.Suite.SuiteClasses; import org.springframework.core.annotation.AliasFor; import org.springframework.data.annotation.Id; import org.springframework.data.geo.Point; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolver.IndexDefinitionHolder; import org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolverUnitTests.CompoundIndexResolutionTests; import org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexResolverUnitTests.GeoSpatialIndexResolutionTests; @@ -695,7 +695,7 @@ public class MongoPersistentEntityIndexResolverUnitTests { assertIndexPathAndCollection(new String[] { "nested.foo" }, "textIndexOnNestedWithWeightRoot", indexDefinitions.get(0)); - org.bson.Document weights = DBObjectTestUtils.getAsDocument(indexDefinitions.get(0).getIndexOptions(), "weights"); + org.bson.Document weights = DocumentTestUtils.getAsDocument(indexDefinitions.get(0).getIndexOptions(), "weights"); assertThat(weights.get("nested.foo"), is((Object) 5F)); } @@ -711,7 +711,7 @@ public class MongoPersistentEntityIndexResolverUnitTests { assertIndexPathAndCollection(new String[] { "nested.foo", "nested.bar" }, "textIndexOnNestedWithMostSpecificValueRoot", indexDefinitions.get(0)); - org.bson.Document weights = DBObjectTestUtils.getAsDocument(indexDefinitions.get(0).getIndexOptions(), "weights"); + org.bson.Document weights = DocumentTestUtils.getAsDocument(indexDefinitions.get(0).getIndexOptions(), "weights"); assertThat(weights.get("nested.foo"), is((Object) 5F)); assertThat(weights.get("nested.bar"), is((Object) 10F)); } @@ -791,7 +791,7 @@ public class MongoPersistentEntityIndexResolverUnitTests { List indexDefinitions = prepareMappingContextAndResolveIndexForType( TextIndexedDocumentWithComposedAnnotation.class); - org.bson.Document weights = DBObjectTestUtils.getAsDocument(indexDefinitions.get(0).getIndexOptions(), "weights"); + org.bson.Document weights = DocumentTestUtils.getAsDocument(indexDefinitions.get(0).getIndexOptions(), "weights"); assertThat(weights, isBsonObject().containing("foo", 99f)); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/GenericMappingTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/GenericMappingTests.java index ed1eb0f58..22234fdb8 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/GenericMappingTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/GenericMappingTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 by the original author(s). + * Copyright (c) 2011-2016 by the original author(s). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,10 +61,10 @@ public class GenericMappingTests { wrapper.container = new Container(); wrapper.container.content = "Foo!"; - Document dbObject = new Document(); - converter.write(wrapper, dbObject); + Document document = new Document(); + converter.write(wrapper, document); - Object container = dbObject.get("container"); + Object container = document.get("container"); assertThat(container, is(notNullValue())); assertTrue(container instanceof Document); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/GeoIndexedTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/GeoIndexedTests.java index 1885d0906..9696d95d8 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/GeoIndexedTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/GeoIndexedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -85,8 +85,8 @@ public class GeoIndexedTests { List indexes = new ArrayList(); collection.listIndexes(Document.class).into(indexes); - for (Document dbo : indexes) { - if ("location".equals(dbo.get("name"))) { + for (Document document : indexes) { + if ("location".equals(document.get("name"))) { return true; } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/MappingTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/MappingTests.java index 66b679862..fd369ed4c 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/MappingTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/MappingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -214,9 +214,9 @@ public class MappingTests extends AbstractIntegrationTests { List indexes = new ArrayList(); collection.listIndexes(Document.class).into(indexes); - for (Document dbo : indexes) { - if (dbo.get("name") != null && dbo.get("name") instanceof String - && ((String) dbo.get("name")).startsWith("name")) { + for (Document document : indexes) { + if (document.get("name") != null && document.get("name") instanceof String + && ((String) document.get("name")).startsWith("name")) { return true; } } @@ -235,9 +235,9 @@ public class MappingTests extends AbstractIntegrationTests { List indexes = new ArrayList(); collection.listIndexes(Document.class).into(indexes); - for (Document dbo : indexes) { - if (dbo.get("name") != null && dbo.get("name") instanceof String - && ((String) dbo.get("name")).startsWith("name")) { + for (Document document : indexes) { + if (document.get("name") != null && document.get("name") instanceof String + && ((String) document.get("name")).startsWith("name")) { return true; } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/event/ApplicationContextEventTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/event/ApplicationContextEventTests.java index 68fdea672..bc258a5d8 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/event/ApplicationContextEventTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapping/event/ApplicationContextEventTests.java @@ -121,16 +121,16 @@ public class ApplicationContextEventTests { BeforeSaveEvent beforeSaveEvent = (BeforeSaveEvent) personBeforeSaveListener.seenEvents .get(0); PersonPojoStringId p2 = beforeSaveEvent.getSource(); - org.bson.Document dbo = beforeSaveEvent.getDocument(); + org.bson.Document document = beforeSaveEvent.getDocument(); - comparePersonAndDbo(p, p2, dbo); + comparePersonAndDocument(p, p2, document); AfterSaveEvent afterSaveEvent = (AfterSaveEvent) afterSaveListener.seenEvents.get(0); Assert.assertTrue(afterSaveEvent.getSource() instanceof PersonPojoStringId); p2 = (PersonPojoStringId) afterSaveEvent.getSource(); - dbo = beforeSaveEvent.getDocument(); + document = beforeSaveEvent.getDocument(); - comparePersonAndDbo(p, p2, dbo); + comparePersonAndDocument(p, p2, document); } /** @@ -416,14 +416,14 @@ public class ApplicationContextEventTests { is(equalTo(RELATED_COLLECTION_NAME))); } - private void comparePersonAndDbo(PersonPojoStringId p, PersonPojoStringId p2, org.bson.Document dbo) { + private void comparePersonAndDocument(PersonPojoStringId p, PersonPojoStringId p2, org.bson.Document document) { assertEquals(p.getId(), p2.getId()); assertEquals(p.getText(), p2.getText()); - assertEquals("org.springframework.data.mongodb.core.mapping.PersonPojoStringId", dbo.get("_class")); - assertEquals("1", dbo.get("_id")); - assertEquals("Text", dbo.get("text")); + assertEquals("org.springframework.data.mongodb.core.mapping.PersonPojoStringId", document.get("_class")); + assertEquals("1", document.get("_id")); + assertEquals("Text", document.get("text")); } @Data diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapreduce/MapReduceOptionsTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapreduce/MapReduceOptionsTests.java index 9cc1728de..b765b8f4b 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapreduce/MapReduceOptionsTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/mapreduce/MapReduceOptionsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 the original author or authors. + * Copyright 2010-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,7 +48,7 @@ public class MapReduceOptionsTests { * @see DATAMONGO-1334 */ @Test - public void limitShouldNotBePresentInDboWhenNotSet() { + public void limitShouldNotBePresentInDocumentWhenNotSet() { assertThat(new MapReduceOptions().getOptionsObject(), isBsonObject().notContaining("limit")); } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/CriteriaTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/CriteriaTests.java index 2d6f0bf53..379eebeb1 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/CriteriaTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/CriteriaTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 the original author or authors. + * Copyright 2010-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,11 +126,11 @@ public class CriteriaTests { * @see DATAMONGO-1068 */ @Test - public void getCriteriaObjectShouldReturnEmptyDBOWhenNoCriteriaSpecified() { + public void getCriteriaObjectShouldReturnEmptyDocumentWhenNoCriteriaSpecified() { - Document dbo = new Criteria().getCriteriaObject(); + Document document = new Criteria().getCriteriaObject(); - assertThat(dbo, equalTo(new Document())); + assertThat(document, equalTo(new Document())); } /** @@ -139,9 +139,9 @@ public class CriteriaTests { @Test public void getCriteriaObjectShouldUseCritieraValuesWhenNoKeyIsPresent() { - Document dbo = new Criteria().lt("foo").getCriteriaObject(); + Document document = new Criteria().lt("foo").getCriteriaObject(); - assertThat(dbo, equalTo(new Document().append("$lt", "foo"))); + assertThat(document, equalTo(new Document().append("$lt", "foo"))); } /** @@ -150,9 +150,9 @@ public class CriteriaTests { @Test public void getCriteriaObjectShouldUseCritieraValuesWhenNoKeyIsPresentButMultipleCriteriasPresent() { - Document dbo = new Criteria().lt("foo").gt("bar").getCriteriaObject(); + Document document = new Criteria().lt("foo").gt("bar").getCriteriaObject(); - assertThat(dbo, equalTo(new Document().append("$lt", "foo").append("$gt", "bar"))); + assertThat(document, equalTo(new Document().append("$lt", "foo").append("$gt", "bar"))); } /** @@ -161,9 +161,9 @@ public class CriteriaTests { @Test public void getCriteriaObjectShouldRespectNotWhenNoKeyPresent() { - Document dbo = new Criteria().lt("foo").not().getCriteriaObject(); + Document document = new Criteria().lt("foo").not().getCriteriaObject(); - assertThat(dbo, equalTo(new Document().append("$not", new Document("$lt", "foo")))); + assertThat(document, equalTo(new Document().append("$not", new Document("$lt", "foo")))); } /** @@ -172,9 +172,9 @@ public class CriteriaTests { @Test public void geoJsonTypesShouldBeWrappedInGeometry() { - Document dbo = new Criteria("foo").near(new GeoJsonPoint(100, 200)).getCriteriaObject(); + Document document = new Criteria("foo").near(new GeoJsonPoint(100, 200)).getCriteriaObject(); - assertThat(dbo, isBsonObject().containing("foo.$near.$geometry", new GeoJsonPoint(100, 200))); + assertThat(document, isBsonObject().containing("foo.$near.$geometry", new GeoJsonPoint(100, 200))); } /** @@ -183,9 +183,9 @@ public class CriteriaTests { @Test public void legacyCoordinateTypesShouldNotBeWrappedInGeometry() { - Document dbo = new Criteria("foo").near(new Point(100, 200)).getCriteriaObject(); + Document document = new Criteria("foo").near(new Point(100, 200)).getCriteriaObject(); - assertThat(dbo, isBsonObject().notContaining("foo.$near.$geometry")); + assertThat(document, isBsonObject().notContaining("foo.$near.$geometry")); } /** @@ -194,9 +194,9 @@ public class CriteriaTests { @Test public void maxDistanceShouldBeMappedInsideNearWhenUsedAlongWithGeoJsonType() { - Document dbo = new Criteria("foo").near(new GeoJsonPoint(100, 200)).maxDistance(50D).getCriteriaObject(); + Document document = new Criteria("foo").near(new GeoJsonPoint(100, 200)).maxDistance(50D).getCriteriaObject(); - assertThat(dbo, isBsonObject().containing("foo.$near.$maxDistance", 50D)); + assertThat(document, isBsonObject().containing("foo.$near.$maxDistance", 50D)); } /** @@ -205,9 +205,9 @@ public class CriteriaTests { @Test public void maxDistanceShouldBeMappedInsideNearSphereWhenUsedAlongWithGeoJsonType() { - Document dbo = new Criteria("foo").nearSphere(new GeoJsonPoint(100, 200)).maxDistance(50D).getCriteriaObject(); + Document document = new Criteria("foo").nearSphere(new GeoJsonPoint(100, 200)).maxDistance(50D).getCriteriaObject(); - assertThat(dbo, isBsonObject().containing("foo.$nearSphere.$maxDistance", 50D)); + assertThat(document, isBsonObject().containing("foo.$nearSphere.$maxDistance", 50D)); } /** @@ -216,9 +216,9 @@ public class CriteriaTests { @Test public void minDistanceShouldBeMappedInsideNearWhenUsedAlongWithGeoJsonType() { - Document dbo = new Criteria("foo").near(new GeoJsonPoint(100, 200)).minDistance(50D).getCriteriaObject(); + Document document = new Criteria("foo").near(new GeoJsonPoint(100, 200)).minDistance(50D).getCriteriaObject(); - assertThat(dbo, isBsonObject().containing("foo.$near.$minDistance", 50D)); + assertThat(document, isBsonObject().containing("foo.$near.$minDistance", 50D)); } /** @@ -227,9 +227,9 @@ public class CriteriaTests { @Test public void minDistanceShouldBeMappedInsideNearSphereWhenUsedAlongWithGeoJsonType() { - Document dbo = new Criteria("foo").nearSphere(new GeoJsonPoint(100, 200)).minDistance(50D).getCriteriaObject(); + Document document = new Criteria("foo").nearSphere(new GeoJsonPoint(100, 200)).minDistance(50D).getCriteriaObject(); - assertThat(dbo, isBsonObject().containing("foo.$nearSphere.$minDistance", 50D)); + assertThat(document, isBsonObject().containing("foo.$nearSphere.$minDistance", 50D)); } /** @@ -238,11 +238,11 @@ public class CriteriaTests { @Test public void minAndMaxDistanceShouldBeMappedInsideNearSphereWhenUsedAlongWithGeoJsonType() { - Document dbo = new Criteria("foo").nearSphere(new GeoJsonPoint(100, 200)).minDistance(50D).maxDistance(100D) + Document document = new Criteria("foo").nearSphere(new GeoJsonPoint(100, 200)).minDistance(50D).maxDistance(100D) .getCriteriaObject(); - assertThat(dbo, isBsonObject().containing("foo.$nearSphere.$minDistance", 50D)); - assertThat(dbo, isBsonObject().containing("foo.$nearSphere.$maxDistance", 100D)); + assertThat(document, isBsonObject().containing("foo.$nearSphere.$minDistance", 50D)); + assertThat(document, isBsonObject().containing("foo.$nearSphere.$maxDistance", 100D)); } /** @@ -260,8 +260,8 @@ public class CriteriaTests { public void intersectsShouldWrapGeoJsonTypeInGeometryCorrectly() { GeoJsonLineString lineString = new GeoJsonLineString(new Point(0, 0), new Point(10, 10)); - Document dbo = new Criteria("foo").intersects(lineString).getCriteriaObject(); + Document document = new Criteria("foo").intersects(lineString).getCriteriaObject(); - assertThat(dbo, isBsonObject().containing("foo.$geoIntersects.$geometry", lineString)); + assertThat(document, isBsonObject().containing("foo.$geoIntersects.$geometry", lineString)); } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/IsTextQuery.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/IsTextQuery.java index dc1e07956..4591e6e1b 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/IsTextQuery.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/IsTextQuery.java @@ -1,5 +1,5 @@ /* - * Copyright 2014 the original author or authors. + * Copyright 2014-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -111,31 +111,31 @@ public class IsTextQuery extends IsQuery { private void appendLanguage(String language) { - Document dbo = getOrCreateTextDbo(); - dbo.put("$language", language); + Document document = getOrCreateTextDocument(); + document.put("$language", language); } - private Document getOrCreateTextDbo() { + private Document getOrCreateTextDocument() { - Document dbo = (Document) query.get("$text"); - if (dbo == null) { - dbo = new Document(); + Document document = (Document) query.get("$text"); + if (document == null) { + document = new Document(); } - return dbo; + return document; } private void appendTerm(String term) { - Document dbo = getOrCreateTextDbo(); - String searchString = (String) dbo.get("$search"); + Document document = getOrCreateTextDocument(); + String searchString = (String) document.get("$search"); if (StringUtils.hasText(searchString)) { searchString += (" " + term); } else { searchString = term; } - dbo.put("$search", searchString); - query.put("$text", dbo); + document.put("$search", searchString); + query.put("$text", document); } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/NearQueryUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/NearQueryUnitTests.java index 1ba8fd721..82cdf01fa 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/NearQueryUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/NearQueryUnitTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2011-2014 the original author or authors. + * Copyright 2011-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ import org.springframework.data.geo.Distance; import org.springframework.data.geo.Metric; import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Point; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; /** * Unit tests for {@link NearQuery}. @@ -156,6 +156,6 @@ public class NearQueryUnitTests { query.num(num); query.query(Query.query(Criteria.where("foo").is("bar"))); - assertThat(DBObjectTestUtils.getTypedValue(query.toDocument(), "num", Integer.class), is(num)); + assertThat(DocumentTestUtils.getTypedValue(query.toDocument(), "num", Integer.class), is(num)); } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/TextCriteriaUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/TextCriteriaUnitTests.java index e399409c9..444b95c58 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/TextCriteriaUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/TextCriteriaUnitTests.java @@ -22,7 +22,7 @@ import static org.hamcrest.core.IsEqual.*; import static org.junit.Assert.*; import org.junit.Test; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; /** * Unit tests for {@link TextCriteria}. @@ -78,7 +78,7 @@ public class TextCriteriaUnitTests { public void shouldCreateSearchFieldForPhraseCorrectly() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matchingPhrase("coffee cake"); - Assert.assertThat(DBObjectTestUtils.getAsDocument(criteria.getCriteriaObject(), "$text"), + Assert.assertThat(DocumentTestUtils.getAsDocument(criteria.getCriteriaObject(), "$text"), IsEqual. equalTo(new Document("$search", "\"coffee cake\""))); } @@ -109,7 +109,7 @@ public class TextCriteriaUnitTests { public void shouldCreateSearchFieldForNotPhraseCorrectly() { TextCriteria criteria = TextCriteria.forDefaultLanguage().notMatchingPhrase("coffee cake"); - Assert.assertThat(DBObjectTestUtils.getAsDocument(criteria.getCriteriaObject(), "$text"), + Assert.assertThat(DocumentTestUtils.getAsDocument(criteria.getCriteriaObject(), "$text"), IsEqual. equalTo(new Document("$search", "-\"coffee cake\""))); } @@ -120,7 +120,7 @@ public class TextCriteriaUnitTests { public void caseSensitiveOperatorShouldBeSetCorrectly() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matching("coffee").caseSensitive(true); - assertThat(DBObjectTestUtils.getAsDocument(criteria.getCriteriaObject(), "$text"), + assertThat(DocumentTestUtils.getAsDocument(criteria.getCriteriaObject(), "$text"), equalTo(new Document("$search", "coffee").append("$caseSensitive", true))); } @@ -131,7 +131,7 @@ public class TextCriteriaUnitTests { public void diacriticSensitiveOperatorShouldBeSetCorrectly() { TextCriteria criteria = TextCriteria.forDefaultLanguage().matching("coffee").diacriticSensitive(true); - assertThat(DBObjectTestUtils.getAsDocument(criteria.getCriteriaObject(), "$text"), + assertThat(DocumentTestUtils.getAsDocument(criteria.getCriteriaObject(), "$text"), equalTo(new Document("$search", "coffee").append("$diacriticSensitive", true))); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/UpdateTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/UpdateTests.java index ad4405599..259cd9d7b 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/UpdateTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/query/UpdateTests.java @@ -25,10 +25,7 @@ import java.util.Map; import org.bson.Document; import org.joda.time.DateTime; import org.junit.Test; -import org.springframework.data.mongodb.core.DBObjectTestUtils; - -import com.mongodb.BasicDBObject; -import com.mongodb.BasicDBObjectBuilder; +import org.springframework.data.mongodb.core.DocumentTestUtils; /** * Test cases for {@link Update}. @@ -249,7 +246,7 @@ public class UpdateTests { * @see DATAMONGO-852 */ @Test - public void testUpdateAffectsFieldShouldReturnTrueWhenUpdateWithKeyCreatedFromDbObject() { + public void testUpdateAffectsFieldShouldReturnTrueWhenUpdateWithKeyCreatedFromDocument() { Update update = new Update().set("foo", "bar"); Update clone = Update.fromDocument(update.getUpdateObject()); @@ -261,7 +258,7 @@ public class UpdateTests { * @see DATAMONGO-852 */ @Test - public void testUpdateAffectsFieldShouldReturnFalseWhenUpdateWithoutKeyCreatedFromDbObject() { + public void testUpdateAffectsFieldShouldReturnFalseWhenUpdateWithoutKeyCreatedFromDocument() { Update update = new Update().set("foo", "bar"); Update clone = Update.fromDocument(update.getUpdateObject()); @@ -490,7 +487,7 @@ public class UpdateTests { Document updateObject = update.getUpdateObject(); - Document pullAll = DBObjectTestUtils.getAsDocument(updateObject, "$pullAll"); + Document pullAll = DocumentTestUtils.getAsDocument(updateObject, "$pullAll"); assertThat(pullAll.get("field1"), is(notNullValue())); assertThat(pullAll.get("field2"), is(notNullValue())); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/performance/PerformanceTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/performance/PerformanceTests.java index 88f665404..b8d93aaa6 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/performance/PerformanceTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/performance/PerformanceTests.java @@ -129,17 +129,17 @@ public class PerformanceTests { Statistics statistics = new Statistics( "Plain conversion of " + NUMBER_OF_PERSONS * 100 + " persons - After %s iterations"); - List dbObjects = getPersonDocuments(NUMBER_OF_PERSONS * 100); + List documents = getPersonDocuments(NUMBER_OF_PERSONS * 100); for (int i = 0; i < ITERATIONS; i++) { - statistics.registerTime(Api.DIRECT, Mode.READ, convertDirectly(dbObjects)); - statistics.registerTime(Api.CONVERTER, Mode.READ, convertUsingConverter(dbObjects)); + statistics.registerTime(Api.DIRECT, Mode.READ, convertDirectly(documents)); + statistics.registerTime(Api.CONVERTER, Mode.READ, convertUsingConverter(documents)); } statistics.printResults(ITERATIONS); } - private long convertDirectly(final List dbObjects) { + private long convertDirectly(final List documents) { executeWatched(new WatchCallback>() { @@ -148,8 +148,8 @@ public class PerformanceTests { List persons = new ArrayList(); - for (Document dbObject : dbObjects) { - persons.add(Person.from(new BasicDBObject(dbObject))); + for (Document document : documents) { + persons.add(Person.from(new BasicDBObject(document))); } return persons; @@ -159,7 +159,7 @@ public class PerformanceTests { return watch.getLastTaskTimeMillis(); } - private long convertUsingConverter(final List dbObjects) { + private long convertUsingConverter(final List documents) { executeWatched(new WatchCallback>() { @@ -168,8 +168,8 @@ public class PerformanceTests { List persons = new ArrayList(); - for (Document dbObject : dbObjects) { - persons.add(converter.read(Person.class, dbObject)); + for (Document document : documents) { + persons.add(converter.read(Person.class, document)); } return persons; @@ -278,11 +278,11 @@ public class PerformanceTests { } private DBObject getCreateCollectionCommand(String name) { - DBObject dbObject = new BasicDBObject(); - dbObject.put("createCollection", name); - dbObject.put("capped", false); - dbObject.put("size", COLLECTION_SIZE); - return dbObject; + DBObject document = new BasicDBObject(); + document.put("createCollection", name); + document.put("capped", false); + document.put("size", COLLECTION_SIZE); + return document; } private long writingObjectsUsingPlainDriver(int numberOfPersons) { @@ -405,13 +405,13 @@ public class PerformanceTests { private List getPersonDocuments(int numberOfPersons) { - List dbObjects = new ArrayList(numberOfPersons); + List documents = new ArrayList(numberOfPersons); for (Person person : getPersonObjects(numberOfPersons)) { - dbObjects.add(person.toDocument()); + documents.add(person.toDocument()); } - return dbObjects; + return documents; } private T executeWatched(WatchCallback callback) { @@ -471,12 +471,12 @@ public class PerformanceTests { public Document toDocument() { - Document dbObject = new Document(); - dbObject.put("firstname", firstname); - dbObject.put("lastname", lastname); - dbObject.put("addresses", writeAll(addresses)); - dbObject.put("orders", writeAll(orders)); - return dbObject; + Document document = new Document(); + document.put("firstname", firstname); + document.put("lastname", lastname); + document.put("addresses", writeAll(addresses)); + document.put("orders", writeAll(orders)); + return document; } } @@ -506,11 +506,11 @@ public class PerformanceTests { } public Document toDocument() { - Document dbObject = new Document(); - dbObject.put("zipCode", zipCode); - dbObject.put("city", city); - dbObject.put("types", toBasicDBList(types)); - return dbObject; + Document document = new Document(); + document.put("zipCode", zipCode); + document.put("city", city); + document.put("types", toBasicDBList(types)); + return document; } } @@ -613,11 +613,11 @@ public class PerformanceTests { public Document toDocument() { - Document dbObject = new Document(); - dbObject.put("description", description); - dbObject.put("price", price); - dbObject.put("amount", amount); - return dbObject; + Document document = new Document(); + document.put("description", description); + document.put("price", price); + document.put("amount", amount); + return document; } } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/StringBasedMongoQueryUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/StringBasedMongoQueryUnitTests.java index 96950e350..a65b649ae 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/StringBasedMongoQueryUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/query/StringBasedMongoQueryUnitTests.java @@ -33,7 +33,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.springframework.data.mongodb.core.DBObjectTestUtils; +import org.springframework.data.mongodb.core.DocumentTestUtils; import org.springframework.data.mongodb.core.MongoOperations; import org.springframework.data.mongodb.core.convert.DbRefResolver; import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper; @@ -98,12 +98,12 @@ public class StringBasedMongoQueryUnitTests { Address address = new Address("Foo", "0123", "Bar"); ConvertingParameterAccessor accesor = StubParameterAccessor.getAccessor(converter, address); - Document dbObject = new Document(); - converter.write(address, dbObject); - dbObject.remove(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY); + Document document = new Document(); + converter.write(address, document); + document.remove(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY); org.springframework.data.mongodb.core.query.Query query = mongoQuery.createQuery(accesor); - Document queryObject = new Document("address", dbObject); + Document queryObject = new Document("address", document); org.springframework.data.mongodb.core.query.Query reference = new BasicQuery(queryObject); assertThat(query.getQueryObject().toJson(), is(reference.getQueryObject().toJson())); @@ -117,12 +117,12 @@ public class StringBasedMongoQueryUnitTests { Address address = new Address("Foo", "0123", "Bar"); ConvertingParameterAccessor accesor = StubParameterAccessor.getAccessor(converter, "Matthews", address); - Document addressDbObject = new Document(); - converter.write(address, addressDbObject); - addressDbObject.remove(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY); + Document addressDocument = new Document(); + converter.write(address, addressDocument); + addressDocument.remove(DefaultMongoTypeMapper.DEFAULT_TYPE_KEY); Document reference = new Document("lastname", "Matthews"); - reference.append("address", addressDbObject); + reference.append("address", addressDocument); org.springframework.data.mongodb.core.query.Query query = mongoQuery.createQuery(accesor); assertThat(query.getQueryObject().toJson(), is(reference.toJson())); @@ -276,7 +276,7 @@ public class StringBasedMongoQueryUnitTests { org.springframework.data.mongodb.core.query.Query query = mongoQuery.createQuery(parameterAccessor); - DBRef dbRef = DBObjectTestUtils.getTypedValue(query.getQueryObject(), "reference", DBRef.class); + DBRef dbRef = DocumentTestUtils.getTypedValue(query.getQueryObject(), "reference", DBRef.class); assertThat(dbRef.getId(), is((Object) "myid")); assertThat(dbRef.getCollectionName(), is("reference")); } diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbSerializerUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbSerializerUnitTests.java index f60507287..32d2d8595 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbSerializerUnitTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/repository/support/SpringDataMongodbSerializerUnitTests.java @@ -17,7 +17,7 @@ package org.springframework.data.mongodb.repository.support; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; -import static org.springframework.data.mongodb.core.DBObjectTestUtils.*; +import static org.springframework.data.mongodb.core.DocumentTestUtils.*; import java.util.List; import java.util.Collections; @@ -95,9 +95,9 @@ public class SpringDataMongodbSerializerUnitTests { DBObject result = serializer.asDBObject("foo", address); assertThat(result, is(instanceOf(BasicDBObject.class))); - BasicDBObject dbObject = (BasicDBObject) result; + BasicDBObject document = (BasicDBObject) result; - Object value = dbObject.get("foo"); + Object value = document.get("foo"); assertThat(value, is(notNullValue())); assertThat(value, is(instanceOf(Document.class))); @@ -163,7 +163,7 @@ public class SpringDataMongodbSerializerUnitTests { * @see DATAMONGO-969 */ @Test - public void shouldConvertCollectionOfObjectIdEvenWhenNestedInOperatorDbObject() { + public void shouldConvertCollectionOfObjectIdEvenWhenNestedInOperatorDocument() { ObjectId firstId = new ObjectId("53bb9fd14438765b29c2d56e"); ObjectId secondId = new ObjectId("53bb9fda4438765b29c2d56f");