usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject git commit: Test that illustrates update with no version problem.
Date Wed, 08 Oct 2014 15:08:20 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o 0b43040f3 -> 66c377df5


Test that illustrates update with no version problem.


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

Branch: refs/heads/two-dot-o
Commit: 66c377df5b5323480d81530bfe2a00c7a803d023
Parents: 0b43040
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Wed Oct 8 11:08:05 2014 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Wed Oct 8 11:08:05 2014 -0400

----------------------------------------------------------------------
 .../collection/EntityCollectionManagerIT.java   | 32 +++++++++++++++++---
 1 file changed, 28 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/66c377df/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 1639d17..3d47e32 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
@@ -25,7 +25,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException;
 import org.apache.usergrid.persistence.collection.exception.WriteUniqueVerifyException;
 import org.apache.usergrid.persistence.collection.guice.MigrationManagerRule;
 import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
@@ -40,9 +39,6 @@ import com.google.inject.Inject;
 
 import rx.Observable;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
 
 import static org.junit.Assert.*;
 
@@ -347,4 +343,32 @@ public class EntityCollectionManagerIT {
     }
 
 
+    @Test
+    public void updateVersioning() {
+
+        // create entity 
+        Entity origEntity = new Entity( new SimpleId( "testUpdate" ) );
+        origEntity.setField( new StringField( "testField", "value" ) );
+
+        CollectionScope context = new CollectionScopeImpl(
+            new SimpleId( "organization" ),  new SimpleId( "testUpdate" ), "testUpdate" );
+        EntityCollectionManager manager = factory.createCollectionManager( context );
+        Entity returned = manager.write(origEntity).toBlocking().lastOrDefault(null);
+
+        // note its version 
+        UUID oldVersion = returned.getVersion();
+
+        // partial update entity but we don't have version number
+        Entity updateEntity = new Entity( origEntity.getId() );
+        updateEntity.setField( new StringField("addedField", "other value" ) );
+        manager.update(origEntity).toBlocking().lastOrDefault(null);
+
+        // get entity now, it must have a new version
+        returned = manager.load(origEntity.getId() ).toBlocking().lastOrDefault(null);
+        UUID newVersion = returned.getVersion();
+
+        // this asswer fails
+        assertNotEquals( newVersion, oldVersion );
+    }
+
 }


Mime
View raw message