usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rockers...@apache.org
Subject [1/6] incubator-usergrid git commit: activities test replaced
Date Tue, 06 Jan 2015 04:44:04 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o acb468cec -> fe7719ab8


activities test replaced


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

Branch: refs/heads/two-dot-o
Commit: 68ca34444881705e2d1bf76b79f72dadc3d943c2
Parents: 8961fec
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Mon Jan 5 15:25:15 2015 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Mon Jan 5 15:25:15 2015 -0700

----------------------------------------------------------------------
 .../activities/ActivityResourceIT.java          | 133 +++++++------------
 .../resource2point0/model/ActivityEntity.java   |   5 +
 2 files changed, 56 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68ca3444/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
index 49fa7bb..af6cdbc 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/ActivityResourceIT.java
@@ -17,16 +17,16 @@
 package org.apache.usergrid.rest.applications.collection.activities;
 
 
+import com.sun.jersey.api.client.UniformInterfaceException;
+import org.apache.usergrid.persistence.index.utils.MapUtils;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
+import org.apache.usergrid.rest.test.resource2point0.model.*;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.usergrid.cassandra.Concurrent;
-import org.apache.usergrid.java.client.Client.Query;
-import org.apache.usergrid.java.client.entities.Entity;
-import org.apache.usergrid.java.client.entities.User;
-import org.apache.usergrid.java.client.response.ApiResponse;
-import org.apache.usergrid.rest.AbstractRestIT;
 import org.apache.usergrid.utils.UUIDUtils;
 
 import static org.junit.Assert.assertEquals;
