diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java index e2ed006f0..0575c8a26 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java @@ -19,11 +19,11 @@ import java.util.Collection; import java.util.List; import java.util.Set; +import org.springframework.data.geo.GeoResults; import org.springframework.data.mongodb.core.aggregation.Aggregation; import org.springframework.data.mongodb.core.aggregation.AggregationResults; import org.springframework.data.mongodb.core.aggregation.TypedAggregation; import org.springframework.data.mongodb.core.convert.MongoConverter; -import org.springframework.data.mongodb.core.geo.GeoResults; import org.springframework.data.mongodb.core.mapreduce.GroupBy; import org.springframework.data.mongodb.core.mapreduce.GroupByResults; import org.springframework.data.mongodb.core.mapreduce.MapReduceOptions; @@ -52,7 +52,6 @@ import com.mongodb.WriteResult; * @author Christoph Strobl * @author Thomas Darimont */ -@SuppressWarnings("deprecation") public interface MongoOperations { /** diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java index 8170898c1..252871e29 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoTemplate.java @@ -53,6 +53,7 @@ import org.springframework.data.authentication.UserCredentials; import org.springframework.data.convert.EntityReader; import org.springframework.data.geo.Distance; import org.springframework.data.geo.GeoResult; +import org.springframework.data.geo.GeoResults; import org.springframework.data.geo.Metric; import org.springframework.data.mapping.context.MappingContext; import org.springframework.data.mapping.model.BeanWrapper; @@ -71,7 +72,6 @@ import org.springframework.data.mongodb.core.convert.MongoConverter; import org.springframework.data.mongodb.core.convert.MongoWriter; import org.springframework.data.mongodb.core.convert.QueryMapper; import org.springframework.data.mongodb.core.convert.UpdateMapper; -import org.springframework.data.mongodb.core.geo.GeoResults; import org.springframework.data.mongodb.core.index.MongoMappingEventPublisher; import org.springframework.data.mongodb.core.index.MongoPersistentEntityIndexCreator; import org.springframework.data.mongodb.core.mapping.MongoMappingContext; diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/GeoConverters.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/GeoConverters.java index ba69103f0..c6c395f1c 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/GeoConverters.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/GeoConverters.java @@ -57,18 +57,15 @@ abstract class GeoConverters { * * @return */ - @SuppressWarnings("unchecked") public static Collection getConvertersToRegister() { return Arrays.asList( // BoxToDbObjectConverter.INSTANCE // , PolygonToDbObjectConverter.INSTANCE // , CircleToDbObjectConverter.INSTANCE // - , LegacyCircleToDbObjectConverter.INSTANCE // , SphereToDbObjectConverter.INSTANCE // , DbObjectToBoxConverter.INSTANCE // , DbObjectToPolygonConverter.INSTANCE // , DbObjectToCircleConverter.INSTANCE // - , DbObjectToLegacyCircleConverter.INSTANCE // , DbObjectToSphereConverter.INSTANCE // , DbObjectToPointConverter.INSTANCE // , PointToDbObjectConverter.INSTANCE // @@ -91,13 +88,11 @@ abstract class GeoConverters { * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) */ @Override - @SuppressWarnings("deprecation") public Point convert(DBObject source) { Assert.isTrue(source.keySet().size() == 2, "Source must contain 2 elements"); - return source == null ? null : new org.springframework.data.mongodb.core.geo.Point((Double) source.get("x"), - (Double) source.get("y")); + return source == null ? null : new Point((Double) source.get("x"), (Double) source.get("y")); } } @@ -151,7 +146,7 @@ abstract class GeoConverters { } /** - * Converts a {@link BasicDBList} into a {@link org.springframework.data.mongodb.core.geo.Box}. + * Converts a {@link BasicDBList} into a {@link Box}. * * @author Thomas Darimont * @since 1.5 @@ -166,7 +161,6 @@ abstract class GeoConverters { * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) */ @Override - @SuppressWarnings("deprecation") public Box convert(DBObject source) { if (source == null) { @@ -176,7 +170,7 @@ abstract class GeoConverters { Point first = DbObjectToPointConverter.INSTANCE.convert((DBObject) source.get("first")); Point second = DbObjectToPointConverter.INSTANCE.convert((DBObject) source.get("second")); - return new org.springframework.data.mongodb.core.geo.Box(first, second); + return new Box(first, second); } } @@ -210,7 +204,7 @@ abstract class GeoConverters { } /** - * Converts a {@link DBObject} into a {@link org.springframework.data.mongodb.core.geo.Circle}. + * Converts a {@link DBObject} into a {@link Circle}. * * @author Thomas Darimont * @since 1.5 @@ -251,71 +245,6 @@ abstract class GeoConverters { } } - /** - * Converts a {@link Circle} into a {@link BasicDBList}. - * - * @author Thomas Darimont - * @since 1.5 - */ - @SuppressWarnings("deprecation") - public static enum LegacyCircleToDbObjectConverter implements - Converter { - - INSTANCE; - - /* - * (non-Javadoc) - * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) - */ - @Override - public DBObject convert(org.springframework.data.mongodb.core.geo.Circle source) { - - if (source == null) { - return null; - } - - DBObject result = new BasicDBObject(); - result.put("center", PointToDbObjectConverter.INSTANCE.convert(source.getCenter())); - result.put("radius", source.getRadius()); - return result; - } - } - - /** - * Converts a {@link BasicDBList} into a {@link org.springframework.data.mongodb.core.geo.Circle}. - * - * @author Thomas Darimont - * @since 1.5 - */ - @ReadingConverter - @SuppressWarnings("deprecation") - public static enum DbObjectToLegacyCircleConverter implements - Converter { - - INSTANCE; - - /* - * (non-Javadoc) - * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) - */ - @Override - public org.springframework.data.mongodb.core.geo.Circle convert(DBObject source) { - - if (source == null) { - return null; - } - - DBObject centerSource = (DBObject) source.get("center"); - Double radius = (Double) source.get("radius"); - - Assert.notNull(centerSource, "Center must not be null!"); - Assert.notNull(radius, "Radius must not be null!"); - - Point center = DbObjectToPointConverter.INSTANCE.convert(centerSource); - return new org.springframework.data.mongodb.core.geo.Circle(center, radius); - } - } - /** * Converts a {@link Sphere} into a {@link BasicDBList}. * @@ -422,7 +351,7 @@ abstract class GeoConverters { } /** - * Converts a {@link BasicDBList} into a {@link org.springframework.data.mongodb.core.geo.Polygon}. + * Converts a {@link BasicDBList} into a {@link Polygon}. * * @author Thomas Darimont * @since 1.5 @@ -437,7 +366,7 @@ abstract class GeoConverters { * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) */ @Override - @SuppressWarnings({ "deprecation", "unchecked" }) + @SuppressWarnings({ "unchecked" }) public Polygon convert(DBObject source) { if (source == null) { @@ -453,7 +382,7 @@ abstract class GeoConverters { newPoints.add(DbObjectToPointConverter.INSTANCE.convert(element)); } - return new org.springframework.data.mongodb.core.geo.Polygon(newPoints); + return new Polygon(newPoints); } } @@ -472,7 +401,6 @@ abstract class GeoConverters { * @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object) */ @Override - @SuppressWarnings("deprecation") public DBObject convert(GeoCommand source) { if (source == null) { @@ -493,10 +421,10 @@ abstract class GeoConverters { argument.add(toList(((Circle) shape).getCenter())); argument.add(((Circle) shape).getRadius().getNormalizedValue()); - } else if (shape instanceof org.springframework.data.mongodb.core.geo.Circle) { + } else if (shape instanceof Circle) { - argument.add(toList(((org.springframework.data.mongodb.core.geo.Circle) shape).getCenter())); - argument.add(((org.springframework.data.mongodb.core.geo.Circle) shape).getRadius()); + argument.add(toList(((Circle) shape).getCenter())); + argument.add(((Circle) shape).getRadius()); } else if (shape instanceof Polygon) { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Box.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Box.java deleted file mode 100644 index d5dd9a6d4..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Box.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2010-2014 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.geo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.springframework.data.geo.Point; - -/** - * Represents a geospatial box value. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Box}. This class is scheduled to be - * removed in the next major release. - * @author Mark Pollack - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public class Box extends org.springframework.data.geo.Box implements Shape { - - public static final String COMMAND = "$box"; - - public Box(Point lowerLeft, Point upperRight) { - super(lowerLeft, upperRight); - } - - public Box(double[] lowerLeft, double[] upperRight) { - super(lowerLeft, upperRight); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Shape#asList() - */ - public List asList() { - - List> list = new ArrayList>(); - - list.add(Arrays.asList(getFirst().getX(), getFirst().getY())); - list.add(Arrays.asList(getSecond().getX(), getSecond().getY())); - - return list; - } - - public org.springframework.data.mongodb.core.geo.Point getLowerLeft() { - return new org.springframework.data.mongodb.core.geo.Point(getFirst()); - } - - public org.springframework.data.mongodb.core.geo.Point getUpperRight() { - return new org.springframework.data.mongodb.core.geo.Point(getSecond()); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Shape#getCommand() - */ - public String getCommand() { - return COMMAND; - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Circle.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Circle.java deleted file mode 100644 index a23b62d72..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Circle.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright 2010-2014 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.geo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.springframework.data.annotation.PersistenceConstructor; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.Metrics; -import org.springframework.data.geo.Point; -import org.springframework.util.Assert; - -/** - * Represents a geospatial circle value. - *

- * Note: We deliberately do not extend org.springframework.data.geo.Circle because introducing it's distance concept - * would break the clients that use the old Circle API. - * - * @author Mark Pollack - * @author Oliver Gierke - * @author Thomas Darimont - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Circle}. This class is scheduled to be - * removed in the next major release. - */ -@Deprecated -public class Circle implements Shape { - - public static final String COMMAND = "$center"; - - private final Point center; - private final double radius; - - /** - * Creates a new {@link Circle} from the given {@link Point} and radius. - * - * @param center must not be {@literal null}. - * @param radius must be greater or equal to zero. - */ - @PersistenceConstructor - public Circle(Point center, double radius) { - - Assert.notNull(center); - Assert.isTrue(radius >= 0, "Radius must not be negative!"); - - this.center = center; - this.radius = radius; - } - - /** - * Creates a new {@link Circle} from the given coordinates and radius as {@link Distance} with a - * {@link Metrics#NEUTRAL}. - * - * @param centerX - * @param centerY - * @param radius must be greater or equal to zero. - */ - public Circle(double centerX, double centerY, double radius) { - this(new Point(centerX, centerY), radius); - } - - /** - * Returns the center of the {@link Circle}. - * - * @return will never be {@literal null}. - */ - public Point getCenter() { - return center; - } - - /** - * Returns the radius of the {@link Circle}. - * - * @return - */ - public double getRadius() { - return radius; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Shape#asList() - */ - public List asList() { - - List result = new ArrayList(); - result.add(Arrays.asList(getCenter().getX(), getCenter().getY())); - result.add(getRadius()); - - return result; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Shape#getCommand() - */ - public String getCommand() { - return COMMAND; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return String.format("Circle [center=%s, radius=%f]", center, radius); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - - if (this == obj) { - return true; - } - - if (obj == null || !getClass().equals(obj.getClass())) { - return false; - } - - Circle that = (Circle) obj; - - return this.center.equals(that.center) && this.radius == that.radius; - } - - /* - * (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - int result = 17; - result += 31 * center.hashCode(); - result += 31 * radius; - return result; - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/CustomMetric.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/CustomMetric.java deleted file mode 100644 index bb5fd4396..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/CustomMetric.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2013-2014 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.geo; - -/** - * Value object to create custom {@link Metric}s on the fly. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Metric}. This class is scheduled to be - * removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public class CustomMetric extends org.springframework.data.geo.CustomMetric implements Metric { - - /** - * Creates a custom {@link Metric} using the given multiplier. - * - * @param multiplier - */ - public CustomMetric(double multiplier) { - super(multiplier); - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Distance.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Distance.java deleted file mode 100644 index 571ffb4e7..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Distance.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2010-2014 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.geo; - -import org.springframework.data.geo.Metric; -import org.springframework.data.geo.Metrics; - -/** - * Value object to represent distances in a given metric. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Distance}. This class is scheduled to - * be removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public class Distance extends org.springframework.data.geo.Distance { - - /** - * Creates a new {@link Distance}. - * - * @param value - */ - public Distance(double value) { - this(value, Metrics.NEUTRAL); - } - - public Distance(double value, Metric metric) { - super(value, metric); - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoPage.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoPage.java deleted file mode 100644 index 33eceda71..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoPage.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; - -/** - * Custom {@link Page} to carry the average distance retrieved from the {@link GeoResults} the {@link GeoPage} is set up - * from. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.GeoPage}. This class is scheduled to - * be removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public class GeoPage extends org.springframework.data.geo.GeoPage { - - private static final long serialVersionUID = 23421312312412L; - - /** - * Creates a new {@link GeoPage} from the given {@link GeoResults}. - * - * @param content must not be {@literal null}. - */ - public GeoPage(GeoResults results) { - super(results); - } - - /** - * Creates a new {@link GeoPage} from the given {@link GeoResults}, {@link Pageable} and total. - * - * @param results must not be {@literal null}. - * @param pageable must not be {@literal null}. - * @param total - */ - public GeoPage(GeoResults results, Pageable pageable, long total) { - super(results, pageable, total); - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResult.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResult.java deleted file mode 100644 index 04601f4a7..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResult.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -/** - * Calue object capturing some arbitrary object plus a distance. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.GeoResult}. This class is scheduled to - * be removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public class GeoResult extends org.springframework.data.geo.GeoResult { - - /** - * Creates a new {@link GeoResult} for the given content and distance. - * - * @param content must not be {@literal null}. - * @param distance must not be {@literal null}. - */ - public GeoResult(T content, Distance distance) { - super(content, distance); - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResults.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResults.java deleted file mode 100644 index 6197a8a1a..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoResults.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import java.util.List; - -import org.springframework.data.annotation.PersistenceConstructor; -import org.springframework.data.geo.Distance; -import org.springframework.data.geo.GeoResult; -import org.springframework.data.geo.Metric; - -/** - * Value object to capture {@link GeoResult}s as well as the average distance they have. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.GeoResults}. This class is scheduled - * to be removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public class GeoResults extends org.springframework.data.geo.GeoResults { - - /** - * Creates a new {@link GeoResults} instance manually calculating the average distance from the distance values of the - * given {@link GeoResult}s. - * - * @param results must not be {@literal null}. - */ - public GeoResults(List> results) { - super(results); - } - - public GeoResults(List> results, Metric metric) { - super(results, metric); - } - - /** - * Creates a new {@link GeoResults} instance from the given {@link GeoResult}s and average distance. - * - * @param results must not be {@literal null}. - * @param averageDistance - */ - @PersistenceConstructor - public GeoResults(List> results, Distance averageDistance) { - super(results, averageDistance); - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metric.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metric.java deleted file mode 100644 index 4db3d1785..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metric.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -/** - * Interface for {@link Metric}s that can be applied to a base scale. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Metric}. This class is scheduled to be - * removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public interface Metric extends org.springframework.data.geo.Metric {} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metrics.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metrics.java deleted file mode 100644 index 2b5939198..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Metrics.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import org.springframework.data.mongodb.core.query.NearQuery; - -/** - * Commonly used {@link Metrics} for {@link NearQuery}s. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Metrics}. This class is scheduled to - * be removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public enum Metrics implements Metric { - - KILOMETERS(org.springframework.data.geo.Metrics.KILOMETERS.getMultiplier()), // - MILES(org.springframework.data.geo.Metrics.MILES.getMultiplier()), // - NEUTRAL(org.springframework.data.geo.Metrics.NEUTRAL.getMultiplier()); // - - private final double multiplier; - - private Metrics(double multiplier) { - this.multiplier = multiplier; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Metric#getMultiplier() - */ - public double getMultiplier() { - return multiplier; - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Point.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Point.java deleted file mode 100644 index 55141dafd..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Point.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2010-2014 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.geo; - -import java.util.Arrays; -import java.util.List; - -import org.springframework.data.annotation.PersistenceConstructor; - -/** - * Represents a geospatial point value. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Point}. This class is scheduled to be - * removed in the next major release. - * @author Mark Pollack - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public class Point extends org.springframework.data.geo.Point { - - @PersistenceConstructor - public Point(double x, double y) { - super(x, y); - } - - public Point(org.springframework.data.geo.Point point) { - super(point); - } - - public double[] asArray() { - return new double[] { getX(), getY() }; - } - - public List asList() { - return asList(this); - } - - public static List asList(org.springframework.data.geo.Point point) { - return Arrays.asList(point.getX(), point.getY()); - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Polygon.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Polygon.java deleted file mode 100644 index 545b727a3..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Polygon.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.springframework.data.geo.Point; - -/** - * Simple value object to represent a {@link Polygon}. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Point}. This class is scheduled to be - * removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public class Polygon extends org.springframework.data.geo.Polygon implements Shape { - - public static final String COMMAND = "$polygon"; - - /** - * Creates a new {@link Polygon} for the given Points. - * - * @param x - * @param y - * @param z - * @param others - */ - public

Polygon(P x, P y, P z, P... others) { - super(x, y, z, others); - } - - /** - * Creates a new {@link Polygon} for the given Points. - * - * @param points - */ - public

Polygon(List

points) { - super(points); - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Shape#getCommand() - */ - public String getCommand() { - return COMMAND; - } - - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Shape#asList() - */ - @Override - public List asList() { - return asList(this); - } - - /** - * Returns a {@link List} of x,y-coordinate tuples of {@link Point}s from the given {@link Polygon}. - * - * @param polygon - * @return - */ - public static List asList(org.springframework.data.geo.Polygon polygon) { - - List points = polygon.getPoints(); - List> tuples = new ArrayList>(points.size()); - - for (Point point : points) { - tuples.add(Arrays.asList(point.getX(), point.getY())); - } - - return tuples; - } -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Shape.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Shape.java deleted file mode 100644 index 3a63935f7..000000000 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Shape.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import java.util.List; - -/** - * Common interface for all shapes. Allows building MongoDB representations of them. - * - * @deprecated As of release 1.5, replaced by {@link org.springframework.data.geo.Shape}. This class is scheduled to be - * removed in the next major release. - * @author Oliver Gierke - * @author Thomas Darimont - */ -@Deprecated -public interface Shape extends org.springframework.data.geo.Shape { - - /** - * Returns the {@link Shape} as a list of usually {@link Double} or {@link List}s of {@link Double}s. Wildcard bound - * to allow implementations to return a more concrete element type. - * - * @return - */ - List asList(); - - /** - * Returns the command to be used to create the {@literal $within} criterion. - * - * @return - */ - String getCommand(); -} diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java index 42390af06..0cb623ef2 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/Sphere.java @@ -22,6 +22,7 @@ import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.data.geo.Circle; import org.springframework.data.geo.Distance; import org.springframework.data.geo.Point; +import org.springframework.data.geo.Shape; import org.springframework.util.Assert; /** @@ -30,7 +31,6 @@ import org.springframework.util.Assert; * @author Thomas Darimont * @since 1.5 */ -@SuppressWarnings("deprecation") public class Sphere implements Shape { public static final String COMMAND = "$centerSphere"; @@ -73,23 +73,13 @@ public class Sphere implements Shape { this(circle.getCenter(), circle.getRadius()); } - /** - * Creates a Sphere from the given {@link Circle}. - * - * @param circle - */ - @Deprecated - public Sphere(org.springframework.data.mongodb.core.geo.Circle circle) { - this(circle.getCenter(), circle.getRadius()); - } - /** * Returns the center of the {@link Circle}. * * @return will never be {@literal null}. */ - public org.springframework.data.mongodb.core.geo.Point getCenter() { - return new org.springframework.data.mongodb.core.geo.Point(this.center); + public Point getCenter() { + return new Point(this.center); } /** @@ -141,20 +131,21 @@ public class Sphere implements Shape { return result; } - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Shape#asList() + /** + * Returns the {@link Shape} as a list of usually {@link Double} or {@link List}s of {@link Double}s. Wildcard bound + * to allow implementations to return a more concrete element type. + * + * @return */ - @Override public List asList() { return Arrays.asList(Arrays.asList(center.getX(), center.getY()), this.radius.getValue()); } - /* - * (non-Javadoc) - * @see org.springframework.data.mongodb.core.geo.Shape#getCommand() + /** + * Returns the command to be used to create the {@literal $within} criterion. + * + * @return */ - @Override public String getCommand() { return COMMAND; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java index 4be68b3bb..f3e215c5e 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/Criteria.java @@ -388,20 +388,6 @@ public class Criteria implements CriteriaDefinition { return this; } - /** - * @see Criteria#withinSphere(Circle) - * @param circle - * @return - * @deprecated As of 1.5, Use {@link #withinSphere(Circle)}. This method is scheduled to be removed in the next major - * release. - */ - @Deprecated - public Criteria withinSphere(org.springframework.data.mongodb.core.geo.Circle circle) { - Assert.notNull(circle); - criteria.put("$within", new GeoCommand(new Sphere(circle))); - return this; - } - /** * Creates a geospatial criterion using a {@literal $within} operation. * diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/GeoCommand.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/GeoCommand.java index 7717c7d60..960b1bc46 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/GeoCommand.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/query/GeoCommand.java @@ -66,17 +66,16 @@ public class GeoCommand { * @param shape must not be {@literal null}. * @return */ - @SuppressWarnings("deprecation") private String getCommand(Shape shape) { Assert.notNull(shape, "Shape must not be null!"); if (shape instanceof Box) { - return org.springframework.data.mongodb.core.geo.Box.COMMAND; - } else if (shape instanceof Circle || shape instanceof org.springframework.data.mongodb.core.geo.Circle) { - return org.springframework.data.mongodb.core.geo.Circle.COMMAND; + return "$box"; + } else if (shape instanceof Circle) { + return "$center"; } else if (shape instanceof Polygon) { - return org.springframework.data.mongodb.core.geo.Polygon.COMMAND; + return "$polygon"; } else if (shape instanceof Sphere) { return org.springframework.data.mongodb.core.geo.Sphere.COMMAND; } diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractMongoQuery.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractMongoQuery.java index 611bd0f9f..f9771dbc6 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractMongoQuery.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/AbstractMongoQuery.java @@ -26,6 +26,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import org.springframework.data.domain.SliceImpl; import org.springframework.data.geo.Distance; +import org.springframework.data.geo.GeoPage; import org.springframework.data.geo.GeoResult; import org.springframework.data.geo.GeoResults; import org.springframework.data.geo.Point; @@ -310,7 +311,6 @@ public abstract class AbstractMongoQuery implements RepositoryQuery { * * @author Oliver Gierke */ - @SuppressWarnings("deprecation") final class GeoNearExecution extends Execution { private final MongoParameterAccessor accessor; @@ -342,12 +342,11 @@ public abstract class AbstractMongoQuery implements RepositoryQuery { MongoEntityMetadata metadata = method.getEntityInformation(); long count = operations.count(countQuery, metadata.getCollectionName()); - return new org.springframework.data.mongodb.core.geo.GeoPage(doExecuteQuery(query), - accessor.getPageable(), count); + return new GeoPage(doExecuteQuery(query), accessor.getPageable(), count); } @SuppressWarnings("unchecked") - private org.springframework.data.mongodb.core.geo.GeoResults doExecuteQuery(Query query) { + private GeoResults doExecuteQuery(Query query) { Point nearLocation = accessor.getGeoNearLocation(); NearQuery nearQuery = NearQuery.near(nearLocation); @@ -367,8 +366,7 @@ public abstract class AbstractMongoQuery implements RepositoryQuery { } MongoEntityMetadata metadata = method.getEntityInformation(); - return (org.springframework.data.mongodb.core.geo.GeoResults) operations.geoNear(nearQuery, - metadata.getJavaType(), metadata.getCollectionName()); + return (GeoResults) operations.geoNear(nearQuery, metadata.getJavaType(), metadata.getCollectionName()); } private boolean isListOfGeoResult() { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoParameters.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoParameters.java index 8e1004e01..debaab3da 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoParameters.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/repository/query/MongoParameters.java @@ -71,11 +71,9 @@ public class MongoParameters extends Parameters this.fullTextIndex = fullTextIndex; } - @SuppressWarnings({ "unchecked", "deprecation" }) private final int getNearIndex(List> parameterTypes) { - for (Class reference : Arrays.asList(Point.class, org.springframework.data.mongodb.core.geo.Point.class, - double[].class)) { + for (Class reference : Arrays.asList(Point.class, double[].class)) { int nearIndex = parameterTypes.indexOf(reference); 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 cc0589e10..3ff7f3e51 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 @@ -31,12 +31,10 @@ import org.springframework.data.mongodb.core.convert.GeoConverters.BoxToDbObject import org.springframework.data.mongodb.core.convert.GeoConverters.CircleToDbObjectConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.DbObjectToBoxConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.DbObjectToCircleConverter; -import org.springframework.data.mongodb.core.convert.GeoConverters.DbObjectToLegacyCircleConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.DbObjectToPointConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.DbObjectToPolygonConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.DbObjectToSphereConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.GeoCommandToDbObjectConverter; -import org.springframework.data.mongodb.core.convert.GeoConverters.LegacyCircleToDbObjectConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.PointToDbObjectConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.PolygonToDbObjectConverter; import org.springframework.data.mongodb.core.convert.GeoConverters.SphereToDbObjectConverter; @@ -52,7 +50,6 @@ import com.mongodb.DBObject; * @author Oliver Gierke * @since 1.5 */ -@SuppressWarnings("deprecation") public class GeoConvertersUnitTests { /** @@ -67,7 +64,7 @@ public class GeoConvertersUnitTests { Box result = DbObjectToBoxConverter.INSTANCE.convert(dbo); assertThat(result, is(box)); - assertThat(result.getClass().equals(org.springframework.data.mongodb.core.geo.Box.class), is(true)); + assertThat(result.getClass().equals(Box.class), is(true)); } /** @@ -100,21 +97,6 @@ public class GeoConvertersUnitTests { assertThat(result.getRadius(), is(radius)); } - /** - * @see DATAMONGO-858 - */ - @Test - public void convertsLegacyCircleToDbObjectAndBackCorrectly() { - - org.springframework.data.mongodb.core.geo.Circle circle = new org.springframework.data.mongodb.core.geo.Circle( - new Point(1, 2), 3); - - DBObject dbo = LegacyCircleToDbObjectConverter.INSTANCE.convert(circle); - org.springframework.data.mongodb.core.geo.Circle result = DbObjectToLegacyCircleConverter.INSTANCE.convert(dbo); - - assertThat(result, is(circle)); - } - /** * @see DATAMONGO-858 */ @@ -127,7 +109,7 @@ public class GeoConvertersUnitTests { Polygon result = DbObjectToPolygonConverter.INSTANCE.convert(dbo); assertThat(result, is(polygon)); - assertThat(result.getClass().equals(org.springframework.data.mongodb.core.geo.Polygon.class), is(true)); + assertThat(result.getClass().equals(Polygon.class), is(true)); } /** @@ -142,7 +124,7 @@ public class GeoConvertersUnitTests { Sphere result = DbObjectToSphereConverter.INSTANCE.convert(dbo); assertThat(result, is(sphere)); - assertThat(result.getClass().equals(org.springframework.data.mongodb.core.geo.Sphere.class), is(true)); + assertThat(result.getClass().equals(Sphere.class), is(true)); } /** @@ -174,14 +156,13 @@ public class GeoConvertersUnitTests { Point result = DbObjectToPointConverter.INSTANCE.convert(dbo); assertThat(result, is(point)); - assertThat(result.getClass().equals(org.springframework.data.mongodb.core.geo.Point.class), is(true)); + assertThat(result.getClass().equals(Point.class), is(true)); } /** * @see DATAMONGO-858 */ @Test - @SuppressWarnings("unchecked") public void convertsGeoCommandToDbObjectCorrectly() { Box box = new Box(new double[] { 1, 2 }, new double[] { 3, 4 }); 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 b7b973afe..b0dd7cdfc 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 @@ -1662,46 +1662,6 @@ public class MappingMongoConverterUnitTests { assertThat(result.circle, is(result.circle)); } - /** - * @DATAMONGO-858 - */ - @Test - @SuppressWarnings("deprecation") - public void shouldWriteEntityWithGeoLegacyCircleCorrectly() { - - ClassWithGeoLegacyCircle object = new ClassWithGeoLegacyCircle(); - org.springframework.data.mongodb.core.geo.Circle circle = new org.springframework.data.mongodb.core.geo.Circle( - new Point(1, 2), 3); - object.circle = circle; - - DBObject dbo = new BasicDBObject(); - converter.write(object, dbo); - - assertThat(dbo, is(notNullValue())); - assertThat(dbo.get("circle"), is(instanceOf(DBObject.class))); - assertThat(dbo.get("circle"), is((Object) new BasicDBObject("center", new BasicDBObject("x", circle.getCenter() - .getX()).append("y", circle.getCenter().getY())).append("radius", circle.getRadius()))); - } - - /** - * @DATAMONGO-858 - */ - @Test - @SuppressWarnings("deprecation") - public void shouldReadEntityWithGeoLegacyCircleCorrectly() { - - ClassWithGeoLegacyCircle object = new ClassWithGeoLegacyCircle(); - object.circle = new org.springframework.data.mongodb.core.geo.Circle(new Point(1, 2), 3); - - DBObject dbo = new BasicDBObject(); - converter.write(object, dbo); - - ClassWithGeoLegacyCircle result = converter.read(ClassWithGeoLegacyCircle.class, dbo); - - assertThat(result, is(notNullValue())); - assertThat(result.circle, is(result.circle)); - } - /** * @DATAMONGO-858 */ @@ -2096,12 +2056,6 @@ public class MappingMongoConverterUnitTests { Circle circle; } - @SuppressWarnings("deprecation") - class ClassWithGeoLegacyCircle { - - org.springframework.data.mongodb.core.geo.Circle circle; - } - class ClassWithGeoSphere { Sphere sphere; diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/BoxUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/BoxUnitTests.java deleted file mode 100644 index 2b401857c..000000000 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/BoxUnitTests.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2011-2014 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. - * 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.geo; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * Unit tests for {@link Box}. - * - * @author Oliver Gierke - */ -@SuppressWarnings("deprecation") -public class BoxUnitTests { - - Box first = new Box(new Point(1d, 1d), new Point(2d, 2d)); - Box second = new Box(new Point(1d, 1d), new Point(2d, 2d)); - Box third = new Box(new Point(3d, 3d), new Point(1d, 1d)); - - @Test - public void equalsWorksCorrectly() { - - assertThat(first.equals(second), is(true)); - assertThat(second.equals(first), is(true)); - assertThat(first.equals(third), is(false)); - } - - @Test - public void hashCodeWorksCorrectly() { - - assertThat(first.hashCode(), is(second.hashCode())); - assertThat(first.hashCode(), is(not(third.hashCode()))); - } -} diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/CircleUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/CircleUnitTests.java deleted file mode 100644 index b0d898e44..000000000 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/CircleUnitTests.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * Unit tests for {@link Circle}. - * - * @author Oliver Gierke - */ -@SuppressWarnings("deprecation") -public class CircleUnitTests { - - @Test(expected = IllegalArgumentException.class) - public void rejectsNullOrigin() { - new Circle(null, 0); - } - - @Test(expected = IllegalArgumentException.class) - public void rejectsNegativeRadius() { - new Circle(1, 1, -1); - } - - @Test - public void considersTwoCirclesEqualCorrectly() { - - Circle left = new Circle(1, 1, 1); - Circle right = new Circle(1, 1, 1); - - assertThat(left, is(right)); - assertThat(right, is(left)); - - right = new Circle(new Point(1, 1), 1); - - assertThat(left, is(right)); - assertThat(right, is(left)); - } -} diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/DistanceUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/DistanceUnitTests.java deleted file mode 100644 index d51fe2547..000000000 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/DistanceUnitTests.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; -import static org.springframework.data.mongodb.core.geo.Metrics.*; - -import org.junit.Test; -import org.springframework.data.geo.Metric; - -/** - * Unit tests for {@link Distance}. - * - * @author Oliver Gierke - * @author Thomas Darimont - */ -@SuppressWarnings("deprecation") -public class DistanceUnitTests { - - @Test - public void defaultsMetricToNeutralOne() { - - assertThat(new Distance(2.5).getMetric(), is((Metric) org.springframework.data.geo.Metrics.NEUTRAL)); - assertThat(new Distance(2.5, null).getMetric(), is((Metric) org.springframework.data.geo.Metrics.NEUTRAL)); - } - - @Test - public void addsDistancesWithoutExplicitMetric() { - - Distance left = new Distance(2.5, KILOMETERS); - Distance right = new Distance(2.5, KILOMETERS); - - assertThat(left.add(right), is(new org.springframework.data.geo.Distance(5.0, KILOMETERS))); - } - - @Test - public void addsDistancesWithExplicitMetric() { - - Distance left = new Distance(2.5, KILOMETERS); - Distance right = new Distance(2.5, KILOMETERS); - - assertThat(left.add(right, MILES), is(new org.springframework.data.geo.Distance(3.106856281073925, MILES))); - } -} diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoResultUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoResultUnitTests.java deleted file mode 100644 index 4a616178a..000000000 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoResultUnitTests.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * Unit tests for {@link GeoResult}. - * - * @author Oliver Gierke - */ -@SuppressWarnings("deprecation") -public class GeoResultUnitTests { - - GeoResult first = new GeoResult("Foo", new Distance(2.5)); - GeoResult second = new GeoResult("Foo", new Distance(2.5)); - GeoResult third = new GeoResult("Bar", new Distance(2.5)); - GeoResult fourth = new GeoResult("Foo", new Distance(5.2)); - - @Test - public void considersSameInstanceEqual() { - - assertThat(first.equals(first), is(true)); - } - - @Test - public void considersSameValuesAsEqual() { - assertThat(first.equals(second), is(true)); - assertThat(second.equals(first), is(true)); - assertThat(first.equals(third), is(false)); - assertThat(third.equals(first), is(false)); - assertThat(first.equals(fourth), is(false)); - assertThat(fourth.equals(first), is(false)); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test(expected = IllegalArgumentException.class) - public void rejectsNullContent() { - new GeoResult(null, new Distance(2.5)); - } -} diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoResultsUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoResultsUnitTests.java deleted file mode 100644 index 82d64db49..000000000 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoResultsUnitTests.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -import java.util.Arrays; - -import org.junit.Test; - -/** - * Unit tests for {@link GeoResults}. - * - * @author Oliver Gierke - * @author Thomas Darimont - */ -@SuppressWarnings("deprecation") -public class GeoResultsUnitTests { - - @Test - @SuppressWarnings("unchecked") - public void calculatesAverageForGivenGeoResults() { - - GeoResult first = new GeoResult(new Object(), new Distance(2)); - GeoResult second = new GeoResult(new Object(), new Distance(5)); - GeoResults geoResults = new GeoResults(Arrays.asList(first, second)); - - assertThat(geoResults.getAverageDistance(), is(new org.springframework.data.geo.Distance(3.5))); - } -} diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoSpatialTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoSpatialTests.java index 9fb0a995a..45f8508a1 100644 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoSpatialTests.java +++ b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/GeoSpatialTests.java @@ -33,6 +33,7 @@ import org.springframework.dao.DataAccessException; import org.springframework.data.domain.Sort.Direction; import org.springframework.data.geo.Box; import org.springframework.data.geo.Circle; +import org.springframework.data.geo.GeoResults; import org.springframework.data.geo.Metric; import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Point; @@ -98,7 +99,6 @@ public class GeoSpatialTests extends AbstractIntegrationTests { } @Test - @SuppressWarnings("deprecation") public void geoNear() { NearQuery geoNear = NearQuery.near(-73, 40, Metrics.KILOMETERS).num(10).maxDistance(150); diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/PointUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/PointUnitTests.java deleted file mode 100644 index 30fdc1810..000000000 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/PointUnitTests.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * Unit tests for {@link Point}. - * - * @author Oliver Gierke - */ -@SuppressWarnings("deprecation") -public class PointUnitTests { - - @Test(expected = IllegalArgumentException.class) - public void rejectsNullforCopyConstructor() { - new Point(null); - } - - @Test - public void equalsIsImplementedCorrectly() { - assertThat(new Point(1.5, 1.5), is(equalTo(new Point(1.5, 1.5)))); - assertThat(new Point(1.5, 1.5), is(not(equalTo(new Point(2.0, 2.0))))); - assertThat(new Point(2.0, 2.0), is(not(equalTo(new Point(1.5, 1.5))))); - } - - @Test - public void invokingToStringWorksCorrectly() { - new Point(1.5, 1.5).toString(); - } -} diff --git a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/PolygonUnitTests.java b/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/PolygonUnitTests.java deleted file mode 100644 index d80329599..000000000 --- a/spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/geo/PolygonUnitTests.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2011-2014 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.geo; - -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; - -import org.junit.Test; - -/** - * Unit tests for {@link Polygon}. - * - * @author Oliver Gierke - */ -@SuppressWarnings("deprecation") -public class PolygonUnitTests { - - Point first = new Point(1, 1); - Point second = new Point(2, 2); - Point third = new Point(3, 3); - - @Test(expected = IllegalArgumentException.class) - public void rejectsNullPoints() { - new Polygon(null, null, null); - } - - @Test - public void createsSimplePolygon() { - Polygon polygon = new Polygon(third, second, first); - assertThat(polygon, is(notNullValue())); - } - - @Test - public void isEqualForSamePoints() { - - Polygon left = new Polygon(third, second, first); - Polygon right = new Polygon(third, second, first); - - assertThat(left, is(right)); - assertThat(right, is(left)); - } -}