You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rya.apache.org by dl...@apache.org on 2018/01/04 22:07:25 UTC
[03/17] incubator-rya git commit: RYA-414 Introduced the stateful
mongo configuratino object so that it is the arbitor of MongoDB state within
a Sail object.
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java
index a014e8f..7043870 100644
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOIT.java
@@ -1,5 +1,4 @@
-package org.apache.rya.mongodb;
-/*
+/**
* 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
@@ -17,6 +16,7 @@ package org.apache.rya.mongodb;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.mongodb;
import static org.apache.rya.mongodb.dao.SimpleMongoDBStorageStrategy.DOCUMENT_VISIBILITY;
import static org.apache.rya.mongodb.dao.SimpleMongoDBStorageStrategy.TIMESTAMP;
@@ -36,461 +36,484 @@ import org.apache.rya.mongodb.document.util.AuthorizationsUtil;
import org.apache.rya.mongodb.document.visibility.DocumentVisibility;
import org.bson.Document;
import org.calrissian.mango.collect.CloseableIterable;
-import org.junit.AfterClass;
-import org.junit.Before;
import org.junit.Test;
-import com.mongodb.MongoClient;
import com.mongodb.MongoException;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
public class MongoDBRyaDAOIT extends MongoTestBase {
- private MongoClient client;
- private static MongoDBRyaDAO dao;
- @Before
- public void setUp() throws IOException, RyaDAOException{
+ @Override
+ protected void updateConfiguration(final MongoDBRdfConfiguration conf) {
conf.setAuths("A", "B", "C");
- client = super.getMongoClient();
- dao = new MongoDBRyaDAO(conf, client);
- }
-
- @AfterClass
- public static void tearDown() throws RyaDAOException {
- dao.destroy();
}
@Test
public void testDeleteWildcard() throws RyaDAOException {
- final RyaStatementBuilder builder = new RyaStatementBuilder();
- builder.setPredicate(new RyaURI("http://temp.com"));
- builder.setColumnVisibility(new DocumentVisibility("A").flatten());
- dao.delete(builder.build(), conf);
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
+
+ final RyaStatementBuilder builder = new RyaStatementBuilder();
+ builder.setPredicate(new RyaURI("http://temp.com"));
+ builder.setColumnVisibility(new DocumentVisibility("A").flatten());
+ dao.delete(builder.build(), conf);
+ } finally {
+ dao.destroy();
+ }
}
@Test
public void testAdd() throws RyaDAOException, MongoException, IOException {
- final RyaStatementBuilder builder = new RyaStatementBuilder();
- builder.setPredicate(new RyaURI("http://temp.com"));
- builder.setSubject(new RyaURI("http://subject.com"));
- builder.setObject(new RyaURI("http://object.com"));
- builder.setColumnVisibility(new DocumentVisibility("B").flatten());
-
- final MongoDatabase db = client.getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
- final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
-
- dao.add(builder.build());
-
- assertEquals(coll.count(),1);
-
- final Document dbo = coll.find().first();
- assertTrue(dbo.containsKey(DOCUMENT_VISIBILITY));
- assertTrue(dbo.containsKey(TIMESTAMP));
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
+
+ final RyaStatementBuilder builder = new RyaStatementBuilder();
+ builder.setPredicate(new RyaURI("http://temp.com"));
+ builder.setSubject(new RyaURI("http://subject.com"));
+ builder.setObject(new RyaURI("http://object.com"));
+ builder.setColumnVisibility(new DocumentVisibility("B").flatten());
+
+ final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+ final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
+
+ dao.add(builder.build());
+
+ assertEquals(coll.count(),1);
+
+ final Document dbo = coll.find().first();
+ assertTrue(dbo.containsKey(DOCUMENT_VISIBILITY));
+ assertTrue(dbo.containsKey(TIMESTAMP));
+ } finally {
+ dao.destroy();
+ }
}
@Test
public void testDelete() throws RyaDAOException, MongoException, IOException {
- final RyaStatementBuilder builder = new RyaStatementBuilder();
- builder.setPredicate(new RyaURI("http://temp.com"));
- builder.setSubject(new RyaURI("http://subject.com"));
- builder.setObject(new RyaURI("http://object.com"));
- builder.setColumnVisibility(new DocumentVisibility("C").flatten());
- final RyaStatement statement = builder.build();
- final MongoDatabase db = client.getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
- final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
-
- dao.add(statement);
-
- assertEquals(1, coll.count());
-
- dao.delete(statement, conf);
-
- assertEquals(0, coll.count());
-
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
+
+ final RyaStatementBuilder builder = new RyaStatementBuilder();
+ builder.setPredicate(new RyaURI("http://temp.com"));
+ builder.setSubject(new RyaURI("http://subject.com"));
+ builder.setObject(new RyaURI("http://object.com"));
+ builder.setColumnVisibility(new DocumentVisibility("C").flatten());
+ final RyaStatement statement = builder.build();
+ final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+ final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
+
+ dao.add(statement);
+ assertEquals(1, coll.count());
+
+ dao.delete(statement, conf);
+ assertEquals(0, coll.count());
+ } finally {
+ dao.destroy();
+ }
}
@Test
public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, MongoException, IOException {
- final RyaStatementBuilder builder = new RyaStatementBuilder();
- builder.setPredicate(new RyaURI("http://temp.com"));
- builder.setSubject(new RyaURI("http://subject.com"));
- builder.setObject(new RyaURI("http://object.com"));
- builder.setContext(new RyaURI("http://context.com"));
- builder.setColumnVisibility(new DocumentVisibility("A&B&C").flatten());
- final RyaStatement statement = builder.build();
-
- final MongoDatabase db = client.getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
- final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
-
- dao.add(statement);
-
- assertEquals(1, coll.count());
-
- final RyaStatementBuilder builder2 = new RyaStatementBuilder();
- builder2.setPredicate(new RyaURI("http://temp.com"));
- builder2.setObject(new RyaURI("http://object.com"));
- builder2.setContext(new RyaURI("http://context3.com"));
- final RyaStatement query = builder2.build();
-
- dao.delete(query, conf);
-
- assertEquals(1, coll.count());
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
+
+ final RyaStatementBuilder builder = new RyaStatementBuilder();
+ builder.setPredicate(new RyaURI("http://temp.com"));
+ builder.setSubject(new RyaURI("http://subject.com"));
+ builder.setObject(new RyaURI("http://object.com"));
+ builder.setContext(new RyaURI("http://context.com"));
+ builder.setColumnVisibility(new DocumentVisibility("A&B&C").flatten());
+ final RyaStatement statement = builder.build();
+
+ final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+ final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
+
+ dao.add(statement);
+ assertEquals(1, coll.count());
+
+ final RyaStatementBuilder builder2 = new RyaStatementBuilder();
+ builder2.setPredicate(new RyaURI("http://temp.com"));
+ builder2.setObject(new RyaURI("http://object.com"));
+ builder2.setContext(new RyaURI("http://context3.com"));
+ final RyaStatement query = builder2.build();
+
+ dao.delete(query, conf);
+ assertEquals(1, coll.count());
+ } finally {
+ dao.destroy();
+ }
}
@Test
public void testVisibility() throws RyaDAOException, MongoException, IOException {
- // Doc requires "A" and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("A", new Authorizations("B")));
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
+
+ // Doc requires "A" and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A", new Authorizations("B")));
- // Doc requires "A" and user has "A" = User can view
- assertTrue(testVisibilityStatement("A", new Authorizations("A")));
+ // Doc requires "A" and user has "A" = User can view
+ assertTrue(testVisibilityStatement(dao, "A", new Authorizations("A")));
- // Doc requires "A" and "B" and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement("A&B", new Authorizations("A", "B")));
+ // Doc requires "A" and "B" and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "A&B", new Authorizations("A", "B")));
- // Doc requires "A" or "B" and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement("A|B", new Authorizations("A", "B")));
+ // Doc requires "A" or "B" and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B", new Authorizations("A", "B")));
- // Doc requires "A" and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement("A", new Authorizations("A", "B")));
+ // Doc requires "A" and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "A", new Authorizations("A", "B")));
- // Doc requires "A" and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("A", new Authorizations("A", "B", "C")));
+ // Doc requires "A" and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "A", new Authorizations("A", "B", "C")));
- // Doc requires "A" and "B" and user has "A" = User CANNOT view
- assertFalse(testVisibilityStatement("A&B", new Authorizations("A")));
+ // Doc requires "A" and "B" and user has "A" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&B", new Authorizations("A")));
- // Doc requires "A" and "B" and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("A&B", new Authorizations("B")));
+ // Doc requires "A" and "B" and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&B", new Authorizations("B")));
- // Doc requires "A" and "B" and user has "C" = User CANNOT view
- assertFalse(testVisibilityStatement("A&B", new Authorizations("C")));
+ // Doc requires "A" and "B" and user has "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&B", new Authorizations("C")));
- // Doc requires "A" and "B" and "C" and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("A&B&C", new Authorizations("A", "B", "C")));
+ // Doc requires "A" and "B" and "C" and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "A&B&C", new Authorizations("A", "B", "C")));
- // Doc requires "A" and "B" and "C" and user has "A" and "B" = User CANNOT view
- assertFalse(testVisibilityStatement("A&B&C", new Authorizations("A", "B")));
+ // Doc requires "A" and "B" and "C" and user has "A" and "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&B&C", new Authorizations("A", "B")));
- // Doc requires "A" and "B" and "C" and user has "A" = User CANNOT view
- assertFalse(testVisibilityStatement("A&B&C", new Authorizations("A")));
+ // Doc requires "A" and "B" and "C" and user has "A" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&B&C", new Authorizations("A")));
- // Doc requires "A" and "B" and "C" and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("A&B&C", new Authorizations("B")));
+ // Doc requires "A" and "B" and "C" and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&B&C", new Authorizations("B")));
- // Doc requires "A" and "B" and "C" and user has "C" = User CANNOT view
- assertFalse(testVisibilityStatement("A&B&C", new Authorizations("C")));
+ // Doc requires "A" and "B" and "C" and user has "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&B&C", new Authorizations("C")));
- // Doc requires "A" and "B" and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("A&B", new Authorizations("A", "B", "C")));
+ // Doc requires "A" and "B" and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "A&B", new Authorizations("A", "B", "C")));
- // Doc requires "A" or "B" and user has "A" = User can view
- assertTrue(testVisibilityStatement("A|B", new Authorizations("A")));
+ // Doc requires "A" or "B" and user has "A" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B", new Authorizations("A")));
- // Doc requires "A" or "B" and user has "B" = User can view
- assertTrue(testVisibilityStatement("A|B", new Authorizations("B")));
+ // Doc requires "A" or "B" and user has "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B", new Authorizations("B")));
- // Doc requires "A" or "B" and user has "C" = User CANNOT view
- assertFalse(testVisibilityStatement("A|B", new Authorizations("C")));
+ // Doc requires "A" or "B" and user has "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|B", new Authorizations("C")));
- // Doc requires "A" or "B" or "C" and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("A|B|C", new Authorizations("A", "B", "C")));
+ // Doc requires "A" or "B" or "C" and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C", new Authorizations("A", "B", "C")));
- // Doc requires "A" or "B" or "C" and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement("A|B|C", new Authorizations("A", "B")));
+ // Doc requires "A" or "B" or "C" and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C", new Authorizations("A", "B")));
- // Doc requires "A" or "B" or "C" and user has "A" = User can view
- assertTrue(testVisibilityStatement("A|B|C", new Authorizations("A")));
+ // Doc requires "A" or "B" or "C" and user has "A" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C", new Authorizations("A")));
- // Doc requires "A" or "B" or "C" and user has "B" = User can view
- assertTrue(testVisibilityStatement("A|B|C", new Authorizations("B")));
+ // Doc requires "A" or "B" or "C" and user has "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C", new Authorizations("B")));
- // Doc requires "A" or "B" or "C" and user has "C" = User can view
- assertTrue(testVisibilityStatement("A|B|C", new Authorizations("C")));
+ // Doc requires "A" or "B" or "C" and user has "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C", new Authorizations("C")));
- // Doc requires "A" or "B" and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("A|B", new Authorizations("A", "B", "C")));
+ // Doc requires "A" or "B" and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B", new Authorizations("A", "B", "C")));
- // Doc requires "A" and user has ALL_AUTHORIZATIONS = User can view
- assertTrue(testVisibilityStatement("A", MongoDbRdfConstants.ALL_AUTHORIZATIONS));
+ // Doc requires "A" and user has ALL_AUTHORIZATIONS = User can view
+ assertTrue(testVisibilityStatement(dao, "A", MongoDbRdfConstants.ALL_AUTHORIZATIONS));
- // Doc requires "A" and "B" and user has ALL_AUTHORIZATIONS = User can view
- assertTrue(testVisibilityStatement("A&B", MongoDbRdfConstants.ALL_AUTHORIZATIONS));
+ // Doc requires "A" and "B" and user has ALL_AUTHORIZATIONS = User can view
+ assertTrue(testVisibilityStatement(dao, "A&B", MongoDbRdfConstants.ALL_AUTHORIZATIONS));
- // Doc requires "A" or "B" and user has ALL_AUTHORIZATIONS = User can view
- assertTrue(testVisibilityStatement("A|B", MongoDbRdfConstants.ALL_AUTHORIZATIONS));
+ // Doc requires "A" or "B" and user has ALL_AUTHORIZATIONS = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B", MongoDbRdfConstants.ALL_AUTHORIZATIONS));
- // Doc has no requirement and user has ALL_AUTHORIZATIONS = User can view
- assertTrue(testVisibilityStatement("", MongoDbRdfConstants.ALL_AUTHORIZATIONS));
+ // Doc has no requirement and user has ALL_AUTHORIZATIONS = User can view
+ assertTrue(testVisibilityStatement(dao, "", MongoDbRdfConstants.ALL_AUTHORIZATIONS));
- // Doc has no requirement and user has "A" = User can view
- assertTrue(testVisibilityStatement("", new Authorizations("A")));
+ // Doc has no requirement and user has "A" = User can view
+ assertTrue(testVisibilityStatement(dao, "", new Authorizations("A")));
- // Doc has no requirement and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement("", new Authorizations("A", "B")));
+ // Doc has no requirement and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "", new Authorizations("A", "B")));
- // Doc requires "A" or ("B" and "C") and user has "A" = User can view
- assertTrue(testVisibilityStatement("A|(B&C)", new Authorizations("A")));
+ // Doc requires "A" or ("B" and "C") and user has "A" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|(B&C)", new Authorizations("A")));
- // Doc requires "A" or ("B" and "C") and user has "B" and "C" = User can view
- assertTrue(testVisibilityStatement("A|(B&C)", new Authorizations("B", "C")));
+ // Doc requires "A" or ("B" and "C") and user has "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|(B&C)", new Authorizations("B", "C")));
- // Doc requires "A" or ("B" and "C") and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("A|(B&C)", new Authorizations("B")));
+ // Doc requires "A" or ("B" and "C") and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|(B&C)", new Authorizations("B")));
- // Doc requires "A" or ("B" and "C") and user has "C" = User CANNOT view
- assertFalse(testVisibilityStatement("A|(B&C)", new Authorizations("C")));
+ // Doc requires "A" or ("B" and "C") and user has "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|(B&C)", new Authorizations("C")));
- // Doc requires "A" and ("B" or "C") and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement("A&(B|C)", new Authorizations("A", "B")));
+ // Doc requires "A" and ("B" or "C") and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "A&(B|C)", new Authorizations("A", "B")));
- // Doc requires "A" and ("B" or "C") and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement("A&(B|C)", new Authorizations("A", "C")));
+ // Doc requires "A" and ("B" or "C") and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "A&(B|C)", new Authorizations("A", "C")));
- // Doc requires "A" and ("B" or "C") and user has "B" and "C" = User CANNOT view
- assertFalse(testVisibilityStatement("A&(B|C)", new Authorizations("B", "C")));
+ // Doc requires "A" and ("B" or "C") and user has "B" and "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&(B|C)", new Authorizations("B", "C")));
- // Doc requires "A" and ("B" or "C") and user has "A" = User CANNOT view
- assertFalse(testVisibilityStatement("A&(B|C)", new Authorizations("A")));
+ // Doc requires "A" and ("B" or "C") and user has "A" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&(B|C)", new Authorizations("A")));
- // Doc requires "A" and ("B" or "C") and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("A&(B|C)", new Authorizations("B")));
+ // Doc requires "A" and ("B" or "C") and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A&(B|C)", new Authorizations("B")));
- // Doc requires "A" and ("B" or "C") and user has "C" = User can view
- assertFalse(testVisibilityStatement("A&(B|C)", new Authorizations("C")));
+ // Doc requires "A" and ("B" or "C") and user has "C" = User can view
+ assertFalse(testVisibilityStatement(dao, "A&(B|C)", new Authorizations("C")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("B")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("B")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "C" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("C")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("C")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "D" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("D")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "D" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("D")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "E" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("E")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("E")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "B")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "B")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "C" and "D" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("C", "D")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "C" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("C", "D")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "E" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "B", "E")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "E" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "B", "E")));
- // Doc requires ("A" and "B")mongoClient or ("C" and "D") and user has
- // "C" and "D" and "E" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("C", "D", "E")));
+ // Doc requires ("A" and "B")mongoClient or ("C" and "D") and user has
+ // "C" and "D" and "E" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("C", "D", "E")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "C" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "C")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "C")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "D" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "D")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "D" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "D")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "B" and "C" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("B", "C")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "B" and "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("B", "C")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "B" and "D" = User CANNOT view
- assertFalse(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("B", "D")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "B" and "D" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("B", "D")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "B", "C")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "B", "C")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "B", "D")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "B", "D")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "C" and "D" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "C", "D")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "C" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "C", "D")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "B" and "C" and "D" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("B", "C", "D")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "B" and "C" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("B", "C", "D")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "B" and "C" and "D" and "E"= User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("B", "C", "D", "E")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "B" and "C" and "D" and "E"= User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("B", "C", "D", "E")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "C" and "D" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "B", "C", "D")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "C" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "B", "C", "D")));
- // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "C" and "D" and "E" = User can view
- assertTrue(testVisibilityStatement("(A&B)|(C&D)", new Authorizations("A", "B", "C", "D", "E")));
+ // Doc requires ("A" and "B") or ("C" and "D") and user has "A" and "B" and "C" and "D" and "E" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A&B)|(C&D)", new Authorizations("A", "B", "C", "D", "E")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("B")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("B")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "C" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("C")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("C")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "D" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("D")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "D" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("D")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "E" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("E")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("E")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "B")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "B")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "C" and "D" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("C", "D")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "C" and "D" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("C", "D")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "E" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "B", "E")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "B", "E")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "C" and "D" and "E" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("C", "D", "E")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "C" and "D" and "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("C", "D", "E")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "C" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "C")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "C")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "D" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "D")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "D")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "C" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("B", "C")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("B", "C")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "D" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("B", "D")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("B", "D")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "D" and "E" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("B", "D", "E")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "D" and "E" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("B", "D", "E")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "B", "C")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "B", "C")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "C" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "B", "D")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "B", "D")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "C" and "D" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "C", "D")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "C" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "C", "D")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "C" and "D" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("B", "C", "D")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "C" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("B", "C", "D")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "C" and "D" and "E"= User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("B", "C", "D", "E")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "B" and "C" and "D" and "E"= User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("B", "C", "D", "E")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "C" and "D" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "B", "C", "D")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "C" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "B", "C", "D")));
- // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "C" and "D" and "E" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|D)", new Authorizations("A", "B", "C", "D", "E")));
+ // Doc requires ("A" or "B") and ("C" or "D") and user has "A" and "B" and "C" and "D" and "E" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|D)", new Authorizations("A", "B", "C", "D", "E")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "A" and "C" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("A", "C")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "A" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("A", "C")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "B" and "C" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("B", "C")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "B" and "C" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("B", "C")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "A" and "D" and "E" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("A", "D", "E")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "A" and "D" and "E" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("A", "D", "E")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "B" and "D" and "E" = User can view
- assertTrue(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("B", "D", "E")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "B" and "D" and "E" = User can view
+ assertTrue(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("B", "D", "E")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "A" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("A")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "A" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("A")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("B")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("B")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "C" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("C")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("C")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "D" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("D")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "D" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("D")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "E" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("E")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("E")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "D" and "E" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("D", "E")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "D" and "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("D", "E")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "A" and "D" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("A", "D")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "A" and "D" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("A", "D")));
- // Doc requires "(A|B)&(C|(D&E))" and user has "B" and "E" = User CANNOT view
- assertFalse(testVisibilityStatement("(A|B)&(C|(D&E))", new Authorizations("B", "E")));
+ // Doc requires "(A|B)&(C|(D&E))" and user has "B" and "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "(A|B)&(C|(D&E))", new Authorizations("B", "E")));
- // Doc requires "A|(B&C&(D|E))" and user has "A" = User can view
- assertTrue(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("A")));
+ // Doc requires "A|(B&C&(D|E))" and user has "A" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("A")));
- // Doc requires "A|(B&C&(D|E))" and user has "B" and "C" and "D" = User can view
- assertTrue(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("B", "C", "D")));
+ // Doc requires "A|(B&C&(D|E))" and user has "B" and "C" and "D" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("B", "C", "D")));
- // Doc requires "A|(B&C&(D|E))" and user has "B" and "C" and "E" = User can view
- assertTrue(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("B", "C", "E")));
+ // Doc requires "A|(B&C&(D|E))" and user has "B" and "C" and "E" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("B", "C", "E")));
- // Doc requires "A|(B&C&(D|E))" and user has "B" = User CANNOT view
- assertFalse(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("B")));
+ // Doc requires "A|(B&C&(D|E))" and user has "B" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("B")));
- // Doc requires "A|(B&C&(D|E))" and user has "C" = User CANNOT view
- assertFalse(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("C")));
+ // Doc requires "A|(B&C&(D|E))" and user has "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("C")));
- // Doc requires "A|(B&C&(D|E))" and user has "D" = User CANNOT view
- assertFalse(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("D")));
+ // Doc requires "A|(B&C&(D|E))" and user has "D" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("D")));
- // Doc requires "A|(B&C&(D|E))" and user has "E" = User CANNOT view
- assertFalse(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("E")));
+ // Doc requires "A|(B&C&(D|E))" and user has "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("E")));
- // Doc requires "A|(B&C&(D|E))" and user has "B" and "C" = User CANNOT view
- assertFalse(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("B", "C")));
+ // Doc requires "A|(B&C&(D|E))" and user has "B" and "C" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("B", "C")));
- // Doc requires "A|(B&C&(D|E))" and user has "D" and "E" = User CANNOT view
- assertFalse(testVisibilityStatement("A|(B&C&(D|E))", new Authorizations("D", "E")));
+ // Doc requires "A|(B&C&(D|E))" and user has "D" and "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|(B&C&(D|E))", new Authorizations("D", "E")));
- // Doc requires "A|B|C|D|(E&F&G&H)" and user has "A" = User can view
- assertTrue(testVisibilityStatement("A|B|C|D|(E&F&G&H)", new Authorizations("A")));
+ // Doc requires "A|B|C|D|(E&F&G&H)" and user has "A" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C|D|(E&F&G&H)", new Authorizations("A")));
- // Doc requires "A|B|C|D|(E&F&G&H)" and user has "E" = User CANNOT view
- assertFalse(testVisibilityStatement("A|B|C|D|(E&F&G&H)", new Authorizations("E")));
+ // Doc requires "A|B|C|D|(E&F&G&H)" and user has "E" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|B|C|D|(E&F&G&H)", new Authorizations("E")));
- // Doc requires "A|B|C|D|(E&F&G&H)" and user has "E" and "F" = User CANNOT view
- assertFalse(testVisibilityStatement("A|B|C|D|(E&F&G&H)", new Authorizations("E", "F")));
+ // Doc requires "A|B|C|D|(E&F&G&H)" and user has "E" and "F" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|B|C|D|(E&F&G&H)", new Authorizations("E", "F")));
- // Doc requires "A|B|C|D|(E&F&G&H)" and user has "I" = User CANNOT view
- assertFalse(testVisibilityStatement("A|B|C|D|(E&F&G&H)", new Authorizations("I")));
+ // Doc requires "A|B|C|D|(E&F&G&H)" and user has "I" = User CANNOT view
+ assertFalse(testVisibilityStatement(dao, "A|B|C|D|(E&F&G&H)", new Authorizations("I")));
- // Doc requires "A|B|C|D|(E&F&G&H)" and user has "A" and "I" = User can view
- assertTrue(testVisibilityStatement("A|B|C|D|(E&F&G&H)", new Authorizations("A", "I")));
+ // Doc requires "A|B|C|D|(E&F&G&H)" and user has "A" and "I" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C|D|(E&F&G&H)", new Authorizations("A", "I")));
- // Doc requires "A|B|C|D|(E&F&G&H)" and user has "E" and "F" and "G" and "H" = User can view
- assertTrue(testVisibilityStatement("A|B|C|D|(E&F&G&H)", new Authorizations("E", "F", "G", "H")));
+ // Doc requires "A|B|C|D|(E&F&G&H)" and user has "E" and "F" and "G" and "H" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C|D|(E&F&G&H)", new Authorizations("E", "F", "G", "H")));
- // Doc requires "A|B|C|D|(E&F&G&H)" and user has "E" and "F" and "G" and "H" and "I" = User can view
- assertTrue(testVisibilityStatement("A|B|C|D|(E&F&G&H)", new Authorizations("E", "F", "G", "H", "I")));
+ // Doc requires "A|B|C|D|(E&F&G&H)" and user has "E" and "F" and "G" and "H" and "I" = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B|C|D|(E&F&G&H)", new Authorizations("E", "F", "G", "H", "I")));
- // Doc has no requirement and user has ALL_AUTHORIZATIONS = User can view
- assertTrue(testVisibilityStatement(null, MongoDbRdfConstants.ALL_AUTHORIZATIONS));
+ // Doc has no requirement and user has ALL_AUTHORIZATIONS = User can view
+ assertTrue(testVisibilityStatement(dao, null, MongoDbRdfConstants.ALL_AUTHORIZATIONS));
- // Doc has no requirement and user has "A" = User can view
- assertTrue(testVisibilityStatement(null, new Authorizations("A")));
+ // Doc has no requirement and user has "A" = User can view
+ assertTrue(testVisibilityStatement(dao, null, new Authorizations("A")));
- // Doc has no requirement and user has "A" and "B" = User can view
- assertTrue(testVisibilityStatement(null, new Authorizations("A", "B")));
+ // Doc has no requirement and user has "A" and "B" = User can view
+ assertTrue(testVisibilityStatement(dao, null, new Authorizations("A", "B")));
- // Doc has no requirement and user has no authorizations = User can view
- assertTrue(testVisibilityStatement(null, null));
+ // Doc has no requirement and user has no authorizations = User can view
+ assertTrue(testVisibilityStatement(dao, null, null));
- // Doc has no requirement and user has no authorizations = User can view
- assertTrue(testVisibilityStatement("", null));
+ // Doc has no requirement and user has no authorizations = User can view
+ assertTrue(testVisibilityStatement(dao, "", null));
- // Doc requires "A" and user has no authorizations = User can view
- assertTrue(testVisibilityStatement("A", null));
+ // Doc requires "A" and user has no authorizations = User can view
+ assertTrue(testVisibilityStatement(dao, "A", null));
- // Doc requires "A" and "B" and user has no authorizations = User can view
- assertTrue(testVisibilityStatement("A&B", null));
+ // Doc requires "A" and "B" and user has no authorizations = User can view
+ assertTrue(testVisibilityStatement(dao, "A&B", null));
- // Doc requires "A" or "B" and user has no authorizations = User can view
- assertTrue(testVisibilityStatement("A|B", null));
+ // Doc requires "A" or "B" and user has no authorizations = User can view
+ assertTrue(testVisibilityStatement(dao, "A|B", null));
+ } finally {
+ dao.destroy();
+ }
}
/**
@@ -503,8 +526,11 @@ public class MongoDBRyaDAOIT extends MongoTestBase {
* in the collection. {@code false} otherwise.
* @throws RyaDAOException
*/
- private boolean testVisibilityStatement(final String documentVisibility, final Authorizations userAuthorizations) throws RyaDAOException {
- final MongoDatabase db = client.getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+ private boolean testVisibilityStatement(
+ final MongoDBRyaDAO dao,
+ final String documentVisibility,
+ final Authorizations userAuthorizations) throws RyaDAOException {
+ final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
final RyaStatement statement = buildVisibilityTestRyaStatement(documentVisibility);
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java
index 8cf75f1..200be9a 100644
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoDBRyaDAOTest.java
@@ -1,5 +1,4 @@
-package org.apache.rya.mongodb;
-/*
+/**
* 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
@@ -17,6 +16,7 @@ package org.apache.rya.mongodb;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.mongodb;
import static org.junit.Assert.assertEquals;
@@ -27,93 +27,112 @@ import org.apache.rya.api.domain.RyaStatement.RyaStatementBuilder;
import org.apache.rya.api.domain.RyaURI;
import org.apache.rya.api.persist.RyaDAOException;
import org.bson.Document;
-import org.junit.Before;
import org.junit.Test;
-import com.mongodb.MongoClient;
import com.mongodb.MongoException;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;
+/**
+ * Integration tests the methods of {@link MongoDBRyaDAO}.
+ */
public class MongoDBRyaDAOTest extends MongoTestBase {
- private MongoClient client;
- private MongoDBRyaDAO dao;
-
- @Before
- public void setUp() throws IOException, RyaDAOException{
- client = super.getMongoClient();
- dao = new MongoDBRyaDAO(conf, client);
- }
@Test
public void testDeleteWildcard() throws RyaDAOException {
- final RyaStatementBuilder builder = new RyaStatementBuilder();
- builder.setPredicate(new RyaURI("http://temp.com"));
- dao.delete(builder.build(), conf);
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
+
+ final RyaStatementBuilder builder = new RyaStatementBuilder();
+ builder.setPredicate(new RyaURI("http://temp.com"));
+ dao.delete(builder.build(), conf);
+ } finally {
+ dao.destroy();
+ }
}
@Test
public void testAdd() throws RyaDAOException, MongoException, IOException {
- final RyaStatementBuilder builder = new RyaStatementBuilder();
- builder.setPredicate(new RyaURI("http://temp.com"));
- builder.setSubject(new RyaURI("http://subject.com"));
- builder.setObject(new RyaURI("http://object.com"));
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
- final MongoDatabase db = client.getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
- final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
+ final RyaStatementBuilder builder = new RyaStatementBuilder();
+ builder.setPredicate(new RyaURI("http://temp.com"));
+ builder.setSubject(new RyaURI("http://subject.com"));
+ builder.setObject(new RyaURI("http://object.com"));
- dao.add(builder.build());
+ final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+ final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
- assertEquals(coll.count(),1);
+ dao.add(builder.build());
+ assertEquals(coll.count(),1);
+ } finally {
+ dao.destroy();
+ }
}
@Test
public void testDelete() throws RyaDAOException, MongoException, IOException {
- final RyaStatementBuilder builder = new RyaStatementBuilder();
- builder.setPredicate(new RyaURI("http://temp.com"));
- builder.setSubject(new RyaURI("http://subject.com"));
- builder.setObject(new RyaURI("http://object.com"));
- final RyaStatement statement = builder.build();
-
- final MongoDatabase db = client.getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
- final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
-
- dao.add(statement);
-
- assertEquals(coll.count(),1);
-
- dao.delete(statement, conf);
-
- assertEquals(coll.count(),0);
-
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
+
+ final RyaStatementBuilder builder = new RyaStatementBuilder();
+ builder.setPredicate(new RyaURI("http://temp.com"));
+ builder.setSubject(new RyaURI("http://subject.com"));
+ builder.setObject(new RyaURI("http://object.com"));
+ final RyaStatement statement = builder.build();
+
+ final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+ final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
+
+ dao.add(statement);
+ assertEquals(coll.count(),1);
+
+ dao.delete(statement, conf);
+ assertEquals(coll.count(),0);
+ } finally {
+ dao.destroy();
+ }
}
@Test
public void testDeleteWildcardSubjectWithContext() throws RyaDAOException, MongoException, IOException {
- final RyaStatementBuilder builder = new RyaStatementBuilder();
- builder.setPredicate(new RyaURI("http://temp.com"));
- builder.setSubject(new RyaURI("http://subject.com"));
- builder.setObject(new RyaURI("http://object.com"));
- builder.setContext(new RyaURI("http://context.com"));
- final RyaStatement statement = builder.build();
-
- final MongoDatabase db = client.getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
- final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
-
- dao.add(statement);
-
- assertEquals(coll.count(),1);
-
- final RyaStatementBuilder builder2 = new RyaStatementBuilder();
- builder2.setPredicate(new RyaURI("http://temp.com"));
- builder2.setObject(new RyaURI("http://object.com"));
- builder2.setContext(new RyaURI("http://context3.com"));
- final RyaStatement query = builder2.build();
-
- dao.delete(query, conf);
-
- assertEquals(coll.count(),1);
+ MongoDBRyaDAO dao = new MongoDBRyaDAO();
+ try {
+ dao.setConf(conf);
+ dao.init();
+
+ final RyaStatementBuilder builder = new RyaStatementBuilder();
+ builder.setPredicate(new RyaURI("http://temp.com"));
+ builder.setSubject(new RyaURI("http://subject.com"));
+ builder.setObject(new RyaURI("http://object.com"));
+ builder.setContext(new RyaURI("http://context.com"));
+ final RyaStatement statement = builder.build();
+
+ final MongoDatabase db = conf.getMongoClient().getDatabase(conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME));
+ final MongoCollection<Document> coll = db.getCollection(conf.getTriplesCollectionName());
+
+ dao.add(statement);
+ assertEquals(coll.count(),1);
+
+ final RyaStatementBuilder builder2 = new RyaStatementBuilder();
+ builder2.setPredicate(new RyaURI("http://temp.com"));
+ builder2.setObject(new RyaURI("http://object.com"));
+ builder2.setContext(new RyaURI("http://context3.com"));
+ final RyaStatement query = builder2.build();
+
+ dao.delete(query, conf);
+ assertEquals(coll.count(),1);
+ } finally {
+ dao.destroy();
+ }
}
-}
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoRyaTestBase.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoRyaTestBase.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoRyaTestBase.java
deleted file mode 100644
index 3d95818..0000000
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoRyaTestBase.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.
- */
-package org.apache.rya.mongodb;
-
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import org.apache.rya.api.persist.RyaDAOException;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-
-import com.mongodb.MongoClient;
-
-import de.flapdoodle.embed.mongo.distribution.Version;
-
-public class MongoRyaTestBase {
-
- private static final AtomicInteger db = new AtomicInteger(1);
-
- protected static EmbeddedMongoFactory testsFactory;
- protected MongoClient mongoClient;
- private int currentTestDb = -1;
-
- @BeforeClass()
- public static void beforeClass() throws Exception {
- testsFactory = EmbeddedMongoFactory.with(Version.Main.PRODUCTION);
- }
-
- @Before
- public void MongoRyaTestBaseSetUp() throws IOException, RyaDAOException {
- mongoClient = testsFactory.newMongoClient();
- currentTestDb = db.getAndIncrement();
- }
-
- @After
- public void MongoRyaTestBaseAfter() throws Exception {
- if (mongoClient != null) {
- mongoClient.close();
- }
- currentTestDb = -1;
- MongoConnectorFactory.closeMongoClient();
- }
-
- @AfterClass()
- public static void afterClass() throws Exception {
- if (testsFactory != null) {
- testsFactory.shutdown();
- }
- }
-
- public String getDbName() {
- return "rya_" + currentTestDb;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java
index e325e82..a3db535 100644
--- a/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java
+++ b/dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/MongoTestBase.java
@@ -18,9 +18,10 @@
*/
package org.apache.rya.mongodb;
+import java.util.List;
+
import org.apache.hadoop.conf.Configuration;
import org.bson.Document;
-import org.junit.After;
import org.junit.Before;
import com.mongodb.DBCollection;
@@ -33,28 +34,43 @@ import com.mongodb.client.MongoCollection;
*/
public class MongoTestBase {
- private static MongoClient mongoClient = null;
- protected static MongoDBRdfConfiguration conf;
+ private MongoClient mongoClient = null;
+ protected StatefulMongoDBRdfConfiguration conf;
@Before
public void setupTest() throws Exception {
- conf = new MongoDBRdfConfiguration( new Configuration() );
+ // Setup the configuration that will be used within the test.
+ final MongoDBRdfConfiguration conf = new MongoDBRdfConfiguration( new Configuration() );
conf.setBoolean("sc.useMongo", true);
conf.setTablePrefix("test_");
conf.setMongoDBName("testDB");
- mongoClient = EmbeddedMongoSingleton.getInstance();
- conf.setMongoClient(mongoClient);
- }
+ conf.setMongoHostname(EmbeddedMongoSingleton.getMongodConfig().net().getServerAddress().getHostAddress());
+ conf.setMongoPort(Integer.toString(EmbeddedMongoSingleton.getMongodConfig().net().getPort()));
+
+ // Let tests update the configuration.
+ updateConfiguration(conf);
+
+ // Create the stateful configuration object.
+ mongoClient = EmbeddedMongoSingleton.getNewMongoClient();
+ final List<MongoSecondaryIndex> indexers = conf.getInstances("ac.additional.indexers", MongoSecondaryIndex.class);
+ this.conf = new StatefulMongoDBRdfConfiguration(conf, mongoClient, indexers);
- @After
- public void cleanupTest() {
- // Remove any DBs that were created by the test.
+ // Remove any DBs that were created by previous tests.
for(final String dbName : mongoClient.listDatabaseNames()) {
mongoClient.dropDatabase(dbName);
}
}
/**
+ * TODO doc
+ *
+ * @param conf
+ */
+ protected void updateConfiguration(final MongoDBRdfConfiguration conf) {
+ // By default, do nothing.
+ }
+
+ /**
* @return A {@link MongoClient} that is connected to the embedded instance of Mongo DB.
*/
public MongoClient getMongoClient() {
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/dao/mongodb.rya/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/dao/mongodb.rya/src/test/resources/log4j.properties b/dao/mongodb.rya/src/test/resources/log4j.properties
new file mode 100644
index 0000000..73b9512
--- /dev/null
+++ b/dao/mongodb.rya/src/test/resources/log4j.properties
@@ -0,0 +1,27 @@
+#
+# 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.
+#
+
+# Root logger option
+log4j.rootLogger=INFO, stdout
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/extras/indexing/src/main/java/org/apache/rya/indexing/entity/EntityIndexOptimizer.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/entity/EntityIndexOptimizer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/entity/EntityIndexOptimizer.java
index cd5278e..507fde2 100644
--- a/extras/indexing/src/main/java/org/apache/rya/indexing/entity/EntityIndexOptimizer.java
+++ b/extras/indexing/src/main/java/org/apache/rya/indexing/entity/EntityIndexOptimizer.java
@@ -19,6 +19,7 @@
package org.apache.rya.indexing.entity;
import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
@@ -35,6 +36,7 @@ import org.apache.rya.indexing.external.matching.ExternalSetProvider;
import org.apache.rya.indexing.external.matching.QueryNodeListRater;
import org.apache.rya.indexing.external.matching.QuerySegment;
import org.apache.rya.indexing.external.matching.TopOfQueryFilterRelocator;
+import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration;
import org.openrdf.query.BindingSet;
import org.openrdf.query.Dataset;
import org.openrdf.query.algebra.TupleExpr;
@@ -68,6 +70,9 @@ public class EntityIndexOptimizer extends AbstractExternalSetOptimizer<EntityQue
@Override
public void setConf(final Configuration conf) {
+ checkState(conf instanceof StatefulMongoDBRdfConfiguration,
+ "The provided Configuration must be of type StatefulMongoDBRdfConfiguration, but was " + conf.getClass().getName());
+
this.conf = conf;
indexer.setConf(conf);
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
index 1ab48b6..d1d00fb 100644
--- a/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
+++ b/extras/indexing/src/main/java/org/apache/rya/indexing/entity/update/mongo/MongoEntityIndexer.java
@@ -18,6 +18,8 @@
*/
package org.apache.rya.indexing.entity.update.mongo;
+import static com.google.common.base.Preconditions.checkState;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.rya.indexing.entity.storage.EntityStorage;
import org.apache.rya.indexing.entity.storage.EntityStorage.EntityStorageException;
@@ -26,8 +28,7 @@ import org.apache.rya.indexing.entity.storage.mongo.MongoEntityStorage;
import org.apache.rya.indexing.entity.storage.mongo.MongoTypeStorage;
import org.apache.rya.indexing.entity.update.BaseEntityIndexer;
import org.apache.rya.indexing.entity.update.EntityIndexer;
-import org.apache.rya.mongodb.MongoConnectorFactory;
-import org.apache.rya.mongodb.MongoDBRdfConfiguration;
+import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration;
import com.mongodb.MongoClient;
@@ -43,29 +44,27 @@ public class MongoEntityIndexer extends BaseEntityIndexer {
@Override
public EntityStorage getEntityStorage(final Configuration conf) throws EntityStorageException {
- final MongoDBRdfConfiguration mongoConf = (MongoDBRdfConfiguration) conf;
+ checkState(conf instanceof StatefulMongoDBRdfConfiguration,
+ "The provided Configuration must be of type StatefulMongoDBRdfConfiguration, but was " + conf.getClass().getName());
+
+ final StatefulMongoDBRdfConfiguration mongoConf = (StatefulMongoDBRdfConfiguration) conf;
if (client == null) {
- if(mongoConf.getMongoClient() != null) {
- client = mongoConf.getMongoClient();
- } else {
- client = MongoConnectorFactory.getMongoClient(conf);
- }
+ client = mongoConf.getMongoClient();
}
- final String ryaInstanceName = new MongoDBRdfConfiguration(conf).getMongoDBName();
+ final String ryaInstanceName = mongoConf.getMongoDBName();
return new MongoEntityStorage(client, ryaInstanceName);
}
@Override
public TypeStorage getTypeStorage(final Configuration conf) {
- final MongoDBRdfConfiguration mongoConf = (MongoDBRdfConfiguration) conf;
+ checkState(conf instanceof StatefulMongoDBRdfConfiguration,
+ "The provided Configuration must be of type StatefulMongoDBRdfConfiguration, but was " + conf.getClass().getName());
+
+ final StatefulMongoDBRdfConfiguration mongoConf = (StatefulMongoDBRdfConfiguration) conf;
if (client == null) {
- if(mongoConf.getMongoClient() != null) {
- client = mongoConf.getMongoClient();
- } else {
- client = MongoConnectorFactory.getMongoClient(conf);
- }
+ client = mongoConf.getMongoClient();
}
- final String ryaInstanceName = new MongoDBRdfConfiguration(conf).getMongoDBName();
+ final String ryaInstanceName = mongoConf.getMongoDBName();
return new MongoTypeStorage(client, ryaInstanceName);
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java
index 9ce6e22..a815040 100644
--- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java
+++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/AbstractMongoIndexer.java
@@ -1,6 +1,4 @@
-package org.apache.rya.indexing.mongodb;
-
-/*
+/**
* 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
@@ -18,6 +16,9 @@ package org.apache.rya.indexing.mongodb;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.indexing.mongodb;
+
+import static com.google.common.base.Preconditions.checkState;
import java.io.IOException;
import java.util.Collection;
@@ -29,10 +30,10 @@ import org.apache.rya.api.domain.RyaStatement;
import org.apache.rya.api.domain.RyaURI;
import org.apache.rya.api.resolver.RyaToRdfConversions;
import org.apache.rya.indexing.StatementConstraints;
-import org.apache.rya.mongodb.MongoConnectorFactory;
import org.apache.rya.mongodb.MongoDBRdfConfiguration;
import org.apache.rya.mongodb.MongoDBRyaDAO;
import org.apache.rya.mongodb.MongoSecondaryIndex;
+import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration;
import org.apache.rya.mongodb.batch.MongoDbBatchWriter;
import org.apache.rya.mongodb.batch.MongoDbBatchWriterConfig;
import org.apache.rya.mongodb.batch.MongoDbBatchWriterException;
@@ -43,14 +44,12 @@ import org.openrdf.model.Statement;
import org.openrdf.model.URI;
import org.openrdf.query.QueryEvaluationException;
-import com.google.common.annotations.VisibleForTesting;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;
import com.mongodb.MongoClient;
import com.mongodb.QueryBuilder;
-import com.mongodb.ServerAddress;
import info.aduna.iteration.CloseableIteration;
@@ -63,7 +62,7 @@ public abstract class AbstractMongoIndexer<T extends IndexingMongoDBStorageStrat
private boolean isInit = false;
private boolean flushEachUpdate = true;
- protected Configuration conf;
+ protected StatefulMongoDBRdfConfiguration conf;
protected MongoDBRyaDAO dao;
protected MongoClient mongoClient;
protected String dbName;
@@ -76,7 +75,7 @@ public abstract class AbstractMongoIndexer<T extends IndexingMongoDBStorageStrat
private MongoDbBatchWriter<DBObject> mongoDbBatchWriter;
protected void initCore() {
- dbName = conf.get(MongoDBRdfConfiguration.MONGO_DB_NAME);
+ dbName = conf.getMongoDBName();
db = this.mongoClient.getDB(dbName);
final String collectionName = conf.get(MongoDBRdfConfiguration.MONGO_COLLECTION_PREFIX, "rya") + getCollectionName();
collection = db.getCollection(collectionName);
@@ -84,7 +83,7 @@ public abstract class AbstractMongoIndexer<T extends IndexingMongoDBStorageStrat
flushEachUpdate = ((MongoDBRdfConfiguration)conf).flushEachUpdate();
final MongoDbBatchWriterConfig mongoDbBatchWriterConfig = MongoDbBatchWriterUtils.getMongoDbBatchWriterConfig(conf);
- mongoDbBatchWriter = new MongoDbBatchWriter<DBObject>(new DbCollectionType(collection), mongoDbBatchWriterConfig);
+ mongoDbBatchWriter = new MongoDbBatchWriter<>(new DbCollectionType(collection), mongoDbBatchWriterConfig);
try {
mongoDbBatchWriter.start();
} catch (final MongoDbBatchWriterException e) {
@@ -97,24 +96,13 @@ public abstract class AbstractMongoIndexer<T extends IndexingMongoDBStorageStrat
this.mongoClient = client;
}
- @VisibleForTesting
- public void initIndexer(final Configuration conf, final MongoClient client) {
- setClient(client);
- final ServerAddress address = client.getAddress();
- conf.set(MongoDBRdfConfiguration.MONGO_INSTANCE, address.getHost());
- conf.set(MongoDBRdfConfiguration.MONGO_INSTANCE_PORT, Integer.toString(address.getPort()));
- setConf(conf);
- if (!isInit) {
- init();
- isInit = true;
- }
- }
-
@Override
public void setConf(final Configuration conf) {
- this.conf = conf;
+ checkState(conf instanceof StatefulMongoDBRdfConfiguration,
+ "The provided Configuration must be a StatefulMongoDBRdfConfiguration, but it was " + conf.getClass().getName());
+ this.conf = (StatefulMongoDBRdfConfiguration) conf;
if (!isInit){
- setClient(MongoConnectorFactory.getMongoClient(conf));
+ setClient(this.conf.getMongoClient());
init();
}
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java
index 5d353b4..249bde5 100644
--- a/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java
+++ b/extras/indexing/src/main/java/org/apache/rya/indexing/mongodb/MongoDbSmartUri.java
@@ -39,8 +39,7 @@ import org.apache.rya.indexing.mongodb.update.RyaObjectStorage.ObjectStorageExce
import org.apache.rya.indexing.smarturi.SmartUriAdapter;
import org.apache.rya.indexing.smarturi.SmartUriException;
import org.apache.rya.indexing.smarturi.SmartUriStorage;
-import org.apache.rya.mongodb.MongoConnectorFactory;
-import org.apache.rya.mongodb.MongoDBRdfConfiguration;
+import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration;
import org.openrdf.model.URI;
import org.openrdf.model.Value;
@@ -52,15 +51,15 @@ import com.mongodb.MongoException;
*/
public class MongoDbSmartUri implements SmartUriStorage {
private boolean isInit = false;
- private final MongoDBRdfConfiguration conf;
+ private final StatefulMongoDBRdfConfiguration conf;
private MongoClient mongoClient = null;
private EntityStorage entityStorage;
/**
* Creates a new instance of {@link MongoDbSmartUri}.
- * @param conf the {@link MongoDBRdfConfiguration}. (not {@code null})
+ * @param conf the {@link StatefulMongoDBRdfConfiguration}. (not {@code null})
*/
- public MongoDbSmartUri(final MongoDBRdfConfiguration conf) {
+ public MongoDbSmartUri(final StatefulMongoDBRdfConfiguration conf) {
this.conf = checkNotNull(conf);
}
@@ -147,13 +146,9 @@ public class MongoDbSmartUri implements SmartUriStorage {
* @throws MongoException
* @throws EntityStorageException
*/
- private void setupClient(final Configuration conf) throws UnknownHostException, MongoException, EntityStorageException {
- final MongoDBRdfConfiguration mongoConf = (MongoDBRdfConfiguration) conf;
- mongoClient = mongoConf.getMongoClient();
- if (mongoClient == null) {
- mongoClient = MongoConnectorFactory.getMongoClient(conf);
- }
- entityStorage = new MongoEntityStorage(mongoClient, mongoConf.getMongoInstance());
+ private void setupClient(final StatefulMongoDBRdfConfiguration conf) throws UnknownHostException, MongoException, EntityStorageException {
+ mongoClient = conf.getMongoClient();
+ entityStorage = new MongoEntityStorage(mongoClient, conf.getRyaInstance());
isInit = true;
}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/767349da/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java b/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
index 91f281c..1025537 100644
--- a/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
+++ b/extras/indexing/src/main/java/org/apache/rya/indexing/statement/metadata/matching/RyaQueryEngineFactory.java
@@ -1,5 +1,4 @@
-package org.apache.rya.indexing.statement.metadata.matching;
-/*
+/**
* 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
@@ -7,9 +6,9 @@ package org.apache.rya.indexing.statement.metadata.matching;
* 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
@@ -17,6 +16,8 @@ package org.apache.rya.indexing.statement.metadata.matching;
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.rya.indexing.statement.metadata.matching;
+
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.Connector;
@@ -28,23 +29,18 @@ import org.apache.rya.accumulo.AccumuloRdfConfiguration;
import org.apache.rya.accumulo.query.AccumuloRyaQueryEngine;
import org.apache.rya.api.RdfCloudTripleStoreConfiguration;
import org.apache.rya.api.persist.query.RyaQueryEngine;
-import org.apache.rya.mongodb.MongoConnectorFactory;
import org.apache.rya.mongodb.MongoDBQueryEngine;
-import org.apache.rya.mongodb.MongoDBRdfConfiguration;
-
-import com.mongodb.MongoClient;
+import org.apache.rya.mongodb.StatefulMongoDBRdfConfiguration;
/**
* THis class creates the appropriate {@link RyaQueryEngine} based on the type of
* {@link RdfCloudTripleStoreConfiguration} object that is passed in and whether or not
* Rya is configured to use Mongo.
- *
*/
public class RyaQueryEngineFactory {
-
@SuppressWarnings("unchecked")
- public static <C extends RdfCloudTripleStoreConfiguration> RyaQueryEngine<C> getQueryEngine(RdfCloudTripleStoreConfiguration conf) {
+ public static <C extends RdfCloudTripleStoreConfiguration> RyaQueryEngine<C> getQueryEngine(RdfCloudTripleStoreConfiguration conf) {
if(conf instanceof AccumuloRdfConfiguration) {
AccumuloRdfConfiguration aConf = (AccumuloRdfConfiguration) conf;
Instance instance;
@@ -64,12 +60,13 @@ public class RyaQueryEngineFactory {
throw new RuntimeException(e);
}
return (RyaQueryEngine<C>) new AccumuloRyaQueryEngine(conn, aConf);
- } else if(conf instanceof MongoDBRdfConfiguration && conf.getBoolean("sc.useMongo", false)) {
- MongoClient client = MongoConnectorFactory.getMongoClient(conf);
- return (RyaQueryEngine<C>) new MongoDBQueryEngine((MongoDBRdfConfiguration) conf, client);
+ } else if(conf instanceof StatefulMongoDBRdfConfiguration && conf.getBoolean("sc.useMongo", false)) {
+ StatefulMongoDBRdfConfiguration mongoConf = (StatefulMongoDBRdfConfiguration)conf;
+ MongoDBQueryEngine mongoQueryEngine = new MongoDBQueryEngine();
+ mongoQueryEngine.setConf(mongoConf);
+ return (RyaQueryEngine<C>) mongoQueryEngine;
} else {
throw new IllegalArgumentException("Invalid configuration type.");
}
}
-
-}
+}
\ No newline at end of file