usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [3/7] incubator-usergrid git commit: Added new test at the graph level
Date Wed, 10 Jun 2015 15:47:13 GMT
Added new test at the graph level


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/f07ea32d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/f07ea32d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/f07ea32d

Branch: refs/heads/two-dot-o-dev
Commit: f07ea32dd84e91f80cfa8f4f4b5893369a14a332
Parents: f9f8534
Author: Todd Nine <tnine@apigee.com>
Authored: Mon Jun 8 17:31:54 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Mon Jun 8 17:31:54 2015 -0600

----------------------------------------------------------------------
 .../persistence/graph/GraphManagerIT.java       | 174 +++++++++++++++++++
 1 file changed, 174 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f07ea32d/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
index be37edc..7e6d2f7 100644
--- a/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
+++ b/stack/corepersistence/graph/src/test/java/org/apache/usergrid/persistence/graph/GraphManagerIT.java
@@ -1529,6 +1529,81 @@ public class GraphManagerIT {
 
 
     @Test
+    public void markCreateSourceNode() {
+
+        final GraphManager gm = emf.createEdgeManager( scope );
+
+        Id sourceId = new SimpleId( "source" );
+        Id targetId1 = new SimpleId( "target" );
+
+        Edge edge1 = createEdge( sourceId, "test", targetId1, System.currentTimeMillis()
);
+
+        gm.writeEdge( edge1 ).toBlocking().singleOrDefault( null );
+
+
+        final long maxVersion = System.currentTimeMillis();
+
+        Iterator<Edge> results =
+            gm.loadEdgesFromSource( createSearchByEdge( sourceId, edge1.getType(), maxVersion,
null ) ).toBlocking()
+              .getIterator();
+
+
+        assertEquals( "Edge found", edge1, results.next() );
+
+        assertFalse( "No more edges", results.hasNext() );
+
+
+        //get our 2 edges
+        results = gm.loadEdgesFromSourceByType(
+            createSearchByEdgeAndId( sourceId, edge1.getType(), maxVersion, targetId1.getType(),
null ) ).toBlocking()
+                    .getIterator();
+
+
+        assertEquals( "Edges correct", edge1, results.next() );
+
+        assertFalse( "No more edges", results.hasNext() );
+
+        //mark the source node
+        gm.markNode( sourceId, edge1.getTimestamp() ).toBlocking().last();
+
+
+        //now re-read, nothing should be there since they're marked
+
+        results =
+            gm.loadEdgesFromSource( createSearchByEdge( sourceId, edge1.getType(), maxVersion,
null ) ).toBlocking()
+              .getIterator();
+
+        assertFalse( "No more edges", results.hasNext() );
+
+
+        //get our 2 edges
+        results = gm.loadEdgesFromSourceByType(
+            createSearchByEdgeAndId( sourceId, edge1.getType(), maxVersion, targetId1.getType(),
null ) ).toBlocking()
+                    .getIterator();
+
+
+        assertFalse( "No more edges", results.hasNext() );
+
+
+        //now re-create the node
+        Edge edge2 = createEdge( sourceId, "test", targetId1, edge1.getTimestamp() + 1 );
+
+        gm.writeEdge( edge2 ).toBlocking().singleOrDefault( null );
+
+
+        //now search to ensure we get it back
+
+        results = gm.loadEdgesFromSource( createSearchByEdge( sourceId, edge2.getType(),
edge2.getTimestamp(), null ) )
+                    .toBlocking().getIterator();
+
+
+        assertEquals( "Edge found", edge2, results.next() );
+
+        assertFalse( "No more edges", results.hasNext() );
+    }
+
+
+    @Test
     public void markTargetNode() {
 
         final GraphManager gm = emf.createEdgeManager( scope );
@@ -1641,6 +1716,105 @@ public class GraphManagerIT {
         assertEquals( "Edges correct", edge2, results.next() );
 
         assertFalse( "No more edges", results.hasNext() );
+
+        gm.compactNode( targetId ).toBlocking().last();
+        //nothing should be left.
+
+        results = gm.loadEdgesToTarget( createSearchByEdgeUnfiltered( targetId, edge1.getType(),
maxVersion, null ) )
+                    .toBlocking().getIterator();
+
+
+        assertFalse( "No more edges", results.hasNext() );
+
+
+        //get our 2 edges
+        results = gm.loadEdgesToTargetByType(
+            createSearchByEdgeAndIdUnfiltered( targetId, edge1.getType(), maxVersion, sourceId1.getType(),
null ) )
+                    .toBlocking().getIterator();
+
+
+        assertFalse( "No more edges", results.hasNext() );
+
+        //now delete one of the edges
+        results = gm.loadEdgesToTargetByType(
+            createSearchByEdgeAndIdUnfiltered( targetId, edge2.getType(), maxVersion, sourceId2.getType(),
null ) )
+                    .toBlocking().getIterator();
+
+
+        assertFalse( "No more edges", results.hasNext() );
+    }
+
+
+    @Test
+    public void markCreateTargetNode() {
+
+        final GraphManager gm = emf.createEdgeManager( scope );
+
+        Id sourceId1 = new SimpleId( "source" );
+        Id targetId = new SimpleId( "target" );
+
+        Edge edge1 = createEdge( sourceId1, "test", targetId, System.currentTimeMillis()
);
+
+        gm.writeEdge( edge1 ).toBlocking().singleOrDefault( null );
+
+
+        final long maxVersion = System.currentTimeMillis();
+
+        Iterator<Edge> results =
+            gm.loadEdgesToTarget( createSearchByEdge( targetId, edge1.getType(), maxVersion,
null ) ).toBlocking()
+              .getIterator();
+
+
+        assertEquals( "Edge found", edge1, results.next() );
+
+        assertFalse( "No more edges", results.hasNext() );
+
+
+        //get our 2 edges
+        results = gm.loadEdgesToTargetByType(
+            createSearchByEdgeAndId( targetId, edge1.getType(), maxVersion, sourceId1.getType(),
null ) ).toBlocking()
+                    .getIterator();
+
+
+        assertEquals( "Edges correct", edge1, results.next() );
+
+        assertFalse( "No more edges", results.hasNext() );
+
+
+        //mark the source node
+        gm.markNode( targetId, edge1.getTimestamp() ).toBlocking().last();
+
+
+        //now re-read, nothing should be there since they're marked
+
+        results = gm.loadEdgesToTarget( createSearchByEdge( targetId, edge1.getType(), maxVersion,
null ) ).toBlocking()
+                    .getIterator();
+
+        assertFalse( "No more edges", results.hasNext() );
+
+
+        //get our 2 edges
+        results = gm.loadEdgesToTargetByType(
+            createSearchByEdgeAndId( targetId, edge1.getType(), maxVersion, sourceId1.getType(),
null ) ).toBlocking()
+                    .getIterator();
+
+
+        assertFalse( "No more edges", results.hasNext() );
+
+        Edge edge2 = createEdge( sourceId1, "test", targetId, edge1.getTimestamp() + 1 );
+
+        gm.writeEdge( edge2 ).toBlocking().singleOrDefault( null );
+
+
+        //now search to ensure we get it back
+
+        results = gm.loadEdgesToTarget( createSearchByEdge( targetId, edge2.getType(), edge2.getTimestamp(),
null ) )
+                    .toBlocking().getIterator();
+
+
+        assertEquals( "Edge found", edge2, results.next() );
+
+        assertFalse( "No more edges", results.hasNext() );
     }
 
 


Mime
View raw message