[
https://issues.apache.org/jira/browse/RYA-303?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16087895#comment-16087895
]
ASF GitHub Bot commented on RYA-303:
------------------------------------
Github user isper3at commented on a diff in the pull request:
https://github.com/apache/incubator-rya/pull/172#discussion_r127532967
--- Diff:
extras/rya.indexing.pcj/src/test/java/org/apache/rya/indexing/pcj/storage/mongo/MongoPcjDocumentsTest.java
---
@@ -0,0 +1,157 @@
+/*
+ * 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.indexing.pcj.storage.mongo;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.rya.indexing.pcj.storage.PcjMetadata;
+import org.apache.rya.indexing.pcj.storage.VisibilityBindingSet;
+import org.apache.rya.indexing.pcj.storage.accumulo.VariableOrder;
+import org.apache.rya.mongodb.MockMongoFactory;
+import org.bson.Document;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openrdf.model.impl.URIImpl;
+import org.openrdf.query.impl.MapBindingSet;
+
+import com.mongodb.MongoClient;
+
+public class MongoPcjDocumentsTest {
+ private static final String PCJ_TEST = "pcjTest";
+
+ private MongoClient client;
+ private MongoPcjDocuments docConverter;
+
+ @Before
+ public void setup() throws Exception {
+ client = MockMongoFactory.newFactory().newMongoClient();
+ docConverter = new MongoPcjDocuments(client, PCJ_TEST);
+ }
+
+ @After
+ public void cleanup() throws Exception {
+ client.close();
+ }
+
+ @Test
+ public void pcjToMetadata() {
+ final String sparql = "SELECT * WHERE { ?a <http://isA> ?b }";
+ final Document actual =
docConverter.getMetadataDocument("pcjTest", sparql);
+ final Document expected = new Document()
+ .append(MongoPcjDocuments.CARDINALITY_FIELD, 0)
+ .append(MongoPcjDocuments.PCJ_ID, "pcjTest_METADATA")
+ .append(MongoPcjDocuments.SPARQL_FIELD, sparql);
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void metadataExists() throws Exception {
+ final String sparql = "SELECT * WHERE { ?a <http://isA> ?b }";
+ docConverter.createPcj("pcjTest", sparql);
+
+ PcjMetadata actual = docConverter.getPcjMetadata("pcjTest");
+ PcjMetadata expected = new PcjMetadata(sparql, 0, new
ArrayList<VariableOrder>());
+ assertEquals(expected, actual);
+
+ // Setup the binding set that will be converted.
+ final MapBindingSet originalBindingSet1 = new MapBindingSet();
+ originalBindingSet1.addBinding("x", new URIImpl("http://a"));
+ originalBindingSet1.addBinding("y", new URIImpl("http://b"));
+ originalBindingSet1.addBinding("z", new URIImpl("http://c"));
+ final VisibilityBindingSet results1 = new
VisibilityBindingSet(originalBindingSet1, "A&B&C");
+
+ // Setup the binding set that will be converted.
+ final MapBindingSet originalBindingSet2 = new MapBindingSet();
+ originalBindingSet2.addBinding("x", new URIImpl("http://1"));
+ originalBindingSet2.addBinding("y", new URIImpl("http://2"));
+ originalBindingSet2.addBinding("z", new URIImpl("http://3"));
+ final VisibilityBindingSet results2 = new
VisibilityBindingSet(originalBindingSet2, "A&B&C");
+
+ final List<VisibilityBindingSet> bindingSets = new ArrayList<>();
+ bindingSets.add(results1);
+ bindingSets.add(results2);
+
+ docConverter.addResults("pcjTest", bindingSets);
+ actual = docConverter.getPcjMetadata("pcjTest");
+ expected = new PcjMetadata(sparql, 2, new
ArrayList<VariableOrder>());
+ assertEquals(expected, actual);
+
+ docConverter.purgePcjs("pcjTest");
+ actual = docConverter.getPcjMetadata("pcjTest");
+ expected = new PcjMetadata(sparql, 0, new
ArrayList<VariableOrder>());
+ assertEquals(expected, actual);
+ }
+
+ /*
+ * @Test public void bindingsToBson_Test() throws
--- End diff --
remove
> Mongo PCJ indexer support
> -------------------------
>
> Key: RYA-303
> URL: https://issues.apache.org/jira/browse/RYA-303
> Project: Rya
> Issue Type: Improvement
> Reporter: Andrew Smith
> Assignee: Andrew Smith
>
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)