Fixed GeoResultsUnitTests.
This commit is contained in:
@@ -136,7 +136,7 @@ public class Distance {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(value);
|
||||
|
||||
if (metric != null) {
|
||||
if (metric != Metrics.NEUTRAL) {
|
||||
builder.append(" ").append(metric.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ public class GeoResults<T> implements Iterable<GeoResult<T>> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the average distance of all {@link GeoResult}s in this list.
|
||||
*
|
||||
* @return the averageDistance
|
||||
*/
|
||||
public Distance getAverageDistance() {
|
||||
|
||||
@@ -15,10 +15,28 @@
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public class GeoResultsUnitTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void calculatesAverageForGivenGeoResults() {
|
||||
|
||||
GeoResult<Object> first = new GeoResult<Object>(new Object(), new Distance(2));
|
||||
GeoResult<Object> second = new GeoResult<Object>(new Object(), new Distance(5));
|
||||
GeoResults<Object> geoResults = new GeoResults<Object>(Arrays.asList(first, second));
|
||||
|
||||
assertThat(geoResults.getAverageDistance(), is(new Distance(3.5)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user