You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by ro...@apache.org on 2014/12/22 17:54:49 UTC
[43/50] incubator-usergrid git commit: fixed 4 tests,
1 failing on put call
fixed 4 tests, 1 failing on put call
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/a98959cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/a98959cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/a98959cd
Branch: refs/heads/two-dot-o
Commit: a98959cd0729643487925ea6004ce8ba9b98632f
Parents: b2db98c
Author: Rod Simpson <ro...@apigee.com>
Authored: Thu Dec 18 20:09:03 2014 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Thu Dec 18 20:09:03 2014 -0700
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 193 +++++++++----------
1 file changed, 93 insertions(+), 100 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/a98959cd/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
index 9e8f040..79ce8c5 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/GroupResourceIT.java
@@ -22,8 +22,10 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import com.fasterxml.jackson.databind.JsonNode;
import com.sun.jersey.api.client.UniformInterfaceException;
import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
import org.apache.usergrid.rest.test.resource2point0.model.Entity;
import org.junit.Test;
import org.slf4j.Logger;
@@ -49,14 +51,14 @@ public class GroupResourceIT extends AbstractRestIT {
String groupName = "testgroup";
String groupPath = "testgroup";
- Entity group = new Entity();
- group.put("name", groupName);
- group.put("path", groupPath);
+ Entity payload = new Entity();
+ payload.put("name", groupName);
+ payload.put("path", groupPath);
- Entity groupResponse = this.app().collection("groups").post(group);
+ Entity group = this.app().collection("groups").post(payload);
- assertEquals(groupResponse.get("path"), groupPath);
- assertEquals(groupResponse.get("name"), groupName);
+ assertEquals(group.get("path"), groupPath);
+ assertEquals(group.get("name"), groupName);
}
@@ -67,15 +69,20 @@ public class GroupResourceIT extends AbstractRestIT {
@Test()
public void createGroupSlashInNameAndPathValidation() throws IOException {
-/*
+
//create the group with a slash in the name
String groupNameSlash = "test/group";
String groupPathSlash = "test/group";
- Group group = new Group(groupNameSlash, groupPathSlash);
- Group testGroup = this.app().groups().post(group);
- assertNull(testGroup.get("errors"));
- assertEquals(testGroup.get("path"), groupPathSlash);
-*/
+
+ Entity payload = new Entity();
+ payload.put("name", groupNameSlash);
+ payload.put("path", groupPathSlash);
+
+ Entity group = this.app().collection("groups").post(payload);
+
+ assertEquals(group.get("name"), groupNameSlash);
+ assertEquals(group.get("path"), groupPathSlash);
+
}
/***
@@ -85,15 +92,20 @@ public class GroupResourceIT extends AbstractRestIT {
@Test()
public void createGroupSpaceInNameValidation() throws IOException {
-/*
+
//create the group with a space in the name
String groupSpaceName = "test group";
String groupPath = "testgroup";
- Group group = new Group(groupSpaceName, groupPath);
- Group testGroup = this.app().groups().post(group);
- assertNull(testGroup.getError());
- assertEquals(testGroup.get("path"), groupPath);
-*/
+
+ Entity payload = new Entity();
+ payload.put("name", groupSpaceName);
+ payload.put("path", groupPath);
+
+ Entity group = this.app().collection("groups").post(payload);
+
+ assertEquals(group.get("name"), groupSpaceName);
+ assertEquals(group.get("path"), groupPath);
+
}
/***
@@ -106,128 +118,80 @@ public class GroupResourceIT extends AbstractRestIT {
String groupName = "testgroup";
String groupSpacePath = "test group";
- //Group group = new Group(groupName, groupSpacePath);
- /*
+ Entity payload = new Entity();
+ payload.put("name", groupName);
+ payload.put("path", groupSpacePath);
+
+
try {
- Group testGroup = this.app().groups().post(group);
+ this.app().collection("groups").post(payload);
+ fail("Should not be able to create a group with a space in the path");
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
assertEquals( "illegal_argument", node.get( "error" ).textValue() );
}
-*/
- /*
- Group testGroup = this.app().groups().post(group);
-
- group.save();
-
- group.connect()..
- String error = testGroup.getError();
- String errorCode = testGroup.getErrorCode();
- String errorDescription = testGroup.getErrorDescription();
- assertEquals(testGroup.getError(), "illegal_argument");
-*/
}
/***
*
* Verify that we can create a group and then change the name
- *//*
+ */
@Test()
public void changeGroupNameValidation() throws IOException {
String groupName = "testgroup";
String groupPath = "testgroup";
String newGroupPath = "newtestgroup";
- Group testGroup = this.app().groups().post(new Group(groupName, groupPath));
- assertNull(testGroup.get("errors"));
- assertEquals(testGroup.get("path"), groupPath);
- /** connections
- * this.app().groups()
- .entityResource("carlovers")
- .connections("likes","cars")
- .connection("ferraris").delete();
- */
- /*
- //now change the name
- testGroup.put("path", newGroupPath);
- Group group = this.app().groups().uniqueID(testGroup.getName()).put(testGroup);
- Group group = this.app().collection("groups").uniqueID(testGroup.get("username")).put(testGroup);
- assertNull(testGroup.get("errors"));
- assertEquals(testGroup.get("path"), newGroupPath);
+ Entity payload = new Entity();
+ payload.put("name", groupName);
+ payload.put("path", groupPath);
+ Entity group = this.app().collection("groups").post(payload);
+ assertEquals(group.get("path"), groupPath);
- //now delete the group
- this.app().groups().uniqueID(testGroup.getName()).delete();
-
-
- Group newGroup = this.app().groups().uniqueID(groupName).get();
- if (newGroup.hasError()) {
- assertEquals(newGroup.ErrorMessage(), "some error");
- assertNotEquals(newGroup.ErrorCode(), "400");
-
- }
- /*
- if (newgroup.ErrorMessage() == "some error") {
-
- }
-
-
-
- if (newGroup.errorCode() == "400") {
-
+ //now change the name
+ group.put("path", newGroupPath);
+ this.app().collection("groups").entity(group).put(group);
+ assertEquals(group.get("path"), newGroupPath);
- } else if (newGroup.errorCode() == "500") {
+ //now delete the group
+ ApiResponse response = this.app().collection("groups").entity(group).delete();
- }
- }
- /*
try {
- //now get the group again
-
- Group newGroup = this.app().groups().uniqueID(groupName).get();
- fail("doh!");
-
-
-
+ Entity newGroup = this.app().collection("groups").uniqueID(groupName).get();
+ fail("Entity still exists");
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
assertEquals( "illegal_argument", node.get( "error" ).textValue() );
}
- */
- // }
+ }
/***
*
- * Verify that we cannot create a group with a space in the path
+ * Verify that we can create a group and then add a user to it
*/
- /*
- @Test
- public void postGroupActivity() throws IOException {
-
-
- //1. create a group
- GroupsCollection groups = context.groups();
-
- //create a group with a normal name
- String groupName = "groupTitle";
- String groupPath = "groupPath";
- JsonNode testGroup = groups.create(groupName, groupPath);
- //verify the group was created
- assertNull(testGroup.get("errors"));
- assertEquals(testGroup.get("path").asText(), groupPath);
+ @Test()
+ public void createGroupAndAddAUserValidation() throws IOException {
- //2. post group activity
+ }
+ /***
+ *
+ * Verify that we can create a group and then add a role to it
+ */
+ @Test()
+ public void createGroupAndAddARoleValidation() throws IOException {
- //TODO: actually post a group activity
}
+ /*
+
@Test
public void addRemovePermission() throws IOException {
@@ -380,4 +344,33 @@ public class GroupResourceIT extends AbstractRestIT {
}
*/
+
+ /***
+ *
+ * Post a group activity
+ */
+
+ @Test
+ public void postGroupActivity() throws IOException {
+
+ /*
+
+ //1. create a group
+ GroupsCollection groups = context.groups();
+
+ //create a group with a normal name
+ String groupName = "groupTitle";
+ String groupPath = "groupPath";
+ JsonNode testGroup = groups.create(groupName, groupPath);
+ //verify the group was created
+ assertNull(testGroup.get("errors"));
+ assertEquals(testGroup.get("path").asText(), groupPath);
+
+ //2. post group activity
+
+ //TODO: actually post a group activity
+ */
+ }
+
+
}
\ No newline at end of file