You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2015/04/17 17:26:45 UTC

[28/51] [abbrv] incubator-usergrid git commit: Adding test for getIdField() to demonstrate that unique values are not per type as they should be.

Adding test for getIdField() to demonstrate that unique values are not per type as they should be.


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

Branch: refs/heads/two-dot-o-import
Commit: b62e76ff1318bc98d1bed39c406219109524fae2
Parents: 09734fa
Author: Dave Johnson <dm...@apigee.com>
Authored: Fri Apr 3 17:00:47 2015 -0400
Committer: Dave Johnson <dm...@apigee.com>
Committed: Fri Apr 3 17:00:47 2015 -0400

----------------------------------------------------------------------
 .../collection/EntityCollectionManagerIT.java   | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/b62e76ff/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
index 252ce1f..e81019b 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java
@@ -705,4 +705,33 @@ public class EntityCollectionManagerIT {
         assertFalse( uniqueValues.iterator().hasNext() );
 
     }
+
+
+    @Test
+    public void testGetIdField() throws Exception {
+
+        ApplicationScope context =  new ApplicationScopeImpl( new SimpleId( "organization" ) );
+        EntityCollectionManager manager = factory.createCollectionManager( context );
+
+        // create an entity of type "item" with a unique_id field value = 1
+
+        Entity entity1 = new Entity( new SimpleId( "item" ) );
+        entity1.setField( new StringField( "unique_id", "1", true ));
+        manager.write( entity1 ).toBlocking().last();
+
+        final Observable<Id> idObs = manager.getIdField("item", new StringField("unique_id", "1"));
+        Id id = idObs.toBlocking().lastOrDefault(null);
+        assertEquals(entity1.getId(), id);
+
+        // create an entity of type "deleted_item" with a unique_id field value = 1
+
+        Entity entity2 = new Entity( new SimpleId( "deleted_item" ) );
+        entity2.setField( new StringField( "unique_id", "1", true ));
+        manager = factory.createCollectionManager( context );
+        manager.write( entity2 ).toBlocking().last();
+
+        final Observable<Id> id2Obs = manager.getIdField("item", new StringField("unique_id", "1"));
+        Id id2 = id2Obs.toBlocking().lastOrDefault(null);
+        assertEquals(entity2.getId(), id2);
+    }
 }