From cba9500e47bbc1db628ad818bbad28d851c19848 Mon Sep 17 00:00:00 2001 From: Thomas Darimont Date: Thu, 4 Sep 2014 13:40:07 +0200 Subject: [PATCH] Fix failing MongoDB exposesGeoSpatialFunctionality test case for travis. Make distance check in exposesGeoSpatialFunctionality test case more robust against minor numeric differences. Travis CI seems to use an older Mongo DB version that produces a slightly different result than what we get. --- .../mongodb/customer/CustomerRepositoryIntegrationTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mongodb/example/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java b/mongodb/example/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java index ed80302d..c9d37924 100644 --- a/mongodb/example/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java +++ b/mongodb/example/src/test/java/example/springdata/mongodb/customer/CustomerRepositoryIntegrationTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.*; import java.util.List; +import org.hamcrest.number.IsCloseTo; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -104,6 +105,9 @@ public class CustomerRepositoryIntegrationTest { GeoResults result = repository.findByAddressLocationNear(referenceLocation, oneKilometer); assertThat(result.getContent(), hasSize(1)); - assertThat(result.getContent().get(0).getDistance(), is(new Distance(0.8624842788060683, Metrics.KILOMETERS))); + + Distance distanceToFirstStore = result.getContent().get(0).getDistance(); + assertThat(distanceToFirstStore.getMetric(), is(Metrics.KILOMETERS)); + assertThat(distanceToFirstStore.getValue(), IsCloseTo.closeTo(0.862, 0.001)); } }