You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by pu...@apache.org on 2016/06/21 17:00:17 UTC

[02/10] incubator-rya git commit: RYA-51 Temporal Indexing mongo support

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/917e7a57/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoFreeTextIndexerTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoFreeTextIndexerTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoFreeTextIndexerTest.java
index 8d52b2d..eac5353 100644
--- a/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoFreeTextIndexerTest.java
+++ b/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoFreeTextIndexerTest.java
@@ -7,9 +7,9 @@ package mvm.rya.indexing.mongo;
  * to you 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
@@ -18,22 +18,9 @@ package mvm.rya.indexing.mongo;
  * under the License.
  */
 
-import info.aduna.iteration.CloseableIteration;
-
 import java.util.HashSet;
 import java.util.Set;
 
-import junit.framework.Assert;
-import mvm.rya.api.domain.RyaStatement;
-import mvm.rya.api.domain.RyaType;
-import mvm.rya.api.domain.RyaURI;
-import mvm.rya.api.resolver.RdfToRyaConversions;
-import mvm.rya.api.resolver.RyaToRdfConversions;
-import mvm.rya.indexing.StatementContraints;
-import mvm.rya.indexing.accumulo.ConfigUtils;
-import mvm.rya.indexing.mongodb.MongoFreeTextIndexer;
-import mvm.rya.mongodb.MongoDBRdfConfiguration;
-
 import org.apache.hadoop.conf.Configuration;
 import org.junit.Before;
 import org.junit.Test;
@@ -46,11 +33,27 @@ import org.openrdf.model.impl.ValueFactoryImpl;
 import org.openrdf.model.vocabulary.RDFS;
 
 import com.google.common.collect.Sets;
