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 2015/02/25 21:36:45 UTC
[01/11] incubator-usergrid git commit: [USERGRID-327] Bringing
DuplicateNameIT inline with the new REST test framework
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o 7e1509e1a -> b4727f1db
[USERGRID-327] Bringing DuplicateNameIT inline with the new REST test framework
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1eb6b1df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1eb6b1df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1eb6b1df
Branch: refs/heads/two-dot-o
Commit: 1eb6b1df907fd285cf0fdfd1ea74eb9b1a2f9261
Parents: 231a449
Author: ryan bridges <rb...@apigee.com>
Authored: Mon Jan 12 14:40:02 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Mon Jan 12 14:40:02 2015 -0500
----------------------------------------------------------------------
.../collection/DuplicateNameIT.java | 64 +++++++-------------
1 file changed, 23 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1eb6b1df/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
index 5c98785..d01c533 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/DuplicateNameIT.java
@@ -16,57 +16,39 @@
package org.apache.usergrid.rest.applications.collection;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import java.io.IOException;
-import java.util.Map;
-import org.apache.usergrid.corepersistence.TestGuiceModule;
-import org.apache.usergrid.persistence.collection.serialization.SerializationFig;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.resource.CustomCollection;
-import org.apache.usergrid.utils.MapUtils;
-import static org.junit.Assert.fail;
-import org.junit.Rule;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DuplicateNameIT extends AbstractRestIT {
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
- private static final Logger logger = LoggerFactory.getLogger( DuplicateNameIT.class );
- @Rule
- public TestContextSetup context = new TestContextSetup( this );
+public class DuplicateNameIT extends AbstractRestIT {
+ /**
+ * Test to ensure that an error is returned when
+ * attempting to POST multiple entities to the
+ * same collection with the same name
+ */
@Test
public void duplicateNamePrevention() {
- CustomCollection things = context.application().customCollection( "things" );
-
- Map<String, String> entity = MapUtils.hashMap( "name", "enzo" );
-
- try {
- things.create( entity );
- } catch (IOException ex) {
- logger.error("Cannot create entity", ex);
- }
-
- refreshIndex( context.getAppUuid() );
-
- Injector injector = Guice.createInjector( new TestGuiceModule( null ) );
- SerializationFig sfig = injector.getInstance( SerializationFig.class );
-
- // wait for any temporary unique value records to timeout
- try { Thread.sleep( sfig.getTimeout() * 1100 ); } catch (InterruptedException ignored) {}
-
+ String collectionName = "things";
+ Entity entity = new Entity();
+ entity.put("name", "enzo");
+ //Create an entity named "enzo" in the "things" collection
+ entity = this.app().collection(collectionName).post(entity);
+ refreshIndex();
try {
- things.create( entity );
+ // Try to create a second entity in "things" with the name "enzo".
+ this.app().collection(collectionName).post(entity);
+ // fail if the POST did not return an exception
fail("Should not have created duplicate entity");
-
- } catch (Exception ex) {
- // good
+ } catch (UniformInterfaceException uie) {
+ //Check for an exception
+ assertEquals(400, uie.getResponse().getStatus());
}
}
}
[02/11] incubator-usergrid git commit: [USERGRID-331] Updating
AdminEmailEncodingIT
Posted by ro...@apache.org.
[USERGRID-331] Updating AdminEmailEncodingIT
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3ad37356
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3ad37356
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3ad37356
Branch: refs/heads/two-dot-o
Commit: 3ad37356bf7f27920b39294e3fc3981318f06c2c
Parents: 6dc62ed
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Jan 22 14:40:52 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Jan 22 14:40:52 2015 -0500
----------------------------------------------------------------------
.../organizations/AdminEmailEncodingIT.java | 138 +++++++++++--------
.../endpoints/mgmt/ManagementResource.java | 7 +-
2 files changed, 84 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ad37356/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
index 145ccd3..22dafdc 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
@@ -17,14 +17,20 @@
package org.apache.usergrid.rest.management.organizations;
-import com.fasterxml.jackson.databind.JsonNode;
-import java.io.IOException;
-import org.junit.Rule;
-import org.junit.Test;
+import com.sun.jersey.api.client.UniformInterfaceException;
import org.apache.usergrid.cassandra.Concurrent;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.rest.TestContextSetup;
-import org.apache.usergrid.rest.test.security.TestAdminUser;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.Application;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.Organization;
+import org.apache.usergrid.rest.test.resource2point0.model.Token;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.UUID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -38,82 +44,94 @@ import static org.junit.Assert.assertNotNull;
*/
@Concurrent()
public class AdminEmailEncodingIT extends AbstractRestIT {
+ private static Logger log = LoggerFactory.getLogger(AdminEmailEncodingIT.class);
- @Rule
- public TestContextSetup context = new TestContextSetup( this );
-
-
+ /**
+ * Ensure that '+' characters in email addresses are handled properly
+ *
+ * @throws Exception
+ */
@Test
public void getTokenPlus() throws Exception {
- String org = "AdminEmailEncodingTestgetTokenPlus";
- String app = "Plus";
-
- doTest( "+", org, app );
+ doTest("+");
}
-
+ /**
+ * Ensure that '_' characters in email addresses are handled properly
+ *
+ * @throws Exception
+ */
@Test
public void getTokenUnderscore() throws Exception {
- String org = "AdminEmailEncodingTestgetTokenUnderscore";
- String app = "Underscore";
-
- doTest( "_", org, app );
+ doTest("_");
}
-
+ /**
+ * Ensure that '-' characters in email addresses are handled properly
+ *
+ * @throws Exception
+ */
@Test
public void getTokenDash() throws Exception {
- String org = "AdminEmailEncodingTestgetTokenDash";
- String app = "Dash";
-
- doTest( "-", org, app );
+ doTest("-");
}
+ /**
+ * Ensure that "'" characters in email addresses are handled properly
+ *
+ * @throws Exception
+ */
+ @Test
+ @Ignore //This fails. I'm not sure if it is by design, but a single quote is valid in an email address
+ public void getTokenQuote() throws Exception {
+ doTest("'");
+ }
- private void doTest( String symbol, String org, String app ) throws IOException {
-
+ /**
+ * Given an organization name and an arbitrary character or string,
+ * ensure that an organization and admin user can be created when
+ * the given string is a part of the admin email address
+ *
+ * @param symbol
+ * @throws IOException
+ */
+ private void doTest(String symbol) throws UniformInterfaceException {
+
+ String unique = UUID.randomUUID().toString();
+ String org = "org_getTokenDash" + unique;
+ String app = "app_getTokenDash" + unique;
org = org.toLowerCase();
app = app.toLowerCase();
- String email = String.format( "admin%sname@adminemailencodingtest.org", symbol );
- String user = email;
- String password = "password";
-
- TestAdminUser adminUser = new TestAdminUser( user, password, email );
-
- context.withApp( app ).withOrg( org ).withUser( adminUser );
-
- // create the org and app
- context.createNewOrgAndUser();
-
- // no need for refresh here as Service module does an index refresh when org/app created
-
- // now log in via a GET
-
- String getToken = context.management().tokenGet( email, password );
-
- assertNotNull( getToken );
-
- String postToken = context.management().tokenPost( email, password );
-
- assertNotNull( postToken );
-
- // not log in with our admin
- context.withUser( adminUser ).loginUser();
+ //Username and password
+ String username = "testuser" + unique;
+ String password = "password" + unique;
+ //create an email address containing 'symbol'
+ String email = String.format("test%suser%s@usergrid.com", symbol, unique);
- //now get the "me" and ensure it's correct
+ //create the organization entity
+ Organization orgPayload = new Organization(org, username, email, username, password, null);
- JsonNode data = context.management().me().get();
+ //post the organization entity
+ Organization organization = clientSetup.getRestClient().management().orgs().post(orgPayload);
+ assertNotNull(organization);
- assertNotNull( data.get( "access_token" ).asText() );
+ //Retrieve an authorization token using the credentials created above
+ Token tokenReturned = clientSetup.getRestClient().management().token().post(new Token("password", username, password));
+ assertNotNull(tokenReturned);
- data = context.management().users().user( email ).get();
+ //Instruct the test framework to use the new token
+ this.app().token().setToken(tokenReturned);
+ //Create an application within the organization
+ clientSetup.getRestClient().management().orgs().organization(organization.getName()).app().post(new Application(app));
- JsonNode admin = data.get( "data" ).get( "organizations" ).get( org ).get( "users" ).get( email );
+ //retrieve the new management user by username and ensure the email address matches the input
+ Entity me = clientSetup.getRestClient().management().users().entity(username).get();
+ assertEquals(email, me.get("email"));
- assertNotNull( admin );
+ //retrieve the new management user by email and ensure the email address matches the input
+ me = clientSetup.getRestClient().management().users().entity(email).get();
+ assertEquals(email, me.get("email"));
- assertEquals( email, admin.get( "email" ).asText() );
- assertEquals( user, admin.get( "username" ).asText() );
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3ad37356/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
index 0443695..0ab260c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ManagementResource.java
@@ -41,4 +41,9 @@ public class ManagementResource extends NamedResource {
public UsersResource users() {
return new UsersResource( context, this );
}
-}
\ No newline at end of file
+
+ public EntityEndpoint get(final String identifier){
+ return new EntityEndpoint(identifier, context, this);
+ }
+
+}
[07/11] incubator-usergrid git commit: continue fixing collection
resource IT
Posted by ro...@apache.org.
continue fixing collection resource IT
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/3cf1a7f3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/3cf1a7f3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/3cf1a7f3
Branch: refs/heads/two-dot-o
Commit: 3cf1a7f36a65911084b7a6efcf031f74c899b77a
Parents: 0929ba9
Author: Rod Simpson <ro...@apigee.com>
Authored: Fri Feb 20 09:03:13 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Fri Feb 20 09:03:13 2015 -0700
----------------------------------------------------------------------
.../collection/CollectionsResourceIT.java | 104 +++++++------------
1 file changed, 39 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3cf1a7f3/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 6fa5b7b..dda1a8e 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -25,6 +25,7 @@ import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
import org.apache.usergrid.rest.test.resource2point0.model.Collection;
import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+import org.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
@@ -178,92 +179,65 @@ public class CollectionsResourceIT extends AbstractRestIT {
@Test
public void stringWithSpaces() throws IOException {
+ String collection = "calendarlists";
// create user
- String username = "sumeet.agarwal@usergrid.com";
- String email = "sumeet.agarwal@usergrid.com";
- String password = "secret";
- String name = "Sumeet Agarwal";
Entity payload = new Entity();
- payload.put("username", username);
- payload.put("email", email);
- payload.put("password", password);
- payload.put("name", name);
- Entity user = this.app().collection("users").post(payload);
- assertEquals(user.get("username"), username);
- assertEquals(user.get("email"), email);
+ String summaryOverview = "My Summary";
+ String calType = "personal";
+ payload.put("summaryOverview", summaryOverview);
+ payload.put("caltype", calType);
+ Entity calendarlistOne = this.app().collection(collection).post(payload);
+ assertEquals(calendarlistOne.get("summaryOverview"), summaryOverview);
+ assertEquals(calendarlistOne.get("caltype"), calType);
+ String calendarlistOneUUID = calendarlistOne.getString("uuid");
this.refreshIndex();
- Map<String, String> payload = hashMap( "summaryOverview", "My Summary" ).map( "caltype", "personal" );
-
- JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
-
-
- UUID id = getEntityId( node, 0 );
-
//post a second entity
+ payload = new Entity();
+ String summaryOverviewTwo = "Your Summary";
+ String calTypeTwo = "personal";
+ payload.put("summaryOverview", summaryOverviewTwo);
+ payload.put("caltype", calTypeTwo);
+ Entity calendarlistTwo = this.app().collection(collection).post(payload);
+ assertEquals(calendarlistTwo.get("summaryOverview"), summaryOverviewTwo);
+ assertEquals(calendarlistTwo.get("caltype"), calTypeTwo);
- payload = hashMap( "summaryOverview", "Your Summary" ).map( "caltype", "personal" );
-
- node = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" ).queryParam( "access_token", access_token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .post( String.class, payload ));
-
-
- refreshIndex("test-organization", "test-app");
-
//query for the first entity
-
String query = "summaryOverview = 'My Summary'";
+ QueryParameters queryParameters = new QueryParameters().setQuery(query);
+ Collection calendarListCollection = this.app().collection(collection).get(queryParameters);
+ assertEquals(calendarListCollection.hasNext(), false);
-
- JsonNode queryResponse = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" )
- .queryParam( "access_token", access_token ).queryParam( "ql", query )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
-
-
- UUID returnedId = getEntityId( queryResponse, 0 );
-
- assertEquals( id, returnedId );
-
- assertEquals( 1, queryResponse.get( "entities" ).size() );
}
/**
* Test to verify "name property returns twice in AppServices response" is fixed.
- * https://apigeesc.atlassian.net/browse/USERGRID-2318
*/
@Test
public void testNoDuplicateFields() throws Exception {
- {
- // create an "app_user" object with name fred
- Map<String, String> payload = hashMap( "type", "app_user" ).map( "name", "fred" );
-
- JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/app_users" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
-
- String uuidString = node.get( "entities" ).get( 0 ).get( "uuid" ).asText();
- UUID entityId = UUIDUtils.tryGetUUID( uuidString );
- Assert.assertNotNull( entityId );
- }
+ // create user
+ String name = "fred";
+ Entity payload = new Entity();
+ payload.put("name", name);
+ Entity user = this.app().collection("app_users").post(payload);
+ assertEquals(user.get("name"), name);
+ this.refreshIndex();
- refreshIndex("test-organization", "test-app");
+ Entity user2 = this.app().collection("app_users").entity(user).get();
- {
- // check REST API response for duplicate name property
- // have to look at raw response data, Jackson will remove dups
- String s = resource().path( "/test-organization/test-app/app_users/fred" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class );
+/*
+ // check REST API response for duplicate name property
+ // have to look at raw response data, Jackson will remove dups
+ String s = resource().path( "/test-organization/test-app/app_users/fred" )
+ .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
+ .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class );
- int firstFred = s.indexOf( "fred" );
- int secondFred = s.indexOf( "fred", firstFred + 4 );
- Assert.assertEquals( "Should not be more than one name property", -1, secondFred );
- }
+ int firstFred = s.indexOf( "fred" );
+ int secondFred = s.indexOf( "fred", firstFred + 4 );
+ Assert.assertEquals( "Should not be more than one name property", -1, secondFred );
+ */
}
}
[09/11] incubator-usergrid git commit: updated collection IT
Posted by ro...@apache.org.
updated collection IT
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/8206b726
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/8206b726
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/8206b726
Branch: refs/heads/two-dot-o
Commit: 8206b7266b8e329a1bcdb1f50dca5438b68024f4
Parents: 90afb20
Author: Rod Simpson <ro...@rodsimpson.com>
Authored: Wed Feb 25 13:26:31 2015 -0700
Committer: Rod Simpson <ro...@rodsimpson.com>
Committed: Wed Feb 25 13:26:31 2015 -0700
----------------------------------------------------------------------
.../applications/collection/CollectionsResourceIT.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/8206b726/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index dda1a8e..b9e1191 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -66,7 +66,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
}
//try to do a POST on a bad path
@@ -79,7 +79,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
}
//try to do a PUT on a bad path
@@ -89,7 +89,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
}
//try to do a delete on a bad path
@@ -99,7 +99,7 @@ public class CollectionsResourceIT extends AbstractRestIT {
} catch (UniformInterfaceException e) {
//verify the correct error was returned
JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
- assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ assertEquals( "organization_application_not_found", node.get( "error" ).textValue() );
}
}
@@ -179,11 +179,11 @@ public class CollectionsResourceIT extends AbstractRestIT {
@Test
public void stringWithSpaces() throws IOException {
+ // create entity with a property with spaces
String collection = "calendarlists";
- // create user
- Entity payload = new Entity();
String summaryOverview = "My Summary";
String calType = "personal";
+ Entity payload = new Entity();
payload.put("summaryOverview", summaryOverview);
payload.put("caltype", calType);
Entity calendarlistOne = this.app().collection(collection).post(payload);
[10/11] incubator-usergrid git commit: Merge branch 'two-dot-o' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into
apache_usergrid/two-dot-o
Posted by ro...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into apache_usergrid/two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/085223fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/085223fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/085223fc
Branch: refs/heads/two-dot-o
Commit: 085223fc269fefd6809322b1ce2a73d81cfe4630
Parents: 8206b72 7e1509e
Author: Rod Simpson <ro...@rodsimpson.com>
Authored: Wed Feb 25 13:26:39 2015 -0700
Committer: Rod Simpson <ro...@rodsimpson.com>
Committed: Wed Feb 25 13:26:39 2015 -0700
----------------------------------------------------------------------
.../apache/usergrid/rest/PartialUpdateTest.java | 2 +-
.../collection/BrowserCompatibilityTest.java | 68 +++++++++-----------
.../collection/groups/GroupResourceIT.java | 4 +-
.../endpoints/CollectionEndpoint.java | 58 ++++++++++++++---
.../endpoints/EntityEndpoint.java | 2 -
.../rest/test/resource2point0/model/Entity.java | 7 +-
6 files changed, 89 insertions(+), 52 deletions(-)
----------------------------------------------------------------------
[06/11] incubator-usergrid git commit: working on collectionsIT
Posted by ro...@apache.org.
working on collectionsIT
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/0929ba95
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/0929ba95
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/0929ba95
Branch: refs/heads/two-dot-o
Commit: 0929ba95d528adbd3fda0548ba176b849a5a2364
Parents: 6ba340a
Author: Rod Simpson <ro...@apigee.com>
Authored: Thu Feb 19 16:05:43 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Thu Feb 19 16:05:43 2015 -0700
----------------------------------------------------------------------
.../collection/CollectionsResourceIT.java | 176 +++++++++++++------
1 file changed, 120 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/0929ba95/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
index 72639ca..6fa5b7b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/CollectionsResourceIT.java
@@ -17,33 +17,29 @@
package org.apache.usergrid.rest.applications.collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.core.MediaType;
-
+import java.io.IOException;
+import java.util.NoSuchElementException;
import com.fasterxml.jackson.databind.JsonNode;
-import org.junit.Assert;
+import com.sun.jersey.api.client.UniformInterfaceException;
+import org.apache.usergrid.rest.test.resource2point0.AbstractRestIT;
+import org.apache.usergrid.rest.test.resource2point0.model.Collection;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
+
+import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.usergrid.cassandra.Concurrent;
-import org.apache.usergrid.rest.AbstractRestIT;
-import org.apache.usergrid.utils.UUIDUtils;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import java.io.IOException;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.apache.usergrid.utils.MapUtils.hashMap;
+import static org.junit.Assert.*;
/**
* @author zznate
* @author tnine
+ * @author rockerston
+ *
+ * misc tests for collections
*/
@Concurrent()
public class CollectionsResourceIT extends AbstractRestIT {
@@ -51,23 +47,71 @@ public class CollectionsResourceIT extends AbstractRestIT {
private static Logger log = LoggerFactory.getLogger( CollectionsResourceIT.class );
+ /***
+ *
+ * Test to make sure we get a 400 back when posting to a bad path
+ *
+ */
@Test
public void postToBadPath() throws IOException {
- Map<String, String> payload = hashMap( "name", "Austin" ).map( "state", "TX" );
- JsonNode node = null;
+
+ String app = "fakeapp";
+ String org = this.clientSetup.getOrganizationName();
+ String entity = "fakeentity";
+ //try to do a GET on a bad path
try {
- node = mapper.readTree( resource().path( "/test-organization/test-organization/test-app/cities" )
- .queryParam( "access_token", access_token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, payload ));
+ this.clientSetup.getRestClient().org(org).app(app).collection("cities").get();
+ fail("Call to bad path exists, but it should not");
+ } catch (UniformInterfaceException e) {
+ //verify the correct error was returned
+ JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
}
- catch ( UniformInterfaceException e ) {
- assertEquals( "Should receive a 400 Not Found", 400, e.getResponse().getStatus() );
+
+ //try to do a POST on a bad path
+ Entity payload = new Entity();
+ payload.put("name", "Austin");
+ payload.put("state", "TX");
+ try {
+ this.clientSetup.getRestClient().org(org).app(app).collection("cities").post(payload);
+ fail("Call to bad path exists, but it should not");
+ } catch (UniformInterfaceException e) {
+ //verify the correct error was returned
+ JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
}
- }
+ //try to do a PUT on a bad path
+ try {
+ this.clientSetup.getRestClient().org(org).app(app).collection("cities").entity(entity).put(payload);
+ fail("Call to bad path exists, but it should not");
+ } catch (UniformInterfaceException e) {
+ //verify the correct error was returned
+ JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ }
+ //try to do a delete on a bad path
+ try {
+ this.clientSetup.getRestClient().org(org).app(app).collection("cities").entity(entity).delete();
+ fail("Call to bad path exists, but it should not");
+ } catch (UniformInterfaceException e) {
+ //verify the correct error was returned
+ JsonNode node = mapper.readTree( e.getResponse().getEntity( String.class ));
+ assertEquals( "service_resource_not_found", node.get( "error" ).textValue() );
+ }
+
+ }
+
+ @Ignore("Not sure that this test makes any sense")
@Test
public void postToEmptyCollection() throws IOException {
+/*
+ Entity payload = new Entity();
+ Entity entity = this.app().collection("cities").post(payload);
+ assertNull(entity.get("name"));
+
+
Map<String, String> payload = new HashMap<String, String>();
JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/cities" ).queryParam( "access_token", access_token )
@@ -75,60 +119,80 @@ public class CollectionsResourceIT extends AbstractRestIT {
.post( String.class, payload ));
assertNull( getEntity( node, 0 ) );
assertNull( node.get( "count" ) );
+*/
}
/**
- * emails with "me" in them are causing errors. Test we can post to a colleciton after creating a user with this
- * email
- * <p/>
- * USERGRID-689
+ * Test posts with a user level token on a path with permissions
*/
@Test
public void permissionWithMeInString() throws Exception {
- // user is created get a token
- createUser( "sumeet.agarwal@usergrid.com", "sumeet.agarwal@usergrid.com", "secret", "Sumeet Agarwal" );
- refreshIndex("test-organization", "test-app");
-
- String token = userToken( "sumeet.agarwal@usergrid.com", "secret" );
+ // create user
+ String username = "sumeet.agarwal@usergrid.com";
+ String email = "sumeet.agarwal@usergrid.com";
+ String password = "secret";
+ String name = "Sumeet Agarwal";
+ Entity payload = new Entity();
+ payload.put("username", username);
+ payload.put("email", email);
+ payload.put("password", password);
+ payload.put("name", name);
+ Entity user = this.app().collection("users").post(payload);
+ assertEquals(user.get("username"), username);
+ assertEquals(user.get("email"), email);
+ this.refreshIndex();
//create a permission with the path "me" in it
- Map<String, String> data = new HashMap<String, String>();
+ payload = new Entity();
+ payload.put( "permission", "get,post,put,delete:/users/sumeet.agarwal@usergrid.com/**" );
+ //POST to /users/sumeet.agarwal@usergrid.com/permissions
+ Entity permission = this.app().collection("users").entity(user).collection("permissions").post(payload);
+ assertEquals(permission.get("data"), "get,post,put,delete:/users/sumeet.agarwal@usergrid.com/**");
- data.put( "permission", "get,post,put,delete:/users/sumeet.agarwal@usergrid.com/**" );
-
- String path = "/test-organization/test-app/users/sumeet.agarwal@usergrid.com/permissions";
- JsonNode posted = mapper.readTree( resource().path( path ).queryParam( "access_token", token ).accept( MediaType.APPLICATION_JSON )
- .type( MediaType.APPLICATION_JSON_TYPE ).post( String.class, data ));
+ //delete the default role, which would allow all authenticated requests
+ this.app().collection("role").uniqueID("Default").delete();
+ //log our new user in
+ this.getAppUserToken(username, password);
//now post data
- data = new HashMap<String, String>();
-
- data.put( "name", "profile-sumeet" );
- data.put( "firstname", "sumeet" );
- data.put( "lastname", "agarwal" );
- data.put( "mobile", "122" );
+ payload = new Entity();
+ String profileName = "profile-sumeet";
+ payload.put( "name", profileName );
+ payload.put( "firstname", "sumeet" );
+ payload.put( "lastname", "agarwal" );
+ payload.put( "mobile", "122" );
+ Entity nestProfile = this.app().collection("nestprofiles").post(payload);
+ assertEquals(nestProfile.get("name"), profileName);
+ this.refreshIndex();
- posted = mapper.readTree( resource().path( "/test-organization/test-app/nestprofiles" ).queryParam( "access_token", token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .post( String.class, data ));
-
- refreshIndex("test-organization", "test-app");
+ Entity nestprofileReturned = this.app().collection("nestprofiles").entity(nestProfile).get();
+ assertEquals(nestprofileReturned.get("name"), name);
- JsonNode response = mapper.readTree( resource().path( "/test-organization/test-app/nestprofiles" ).queryParam( "access_token", token )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE )
- .get( String.class ));
-
- assertNotNull( getEntity( response, 0 ) );
- assertNotNull( response.get( "count" ) );
}
@Test
public void stringWithSpaces() throws IOException {
+
+ // create user
+ String username = "sumeet.agarwal@usergrid.com";
+ String email = "sumeet.agarwal@usergrid.com";
+ String password = "secret";
+ String name = "Sumeet Agarwal";
+ Entity payload = new Entity();
+ payload.put("username", username);
+ payload.put("email", email);
+ payload.put("password", password);
+ payload.put("name", name);
+ Entity user = this.app().collection("users").post(payload);
+ assertEquals(user.get("username"), username);
+ assertEquals(user.get("email"), email);
+ this.refreshIndex();
+
Map<String, String> payload = hashMap( "summaryOverview", "My Summary" ).map( "caltype", "personal" );
JsonNode node = mapper.readTree( resource().path( "/test-organization/test-app/calendarlists" )
[03/11] incubator-usergrid git commit: Merge branch 'USERGRID-327'
into rest-tests
Posted by ro...@apache.org.
Merge branch 'USERGRID-327' into rest-tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/88bda3b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/88bda3b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/88bda3b0
Branch: refs/heads/two-dot-o
Commit: 88bda3b0a8ac1b3acde5104e50b81116f5378975
Parents: 3ad3735 1eb6b1d
Author: ryan bridges <rb...@apigee.com>
Authored: Fri Jan 23 11:08:07 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Fri Jan 23 11:08:07 2015 -0500
----------------------------------------------------------------------
.../collection/DuplicateNameIT.java | 64 +++++++-------------
1 file changed, 23 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
[05/11] incubator-usergrid git commit: [USERGRID-328] Someone had
already updated these test, but mine is a bit more verbose
Posted by ro...@apache.org.
[USERGRID-328] Someone had already updated these test, but mine is a bit more verbose
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/4cf0bba5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/4cf0bba5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/4cf0bba5
Branch: refs/heads/two-dot-o
Commit: 4cf0bba52b75bfcc95cdcd6ca34edea15c6a13d0
Parents: 6e43fc5
Author: ryan bridges <rb...@apigee.com>
Authored: Fri Jan 23 18:26:17 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Fri Jan 23 18:26:17 2015 -0500
----------------------------------------------------------------------
.../users/ConnectionResourceTest.java | 272 ++++++++-----------
1 file changed, 114 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/4cf0bba5/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
index 716b15f..de1aee7 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/ConnectionResourceTest.java
@@ -17,235 +17,191 @@
package org.apache.usergrid.rest.applications.collection.users;
-import java.io.IOException;
-import java.util.Map;
-import java.util.UUID;
-
-import org.junit.Before;
-import org.junit.Test;
-
+import com.sun.jersey.api.client.UniformInterfaceException;
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.apache.usergrid.rest.test.resource2point0.model.User;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-import com.sun.jersey.api.client.UniformInterfaceException;
+import java.io.IOException;
+import java.util.Map;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
/**
- * Contains tests that center around using connections with entities and users.
+ * // TODO: Document this
+ *
+ * @author ApigeeCorporation
+ * @since 4.0
*/
public class ConnectionResourceTest extends AbstractRestIT {
+ private static Logger log = LoggerFactory.getLogger(ConnectionResourceTest.class);
- private CollectionEndpoint thingsResource;
- private UUID thing1Id;
- private UUID thing2Id;
-
-
- /**
- * Setup two thing objects for use in the following tests
- */
- @Before
- public void setup(){
- this.thingsResource = this.app().collection("things");
-
- thing1Id = thingsResource.post( new Entity().chainPut("name", "thing1") ).getUuid();
-
- thing2Id = thingsResource.post( new Entity().chainPut("name", "thing2") ).getUuid();
-
- refreshIndex();
- }
- /**
- * Checks to see that a connection associated with one user cannot be retrieved by a different user.
- * @throws IOException
- */
@Test
- public void connectionMisMatchTest() throws IOException {
-
- //Creates collection and posts a chicken entity to it.
- CollectionEndpoint activities = this.app().collection("peeps");
-
- Entity stuff = new Entity().chainPut("name", "chicken").chainPut("type","chicken");
+ public void connectionsQueryTest() throws IOException {
- activities.post(stuff);
+ //create a peep
+ Entity peep = new Entity();
+ peep.put("type", "chicken");
- //Create two users
- User payload = new User("todd", "todd", "todd@apigee.com", "password");
- this.app().collection("users").post(payload);
- payload = new User("scott", "scott", "scott@apigee.com", "password");
- this.app().collection("users").post(payload);
+ peep = this.app().collection("peeps").post(peep);
- refreshIndex();
- //Set user Todd to connect to the chicken entity.
- Entity entity = this.app().collection("users").entity("todd").connection("likes").collection("peeps").entity("chicken").post();
+ Entity todd = new Entity();
+ todd.put("username", "todd");
+ todd = this.app().collection("users").post(todd);
- assertNotNull(entity);
+ Entity scott = new Entity();
+ scott.put("username", "scott");
+ scott = this.app().collection("users").post(scott);
+ Entity objectOfDesire = new Entity();
+ objectOfDesire.put("codingmunchies", "doritoes");
+ objectOfDesire = this.app().collection("snacks").post(objectOfDesire);
refreshIndex();
- //Get the collection and get the chicken entity.
- Collection collection = this.app().collection("peeps").get();
-
- String uuid = collection.next().get("uuid").toString();
+ Entity toddWant = this.app().collection("users").entity(todd).collection("likes").collection("snacks").entity(objectOfDesire).post();
+ assertNotNull(toddWant);
- //Set user Scott to get back a nonexistant connection.
try {
- this.app().collection("users").entity("scott").connection("likes").entity(uuid).get();
- fail("We shouldn't be able to see user1 connection through user2");
- }
- catch ( UniformInterfaceException uie ) {
- assertEquals( 404, uie.getResponse().getStatus() );
- }
- }
-
-
- /**
- * Checks that we can setup a connection loop and that we can retrieve both entities from the loop.
- * @throws IOException
- */
- @Test
- public void connectionsLoopbackTest() throws IOException {
-
- //create a connection loop by having thing1 connect to thing2 and vise versa.
- thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
- thingsResource.entity( thing2Id ).connection( "likes" ).entity( thing1Id ).post();
-
- refreshIndex();
-
- //Do a get on thing1 to make sure we have the connection present
- Collection collection =this.app().collection("things").entity(thing1Id).connection( "likes" ).get();
-
- assertTrue("Connection url returned in entity", collection.hasNext());
- //Verify that thing1 is connected to thing2
- UUID returnedUUID = collection.next().getUuid();
-
- assertEquals( thing2Id, returnedUUID );
-
- //now follow the loopback from thing2, which should be pointers to thing1
-
- collection = this.app().collection("things").entity(thing2Id).connection("likes").get();
-
- UUID returned = collection.next().getUuid();
-
- assertEquals( "Should point to thing1 as an incoming entity connection", thing1Id, returned );
-
- //Follow the connection through the loop to make sure it works.
- Entity thing1Return = this.app().collection("things").entity(thing1Id).connection( "likes" )
- .collection( "things" ).entity( thing2Id ).connection( "likes" )
- .collection( "things" ).entity( thing1Id ).get();
+ this.app().collection("users").entity(scott).collection("likes").collection("peeps").entity(peep).get();
+ fail("This should throw an exception");
+ } catch (UniformInterfaceException uie) {
+ // Should return a 404 Not Found
+ assertEquals(404, uie.getResponse().getStatus());
+ }
- assertEquals(thing1Id,thing1Return.getUuid());
}
- /**
- * Checks that we can get a valid uuid from a connection url and follow it to the correct entity.
- * @throws IOException
- */
@Test
- public void connectionsUrlTest() throws IOException {
+ public void connectionsLoopbackTest() throws IOException {
- //Create a connection between thing1 and thing2
- thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
+ // create entities thing1 and thing2
+ Entity thing1 = new Entity();
+ thing1.put("name", "thing1");
+ thing1 = this.app().collection("things").post(thing1);
+ Entity thing2 = new Entity();
+ thing2.put("name", "thing2");
+ thing2 = this.app().collection("things").post(thing2);
refreshIndex();
+ //create the connection: thing1 likes thing2
+ this.app().collection("things").entity(thing1).connection("likes").collection("things").entity(thing2).post();
+ refreshIndex();
- //Do a get on thing1 to make sure we have the connection present
- Entity response = thingsResource.entity( "thing1" ).get();
-
- String url =((Map) ((Map)response.get( "metadata" )).get( "connections" )).get("likes").toString();
-
-
- assertNotNull( "Connection url returned in entity", url );
-
- //trim off the starting / from the url.
- url = url.substring( 1 );
-
+ //test we have the "likes" in our connection meta data response
+ thing1 = this.app().collection("things").entity(thing1).get();
+ //TODO this is ugly. revisit.
+ String url = (String) ((Map<String, Object>) ((Map<String, Object>) thing1.get("metadata")).get("connections")).get("likes");
+ assertNotNull("Connection url returned with entity", url);
- //now that we know the URl is correct, follow it to get the entity in the connection
+ //now that we know the URl is correct, follow it
+ CollectionEndpoint likesEndpoint = new CollectionEndpoint(url, this.context(), this.app());
+ Collection likes = likesEndpoint.get();
+ assertNotNull(likes);
+ Entity likedEntity = likes.next();
+ assertNotNull(likedEntity);
- Collection collection = this.app().collection(url).get();
+ //make sure the returned entity is thing2
+ assertEquals(thing2.getUuid(), likedEntity.getUuid());
- UUID returnedUUID =collection.next().getUuid();
- assertEquals( thing2Id, returnedUUID );
+ //now follow the loopback, which should be pointers to the other entity
+ thing2 = this.app().collection("things").entity(thing2).get();
+ //TODO this is ugly. revisit.
+ url = (String) ((Map<String, Object>) ((Map<String, Object>) thing2.get("metadata")).get("connecting")).get("likes");
+ assertNotNull("Connecting url returned with entity", url);
- //get on the collection works, now get it directly by uuid. We should also get thing1 from the loopback url.
- response = thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).get();
+ CollectionEndpoint likedByEndpoint = new CollectionEndpoint(url, this.context(), this.app());
+ Collection likedBy = likedByEndpoint.get();
+ assertNotNull(likedBy);
+ Entity likedByEntity = likedBy.next();
+ assertNotNull(likedByEntity);
- UUID returned = response.getUuid();
+ //make sure the returned entity is thing1
+ assertEquals(thing1.getUuid(), likedByEntity.getUuid());
- assertEquals( "Should point to thing2 as an entity connection", thing2Id, returned );
}
/**
- * Deletes the connected to entity and make sure the delete persists.
+ * Ensure that the connected entity can be deleted
+ * properly after it has been connected to another entity
+ *
* @throws IOException
*/
@Test //USERGRID-3011
- public void deleteConnectedEntity() throws IOException {
+ public void connectionsDeleteSecondEntityInConnectionTest() throws IOException {
- //create the connection
- thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
+ //Create 2 entities, thing1 and thing2
+ Entity thing1 = new Entity();
+ thing1.put("name", "thing1");
+ thing1 = this.app().collection("things").post(thing1);
- refreshIndex();
+ Entity thing2 = new Entity();
+ thing2.put("name", "thing2");
+ thing2 = this.app().collection("things").post(thing2);
- //Delete the connected entity.
- thingsResource.entity( "thing2" ).delete();
+ refreshIndex();
+ //create the connection: thing1 likes thing2
+ this.app().collection("things").entity(thing1).connection("likes").collection("things").entity(thing2).post();
+ //delete thing2
+ this.app().collection("things").entity(thing2).delete();
refreshIndex();
- //Make sure that we can no longer retrieve the entity.
- int status = 0;
try {
- thingsResource.entity("thing2").get();
- fail( "Entity should have been deleted." );
- }catch (UniformInterfaceException e){
- status = e.getResponse().getStatus();
+ //attempt to retrieve thing1
+ thing2 = this.app().collection("things").entity(thing2).get();
+ fail("This should throw an exception");
+ } catch (UniformInterfaceException uie) {
+ // Should return a 404 Not Found
+ assertEquals(404, uie.getResponse().getStatus());
}
- assertEquals(404,status);
-
-
}
-
/**
- * Delete the connecting entity and make sure the delete persists.
+ * Ensure that the connecting entity can be deleted
+ * properly after a connection has been added
+ *
* @throws IOException
*/
@Test //USERGRID-3011
- public void deleteConnectingEntity() throws IOException {
+ public void connectionsDeleteFirstEntityInConnectionTest() throws IOException {
- //create the connection
- thingsResource.entity( thing1Id ).connection( "likes" ).entity( thing2Id ).post();
+ //Create 2 entities, thing1 and thing2
+ Entity thing1 = new Entity();
+ thing1.put("name", "thing1");
+ thing1 = this.app().collection("things").post(thing1);
- refreshIndex();
+ Entity thing2 = new Entity();
+ thing2.put("name", "thing2");
+ thing2 = this.app().collection("things").post(thing2);
- //Delete the connecting entity
- thingsResource.entity( "thing1" ).delete();
+ refreshIndex();
+ //create the connection: thing1 likes thing2
+ this.app().collection("things").entity(thing1).connection("likes").collection("things").entity(thing2).post();
+ //delete thing1
+ this.app().collection("things").entity(thing1).delete();
refreshIndex();
- //Make sure that we can no longer retrieve the entity.
- int status = 0;
try {
- thingsResource.entity("thing1").get();
- fail( "Entity should have been deleted." );
- }catch (UniformInterfaceException e){
- status = e.getResponse().getStatus();
+ //attempt to retrieve thing1
+ thing1 = this.app().collection("things").entity(thing1).get();
+ fail("This should throw an exception");
+ } catch (UniformInterfaceException uie) {
+ // Should return a 404 Not Found
+ assertEquals(404, uie.getResponse().getStatus());
}
- assertEquals(404,status);
}
[11/11] incubator-usergrid git commit: Merge remote-tracking branch
'r3b/rest-tests' into apache_usergrid/two-dot-o
Posted by ro...@apache.org.
Merge remote-tracking branch 'r3b/rest-tests' into apache_usergrid/two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/b4727f1d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/b4727f1d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/b4727f1d
Branch: refs/heads/two-dot-o
Commit: b4727f1db4b3e3e312b6f40d25a42ee66246cfd7
Parents: 085223f 4cf0bba
Author: Rod Simpson <ro...@rodsimpson.com>
Authored: Wed Feb 25 13:36:33 2015 -0700
Committer: Rod Simpson <ro...@rodsimpson.com>
Committed: Wed Feb 25 13:36:33 2015 -0700
----------------------------------------------------------------------
.../collection/DuplicateNameIT.java | 64 ++---
.../users/ConnectionResourceTest.java | 272 ++++++++-----------
.../organizations/AdminEmailEncodingIT.java | 156 ++++++-----
.../endpoints/mgmt/ManagementResource.java | 7 +-
4 files changed, 230 insertions(+), 269 deletions(-)
----------------------------------------------------------------------
[04/11] incubator-usergrid git commit: [USERGRID-331] Adding
additional checks for correct username on returned entity
Posted by ro...@apache.org.
[USERGRID-331] Adding additional checks for correct username on returned entity
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6e43fc55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6e43fc55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6e43fc55
Branch: refs/heads/two-dot-o
Commit: 6e43fc55e7ea12a5710c1a92b1df554bfcbed38f
Parents: 88bda3b
Author: ryan bridges <rb...@apigee.com>
Authored: Fri Jan 23 18:16:33 2015 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Fri Jan 23 18:16:33 2015 -0500
----------------------------------------------------------------------
.../rest/management/organizations/AdminEmailEncodingIT.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e43fc55/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
index 22dafdc..648abd1 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/management/organizations/AdminEmailEncodingIT.java
@@ -100,8 +100,6 @@ public class AdminEmailEncodingIT extends AbstractRestIT {
String unique = UUID.randomUUID().toString();
String org = "org_getTokenDash" + unique;
String app = "app_getTokenDash" + unique;
- org = org.toLowerCase();
- app = app.toLowerCase();
//Username and password
String username = "testuser" + unique;
@@ -125,13 +123,15 @@ public class AdminEmailEncodingIT extends AbstractRestIT {
//Create an application within the organization
clientSetup.getRestClient().management().orgs().organization(organization.getName()).app().post(new Application(app));
- //retrieve the new management user by username and ensure the email address matches the input
+ //retrieve the new management user by username and ensure the username and email address matches the input
Entity me = clientSetup.getRestClient().management().users().entity(username).get();
assertEquals(email, me.get("email"));
+ assertEquals(username, me.get("username"));
- //retrieve the new management user by email and ensure the email address matches the input
+ //retrieve the new management user by email and ensure the username and email address matches the input
me = clientSetup.getRestClient().management().users().entity(email).get();
assertEquals(email, me.get("email"));
+ assertEquals(username, me.get("username"));
}
}
[08/11] incubator-usergrid git commit: Merge branch 'two-dot-o' of
https://git-wip-us.apache.org/repos/asf/incubator-usergrid into
apache_usergrid/two-dot-o
Posted by ro...@apache.org.
Merge branch 'two-dot-o' of https://git-wip-us.apache.org/repos/asf/incubator-usergrid into apache_usergrid/two-dot-o
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/90afb20f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/90afb20f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/90afb20f
Branch: refs/heads/two-dot-o
Commit: 90afb20f4549ad8a5b52565958c4f3e2dc9dc559
Parents: 3cf1a7f 198f479
Author: Rod Simpson <ro...@rodsimpson.com>
Authored: Wed Feb 25 13:01:54 2015 -0700
Committer: Rod Simpson <ro...@rodsimpson.com>
Committed: Wed Feb 25 13:01:54 2015 -0700
----------------------------------------------------------------------
.../Usergrid.Notifications/Client/PushClient.cs | 12 +++++++-----
.../Usergrid.Notifications/Client/Usergrid.cs | 10 ++++++----
.../Usergrid.Notifications/MainPage.xaml.cs | 15 ++++++---------
3 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------