Corrects test setup and adds debug logging

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

Branch: refs/heads/USERGRID-933
Commit: 85e1e7c1e17470bf012308011950a7ae43565b5f
Parents: b625ed2
Author: Todd Nine <tn...@apigee.com>
Authored: Mon Sep 14 19:07:28 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Mon Sep 14 19:07:28 2015 -0600

----------------------------------------------------------------------
 .../service/ConnectionServiceImpl.java          | 26 ++++++++++++++++++--
 .../service/ConnectionServiceImplTest.java      | 12 ++++++---
 2 files changed, 33 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/85e1e7c1/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
index 82c1038..41e6f80 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImpl.java
@@ -18,6 +18,9 @@
 package org.apache.usergrid.corepersistence.service;
 
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import org.apache.usergrid.corepersistence.pipeline.builder.EntityBuilder;
 import org.apache.usergrid.corepersistence.pipeline.builder.IdBuilder;
 import 
org.apache.usergrid.corepersistence.pipeline.builder.PipelineBuilderFactory;
@@ -47,6 +50,9 @@ import rx.Observable;
 @Singleton
 public class ConnectionServiceImpl implements ConnectionService {
 
+
+    private static final Logger logger = LoggerFactory.getLogger( 
ConnectionServiceImpl.class );
+
     private final PipelineBuilderFactory pipelineBuilderFactory;
     private final AllEntityIdsObservable allEntityIdsObservable;
     private final GraphManagerFactory graphManagerFactory;
@@ -152,11 +158,16 @@ public class ConnectionServiceImpl implements 
ConnectionService {
 
             final GraphManager gm = 
graphManagerFactory.createEdgeManager(applicationScope );
 
+           logger.debug( "Checking connections of id {} in application {}", 
entityId, applicationScope );
+
             return gm.getEdgeTypesFromSource(
                 new SimpleSearchEdgeType( entityId, 
CpNamingUtils.EDGE_CONN_PREFIX, Optional.absent() ) )
 
                 //now load all edges from this node of this type
                 .flatMap( edgeType -> {
+
+                    logger.debug( "Found edge of types of {}, searching for 
edges", edgeType );
+
                     final SearchByEdgeType searchByEdge =
                         new SimpleSearchByEdgeType( entityId, edgeType, 
Long.MAX_VALUE,
                             SearchByEdgeType.Order.ASCENDING, 
Optional.absent() );
@@ -167,6 +178,9 @@ public class ConnectionServiceImpl implements 
ConnectionService {
 
                 //now that we have a stream of edges, stream all versions
                 .flatMap( edge -> {
+
+                    logger.debug( "Found edge {}, searching for multiple 
versions of edge", edge );
+
                     final SearchByEdge searchByEdge =
                         new SimpleSearchByEdge( edge.getSourceNode(), 
edge.getType(), edge.getTargetNode(),
                             Long.MAX_VALUE, SearchByEdgeType.Order.ASCENDING, 
Optional.absent() );
@@ -176,8 +190,16 @@ public class ConnectionServiceImpl implements 
ConnectionService {
             //skip the first version since it's the one we want to retain
             // validate there is only 1 version of it, delete anything > than 
the min
                 .skip( 1 )
-                .flatMap( edgeToDelete -> gm.deleteEdge( edgeToDelete ) )
-                .map(deletedEdge ->  new ConnectionScope( applicationScope, 
deletedEdge ) ) ;
+                .flatMap( edgeToDelete -> {
+
+                    logger.debug( "Deleting edge {}", edgeToDelete );
+
+                    //mark the edge and ignore the cleanup result
+                    return gm.markEdge( edgeToDelete )
+                             //delete the edge
+                             .flatMap( edge -> gm.deleteEdge( edgeToDelete ));
+                } )
+                .map( deletedEdge -> new ConnectionScope( applicationScope, 
deletedEdge ) ) ;
         });
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/85e1e7c1/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
 
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
index 0a29286..e03a9b3 100644
--- 
a/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
+++ 
b/stack/core/src/test/java/org/apache/usergrid/corepersistence/service/ConnectionServiceImplTest.java
@@ -132,9 +132,6 @@ public class ConnectionServiceImplTest {
 
         final Id source = new SimpleId( "source" );
 
-        final Id target = new SimpleId( "target" );
-
-        final String connectionType = "testConnection";
 
 
           //add to a collection
@@ -147,6 +144,15 @@ public class ConnectionServiceImplTest {
 
         assertNotNull("Collection edge written", writtenCollection);
 
+
+        //now write 3 connections between the same nodes.
+
+        final Id target = new SimpleId( "target" );
+
+        final String connectionType = "testConnection";
+
+
+
         //write our first connection
         final Edge connection1 = CpNamingUtils.createConnectionEdge( source, 
connectionType, target );
 

Reply via email to