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/06 05:37:09 UTC
[1/3] incubator-usergrid git commit: removed UpdateGroupIT,
merged test into GroupResourceIT
Repository: incubator-usergrid
Updated Branches:
refs/heads/two-dot-o 8961fecd2 -> acb468cec
removed UpdateGroupIT, merged test into GroupResourceIT
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/132b6304
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/132b6304
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/132b6304
Branch: refs/heads/two-dot-o
Commit: 132b63041e74732326df31877ace542e51e37064
Parents: 8961fec
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 5 20:29:02 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 5 20:29:02 2015 -0700
----------------------------------------------------------------------
.../collection/groups/GroupResourceIT.java | 32 ++++++
.../collection/groups/UpdateGroupIT.java | 114 -------------------
.../rest/test/resource2point0/model/Entity.java | 4 +
3 files changed, 36 insertions(+), 114 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/132b6304/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 e7acf4b..08b6fa6 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
@@ -48,9 +48,14 @@ public class GroupResourceIT extends AbstractRestIT {
*
*/
private Entity createGroup(String groupName, String groupPath) throws IOException{
+ String title = "title";
+ return createGroup(groupName, groupPath, title);
+ }
+ private Entity createGroup(String groupName, String groupPath, String groupTitle) throws IOException{
Entity payload = new Entity();
payload.put("name", groupName);
payload.put("path", groupPath);
+ payload.put("title", groupTitle);
Entity entity = this.app().collection("groups").post(payload);
assertEquals(entity.get("name"), groupName);
assertEquals(entity.get("path"), groupPath);
@@ -507,5 +512,32 @@ public class GroupResourceIT extends AbstractRestIT {
}
+ public void updateGroupWithSameNameAsApp() throws IOException {
+
+
+ // create groupMap with same name as app
+ String groupPath = this.clientSetup.getAppName();
+ String groupName = this.clientSetup.getAppName();
+ String title = "Old Title";
+ Entity group = this.createGroup(groupName, groupPath, title);
+
+ String newTitle = "New Title";
+ group.put("title", newTitle);
+ Entity groupResponse = this.app().collection("groups").entity(group).put(group);
+ assertEquals(groupResponse.get("title"), newTitle);
+ this.refreshIndex();
+
+ // update that group by giving it a new title and using UUID in URL
+ String evenNewerTitle = "Even New Title";
+ group.put("title", newTitle);
+ String uuid = group.getString("uuid");
+ groupResponse = this.app().collection("groups").uniqueID(uuid).put(group);
+ assertEquals(groupResponse.get("title"), evenNewerTitle);
+ this.refreshIndex();
+
+
+
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/132b6304/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
deleted file mode 100644
index 7bbd95b..0000000
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/groups/UpdateGroupIT.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.usergrid.rest.applications.collection.groups;
-
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.core.MediaType;
-
-import com.fasterxml.jackson.databind.JsonNode;
-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.commons.io.IOUtils;
-
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-
-import junit.framework.Assert;
-
-import static org.junit.Assert.fail;
-
-
-public class UpdateGroupIT extends AbstractRestIT {
- private static final Logger logger = LoggerFactory.getLogger( UpdateGroupIT.class );
-
- @Rule
- public TestContextSetup context = new TestContextSetup( this );
-
-
- @Test // USERGRID-1729
- public void updateGroupWithSameNameAsApp() throws IOException {
-
- // create groupMap with same name as app
- String groupId = null;
- String groupPath = context.getAppName();
- try {
- Map<String, Object> groupMap = new HashMap<String, Object>();
- groupMap.put( "title", "Old Title" );
- groupMap.put( "path", groupPath );
- String path = context.getOrgName() + "/" + context.getAppName() + "/groups";
- JsonNode groupJson = mapper.readTree( webResourceBuilder( path ).post( String.class, groupMap ));
- groupId = groupJson.get( "entities" ).get( 0 ).get( "uuid" ).textValue();
- }
- catch ( UniformInterfaceException e ) {
- fail( "Error creating group: " + IOUtils.toString( e.getResponse().getEntityInputStream() ) );
- }
-
- assertTitle( groupId, "Old Title" );
-
- refreshIndex(context.getOrgName(), context.getAppName());
-
- // update that group by giving it a new title and using group path in URL
- try {
- Map<String, Object> group = new HashMap<String, Object>();
- group.put( "title", "New Title" );
- String path = context.getOrgName() + "/" + context.getAppName() + "/groups/" + groupPath;
- webResourceBuilder( path ).put( String.class, group );
- }
- catch ( UniformInterfaceException e ) {
- fail( "Error updating group: " + IOUtils.toString( e.getResponse().getEntityInputStream() ) );
- }
-
- assertTitle( groupId, "New Title" );
-
- refreshIndex(context.getOrgName(), context.getAppName());
-
- // update that group by giving it a new title and using UUID in URL
- try {
- Map<String, Object> group = new HashMap<String, Object>();
- group.put( "title", "Even Newer Title" );
- String path = context.getOrgName() + "/" + context.getAppName() + "/groups/" + groupId;
- webResourceBuilder( path ).put( String.class, group );
- }
- catch ( UniformInterfaceException e ) {
- fail( "Error updating group: " + IOUtils.toString( e.getResponse().getEntityInputStream() ) );
- }
-
- assertTitle( groupId, "Even Newer Title" );
- }
-
-
- private WebResource.Builder webResourceBuilder( String path ) {
- return resource().path( path ).queryParam( "access_token", context.getActiveUser().getToken() )
- .accept( MediaType.APPLICATION_JSON ).type( MediaType.APPLICATION_JSON_TYPE );
- }
-
-
- private void assertTitle( String groupId, String title ) throws IOException {
- String path = context.getOrgName() + "/" + context.getAppName() + "/groups/" + groupId;
- JsonNode groupJson = mapper.readTree( webResourceBuilder( path ).get( String.class ));
- Assert.assertEquals( title, groupJson.get( "entities" ).get( 0 ).get( "title" ).textValue() );
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/132b6304/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 3a4b2b0..13416c0 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -118,6 +118,10 @@ public class Entity implements Serializable, Map<String,Object> {
//All values are strings , so doing the cast here saves doing the cast elsewhere
return getDynamicProperties().get( key );
}
+ public String getString( final Object key ) {
+ //All values are strings , so doing the cast here saves doing the cast elsewhere
+ return String.valueOf(getDynamicProperties().get( key ));
+ }
public String getError () {
return (String) this.get("error").toString();
[3/3] incubator-usergrid git commit: updated cast
Posted by sf...@apache.org.
updated cast
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/acb468ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/acb468ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/acb468ce
Branch: refs/heads/two-dot-o
Commit: acb468ceccc2be55f02bb5153cb26285f21bb775
Parents: ac4e0ae
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 5 21:30:42 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 5 21:30:42 2015 -0700
----------------------------------------------------------------------
.../apache/usergrid/rest/test/resource2point0/model/Entity.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/acb468ce/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
index 13416c0..b70f90c 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/model/Entity.java
@@ -120,7 +120,7 @@ public class Entity implements Serializable, Map<String,Object> {
}
public String getString( final Object key ) {
//All values are strings , so doing the cast here saves doing the cast elsewhere
- return String.valueOf(getDynamicProperties().get( key ));
+ return (String) getDynamicProperties().get( key );
}
public String getError () {
[2/3] incubator-usergrid git commit: fixed app level user token method
Posted by sf...@apache.org.
fixed app level user token method
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/ac4e0ae3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/ac4e0ae3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/ac4e0ae3
Branch: refs/heads/two-dot-o
Commit: ac4e0ae31601096cf4b6ce9e4556d8405a62b83c
Parents: 132b630
Author: Rod Simpson <ro...@apigee.com>
Authored: Mon Jan 5 21:10:03 2015 -0700
Committer: Rod Simpson <ro...@apigee.com>
Committed: Mon Jan 5 21:10:03 2015 -0700
----------------------------------------------------------------------
.../apache/usergrid/rest/test/resource2point0/AbstractRestIT.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ac4e0ae3/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
index 370823d..339bb8b 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/AbstractRestIT.java
@@ -121,7 +121,7 @@ public class AbstractRestIT extends JerseyTest {
protected Token getAppUserToken(String username, String password){
- return this.clientSetup.getRestClient().token().post(new Token(username,password));
+ return this.app().token().post(new Token(username,password));
}
public void refreshIndex() {