You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/02/04 01:27:11 UTC

[5/6] usergrid git commit: Added a test verifying that older properties are patched instead of completely removed. And that the entity isn't entirely recreated with the new PUT logic. Also removed the redundant properties delete from the entityManager wi

Added a test verifying that older properties are patched instead of completely removed. And that the entity isn't entirely recreated with the new PUT logic.
Also removed the redundant properties delete from the entityManager with no change to functionality.


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

Branch: refs/heads/1.x
Commit: 341b25bf10b4b04cc148ebaab6249eb10090a18a
Parents: b09a5e4
Author: George Reyes <gr...@apache.org>
Authored: Wed Feb 3 16:17:59 2016 -0800
Committer: George Reyes <gr...@apache.org>
Committed: Wed Feb 3 16:17:59 2016 -0800

----------------------------------------------------------------------
 .../cassandra/EntityManagerImpl.java            |  2 +-
 .../users/CollectionsResourceIT.java            | 40 ++++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/341b25bf/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
index c6ba7eb..4581850 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerImpl.java
@@ -1615,7 +1615,7 @@ public class EntityManagerImpl implements EntityManager {
             }
         }
 
-        addDeleteToMutator( m, ENTITY_PROPERTIES, key( entityId ), timestamp );
+        //addDeleteToMutator( m, ENTITY_PROPERTIES, key( entityId ), timestamp );
 
         batchExecute( m, CassandraService.RETRY_COUNT );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/341b25bf/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java
index 4b4b13a..1e64c5b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/users/CollectionsResourceIT.java
@@ -262,6 +262,46 @@ public class CollectionsResourceIT extends AbstractRestIT {
         assertNotNull( node );
     }
 
+    @Test
+    public void testAddingAndRemovingProperties() throws Exception {
+
+        UUID entityId = null;
+        String entityName = "tonythetiger";
+        // create an "app_user" object with name fred
+        Map<String, String> payload = hashMap( "type", "app_user" ).map( "name", entityName ).map("testProperty","randomValue");
+
+        JsonNode node =
+                resource().path( "/test-organization/test-app/app_users" ).queryParam( "access_token", access_token )
+                          .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
+                          .post( JsonNode.class, payload );
+
+        String uuidString = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
+        entityId = UUIDUtils.tryGetUUID( uuidString );
+        UUID applicationId = UUIDUtils.tryGetUUID( node.get( "application" ).asText() );
+
+        payload = hashMap( "testProperty", null );
+        payload.put( "newTestProperty","newRandomValue" );
+
+
+        // check REST API response for duplicate name property
+        // have to look at raw response data, Jackson will remove dups
+        node = resource().path( "/test-organization/test-app/app_users/"+entityName ) //+entityId )
+                         .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
+                         .type( MediaType.APPLICATION_JSON_TYPE ).put( JsonNode.class, payload );
+
+        assertNotNull( node );
+
+
+        node = resource().path( "/test-organization/test-app/app_users/"+entityName )//+entityId )
+                         .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
+                         .type( MediaType.APPLICATION_JSON_TYPE ).get( JsonNode.class );
+
+        assertNotNull( node );
+        assertEquals( entityName,node.get( "entities" ).get( 0 ).get( "name" ).asText() );
+        assertNull( node.get( "entities" ).get( 0 ).get( "testProperty" ) );
+        assertEquals( "newRandomValue",node.get( "entities" ).get( 0 ).get( "newTestProperty" ).asText() );
+    }
+
 
     @Test
     public void testDeleteByNameOfMissingEntityAndRecreation() throws Exception {