Return-Path: X-Original-To: apmail-usergrid-commits-archive@minotaur.apache.org Delivered-To: apmail-usergrid-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ECA1B172BD for ; Thu, 12 Feb 2015 22:02:15 +0000 (UTC) Received: (qmail 48967 invoked by uid 500); 12 Feb 2015 22:02:16 -0000 Delivered-To: apmail-usergrid-commits-archive@usergrid.apache.org Received: (qmail 48952 invoked by uid 500); 12 Feb 2015 22:02:16 -0000 Mailing-List: contact commits-help@usergrid.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@usergrid.incubator.apache.org Delivered-To: mailing list commits@usergrid.incubator.apache.org Received: (qmail 48943 invoked by uid 99); 12 Feb 2015 22:02:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2015 22:02:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B1E6DE01C2; Thu, 12 Feb 2015 22:02:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: toddnine@apache.org To: commits@usergrid.apache.org Message-Id: <43d0e9d26dc94f6f93632a277022b66e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-usergrid git commit: Creates test that proves issue. Date: Thu, 12 Feb 2015 22:02:15 +0000 (UTC) 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 Authored: Thu Feb 12 15:02:13 2015 -0700 Committer: Todd Nine 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(); - 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 properties = new LinkedHashMap(); + 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 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); + } + + } + } + + +