usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject incubator-usergrid git commit: Creates test that proves issue.
Date Thu, 12 Feb 2015 22:02:15 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/reduce-fix [created] 1203f55de


Creates test that proves issue.


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

Branch: refs/heads/reduce-fix
Commit: 1203f55de2ec28e2643cedde31251190a7f91141
Parents: e57e5e5
Author: Todd Nine <tnine@apigee.com>
Authored: Thu Feb 12 15:02:13 2015 -0700
Committer: Todd Nine <tnine@apigee.com>
Committed: Thu Feb 12 15:02:13 2015 -0700

----------------------------------------------------------------------
 .../usergrid/persistence/CollectionIT.java      | 83 ++++++++++++++++++--
 1 file changed, 78 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1203f55d/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
index b24bd31..2bab323 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CollectionIT.java
@@ -29,6 +29,8 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.avro.generic.GenericData;
+
 import org.apache.usergrid.AbstractCoreIT;
 import org.apache.usergrid.Application;
 import org.apache.usergrid.CoreApplication;
@@ -67,7 +69,7 @@ public class
         app.put( "username", "edanuff" );
         app.put( "email", "ed@anuff.com" );
         Entity user = app.create( "user" );
-        assertNotNull( user ); 
+        assertNotNull( user );
 
         user = app.get( user.getUuid(), "user" );
         assertNotNull( user );
@@ -374,7 +376,7 @@ public class
 
         em.refreshIndex();
 
-        Results r = em.searchCollection( group, "users", 
+        Results r = em.searchCollection( group, "users",
             new Query().addEqualityFilter( "nickname", "ed" )
                 .withResultsLevel(Level.LINKED_PROPERTIES ) );
 
@@ -930,7 +932,7 @@ public class
     public void pagingAfterDelete() throws Exception {
         LOG.debug( "pagingAfterDelete" );
 
-        
+
         EntityManager em = app.getEntityManager();
         assertNotNull( em );
 
@@ -1497,7 +1499,7 @@ public class
         em.refreshIndex();
 
         location = new LinkedHashMap<String, Object>();
-        location.put( "Place", 
+        location.put( "Place",
             "Via Pietro Maroncelli, 48, 62012 Santa Maria Apparente Province of Macerata,
Italy" );
         location.put( "Longitude", 13.693080199999999 );
         location.put( "Latitude", 43.2985019 );
@@ -1516,7 +1518,7 @@ public class
         em.refreshIndex();
 
         // String s = "select * where Flag = 'requested'";
-        // String s = "select * where Flag = 'requested' and NOT Recipient.Username = 
+        // String s = "select * where Flag = 'requested' and NOT Recipient.Username =
         // 'fb_536692245' order by created asc";
 
         String s = "select * where Flag = 'requested' and NOT Recipient.Username "
@@ -1776,4 +1778,75 @@ public class
 
         em.create( "restaurant", restaurant2.getProperties() );
     }
+
+
+    @Test
+    public void testConnectionWithIndexUpdated() throws Exception {
+        LOG.debug( "testSelectEmailViaConnection" );
+
+        EntityManager em = app.getEntityManager();
+        assertNotNull( em );
+
+        Map<String, Object> properties = new LinkedHashMap<String, Object>();
+        properties.put( "username", "ed@anuff.com" );
+        properties.put( "email", "ed@anuff.com" );
+
+        final Entity userEntity =  em.create( "user", properties );
+
+        int connectionCount = 10;
+        int updateCount = 20;
+
+
+        UUID[] ids = new UUID[connectionCount];
+        UUID[] versions = new UUID[connectionCount];
+
+
+        for ( int i = 0; i < connectionCount; i++ ) {
+
+            final Map<String, Object> thing = new HashMap<>();
+            thing.put( "entityindex", i );
+
+            final Entity entity = em.create( "thing", thing );
+
+            em.createConnection( userEntity, "likes", entity );
+
+            ids[i] = entity.getUuid();
+
+            for ( int j = 0; j < updateCount; j++ ) {
+                entity.setDynamicProperty( "updateNumber", j + 1 );
+                em.update( entity );
+
+                versions[i] =  ( UUID ) entity.getProperty( "version" );
+            }
+        }
+
+
+        final Query query = Query.fromQLNullSafe( null );
+        query.setConnectionType( "likes" );
+        query.setEntityType( "thing" );
+
+
+
+        Results r = em.searchConnectedEntities( userEntity, query );
+        assertEquals("Expected result size", connectionCount, r.size()  );
+
+        // selection results should be a list of lists
+        for(int i = 0; i < connectionCount; i ++){
+            final Entity returned = r.getEntities().get( i );
+            final UUID entityId = returned.getUuid();
+            final UUID version = ( UUID ) returned.getProperty( "version" );
+
+            final UUID expectedId = ids[i];
+            final UUID expectedVersion = ids[i];
+
+
+            assertEquals("Same uuid expected", expectedId, entityId );
+            assertEquals("Same version expected", expectedVersion, version);
+        }
+
+    }
+
 }
+
+
+


Mime
View raw message