You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2015/01/05 23:34:33 UTC
[1/2] incubator-usergrid git commit: activities test replaced
Repository: incubator-usergrid
Updated Branches:
refs/heads/Usergrid-310 [created] 4d86a9531
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/Usergrid-310
Commit: 68ca34444881705e2d1bf76b79f72dadc3d943c2
Parents: 8961fec
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jan 5 15:25:15 2015 -0700
Committer: Shawn Feldman <sf...@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);
}
[2/2] incubator-usergrid git commit: fix put test
Posted by sf...@apache.org.
fix put test
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/4d86a953
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4d86a953
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4d86a953
Branch: refs/heads/Usergrid-310
Commit: 4d86a9531e3ab5f35bb90ea2e8ca5d6e46865887
Parents: 68ca344
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Jan 5 15:33:48 2015 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Jan 5 15:33:48 2015 -0700
----------------------------------------------------------------------
.../collection/activities/PutTest.java | 33 ++++++++++----------
1 file changed, 17 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4d86a953/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
index 850bd0e..2df73a2 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/activities/PutTest.java
@@ -21,11 +21,14 @@ import com.fasterxml.jackson.databind.JsonNode;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
import static org.apache.usergrid.utils.MapUtils.hashMap;
import static org.junit.Assert.assertEquals;
+
+import org.apache.usergrid.rest.test.resource.CollectionResource;
+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.Collection;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
import org.junit.Rule;
import org.junit.Test;
import org.slf4j.Logger;
@@ -38,13 +41,11 @@ import org.slf4j.LoggerFactory;
public class PutTest extends AbstractRestIT {
private static final Logger log= LoggerFactory.getLogger( PutTest.class );
- @Rule
- public TestContextSetup context = new TestContextSetup( this );
@Test //USERGRID-545
public void putMassUpdateTest() throws IOException {
- CustomCollection activities = context.customCollection( "activities" );
+ CollectionEndpoint activities = this.app().collection("activities");
Map actor = hashMap( "displayName", "Erin" );
Map newActor = hashMap( "displayName", "Bob" );
@@ -57,24 +58,24 @@ public class PutTest extends AbstractRestIT {
for ( int i = 0; i < 5; i++ ) {
props.put( "ordinal", i );
- JsonNode activity = activities.create( props );
+ Entity activity = activities.post(new Entity(props));
}
- refreshIndex(context.getOrgName(), context.getAppName());
+ refreshIndex();
String query = "select * ";
- JsonNode node = activities.withQuery( query ).get();
- String uuid = node.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
+ Collection collection = activities.get();
+ String uuid = collection.getResponse().getEntities().get( 0 ).getUuid().toString();
StringBuilder buf = new StringBuilder( uuid );
-
- activities.addToUrlEnd( buf );
+ buf.append( "/" );
+ buf.append( buf );
props.put( "actor", newActor );
- node = activities.put( props );
+ Entity activity = activities.post(new Entity(props));
- refreshIndex(context.getOrgName(), context.getAppName());
+ refreshIndex();
- node = activities.withQuery( query ).get();
- assertEquals( 6, node.get( "entities" ).size() );
+ collection = activities.get( );
+ assertEquals( 6, collection.getResponse().getEntities().size() );
}
}