+import com.mongodb.MongoClient;
+
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
+import info.aduna.iteration.CloseableIteration;
+import junit.framework.Assert;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaType;
+import mvm.rya.api.domain.RyaURI;
+import mvm.rya.api.resolver.RdfToRyaConversions;
+import mvm.rya.api.resolver.RyaToRdfConversions;
+import mvm.rya.indexing.StatementConstraints;
+import mvm.rya.indexing.accumulo.ConfigUtils;
+import mvm.rya.indexing.mongodb.freetext.MongoFreeTextIndexer;
+import mvm.rya.mongodb.MongoDBRdfConfiguration;
 
 public class MongoFreeTextIndexerTest {
-    private static final StatementContraints EMPTY_CONSTRAINTS = new StatementContraints();
+    private static final StatementConstraints EMPTY_CONSTRAINTS = new StatementConstraints();
 
     Configuration conf;
+    MongoClient mongoClient;
 
     @Before
     public void before() throws Exception {
@@ -59,22 +62,25 @@ public class MongoFreeTextIndexerTest {
         conf.set(MongoDBRdfConfiguration.USE_TEST_MONGO, "true");
         conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test");
         conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_");
+        conf.set(ConfigUtils.FREE_TEXT_DOC_TABLENAME, "freetext");
+        final MongodForTestsFactory testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
+        mongoClient = testsFactory.newMongo();
    }
 
      @Test
     public void testSearch() throws Exception {
-        try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) {
+        try (MongoFreeTextIndexer f = new MongoFreeTextIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
+            final ValueFactory vf = new ValueFactoryImpl();
 
-            URI subject = new URIImpl("foo:subj");
-            URI predicate = RDFS.LABEL;
-            Value object = vf.createLiteral("this is a new hat");
+            final URI subject = new URIImpl("foo:subj");
+            final URI predicate = RDFS.LABEL;
+            final Value object = vf.createLiteral("this is a new hat");
 
-            URI context = new URIImpl("foo:context");
+            final URI context = new URIImpl("foo:context");
 
-            Statement statement = vf.createStatement(subject, predicate, object, context);
+            final Statement statement = vf.createStatement(subject, predicate, object, context);
             f.storeStatement(RdfToRyaConversions.convertStatement(statement));
             f.flush();
 
@@ -87,27 +93,27 @@ public class MongoFreeTextIndexerTest {
 
     @Test
     public void testDelete() throws Exception {
-        try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) {
+        try (MongoFreeTextIndexer f = new MongoFreeTextIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
+            final ValueFactory vf = new ValueFactoryImpl();
 
-            URI subject1 = new URIImpl("foo:subj");
-            URI predicate1 = RDFS.LABEL;
-            Value object1 = vf.createLiteral("this is a new hat");
+            final URI subject1 = new URIImpl("foo:subj");
+            final URI predicate1 = RDFS.LABEL;
+            final Value object1 = vf.createLiteral("this is a new hat");
 
-            URI context1 = new URIImpl("foo:context");
+            final URI context1 = new URIImpl("foo:context");
 
-            Statement statement1 = vf.createStatement(subject1, predicate1, object1, context1);
+            final Statement statement1 = vf.createStatement(subject1, predicate1, object1, context1);
             f.storeStatement(RdfToRyaConversions.convertStatement(statement1));
 
-            URI subject2 = new URIImpl("foo:subject");
-            URI predicate2 = RDFS.LABEL;
-            Value object2 = vf.createLiteral("Do you like my new hat?");
+            final URI subject2 = new URIImpl("foo:subject");
+            final URI predicate2 = RDFS.LABEL;
+            final Value object2 = vf.createLiteral("Do you like my new hat?");
 
-            URI context2 = new URIImpl("foo:context");
+            final URI context2 = new URIImpl("foo:context");
 
-            Statement statement2 = vf.createStatement(subject2, predicate2, object2, context2);
+            final Statement statement2 = vf.createStatement(subject2, predicate2, object2, context2);
             f.storeStatement(RdfToRyaConversions.convertStatement(statement2));
 
             f.flush();
@@ -137,19 +143,19 @@ public class MongoFreeTextIndexerTest {
     public void testRestrictPredicatesSearch() throws Exception {
         conf.setStrings(ConfigUtils.FREETEXT_PREDICATES_LIST, "pred:1,pred:2");
 
-        try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) {
+        try (MongoFreeTextIndexer f = new MongoFreeTextIndexer(mongoClient)) {
             f.setConf(conf);
 
             // These should not be stored because they are not in the predicate list
             f.storeStatement(new RyaStatement(new RyaURI("foo:subj1"), new RyaURI(RDFS.LABEL.toString()), new RyaType("invalid")));
             f.storeStatement(new RyaStatement(new RyaURI("foo:subj2"), new RyaURI(RDFS.COMMENT.toString()), new RyaType("invalid")));
 
-            RyaURI pred1 = new RyaURI("pred:1");
-            RyaURI pred2 = new RyaURI("pred:2");
+            final RyaURI pred1 = new RyaURI("pred:1");
+            final RyaURI pred2 = new RyaURI("pred:2");
 
             // These should be stored because they are in the predicate list
-            RyaStatement s3 = new RyaStatement(new RyaURI("foo:subj3"), pred1, new RyaType("valid"));
-            RyaStatement s4 = new RyaStatement(new RyaURI("foo:subj4"), pred2, new RyaType("valid"));
+            final RyaStatement s3 = new RyaStatement(new RyaURI("foo:subj3"), pred1, new RyaType("valid"));
+            final RyaStatement s4 = new RyaStatement(new RyaURI("foo:subj4"), pred2, new RyaType("valid"));
             f.storeStatement(s3);
             f.storeStatement(s4);
 
@@ -161,7 +167,7 @@ public class MongoFreeTextIndexerTest {
             Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("invalid", EMPTY_CONSTRAINTS)));
             Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("in:validURI", EMPTY_CONSTRAINTS)));
 
-            Set<Statement> actual = getSet(f.queryText("valid", EMPTY_CONSTRAINTS));
+            final Set<Statement> actual = getSet(f.queryText("valid", EMPTY_CONSTRAINTS));
             Assert.assertEquals(2, actual.size());
             Assert.assertTrue(actual.contains(RyaToRdfConversions.convertStatement(s3)));
             Assert.assertTrue(actual.contains(RyaToRdfConversions.convertStatement(s4)));
@@ -170,29 +176,29 @@ public class MongoFreeTextIndexerTest {
 
     @Test
     public void testContextSearch() throws Exception {
-        try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) {
+        try (MongoFreeTextIndexer f = new MongoFreeTextIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            URI subject = new URIImpl("foo:subj");
-            URI predicate = new URIImpl(RDFS.COMMENT.toString());
-            Value object = vf.createLiteral("this is a new hat");
-            URI context = new URIImpl("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final URI subject = new URIImpl("foo:subj");
+            final URI predicate = new URIImpl(RDFS.COMMENT.toString());
+            final Value object = vf.createLiteral("this is a new hat");
+            final URI context = new URIImpl("foo:context");
 
-            Statement statement = vf.createStatement(subject, predicate, object, context);
+            final Statement statement = vf.createStatement(subject, predicate, object, context);
             f.storeStatement(RdfToRyaConversions.convertStatement(statement));
             f.flush();
 
             Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat", EMPTY_CONSTRAINTS)));
-            Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat", new StatementContraints().setContext(context))));
+            Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat", new StatementConstraints().setContext(context))));
             Assert.assertEquals(Sets.newHashSet(),
-                    getSet(f.queryText("hat", new StatementContraints().setContext(vf.createURI("foo:context2")))));
+                    getSet(f.queryText("hat", new StatementConstraints().setContext(vf.createURI("foo:context2")))));
         }
     }
 
- 
-    private static <X> Set<X> getSet(CloseableIteration<X, ?> iter) throws Exception {
-        Set<X> set = new HashSet<X>();
+
+    private static <X> Set<X> getSet(final CloseableIteration<X, ?> iter) throws Exception {
+        final Set<X> set = new HashSet<X>();
         while (iter.hasNext()) {
             set.add(iter.next());
         }

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/917e7a57/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerSfTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerSfTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerSfTest.java
index 7e1eaec..1220370 100644
--- a/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerSfTest.java
+++ b/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerSfTest.java
@@ -1,5 +1,4 @@
 package mvm.rya.indexing.mongo;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -8,9 +7,9 @@ package mvm.rya.indexing.mongo;
  * to you 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
@@ -19,27 +18,11 @@ package mvm.rya.indexing.mongo;
  * under the License.
  */
 
-
-
-import info.aduna.iteration.CloseableIteration;
-
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
-import mvm.rya.api.RdfCloudTripleStoreConfiguration;
-import mvm.rya.api.domain.RyaStatement;
-import mvm.rya.api.resolver.RdfToRyaConversions;
-import mvm.rya.api.resolver.RyaToRdfConversions;
-import mvm.rya.indexing.StatementContraints;
-import mvm.rya.indexing.accumulo.ConfigUtils;
-import mvm.rya.indexing.accumulo.geo.GeoConstants;
-import mvm.rya.indexing.accumulo.geo.GeoMesaGeoIndexer;
-import mvm.rya.indexing.mongodb.MongoGeoIndexer;
-import mvm.rya.mongodb.MongoDBRdfConfiguration;
-
-import org.apache.accumulo.core.client.admin.TableOperations;
 import org.apache.hadoop.conf.Configuration;
 import org.junit.Assert;
 import org.junit.Before;
@@ -54,6 +37,7 @@ import org.openrdf.model.impl.ValueFactoryImpl;
 
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import com.mongodb.MongoClient;
 import com.vividsolutions.jts.geom.Coordinate;
 import com.vividsolutions.jts.geom.Geometry;
 import com.vividsolutions.jts.geom.GeometryFactory;
@@ -64,6 +48,19 @@ import com.vividsolutions.jts.geom.Polygon;
 import com.vividsolutions.jts.geom.PrecisionModel;
 import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence;
 
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
+import info.aduna.iteration.CloseableIteration;
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.resolver.RdfToRyaConversions;
+import mvm.rya.api.resolver.RyaToRdfConversions;
+import mvm.rya.indexing.StatementConstraints;
+import mvm.rya.indexing.accumulo.ConfigUtils;
+import mvm.rya.indexing.accumulo.geo.GeoConstants;
+import mvm.rya.indexing.mongodb.geo.MongoGeoIndexer;
+import mvm.rya.mongodb.MongoDBRdfConfiguration;
+
 /**
  * Tests all of the "simple functions" of the geoindexer.
  */
@@ -72,7 +69,7 @@ public class MongoGeoIndexerSfTest {
     private static GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 4326);
     private static MongoGeoIndexer g;
 
-    private static final StatementContraints EMPTY_CONSTRAINTS = new StatementContraints();
+    private static final StatementConstraints EMPTY_CONSTRAINTS = new StatementConstraints();
 
     // Here is the landscape:
     /**
@@ -122,7 +119,9 @@ public class MongoGeoIndexerSfTest {
         conf.set(ConfigUtils.USE_GEO, "true");
         conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
 
-        g = new MongoGeoIndexer();
+        final MongodForTestsFactory testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
+        final MongoClient mongoClient = testsFactory.newMongo();
+        g = new MongoGeoIndexer(mongoClient);
         g.setConf(conf);
         g.storeStatement(statement(A));
         g.storeStatement(statement(B));
@@ -132,44 +131,44 @@ public class MongoGeoIndexerSfTest {
         g.storeStatement(statement(E));
     }
 
-    private static RyaStatement statement(Geometry geo) {
-        ValueFactory vf = new ValueFactoryImpl();
-        Resource subject = vf.createURI("uri:" + names.get(geo));
-        URI predicate = GeoConstants.GEO_AS_WKT;
-        Value object = vf.createLiteral(geo.toString(), GeoConstants.XMLSCHEMA_OGC_WKT);
+    private static RyaStatement statement(final Geometry geo) {
+        final ValueFactory vf = new ValueFactoryImpl();
+        final Resource subject = vf.createURI("uri:" + names.get(geo));
+        final URI predicate = GeoConstants.GEO_AS_WKT;
+        final Value object = vf.createLiteral(geo.toString(), GeoConstants.XMLSCHEMA_OGC_WKT);
         return RdfToRyaConversions.convertStatement(new StatementImpl(subject, predicate, object));
 
     }
 
-    private static Point point(double x, double y) {
+    private static Point point(final double x, final double y) {
         return gf.createPoint(new Coordinate(x, y));
     }
 
-    private static LineString line(double x1, double y1, double x2, double y2) {
+    private static LineString line(final double x1, final double y1, final double x2, final double y2) {
         return new LineString(new PackedCoordinateSequence.Double(new double[] { x1, y1, x2, y2 }, 2), gf);
     }
 
-    private static Polygon poly(double[] arr) {
-        LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(arr, 2));
-        Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+    private static Polygon poly(final double[] arr) {
+        final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(arr, 2));
+        final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
         return p1;
     }
 
-    private static double[] bbox(double x1, double y1, double x2, double y2) {
+    private static double[] bbox(final double x1, final double y1, final double x2, final double y2) {
         return new double[] { x1, y1, x1, y2, x2, y2, x2, y1, x1, y1 };
     }
 
-    public void compare(CloseableIteration<Statement, ?> actual, Geometry... expected) throws Exception {
-        Set<Statement> expectedSet = Sets.newHashSet();
-        for (Geometry geo : expected) {
+    public void compare(final CloseableIteration<Statement, ?> actual, final Geometry... expected) throws Exception {
+        final Set<Statement> expectedSet = Sets.newHashSet();
+        for (final Geometry geo : expected) {
             expectedSet.add(RyaToRdfConversions.convertStatement(statement(geo)));
         }
 
         Assert.assertEquals(expectedSet, getSet(actual));
     }
 
-    private static <X> Set<X> getSet(CloseableIteration<X, ?> iter) throws Exception {
-        Set<X> set = new HashSet<X>();
+    private static <X> Set<X> getSet(final CloseableIteration<X, ?> iter) throws Exception {
+        final Set<X> set = new HashSet<X>();
         while (iter.hasNext()) {
             set.add(iter.next());
         }

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/917e7a57/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerTest.java
index 4075b29..cdbf36a 100644
--- a/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerTest.java
+++ b/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoGeoIndexerTest.java
@@ -8,9 +8,9 @@ package mvm.rya.indexing.mongo;
  * to you 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
@@ -22,19 +22,11 @@ package mvm.rya.indexing.mongo;
 
 
 import static mvm.rya.api.resolver.RdfToRyaConversions.convertStatement;
-import info.aduna.iteration.CloseableIteration;
 
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
-import mvm.rya.api.RdfCloudTripleStoreConfiguration;
-import mvm.rya.indexing.StatementContraints;
-import mvm.rya.indexing.accumulo.ConfigUtils;
-import mvm.rya.indexing.accumulo.geo.GeoConstants;
-import mvm.rya.indexing.mongodb.MongoGeoIndexer;
-import mvm.rya.mongodb.MongoDBRdfConfiguration;
-
 import org.apache.hadoop.conf.Configuration;
 import org.junit.Assert;
 import org.junit.Before;
@@ -49,6 +41,7 @@ import org.openrdf.model.impl.StatementImpl;
 import org.openrdf.model.impl.ValueFactoryImpl;
 
 import com.google.common.collect.Sets;
+import com.mongodb.MongoClient;
 import com.vividsolutions.jts.geom.Coordinate;
 import com.vividsolutions.jts.geom.GeometryFactory;
 import com.vividsolutions.jts.geom.LinearRing;
@@ -57,11 +50,22 @@ import com.vividsolutions.jts.geom.Polygon;
 import com.vividsolutions.jts.geom.PrecisionModel;
 import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence;
 
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
+import info.aduna.iteration.CloseableIteration;
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.indexing.StatementConstraints;
+import mvm.rya.indexing.accumulo.ConfigUtils;
+import mvm.rya.indexing.accumulo.geo.GeoConstants;
+import mvm.rya.indexing.mongodb.geo.MongoGeoIndexer;
+import mvm.rya.mongodb.MongoDBRdfConfiguration;
+
 public class MongoGeoIndexerTest {
 
-    private static final StatementContraints EMPTY_CONSTRAINTS = new StatementContraints();
+    private static final StatementConstraints EMPTY_CONSTRAINTS = new StatementConstraints();
 
     Configuration conf;
+    MongoClient mongoClient;
     GeometryFactory gf = new GeometryFactory(new PrecisionModel(), 4326);
 
     @Before
@@ -74,30 +78,34 @@ public class MongoGeoIndexerTest {
         conf.set(ConfigUtils.GEO_PREDICATES_LIST, "http://www.opengis.net/ont/geosparql#asWKT");
         conf.set(ConfigUtils.USE_GEO, "true");
         conf.set(RdfCloudTripleStoreConfiguration.CONF_TBL_PREFIX, "rya_");
+        conf.set(ConfigUtils.GEO_TABLENAME, "geospacial");
+
+        final MongodForTestsFactory testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
+        mongoClient = testsFactory.newMongo();
     }
 
     @Test
     public void testRestrictPredicatesSearch() throws Exception {
         conf.setStrings(ConfigUtils.GEO_PREDICATES_LIST, "pred:1,pred:2");
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
+            final ValueFactory vf = new ValueFactoryImpl();
 
-            Point point = gf.createPoint(new Coordinate(10, 10));
-            Value pointValue = vf.createLiteral("Point(10 10)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            URI invalidPredicate = GeoConstants.GEO_AS_WKT;
+            final Point point = gf.createPoint(new Coordinate(10, 10));
+            final Value pointValue = vf.createLiteral("Point(10 10)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final URI invalidPredicate = GeoConstants.GEO_AS_WKT;
 
             // These should not be stored because they are not in the predicate list
             f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj1"), invalidPredicate, pointValue)));
             f.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj2"), invalidPredicate, pointValue)));
 
-            URI pred1 = vf.createURI("pred:1");
-            URI pred2 = vf.createURI("pred:2");
+            final URI pred1 = vf.createURI("pred:1");
+            final URI pred2 = vf.createURI("pred:2");
 
             // These should be stored because they are in the predicate list
-            Statement s3 = new StatementImpl(vf.createURI("foo:subj3"), pred1, pointValue);
-            Statement s4 = new StatementImpl(vf.createURI("foo:subj4"), pred2, pointValue);
+            final Statement s3 = new StatementImpl(vf.createURI("foo:subj3"), pred1, pointValue);
+            final Statement s4 = new StatementImpl(vf.createURI("foo:subj4"), pred2, pointValue);
             f.storeStatement(convertStatement(s3));
             f.storeStatement(convertStatement(s4));
 
@@ -109,15 +117,15 @@ public class MongoGeoIndexerTest {
 
             f.flush();
 
-            Set<Statement> actual = getSet(f.queryEquals(point, EMPTY_CONSTRAINTS));
+            final Set<Statement> actual = getSet(f.queryEquals(point, EMPTY_CONSTRAINTS));
             Assert.assertEquals(2, actual.size());
             Assert.assertTrue(actual.contains(s3));
             Assert.assertTrue(actual.contains(s4));
         }
     }
 
-    private static <X> Set<X> getSet(CloseableIteration<X, ?> iter) throws Exception {
-        Set<X> set = new HashSet<X>();
+    private static <X> Set<X> getSet(final CloseableIteration<X, ?> iter) throws Exception {
+        final Set<X> set = new HashSet<X>();
         while (iter.hasNext()) {
             set.add(iter.next());
         }
@@ -126,43 +134,43 @@ public class MongoGeoIndexerTest {
 
     @Test
     public void testPrimeMeridianSearch() throws Exception {
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            Resource subject = vf.createURI("foo:subj");
-            URI predicate = GeoConstants.GEO_AS_WKT;
-            Value object = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Resource context = vf.createURI("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final Resource subject = vf.createURI("foo:subj");
+            final URI predicate = GeoConstants.GEO_AS_WKT;
+            final Value object = vf.createLiteral("Point(0 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Resource context = vf.createURI("foo:context");
 
-            Statement statement = new ContextStatementImpl(subject, predicate, object, context);
+            final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
             f.storeStatement(convertStatement(statement));
             f.flush();
 
-            double[] ONE = { 1, 1, -1, 1, -1, -1, 1, -1, 1, 1 };
-            double[] TWO = { 2, 2, -2, 2, -2, -2, 2, -2, 2, 2 };
-            double[] THREE = { 3, 3, -3, 3, -3, -3, 3, -3, 3, 3 };
+            final double[] ONE = { 1, 1, -1, 1, -1, -1, 1, -1, 1, 1 };
+            final double[] TWO = { 2, 2, -2, 2, -2, -2, 2, -2, 2, 2 };
+            final double[] THREE = { 3, 3, -3, 3, -3, -3, 3, -3, 3, 3 };
 
-            LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));
-            LinearRing r2 = gf.createLinearRing(new PackedCoordinateSequence.Double(TWO, 2));
-            LinearRing r3 = gf.createLinearRing(new PackedCoordinateSequence.Double(THREE, 2));
+            final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));
+            final LinearRing r2 = gf.createLinearRing(new PackedCoordinateSequence.Double(TWO, 2));
+            final LinearRing r3 = gf.createLinearRing(new PackedCoordinateSequence.Double(THREE, 2));
 
-            Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
-            Polygon p2 = gf.createPolygon(r2, new LinearRing[] {});
-            Polygon p3 = gf.createPolygon(r3, new LinearRing[] {});
+            final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+            final Polygon p2 = gf.createPolygon(r2, new LinearRing[] {});
+            final Polygon p3 = gf.createPolygon(r3, new LinearRing[] {});
 
             Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
             Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p2, EMPTY_CONSTRAINTS)));
             Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p3, EMPTY_CONSTRAINTS)));
 
             // Test a ring with a hole in it
-            Polygon p3m2 = gf.createPolygon(r3, new LinearRing[] { r2 });
+            final Polygon p3m2 = gf.createPolygon(r3, new LinearRing[] { r2 });
             Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p3m2, EMPTY_CONSTRAINTS)));
 
             // test a ring outside the point
-            double[] OUT = { 3, 3, 1, 3, 1, 1, 3, 1, 3, 3 };
-            LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
-            Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
+            final double[] OUT = { 3, 3, 1, 3, 1, 1, 3, 1, 3, 3 };
+            final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
+            final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
             Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
         }
     }
@@ -170,28 +178,28 @@ public class MongoGeoIndexerTest {
     @Test
     public void testDcSearch() throws Exception {
         // test a ring around dc
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            Resource subject = vf.createURI("foo:subj");
-            URI predicate = GeoConstants.GEO_AS_WKT;
-            Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Resource context = vf.createURI("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final Resource subject = vf.createURI("foo:subj");
+            final URI predicate = GeoConstants.GEO_AS_WKT;
+            final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Resource context = vf.createURI("foo:context");
 
-            Statement statement = new ContextStatementImpl(subject, predicate, object, context);
+            final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
             f.storeStatement(convertStatement(statement));
             f.flush();
 
-            double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
-            LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
-            Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+            final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
+            final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
+            final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
             Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
 
             // test a ring outside the point
-            double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
-            LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
-            Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
+            final double[] OUT = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
+            final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(OUT, 2));
+            final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
             Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
         }
     }
@@ -199,38 +207,38 @@ public class MongoGeoIndexerTest {
     @Test
     public void testDeleteSearch() throws Exception {
         // test a ring around dc
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            Resource subject = vf.createURI("foo:subj");
-            URI predicate = GeoConstants.GEO_AS_WKT;
-            Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Resource context = vf.createURI("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final Resource subject = vf.createURI("foo:subj");
+            final URI predicate = GeoConstants.GEO_AS_WKT;
+            final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Resource context = vf.createURI("foo:context");
 
-            Statement statement = new ContextStatementImpl(subject, predicate, object, context);
+            final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
             f.storeStatement(convertStatement(statement));
             f.flush();
 
             f.deleteStatement(convertStatement(statement));
 
             // test a ring that the point would be inside of if not deleted
-            double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
-            LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2));
-            Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+            final double[] in = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
+            final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(in, 2));
+            final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
             Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
 
             // test a ring that the point would be outside of if not deleted
-            double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
-            LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2));
-            Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
+            final double[] out = { -77, 39, -76, 39, -76, 38, -77, 38, -77, 39 };
+            final LinearRing rOut = gf.createLinearRing(new PackedCoordinateSequence.Double(out, 2));
+            final Polygon pOut = gf.createPolygon(rOut, new LinearRing[] {});
             Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pOut, EMPTY_CONSTRAINTS)));
 
             // test a ring for the whole world and make sure the point is gone
             // Geomesa is a little sensitive around lon 180, so we only go to 179
-            double[] world = { -180, 90, 179, 90, 179, -90, -180, -90, -180, 90 };
-            LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
-            Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
+            final double[] world = { -180, 90, 179, 90, 179, -90, -180, -90, -180, 90 };
+            final LinearRing rWorld = gf.createLinearRing(new PackedCoordinateSequence.Double(world, 2));
+            final Polygon pWorld = gf.createPolygon(rWorld, new LinearRing[] {});
             Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(pWorld, EMPTY_CONSTRAINTS)));
         }
     }
@@ -238,151 +246,151 @@ public class MongoGeoIndexerTest {
     @Test
     public void testDcSearchWithContext() throws Exception {
         // test a ring around dc
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            Resource subject = vf.createURI("foo:subj");
-            URI predicate = GeoConstants.GEO_AS_WKT;
-            Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Resource context = vf.createURI("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final Resource subject = vf.createURI("foo:subj");
+            final URI predicate = GeoConstants.GEO_AS_WKT;
+            final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Resource context = vf.createURI("foo:context");
 
-            Statement statement = new ContextStatementImpl(subject, predicate, object, context);
+            final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
             f.storeStatement(convertStatement(statement));
             f.flush();
 
-            double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
-            LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
-            Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+            final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
+            final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
+            final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
 
             // query with correct context
-            Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementContraints().setContext(context))));
+            Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setContext(context))));
 
             // query with wrong context
             Assert.assertEquals(Sets.newHashSet(),
-                    getSet(f.queryWithin(p1, new StatementContraints().setContext(vf.createURI("foo:context2")))));
+                    getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));
         }
     }
 
     @Test
     public void testDcSearchWithSubject() throws Exception {
         // test a ring around dc
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            Resource subject = vf.createURI("foo:subj");
-            URI predicate = GeoConstants.GEO_AS_WKT;
-            Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Resource context = vf.createURI("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final Resource subject = vf.createURI("foo:subj");
+            final URI predicate = GeoConstants.GEO_AS_WKT;
+            final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Resource context = vf.createURI("foo:context");
 
-            Statement statement = new ContextStatementImpl(subject, predicate, object, context);
+            final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
             f.storeStatement(convertStatement(statement));
             f.flush();
 
-            double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
-            LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
-            Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+            final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
+            final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
+            final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
 
             // query with correct subject
-            Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementContraints().setSubject(subject))));
+            Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(subject))));
 
             // query with wrong subject
-            Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementContraints().setSubject(vf.createURI("foo:subj2")))));
+            Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
         }
     }
 
     @Test
     public void testDcSearchWithSubjectAndContext() throws Exception {
         // test a ring around dc
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            Resource subject = vf.createURI("foo:subj");
-            URI predicate = GeoConstants.GEO_AS_WKT;
-            Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Resource context = vf.createURI("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final Resource subject = vf.createURI("foo:subj");
+            final URI predicate = GeoConstants.GEO_AS_WKT;
+            final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Resource context = vf.createURI("foo:context");
 
-            Statement statement = new ContextStatementImpl(subject, predicate, object, context);
+            final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
             f.storeStatement(convertStatement(statement));
             f.flush();
 
-            double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
-            LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
-            Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+            final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
+            final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
+            final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
 
             // query with correct context subject
             Assert.assertEquals(Sets.newHashSet(statement),
-                    getSet(f.queryWithin(p1, new StatementContraints().setContext(context).setSubject(subject))));
+                    getSet(f.queryWithin(p1, new StatementConstraints().setContext(context).setSubject(subject))));
 
             // query with wrong context
             Assert.assertEquals(Sets.newHashSet(),
-                    getSet(f.queryWithin(p1, new StatementContraints().setContext(vf.createURI("foo:context2")))));
+                    getSet(f.queryWithin(p1, new StatementConstraints().setContext(vf.createURI("foo:context2")))));
 
             // query with wrong subject
-            Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementContraints().setSubject(vf.createURI("foo:subj2")))));
+            Assert.assertEquals(Sets.newHashSet(), getSet(f.queryWithin(p1, new StatementConstraints().setSubject(vf.createURI("foo:subj2")))));
         }
     }
 
     @Test
     public void testDcSearchWithPredicate() throws Exception {
         // test a ring around dc
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            Resource subject = vf.createURI("foo:subj");
-            URI predicate = GeoConstants.GEO_AS_WKT;
-            Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Resource context = vf.createURI("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final Resource subject = vf.createURI("foo:subj");
+            final URI predicate = GeoConstants.GEO_AS_WKT;
+            final Value object = vf.createLiteral("Point(-77.03524 38.889468)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Resource context = vf.createURI("foo:context");
 
-            Statement statement = new ContextStatementImpl(subject, predicate, object, context);
+            final Statement statement = new ContextStatementImpl(subject, predicate, object, context);
             f.storeStatement(convertStatement(statement));
             f.flush();
 
-            double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
-            LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
-            Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+            final double[] IN = { -78, 39, -77, 39, -77, 38, -78, 38, -78, 39 };
+            final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(IN, 2));
+            final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
 
             // query with correct Predicate
             Assert.assertEquals(Sets.newHashSet(statement),
-                    getSet(f.queryWithin(p1, new StatementContraints().setPredicates(Collections.singleton(predicate)))));
+                    getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(predicate)))));
 
             // query with wrong predicate
             Assert.assertEquals(Sets.newHashSet(),
-                    getSet(f.queryWithin(p1, new StatementContraints().setPredicates(Collections.singleton(vf.createURI("other:pred"))))));
+                    getSet(f.queryWithin(p1, new StatementConstraints().setPredicates(Collections.singleton(vf.createURI("other:pred"))))));
         }
     }
 
     // @Test
     public void testAntiMeridianSearch() throws Exception {
         // verify that a search works if the bounding box crosses the anti meridian
-        try (MongoGeoIndexer f = new MongoGeoIndexer()) {
+        try (MongoGeoIndexer f = new MongoGeoIndexer(mongoClient)) {
             f.setConf(conf);
 
-            ValueFactory vf = new ValueFactoryImpl();
-            Resource context = vf.createURI("foo:context");
+            final ValueFactory vf = new ValueFactoryImpl();
+            final Resource context = vf.createURI("foo:context");
 
-            Resource subjectEast = vf.createURI("foo:subj:east");
-            URI predicateEast = GeoConstants.GEO_AS_WKT;
-            Value objectEast = vf.createLiteral("Point(179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Statement statementEast = new ContextStatementImpl(subjectEast, predicateEast, objectEast, context);
+            final Resource subjectEast = vf.createURI("foo:subj:east");
+            final URI predicateEast = GeoConstants.GEO_AS_WKT;
+            final Value objectEast = vf.createLiteral("Point(179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Statement statementEast = new ContextStatementImpl(subjectEast, predicateEast, objectEast, context);
             f.storeStatement(convertStatement(statementEast));
 
-            Resource subjectWest = vf.createURI("foo:subj:west");
-            URI predicateWest = GeoConstants.GEO_AS_WKT;
-            Value objectWest = vf.createLiteral("Point(-179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
-            Statement statementWest = new ContextStatementImpl(subjectWest, predicateWest, objectWest, context);
+            final Resource subjectWest = vf.createURI("foo:subj:west");
+            final URI predicateWest = GeoConstants.GEO_AS_WKT;
+            final Value objectWest = vf.createLiteral("Point(-179 0)", GeoConstants.XMLSCHEMA_OGC_WKT);
+            final Statement statementWest = new ContextStatementImpl(subjectWest, predicateWest, objectWest, context);
             f.storeStatement(convertStatement(statementWest));
 
             f.flush();
 
-            double[] ONE = { 178.1, 1, -178, 1, -178, -1, 178.1, -1, 178.1, 1 };
+            final double[] ONE = { 178.1, 1, -178, 1, -178, -1, 178.1, -1, 178.1, 1 };
 
-            LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));
+            final LinearRing r1 = gf.createLinearRing(new PackedCoordinateSequence.Double(ONE, 2));
 
-            Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
+            final Polygon p1 = gf.createPolygon(r1, new LinearRing[] {});
 
             Assert.assertEquals(Sets.newHashSet(statementEast, statementWest), getSet(f.queryWithin(p1, EMPTY_CONSTRAINTS)));
         }

http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/917e7a57/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoTemporalIndexerTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoTemporalIndexerTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoTemporalIndexerTest.java
new file mode 100644
index 0000000..c8e1289
--- /dev/null
+++ b/extras/indexing/src/test/java/mvm/rya/indexing/mongo/MongoTemporalIndexerTest.java
@@ -0,0 +1,700 @@
+package mvm.rya.indexing.mongo;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+
+import static mvm.rya.api.resolver.RdfToRyaConversions.convertStatement;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.accumulo.core.client.TableExistsException;
+import org.apache.accumulo.core.client.TableNotFoundException;
+import org.apache.hadoop.conf.Configuration;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.StatementImpl;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.model.vocabulary.RDFS;
+import org.openrdf.query.QueryEvaluationException;
+
+import com.mongodb.DB;
+import com.mongodb.DBCollection;
+import com.mongodb.DBCursor;
+import com.mongodb.DBObject;
+import com.mongodb.MongoClient;
+import com.mongodb.MongoException;
+
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.mongo.tests.MongodForTestsFactory;
+import info.aduna.iteration.CloseableIteration;
+import mvm.rya.indexing.StatementConstraints;
+import mvm.rya.indexing.TemporalInstant;
+import mvm.rya.indexing.TemporalInstantRfc3339;
+import mvm.rya.indexing.TemporalInterval;
+import mvm.rya.indexing.accumulo.ConfigUtils;
+import mvm.rya.indexing.mongodb.temporal.MongoTemporalIndexer;
+import mvm.rya.mongodb.MongoDBRdfConfiguration;
+
+/**
+ * JUnit tests for TemporalIndexer and it's implementation MongoTemporalIndexer
+ *
+ * If you enjoy this test, please read RyaTemporalIndexerTest and YagoKBTest, which contain
+ * many example SPARQL queries and updates and attempts to test independently of Mongo:
+ *
+ *     extras/indexingSail/src/test/java/mvm/rya/indexing/Mongo/RyaTemporalIndexerTest.java
+ *     {@link mvm.rya.indexing.Mongo.RyaTemporalIndexerTest}
+ *     {@link mvm.rya.indexing.Mongo.YagoKBTest.java}
+ *
+ * Remember, this class in instantiated fresh for each @test method.
+ * so fields are reset, unless they are static.
+ *
+ * These are covered:
+ *   Instance {before, equals, after} given Instance
+ *   Instance {before, after, inside} given Interval
+ *   Instance {hasBeginning, hasEnd} given Interval
+ * And a few more.
+ *
+ */
+public final class MongoTemporalIndexerTest {
+    Configuration conf;
+    MongoTemporalIndexer tIndexer;
+    DBCollection collection;
+
+    private static final String URI_PROPERTY_EVENT_TIME = "Property:event:time";
+    private static final String URI_PROPERTY_CIRCA = "Property:circa";
+    private static final String URI_PROPERTY_AT_TIME = "Property:atTime";
+    private static final String STAT_VALUEHASH = "valuehash";
+    private static final String TEST_TEMPORAL_INDEX_TABLE_NAME = "testTemporalIndex";
+    private static final StatementConstraints EMPTY_CONSTRAINTS = new StatementConstraints();
+
+    // Recreate table name for each test instance in this JVM.
+    String uniquePerTestTemporalIndexTableName = TEST_TEMPORAL_INDEX_TABLE_NAME + String.format("%05d", nextTableSuffixAtomic.getAndIncrement());
+    // start at 0, for uniqueness between jvm's consider AtomicLong(new Random().nextLong())
+    private static final AtomicLong nextTableSuffixAtomic = new AtomicLong();
+
+    // Assign this in setUpBeforeClass, store them in each test.
+    // setup() deletes table before each test.
+    static final Statement spo_B00_E01;
+    static final Statement spo_B03_E20;
+    static final Statement spo_B02_E29;
+    static final Statement spo_B02_E30;
+    static final Statement spo_B02_E40;
+    static final Statement spo_B02_E31;
+    static final Statement spo_B29_E30;
+    static final Statement spo_B30_E32;
+
+    // Instants:
+    static final Statement spo_B02;
+    static final int SERIES_OF_SECONDS = 41;
+    static final Statement seriesSpo[] = new Statement[SERIES_OF_SECONDS];
+
+    // These are shared for several tests. Only the seconds are different.
+    // tvB03_E20 read as: interval Begins 3 seconds, ends at 20 seconds
+    static final TemporalInterval tvB00_E01 = new TemporalInterval(makeInstant(00), makeInstant(01));
+    static final TemporalInterval tvB29_E30= new TemporalInterval(makeInstant(29), makeInstant(30));
+    static final TemporalInterval tvB30_E32= new TemporalInterval(makeInstant(30), makeInstant(32));
+    static final TemporalInterval tvB03_E20 = new TemporalInterval(makeInstant(03), makeInstant(20));
+    // 30 seconds, Begins earlier, ends later
+    static final TemporalInterval tvB02_E30= new TemporalInterval(makeInstant(02), makeInstant(30));
+    // use for interval after
+    static final TemporalInterval tvB02_E29= new TemporalInterval(makeInstant(02), makeInstant(29));
+    // same as above, but ends in the middle
+    static final TemporalInterval tvB02_E31 = new TemporalInterval(makeInstant(02), makeInstant(31));
+    // same as above, but ends even later
+    static final TemporalInterval tvB02_E40 = new TemporalInterval(makeInstant(02), makeInstant(40));
+    // instant, match beginnings of several above, before tiB03_E20
+    static final TemporalInstant tsB02 = makeInstant(02);
+    // instant, after all above
+    static final TemporalInstant tsB04 = makeInstant(04);
+
+    // Create a series of instants about times 0 - 40 seconds
+    static final TemporalInstant seriesTs[];
+    static {
+        seriesTs = new TemporalInstant[SERIES_OF_SECONDS];
+        for (int i = 0; i <= 40; i++) {
+            seriesTs[i] = makeInstant(i);
+        }
+    };
+
+    /**
+     * Make an uniform instant with given seconds.
+     */
+    static TemporalInstant makeInstant(final int secondsMakeMeUnique) {
+        return new TemporalInstantRfc3339(2015, 12, 30, 12, 00, secondsMakeMeUnique);
+    }
+
+    static {
+        // Setup the statements only once. Each test will store some of these in there own index table.
+        final ValueFactory vf = new ValueFactoryImpl();
+        final URI pred1_atTime = vf.createURI(URI_PROPERTY_AT_TIME);
+        // tiB03_E20 read as: time interval that Begins 3 seconds, ends at 20 seconds,
+        // Each time element the same, except seconds. year, month, .... minute are the same for each statement below.
+        spo_B00_E01 = new StatementImpl(vf.createURI("foo:event0"), pred1_atTime, vf.createLiteral(tvB00_E01.toString()));
+        spo_B02_E29 = new StatementImpl(vf.createURI("foo:event2"), pred1_atTime, vf.createLiteral(tvB02_E29.toString()));
+        spo_B02_E30 = new StatementImpl(vf.createURI("foo:event2"), pred1_atTime, vf.createLiteral(tvB02_E30.toString()));
+        spo_B02_E31 = new StatementImpl(vf.createURI("foo:event3"), pred1_atTime, vf.createLiteral(tvB02_E31.toString()));
+        spo_B02_E40 = new StatementImpl(vf.createURI("foo:event4"), pred1_atTime, vf.createLiteral(tvB02_E40.toString()));
+        spo_B03_E20 = new StatementImpl(vf.createURI("foo:event5"), pred1_atTime, vf.createLiteral(tvB03_E20.toString()));
+        spo_B29_E30 = new StatementImpl(vf.createURI("foo:event1"), pred1_atTime, vf.createLiteral(tvB29_E30.toString()));
+        spo_B30_E32 = new StatementImpl(vf.createURI("foo:event1"), pred1_atTime, vf.createLiteral(tvB30_E32.toString()));
+        spo_B02 = new StatementImpl(vf.createURI("foo:event6"), pred1_atTime, vf.createLiteral(tsB02.getAsReadable()));
+
+        // Create statements about time instants 0 - 40 seconds
+        for (int i = 0; i < seriesTs.length; i++) {
+            seriesSpo[i] = new StatementImpl(vf.createURI("foo:event0" + i), pred1_atTime, vf.createLiteral(seriesTs[i].getAsReadable()));
+        }
+
+    }
+
+    /**
+     * @throws java.lang.Exception
+     */
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    @Before
+    public void before() throws Exception {
+        conf = new Configuration();
+        conf.set(ConfigUtils.USE_MONGO, "true");
+        conf.set(MongoDBRdfConfiguration.USE_TEST_MONGO, "true");
+        conf.set(MongoDBRdfConfiguration.MONGO_DB_NAME, "test");
+        conf.set(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya_");
+        conf.set(ConfigUtils.TEMPORAL_TABLENAME, uniquePerTestTemporalIndexTableName);
+        // This is from http://linkedevents.org/ontology
+        // and http://motools.sourceforge.net/event/event.html
+        conf.setStrings(ConfigUtils.TEMPORAL_PREDICATES_LIST, ""
+                + URI_PROPERTY_AT_TIME + ","
+                + URI_PROPERTY_CIRCA + ","
+                + URI_PROPERTY_EVENT_TIME);
+
+        final MongodForTestsFactory testsFactory = MongodForTestsFactory.with(Version.Main.PRODUCTION);
+        final MongoClient mongoClient = testsFactory.newMongo();
+        tIndexer = new MongoTemporalIndexer(mongoClient);
+        tIndexer.setConf(conf);
+
+
+        final String dbName = conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME);
+        final DB db = mongoClient.getDB(dbName);
+        collection = db.getCollection(conf.get(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya") + tIndexer.getCollectionName());
+   }
+    /**
+     * @throws java.lang.Exception
+     */
+    @After
+    public void tearDown() throws Exception {
+        tIndexer.close();
+    }
+
+    /**
+     * Test method for {@link MongoTemporalIndexer#storeStatement(convertStatement(org.openrdf.model.Statement)}
+     */
+    @Test
+    public void testStoreStatement() throws IOException {
+        final ValueFactory vf = new ValueFactoryImpl();
+
+        final URI pred1_atTime = vf.createURI(URI_PROPERTY_AT_TIME);
+        final URI pred2_circa = vf.createURI(URI_PROPERTY_CIRCA);
+
+        // Should not be stored because they are not in the predicate list
+        final String validDateStringWithThirteens = "1313-12-13T13:13:13Z";
+        tIndexer.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj1"), RDFS.LABEL, vf.createLiteral(validDateStringWithThirteens))));
+
+        final String invalidDateString = "ThisIsAnInvalidDate";
+        tIndexer.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj2"), pred1_atTime, vf.createLiteral(invalidDateString))));
+
+        // These are different datetimes instant but from different time zones.
+        // This is an arbitrary zone, BRST=Brazil, better if not local.
+        // same as "2015-01-01T01:59:59Z"
+        final String testDate2014InBRST = "2014-12-31T23:59:59-02:00";
+        // next year, same as "2017-01-01T01:59:59Z"
+        final String testDate2016InET = "2016-12-31T20:59:59-05:00";
+
+        // These should be stored because they are in the predicate list.
+        // BUT they will get converted to the same exact datetime in UTC.
+        final Statement s3 = new StatementImpl(vf.createURI("foo:subj3"), pred1_atTime, vf.createLiteral(testDate2014InBRST));
+        final Statement s4 = new StatementImpl(vf.createURI("foo:subj4"), pred2_circa, vf.createLiteral(testDate2016InET));
+        tIndexer.storeStatement(convertStatement(s3));
+        tIndexer.storeStatement(convertStatement(s4));
+
+        // This should not be stored because the object is not a literal
+        tIndexer.storeStatement(convertStatement(new StatementImpl(vf.createURI("foo:subj5"), pred1_atTime, vf.createURI("in:valid"))));
+
+        printTables("junit testing: Temporal entities stored in testStoreStatement");
+        assertEquals(2, tIndexer.getCollection().find().count());
+    }
+
+    @Test
+    public void testDelete() throws IOException, MongoException, TableNotFoundException, TableExistsException, NoSuchAlgorithmException {
+        final ValueFactory vf = new ValueFactoryImpl();
+
+        final URI pred1_atTime = vf.createURI(URI_PROPERTY_AT_TIME);
+        final URI pred2_circa = vf.createURI(URI_PROPERTY_CIRCA);
+
+        final String testDate2014InBRST = "2014-12-31T23:59:59-02:00";
+        final String testDate2016InET = "2016-12-31T20:59:59-05:00";
+
+        // These should be stored because they are in the predicate list.
+        // BUT they will get converted to the same exact datetime in UTC.
+        final Statement s1 = new StatementImpl(vf.createURI("foo:subj3"), pred1_atTime, vf.createLiteral(testDate2014InBRST));
+        final Statement s2 = new StatementImpl(vf.createURI("foo:subj4"), pred2_circa, vf.createLiteral(testDate2016InET));
+        tIndexer.storeStatement(convertStatement(s1));
+        tIndexer.storeStatement(convertStatement(s2));
+
+
+        printTables("junit testing: Temporal entities stored in testDelete before delete");
+        assertEquals("Number of rows stored.", 2, collection.count()); // 4 index entries per statement
+
+        tIndexer.deleteStatement(convertStatement(s1));
+        tIndexer.deleteStatement(convertStatement(s2));
+
+        printTables("junit testing: Temporal entities stored in testDelete after delete");
+        assertEquals("Number of rows stored after delete.", 0, collection.count());
+    }
+
+    /**
+     * Test instant after a given instant.
+     * From the series: instant {equal, before, after} instant
+     * @throws MongoSecurityException
+     * @throws MongoException
+     * @throws TableNotFoundException
+     */
+    @Test
+    public void testQueryInstantAfterInstant() throws IOException, QueryEvaluationException, TableNotFoundException, MongoException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        // these should not match as they are not instances.
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+
+        // seriesSpo[s] and seriesTs[s] are statements and instant for s seconds after the uniform time.
+        final int searchForSeconds = 4;
+        final int expectedResultCount = 9;
+        for (int s = 0; s <= searchForSeconds + expectedResultCount; s++) { // <== logic here
+            tIndexer.storeStatement(convertStatement(seriesSpo[s]));
+        }
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryInstantAfterInstant(seriesTs[searchForSeconds], EMPTY_CONSTRAINTS);
+        int count = 0;
+        while (iter.hasNext()) {
+            final Statement s = iter.next();
+            final Statement nextExpectedStatement = seriesSpo[searchForSeconds + count + 1]; // <== logic here
+            assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
+            count++;
+        }
+        assertEquals("Should find count of rows.", expectedResultCount, count);
+    }
+    /**
+     * Test instant before a given instant.
+     * From the series: instant {equal, before, after} instant
+     */
+    @Test
+    public void testQueryInstantBeforeInstant() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        // these should not match as they are not instances.
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+
+        // seriesSpo[s] and seriesTs[s] are statements and instant for s seconds after the uniform time.
+        final int searchForSeconds = 4;
+        final int expectedResultCount = 4;
+        for (int s = 0; s <= searchForSeconds + 15; s++) { // <== logic here
+            tIndexer.storeStatement(convertStatement(seriesSpo[s]));
+        }
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+
+        iter = tIndexer.queryInstantBeforeInstant(seriesTs[searchForSeconds], EMPTY_CONSTRAINTS);
+        int count = 0;
+        while (iter.hasNext()) {
+            final Statement s = iter.next();
+            final Statement nextExpectedStatement = seriesSpo[count]; // <== logic here
+            assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
+            count++;
+        }
+        assertEquals("Should find count of rows.", expectedResultCount, count);
+    }
+
+    /**
+     * Test instant before given interval.
+     * From the series:  Instance {before, after, inside} given Interval
+     */
+    @Test
+    public void testQueryInstantBeforeInterval() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        // these should not match as they are not instances.
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+
+        // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
+        final TemporalInterval searchForSeconds = tvB02_E31;
+        final int expectedResultCount = 2; // 00 and 01 seconds.
+        for (int s = 0; s <= 40; s++) { // <== logic here
+            tIndexer.storeStatement(convertStatement(seriesSpo[s]));
+        }
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryInstantBeforeInterval(searchForSeconds, EMPTY_CONSTRAINTS);
+        int count = 0;
+        while (iter.hasNext()) {
+            final Statement s = iter.next();
+            final Statement nextExpectedStatement = seriesSpo[count]; // <== logic here
+            assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
+            count++;
+        }
+        assertEquals("Should find count of rows.", expectedResultCount, count);
+    }
+
+    /**
+     * Test instant after given interval.
+     * Instance {before, after, inside} given Interval
+     */
+    @Test
+    public void testQueryInstantAfterInterval() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        // these should not match as they are not instances.
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+
+        // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
+        final TemporalInterval searchAfterInterval = tvB02_E31; // from 2 to 31 seconds
+        final int endingSeconds = 31;
+        final int expectedResultCount = 9; // 32,33,...,40 seconds.
+        for (int s = 0; s <= endingSeconds + expectedResultCount; s++) { // <== logic here
+            tIndexer.storeStatement(convertStatement(seriesSpo[s]));
+        }
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryInstantAfterInterval(searchAfterInterval, EMPTY_CONSTRAINTS);
+        int count = 0;
+        while (iter.hasNext()) {
+            final Statement s = iter.next();
+            final Statement nextExpectedStatement = seriesSpo[count + endingSeconds + 1]; // <== logic here
+            assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
+            count++;
+        }
+        assertEquals("Should find count of rows.", expectedResultCount, count);
+    }
+
+    /**
+     * Test instant inside given interval.
+     * Instance {before, after, inside} given Interval
+     */
+    @Test
+    public void testQueryInstantInsideInterval() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        // these should not match as they are not instances.
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+
+        // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
+        final TemporalInterval searchInsideInterval = tvB02_E31; // from 2 to 31 seconds
+        final int beginningSeconds = 2; // <== logic here, and next few lines.
+        final int endingSeconds = 31;
+        final int expectedResultCount = endingSeconds - beginningSeconds - 1; // 3,4,...,30 seconds.
+        for (int s = 0; s <= 40; s++) {
+            tIndexer.storeStatement(convertStatement(seriesSpo[s]));
+        }
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryInstantInsideInterval(searchInsideInterval, EMPTY_CONSTRAINTS);
+        int count = 0;
+        while (iter.hasNext()) {
+            final Statement s = iter.next();
+            final Statement nextExpectedStatement = seriesSpo[count + beginningSeconds + 1]; // <== logic here
+            assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
+            count++;
+        }
+        assertEquals("Should find count of rows.", expectedResultCount, count);
+    }
+    /**
+     * Test instant is the Beginning of the given interval.
+     * from the series: Instance {hasBeginning, hasEnd} Interval
+     */
+    @Test
+    public void testQueryInstantHasBeginningInterval() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        // these should not match as they are not instances.
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+
+        // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
+        final TemporalInterval searchInsideInterval = tvB02_E31; // from 2 to 31 seconds
+        final int searchSeconds = 2; // <== logic here, and next few lines.
+        final int expectedResultCount = 1; // 2 seconds.
+        for (int s = 0; s <= 10; s++) {
+            tIndexer.storeStatement(convertStatement(seriesSpo[s]));
+        }
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryInstantHasBeginningInterval(searchInsideInterval, EMPTY_CONSTRAINTS);
+        int count = 0;
+        while (iter.hasNext()) {
+            final Statement s = iter.next();
+            final Statement nextExpectedStatement = seriesSpo[searchSeconds]; // <== logic here
+            assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
+            count++;
+        }
+        assertEquals("Should find count of rows.", expectedResultCount, count);
+    }
+    /**
+     * Test instant is the end of the given interval.
+     * from the series: Instance {hasBeginning, hasEnd} Interval
+     */
+    @Test
+    public void testQueryInstantHasEndInterval()  throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        // these should not match as they are not instances.
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+
+        // seriesSpo[s] and seriesTs[s] are statements and instants for s seconds after the uniform time.
+        final TemporalInterval searchInsideInterval = tvB02_E31; // from 2 to 31 seconds
+        final int searchSeconds = 31; // <== logic here, and next few lines.
+        final int expectedResultCount = 1; // 31 seconds.
+        for (int s = 0; s <= 40; s++) {
+            tIndexer.storeStatement(convertStatement(seriesSpo[s]));
+        }
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryInstantHasEndInterval(searchInsideInterval, EMPTY_CONSTRAINTS);
+        int count = 0;
+        while (iter.hasNext()) {
+            final Statement s = iter.next();
+            final Statement nextExpectedStatement = seriesSpo[searchSeconds]; // <== logic here
+            assertTrue("Should match: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
+            count++;
+        }
+        assertEquals("Should find count of rows.", expectedResultCount, count);
+    }
+
+    /**
+     * Test method for
+     * {@link mvm.rya.indexing.Mongo.temporal.MongoTemporalIndexer#queryIntervalEquals(TemporalInterval, StatementConstraints)}
+     * .
+     * @throws IOException
+     * @throws QueryEvaluationException
+     *
+     */
+    @Test
+    public void testQueryIntervalEquals() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+        tIndexer.storeStatement(convertStatement(seriesSpo[4])); // instance at 4 seconds
+
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryIntervalEquals(tvB02_E40, EMPTY_CONSTRAINTS);
+        // Should be found twice:
+        assertTrue("queryIntervalEquals: spo_B02_E40 should be found, but actually returned empty results. spo_B02_E40=" + spo_B02_E40, iter.hasNext());
+        assertTrue("queryIntervalEquals: spo_B02_E40 should be found, but does not match.", spo_B02_E40.equals(iter.next()));
+        assertFalse("queryIntervalEquals: Find no more than one, but actually has more.", iter.hasNext());
+    }
+
+    /**
+     * Test interval before a given interval, for method:
+     * {@link MongoTemporalIndexer#queryIntervalBefore(TemporalInterval, StatementConstraints)}.
+     *
+     * @throws IOException
+     * @throws QueryEvaluationException
+     */
+    @Test
+    public void testQueryIntervalBefore() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        tIndexer.storeStatement(convertStatement(spo_B00_E01));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        // instants should be ignored.
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+        tIndexer.storeStatement(convertStatement(seriesSpo[1])); // instance at 1 seconds
+        tIndexer.storeStatement(convertStatement(seriesSpo[2]));
+        tIndexer.storeStatement(convertStatement(seriesSpo[31]));
+
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryIntervalBefore(tvB02_E31, EMPTY_CONSTRAINTS);
+        // Should be found twice:
+        assertTrue("spo_B00_E01 should be found, but actually returned empty results. spo_B00_E01=" + spo_B00_E01, iter.hasNext());
+        assertTrue("spo_B00_E01 should be found, but found another.", spo_B00_E01.equals(iter.next()));
+        assertFalse("Find no more than one, but actually has more.", iter.hasNext());
+    }
+
+    /**
+     * interval is after the given interval.  Find interval beginnings after the endings of the given interval.
+     * {@link MongoTemporalIndexer#queryIntervalAfter(TemporalInterval, StatementContraints).
+     *
+     * @throws IOException
+     * @throws QueryEvaluationException
+     */
+    @Test
+    public void testQueryIntervalAfter() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        tIndexer.storeStatement(convertStatement(spo_B00_E01));
+        tIndexer.storeStatement(convertStatement(spo_B02_E29)); //<- after this one.
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B29_E30));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+        // instants should be ignored.
+        tIndexer.storeStatement(convertStatement(spo_B02));
+        tIndexer.storeStatement(convertStatement(seriesSpo[1])); // instance at 1 seconds
+        tIndexer.storeStatement(convertStatement(seriesSpo[2]));
+        tIndexer.storeStatement(convertStatement(seriesSpo[31]));
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        iter = tIndexer.queryIntervalAfter(tvB02_E29, EMPTY_CONSTRAINTS);
+        // Should be found twice:
+        assertTrue("spo_B30_E32 should be found, but actually returned empty results. spo_B30_E32=" + spo_B30_E32, iter.hasNext());
+        final Statement s = iter.next();
+        assertTrue("spo_B30_E32 should be found, but found another. spo_B30_E32="+spo_B30_E32+", but found="+s, spo_B30_E32.equals(s));
+        assertFalse("Find no more than one, but actually has more.", iter.hasNext());
+
+    }
+
+    /**
+     * Test instant after a given instant WITH two different predicates as constraints.
+     */
+    @Test
+    public void testQueryWithMultiplePredicates() throws IOException, QueryEvaluationException {
+        // tiB02_E30 read as: Begins 2 seconds, ends at 30 seconds
+        // these should not match as they are not instances.
+        tIndexer.storeStatement(convertStatement(spo_B03_E20));
+        tIndexer.storeStatement(convertStatement(spo_B02_E30));
+        tIndexer.storeStatement(convertStatement(spo_B02_E40));
+        tIndexer.storeStatement(convertStatement(spo_B02_E31));
+        tIndexer.storeStatement(convertStatement(spo_B30_E32));
+
+        // seriesSpo[s] and seriesTs[s] are statements and instant for s seconds after the uniform time.
+        final int searchForSeconds = 4;
+        final int expectedResultCount = 9;
+        for (int s = 0; s <= searchForSeconds + expectedResultCount; s++) { // <== logic here
+            tIndexer.storeStatement(convertStatement(seriesSpo[s]));
+        }
+        final ValueFactory vf = new ValueFactoryImpl();
+        final URI pred3_CIRCA_ = vf.createURI(URI_PROPERTY_CIRCA);  // this one to ignore.
+        final URI pred2_eventTime = vf.createURI(URI_PROPERTY_EVENT_TIME);
+        final URI pred1_atTime = vf.createURI(URI_PROPERTY_AT_TIME);
+
+        // add the predicate = EventTime ; Store in an array for verification.
+        final Statement[] SeriesTs_EventTime = new Statement[expectedResultCount+1];
+        for (int s = 0; s <= searchForSeconds + expectedResultCount; s++) { // <== logic here
+            final Statement statement = new StatementImpl(vf.createURI("foo:EventTimeSubj0" + s), pred2_eventTime, vf.createLiteral(seriesTs[s].getAsReadable()));
+            tIndexer.storeStatement(convertStatement(statement));
+            if (s>searchForSeconds) {
+                SeriesTs_EventTime[s - searchForSeconds -1 ] = statement;
+            }
+        }
+        // add the predicate = CIRCA ; to be ignored because it is not in the constraints.
+        for (int s = 0; s <= searchForSeconds + expectedResultCount; s++) { // <== logic here
+            final Statement statement = new StatementImpl(vf.createURI("foo:CircaEventSubj0" + s), pred3_CIRCA_, vf.createLiteral(seriesTs[s].getAsReadable()));
+            tIndexer.storeStatement(convertStatement(statement));
+        }
+
+        CloseableIteration<Statement, QueryEvaluationException> iter;
+        final StatementConstraints constraints = new StatementConstraints();
+        constraints.setPredicates(new HashSet<URI>(Arrays.asList( pred2_eventTime,  pred1_atTime )));
+
+        iter = tIndexer.queryInstantAfterInstant(seriesTs[searchForSeconds], constraints); // EMPTY_CONSTRAINTS);//
+        int count_AtTime = 0;
+        int count_EventTime = 0;
+        while (iter.hasNext()) {
+            final Statement s = iter.next();
+            final Statement nextExpectedStatement = seriesSpo[searchForSeconds + count_AtTime + 1]; // <== logic here
+            if (s.getPredicate().equals(pred1_atTime)) {
+                assertTrue("Should match atTime: " + nextExpectedStatement + " == " + s, nextExpectedStatement.equals(s));
+                count_AtTime++;
+            }
+            else if (s.getPredicate().equals(pred2_eventTime)) {
+                assertTrue("Should match eventTime: " + SeriesTs_EventTime[count_EventTime] + " == " + s, SeriesTs_EventTime[count_EventTime].equals(s));
+                count_EventTime++;
+            } else {
+                assertTrue("This predicate should not be returned: "+s, false);
+            }
+
+        }
+
+        assertEquals("Should find count of atTime    rows.", expectedResultCount, count_AtTime);
+        assertEquals("Should find count of eventTime rows.", expectedResultCount, count_EventTime);
+    }
+
+    /**
+     * Print and gather statistics on the entire index table.
+     *
+     * @param description
+     *            Printed to the console to find the test case.
+     * @param out
+     *            null or System.out or other output to send a listing.
+     * @param statistics
+     *            Hashes, sums, and counts for assertions.
+     * @return Count of entries in the index table.
+     * @throws IOException
+     */
+    public void printTables(final String description) throws IOException {
+        System.out.println("-- start printTables() -- " + description);
+        System.out.println("Reading : " + tIndexer.getCollection().getFullName());
+        final DBCursor cursor = tIndexer.getCollection().find();
+        while(cursor.hasNext()) {
+            final DBObject dbo = cursor.next();
+            System.out.println(dbo.toString());
+        }
+        System.out.println();
+    }
+}