You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/11/10 15:33:18 UTC
[4/5] usergrid git commit: Test for ascending geo-distance in three
of the GeoIT tests.
Test for ascending geo-distance in three of the GeoIT tests.
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/1c0b0a99
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/1c0b0a99
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/1c0b0a99
Branch: refs/heads/master
Commit: 1c0b0a99c48ad86a964a0dcf4a914d9de3384d92
Parents: 73cbd2e
Author: Dave Johnson <sn...@apache.org>
Authored: Tue Nov 10 09:29:35 2015 -0500
Committer: Dave Johnson <sn...@apache.org>
Committed: Tue Nov 10 09:29:35 2015 -0500
----------------------------------------------------------------------
.../org/apache/usergrid/persistence/GeoIT.java | 31 +++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/1c0b0a99/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
index fcc4c32..ae09f97 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/GeoIT.java
@@ -171,7 +171,7 @@ public class GeoIT extends AbstractCoreIT {
*/
@Test
public void validateDistanceQueryExists() throws Exception {
- LOG.info("GeoIT.testMovingTarget");
+ LOG.info("GeoIT.validateDistanceQueryExists");
//Get the EntityManager instance
EntityManager em = app.getEntityManager();
assertNotNull(em);
@@ -191,6 +191,7 @@ public class GeoIT extends AbstractCoreIT {
final double lat = 37.776753;
final double lon = -122.407846;
+
//2. Query from a point near the entity's location
Query query = Query.fromQL("select * where location within 100 of "
+ lat + "," + lon);
@@ -503,11 +504,20 @@ public class GeoIT extends AbstractCoreIT {
int count = 0;
Results results;
+ double previousDistance = 0d;
do {
results = em.searchCollection(em.getApplicationRef(), "stores", query);
for (Entity entity : results.getEntities()) {
assertEquals(String.valueOf(count), entity.getName());
+
+ Object distanceObject = entity.getMetadata("distance");
+ assertNotNull( distanceObject );
+ assertTrue( distanceObject instanceof Double );
+ double distance = (Double)distanceObject;
+ assertTrue( distance >= previousDistance );
+ previousDistance = distance;
+
count++;
}
@@ -550,6 +560,8 @@ public class GeoIT extends AbstractCoreIT {
int count = 0;
Results results;
+
+ double previousDistance = 0d;
do {
results = em.searchCollection(em.getApplicationRef(), "stores", query);
@@ -557,6 +569,13 @@ public class GeoIT extends AbstractCoreIT {
//TODO:can we assert order
final int expected = numEntities - count - 1;
+ Object distanceObject = entity.getMetadata("distance");
+ assertNotNull( distanceObject );
+ assertTrue( distanceObject instanceof Double );
+ double distance = (Double)distanceObject;
+ assertTrue( distance >= previousDistance );
+ previousDistance = distance;
+
assertEquals(String.valueOf(expected), entity.getName());
count++;
}
@@ -616,8 +635,18 @@ public class GeoIT extends AbstractCoreIT {
do {
Results results = em.searchCollection(em.getApplicationRef(), "stores", query);
+ double previousDistance = 0d;
+
for (Entity entity : results.getEntities()) {
assertEquals(String.valueOf(count), entity.getName());
+
+ Object distanceObject = entity.getMetadata("distance");
+ assertNotNull( distanceObject );
+ assertTrue( distanceObject instanceof Double );
+ double distance = (Double)distanceObject;
+ assertTrue( distance >= previousDistance );
+ previousDistance = distance;
+
count++;
}
}