@@ -43,24 +43,27 @@ public class ActivityResourceIT extends AbstractRestIT {
     private static final String USER = "edanuff";
 
     private static boolean groupCreated = false;
-
-
-    public ActivityResourceIT() throws Exception {
-
-    }
+    private CollectionEndpoint groupsResource;
+    private CollectionEndpoint groupActivityResource;
+    private CollectionEndpoint usersResource;
+    private User current;
+    private Entity activity;
+    private String activityTitle;
+    private String activityDesc;
 
 
     @Before
-    public void setupGroup() {
-        if ( groupCreated ) {
-            return;
-        }
-
-        client.createGroup( GROUP );
-
-        refreshIndex("test-organization", "test-app");
-
-        groupCreated = true;
+    public void setup() {
+        this.groupsResource = this.app().collection("groups");
+        this.usersResource = this.app().collection("users");
+        Entity entity = groupsResource.post(new Entity().chainPut("name",GROUP).chainPut("path","/"+GROUP));
+        current = new User("user1","user1","user1","user1");
+        current = new User( this.app().collection("users").post(current));
+        this.activityTitle = "testTitle" ;
+        this.activityDesc = "testActivity" ;
+        this.activity = new ActivityEntity().putActor(current).chainPut("title", activityTitle).chainPut("content",
activityDesc).chainPut("category", "testCategory").chainPut("verb", "POST");
+        this.groupActivityResource = groupsResource.entity(entity).activities();
+        refreshIndex();
     }
 
 
@@ -69,9 +72,7 @@ public class ActivityResourceIT extends AbstractRestIT {
 
         boolean fail = false;
         try {
-            ApiResponse groupActivity = client.postGroupActivity( GROUP, null );
-            fail = (groupActivity.getError() != null);
-            
+            Entity groupActivity = groupActivityResource.post(new Entity());
         }
         catch ( Exception e ) {
             fail = true;
@@ -84,36 +85,24 @@ public class ActivityResourceIT extends AbstractRestIT {
     public void postGroupActivity() {
 
         // don't populate the user, it will use the currently authenticated user.
+        try {
+            groupActivityResource.post(activity);
+        }catch (UniformInterfaceException e)
+        {
+            throw e;
+        }
+        refreshIndex();
 
-        String activityTitle = "testTitle" + UUIDUtils.newTimeUUID();
-        String activityDesc = "testActivity" + UUIDUtils.newTimeUUID();
-
-        client.postGroupActivity( GROUP, "POST", 
-            activityTitle, activityDesc, "testCategory", null, null, null, null, null );
-
-        refreshIndex("test-organization", "test-app");
-
-        Query results = client.queryActivityFeedForGroup( GROUP );
+        Collection results = groupActivityResource.get();
 
         ApiResponse response = results.getResponse();
 
         Entity result = response.getEntities().get( 0 );
 
-        assertEquals( "POST", result.getProperties().get( "verb" ).asText() );
-        assertEquals( activityTitle, result.getProperties().get( "title" ).asText() );
-        assertEquals( activityDesc, result.getProperties().get( "content" ).asText() );
+        assertEquals("POST", result.get("verb").toString());
+        assertEquals( activityTitle, result.get("title").toString() );
+        assertEquals( activityDesc, result.get("content").toString() );
 
-        // now pull the activity directly, we should find it
-
-        results = client.queryActivity();
-
-        response = results.getResponse();
-
-        result = response.getEntities().get( 0 );
-
-        assertEquals( "POST", result.getProperties().get( "verb" ).asText() );
-        assertEquals( activityTitle, result.getProperties().get( "title" ).asText() );
-        assertEquals( activityDesc, result.getProperties().get( "content" ).asText() );
     }
 
 
@@ -123,37 +112,23 @@ public class ActivityResourceIT extends AbstractRestIT {
         // don't populate the user, it will use the currently authenticated
         // user.
 
-        User current = client.getLoggedInUser();
+        usersResource.entity(current).activities().post(activity);
 
-        String activityTitle = "testTitle" + UUIDUtils.newTimeUUID();
-        String activityDesc = "testActivity" + UUIDUtils.newTimeUUID();
 
-        client.postUserActivity( "POST", activityTitle, activityDesc, "testCategory", current,
null, null, null, null );
+        refreshIndex();
 
-        refreshIndex("test-organization", "test-app");
-
-        Query results = client.queryActivityFeedForUser( USER );
+        Collection results = usersResource.entity(current).activities().get();
 
         ApiResponse response = results.getResponse();
 
-        Entity result = response.getEntities().get( 0 );
-
-        assertEquals( "POST", result.getProperties().get( "verb" ).asText() );
-        assertEquals( activityTitle, result.getProperties().get( "title" ).asText() );
-        assertEquals( activityDesc, result.getProperties().get( "content" ).asText() );
-        assertEquals( current.getUuid().toString(), result.getProperties().get( "actor" ).get(
"uuid" ).asText() );
+        ActivityEntity result =new ActivityEntity( response.getEntities().get( 0 ));
 
-        // now pull the activity directly, we should find it
+        assertEquals("POST", result.get("verb").toString());
+        assertEquals(activityTitle, result.get("title").toString());
+        assertEquals(activityDesc, result.get("content").toString());
+        assertEquals( current.getUuid().toString(), result.getActor().get("uuid").toString()
);
 
-        results = client.queryActivity();
 
-        response = results.getResponse();
-
-        result = response.getEntities().get( 0 );
-
-        assertEquals( "POST", result.getProperties().get( "verb" ).asText() );
-        assertEquals( activityTitle, result.getProperties().get( "title" ).asText() );
-        assertEquals( activityDesc, result.getProperties().get( "content" ).asText() );
     }
 
 
@@ -163,26 +138,20 @@ public class ActivityResourceIT extends AbstractRestIT {
         // don't populate the user, it will use the currently authenticated
         // user.
 
-        User current = client.getLoggedInUser();
-
-        String activityTitle = "testTitle" + UUIDUtils.newTimeUUID();
-        String activityDesc = "testActivity" + UUIDUtils.newTimeUUID();
+        this.app().collection("activities").post(activity);
 
-        client.postActivity( "POST", activityTitle, activityDesc, "testCategory", current,
null, null, null, null );
+        refreshIndex();
 
-        refreshIndex("test-organization", "test-app");
-
-        Query results = client.queryActivity();
+        Collection results = this.app().collection("activities").get();
 
         ApiResponse response = results.getResponse();
 
-        Entity result = response.getEntities().get( 0 );
-
-        assertEquals( "POST", result.getProperties().get( "verb" ).asText() );
-        assertEquals( activityTitle, result.getProperties().get( "title" ).asText() );
-        assertEquals( activityDesc, result.getProperties().get( "content" ).asText() );
+        ActivityEntity result =new  ActivityEntity( response.getEntities().get( 0 ));
 
+        assertEquals("POST", result.get("verb").toString());
+        assertEquals(activityTitle, result.get("title").toString());
+        assertEquals(activityDesc, result.get("content").toString());
         //ACTOR isn't coming back, why?
-        assertEquals( current.getUuid().toString(), result.getProperties().get( "actor" ).get(
"uuid" ).asText() );
+        assertEquals(current.getUuid().toString(), result.getActor().get("uuid").toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/68ca3444/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/ActivityEntity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/ActivityEntity.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/ActivityEntity.java
index 63bb03a..6143796 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/ActivityEntity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/ActivityEntity.java
@@ -20,6 +20,8 @@
 
 package org.apache.usergrid.rest.test.resource2point0.model;
 
+import org.apache.usergrid.persistence.index.utils.MapUtils;
+
 import java.util.Map;
 
 /**
@@ -29,6 +31,9 @@ public class ActivityEntity extends Entity {
     public ActivityEntity(String email, String verb, String content){
         this.chainPut("content",content).chainPut("verb",verb).chainPut("email",email);
     }
+    public ActivityEntity() {
+        this.putAll(new MapUtils.HashMapBuilder<String, Object>());
+    }
     public ActivityEntity(Map<String,Object> map){
         this.putAll(map);
     }


Mime
View raw message