You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/11/17 21:12:59 UTC
[49/50] [abbrv] incubator-usergrid git commit: Created wrapper class
for admin user and organization uuid's . Fixed querying by said uuids.
Created wrapper class for admin user and organization uuid's . Fixed querying by said uuids.
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/66ab3761
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/66ab3761
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/66ab3761
Branch: refs/heads/two-dot-o-events
Commit: 66ab3761982a0e3113b339ffa75738e1e7093580
Parents: 96cb667
Author: grey <gr...@apigee.com>
Authored: Mon Nov 17 08:55:46 2014 -0800
Committer: grey <gr...@apigee.com>
Committed: Mon Nov 17 08:55:46 2014 -0800
----------------------------------------------------------------------
.../rest/test/resource/OrgUserUUIDWrapper.java | 29 +++++++++++++++
.../rest/test/resource/TestContext.java | 21 ++++++-----
.../rest/test/resource/TestOrganization.java | 39 ++++++++++++++++++++
.../resource/mgmt/OrganizationsCollection.java | 28 +++++++++++---
.../usergrid/rest/test/security/TestUser.java | 4 +-
5 files changed, 105 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/66ab3761/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/OrgUserUUIDWrapper.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/OrgUserUUIDWrapper.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/OrgUserUUIDWrapper.java
new file mode 100644
index 0000000..c147f27
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/OrgUserUUIDWrapper.java
@@ -0,0 +1,29 @@
+package org.apache.usergrid.rest.test.resource;
+
+
+import java.util.UUID;
+
+
+/**
+ * Created by ApigeeCorporation on 11/14/14.
+ */
+public class OrgUserUUIDWrapper {
+ private UUID orgUUID;
+ private UUID userUUID;
+
+
+ public OrgUserUUIDWrapper( final UUID orgUUID, final UUID userUUID ) {
+ this.orgUUID = orgUUID;
+ this.userUUID = userUUID;
+ }
+
+
+ public UUID getOrgUUID() {
+ return orgUUID;
+ }
+
+
+ public UUID getUserUUID() {
+ return userUUID;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/66ab3761/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
index 00e2c4a..c75945e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestContext.java
@@ -38,8 +38,7 @@ public class TestContext {
private JerseyTest test;
private TestUser activeUser;
- private String orgName;
- private UUID orgUuid;
+ private TestOrganization testOrganization;
private String appName;
private UUID appUuid;
@@ -75,7 +74,7 @@ public class TestContext {
public TestContext withOrg( String orgName ) {
- this.orgName = orgName;
+ testOrganization = new TestOrganization( orgName );
return this;
}
@@ -87,7 +86,7 @@ public class TestContext {
public String getOrgName() {
- return orgName;
+ return testOrganization.getOrgName();
}
@@ -98,16 +97,18 @@ public class TestContext {
/** Creates the org specified */
public TestContext createNewOrgAndUser() throws IOException {
- orgUuid = management().orgs().create( orgName, activeUser );
- refreshIndex( orgName, appName );
+ OrgUserUUIDWrapper ouuw = management().orgs().create( getOrgName(),activeUser );
+ testOrganization.setUuid( ouuw.getOrgUUID() );
+ activeUser.setUUID( ouuw.getUserUUID() );
+ refreshIndex( getOrgName(), appName );
return this;
}
/** Creates the org specified */
public TestContext createAppForOrg() throws IOException {
- appUuid = management().orgs().organization( orgName ).apps().create( appName );
- refreshIndex( orgName, appName );
+ appUuid = management().orgs().organization( getOrgName() ).apps().create( appName );
+ refreshIndex( getOrgName(), appName );
return this;
}
@@ -140,7 +141,7 @@ public class TestContext {
/** @return the orgUuid */
public UUID getOrgUuid() {
- return orgUuid;
+ return testOrganization.getUuid();
}
@@ -152,7 +153,7 @@ public class TestContext {
/** Get the application resource */
public Application application() {
- return new Application( orgName, appName, root() );
+ return new Application( getOrgName(), appName, root() );
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/66ab3761/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestOrganization.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestOrganization.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestOrganization.java
new file mode 100644
index 0000000..a98cd9a
--- /dev/null
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/TestOrganization.java
@@ -0,0 +1,39 @@
+package org.apache.usergrid.rest.test.resource;
+
+
+import java.util.UUID;
+
+
+/**
+ * Wrapper class that contains all the resources needed by a organization
+ */
+public class TestOrganization {
+ private String orgName;
+ private UUID uuid;
+
+ //test organizations are always initialized by name, and the uuid will be set on creations
+ public TestOrganization( final String orgName) {
+ this.orgName = orgName;
+ }
+
+ public UUID getUuid() {
+ return uuid;
+ }
+
+
+ public void setUuid( final UUID uuid ) {
+ this.uuid = uuid;
+ }
+
+
+ public String getOrgName() {
+
+ return orgName;
+ }
+
+
+ public void setOrgName( final String orgName ) {
+ this.orgName = orgName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/66ab3761/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java
index f89a476..522eadf 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource/mgmt/OrganizationsCollection.java
@@ -17,12 +17,14 @@
package org.apache.usergrid.rest.test.resource.mgmt;
+import java.util.Map;
import java.util.UUID;
import com.fasterxml.jackson.databind.JsonNode;
import java.io.IOException;
import org.apache.usergrid.rest.test.resource.CollectionResource;
import org.apache.usergrid.rest.test.resource.NamedResource;
+import org.apache.usergrid.rest.test.resource.OrgUserUUIDWrapper;
import org.apache.usergrid.rest.test.security.TestUser;
import org.apache.usergrid.utils.MapUtils;
@@ -45,12 +47,28 @@ public class OrganizationsCollection extends CollectionResource {
/** Create the org and return it's UUID */
- public UUID create( String name, TestUser owner ) throws IOException {
+ public OrgUserUUIDWrapper create( String name, TestUser owner ) throws IOException {
+//not entirely convinced we want to do this here, maybe we should shove the node and data get another level deeper?
+ JsonNode node = postInternal(mapOrganization( name,owner.getUser(),owner.getEmail(),owner.getUser(),owner.getPassword() ) );
- JsonNode node = postInternal( MapUtils.hashMap( "organization", name ).map( "username", owner.getUser() )
- .map( "email", owner.getEmail() ).map( "name", owner.getUser() )
- .map( "password", owner.getPassword() ) );
+//org && user uuid wrapper
+ OrgUserUUIDWrapper wrapper = new OrgUserUUIDWrapper(getOrgUUID( node ),getUserUUID(node) );
- return UUID.fromString( node.get( "data" ).get( "organization" ).get( "uuid" ).asText() );
+ return wrapper;
+ }
+
+ public UUID getOrgUUID(JsonNode node){
+ return UUID.fromString(node.get("data").get( "organization" ).get("uuid").asText());
+ }
+
+ public UUID getUserUUID (JsonNode node){
+ return UUID.fromString( node.get( "data" ).get( "owner" ).get( "uuid" ).asText() );
+ }
+
+ public Map<String,String> mapOrganization(String orgName, String username, String email, String name, String password){
+
+ return MapUtils.hashMap( "organization", orgName ).map( "username", username )
+ .map( "email", email ).map( "name", name )
+ .map( "password", password);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/66ab3761/stack/rest/src/test/java/org/apache/usergrid/rest/test/security/TestUser.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/security/TestUser.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/security/TestUser.java
index b322d90..4d49914 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/security/TestUser.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/security/TestUser.java
@@ -45,7 +45,6 @@ public abstract class TestUser {
this.user = user;
this.password = password;
this.email = email;
- this.uuid = UUIDUtils.newTimeUUID();
}
@@ -101,6 +100,9 @@ public abstract class TestUser {
return uuid;
}
+ public void setUUID(UUID uuid) {
+ this.uuid = uuid;
+ }
public boolean isLoggedIn() {
return this.token != null;