usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject incubator-usergrid git commit: fixed retrieve users
Date Tue, 06 Jan 2015 02:01:12 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/Usergrid-310 3c089f550 -> 80b093f57


fixed retrieve users


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

Branch: refs/heads/Usergrid-310
Commit: 80b093f57b5129e0eed5f6c8c230ac98167a4404
Parents: 3c089f5
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Mon Jan 5 19:00:47 2015 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Mon Jan 5 19:00:47 2015 -0700

----------------------------------------------------------------------
 .../collection/users/RetrieveUsersTest.java     | 40 ++++++++++----------
 1 file changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/80b093f5/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
index 5a8d363..f85cd5a 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/RetrieveUsersTest.java
@@ -22,14 +22,17 @@ import java.util.Map;
 
 import com.fasterxml.jackson.databind.JsonNode;
 import java.io.IOException;
+
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.CollectionEndpoint;
+import org.apache.usergrid.rest.test.resource2point0.endpoints.EntityEndpoint;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
 import org.junit.Assert;
 import org.junit.Rule;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
 
 import static org.junit.Assert.assertEquals;
 
@@ -43,45 +46,42 @@ import static org.junit.Assert.assertEquals;
 public class RetrieveUsersTest extends AbstractRestIT {
     private static final Logger log = LoggerFactory.getLogger( RetrieveUsersTest.class );
 
-    @Rule
-    public TestContextSetup context = new TestContextSetup( this );
 
 
     @Test // USERGRID-1222
     public void queryForUsername() throws IOException {
-        CustomCollection users = context.customCollection( "users" );
+        CollectionEndpoint users =this.app().collection( "users" );
 
-        Map props = new HashMap();
+        Entity props = new Entity();
 
         props.put( "username", "Alica" );
-        users.create( props );
+        users.post(props);
 
         props.put( "username", "Bob" );
-        users.create( props );
+        users.post(props);
 
-        refreshIndex(context.getOrgName(), context.getAppName());
+        refreshIndex();
 
         String query = "select *";
         String incorrectQuery = "select * where username = 'Alica'";
 
-        assertEquals( users.entityValue( query, "username", 0 ), users.entityValue( incorrectQuery,
"username", 0 ) );
+        assertEquals( users.get(new QueryParameters().setQuery( query) ).next().get( "username").toString(),
users.get(new QueryParameters().setQuery( incorrectQuery)).next().get( "username").toString()
);
     }
 
 
     @Test // USERGRID-1727
     public void userEntityDictionaryHasRoles() throws IOException {
-        CustomCollection users = context.customCollection( "users" );
+        CollectionEndpoint users = this.app().collection("users");
 
-        Map props = new HashMap();
+        Entity props = new Entity();
         props.put( "username", "Nina" );
 
-        JsonNode response = users.create( props );
-        refreshIndex(context.getOrgName(), context.getAppName());
+        Entity entity = users.post(props);
+        refreshIndex();
 
-        JsonNode entity = response.get( "entities" ).get( 0 );
-        JsonNode metadata = entity.get( "metadata" );
-        JsonNode sets = metadata.get( "sets" );
-        JsonNode rolenames = sets.get( "rolenames" );
-        Assert.assertTrue( "rolenames URL ends with /roles", rolenames.asText().endsWith(
"/roles" ) );
+        Map<String,Object> metadata = (Map)entity.get( "metadata" );
+        Map<String,Object> sets = (Map)metadata.get( "sets" );
+        Map<String,Object> rolenames =(Map) sets.get( "rolenames" );
+        Assert.assertTrue( "rolenames URL ends with /roles", rolenames.toString().endsWith(
"/roles" ) );
     }
 }


Mime
View raw message