usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [2/2] incubator-usergrid git commit: [USERGRID-613] juryrigged a way to test for lowercase and mixed case values.
Date Tue, 09 Jun 2015 22:39:39 GMT
[USERGRID-613] juryrigged a way to test for lowercase and mixed case values.


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

Branch: refs/heads/two-dot-o
Commit: 7fd643cdfd2d92dddcf0417bfbca565b4089efc0
Parents: e9ad00c
Author: GERey <greyes@apigee.com>
Authored: Tue Jun 9 15:36:06 2015 -0700
Committer: GERey <greyes@apigee.com>
Committed: Tue Jun 9 15:36:06 2015 -0700

----------------------------------------------------------------------
 .../apache/usergrid/rest/IndexResourceIT.java   | 92 ++++++++++++++------
 .../rest/test/resource2point0/ClientSetup.java  | 12 ++-
 .../endpoints/SystemResource.java               | 21 +++++
 .../endpoints/mgmt/ApplicationResource.java     |  6 +-
 4 files changed, 100 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7fd643cd/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
index 77f443f..a310368 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/IndexResourceIT.java
@@ -32,6 +32,13 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
+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.apache.usergrid.rest.test.resource2point0.model.QueryParameters;
+import org.apache.usergrid.rest.test.resource2point0.model.Token;
+
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.fail;
 
@@ -49,33 +56,66 @@ public class IndexResourceIT extends AbstractRestIT {
     public IndexResourceIT(){
 
     }
-
-    @Ignore( "will finish when tests are working from rest" )
+//TODO: convert over and recheck intention of test.
+//    @Ignore( "will finish when tests are working from rest" )
+//    @Test
+//    public void TestAddIndex() throws Exception{
+//        String superToken = superAdminToken();
+//
+//        Map<String, Object> data = new HashMap<String, Object>();
+//        data.put( "replicas", 0 );
+//        data.put( "shards", 1 );
+//        data.put( "writeConsistency", "one" );
+//
+//        UUID appId = this.context.getAppUuid();
+//
+//        // change the password as admin. The old password isn't required
+//        JsonNode node = null;
+//        try {
+//            node = mapper.readTree(resource().path("/system/index/" + appId)
+//                    .queryParam("access_token", superToken)
+//                    .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON_TYPE)
+//                    .post(String.class, data));
+//        } catch (Exception e) {
+//            LOG.error("failed", e);
+//            fail(e.toString());
+//        }
+//        assertNull( getError( node ) );
+//
+//        refreshIndex("test-organization", "test-app");
+//
+//    }
     @Test
-    public void TestAddIndex() throws Exception{
-        String superToken = superAdminToken();
-
-        Map<String, Object> data = new HashMap<String, Object>();
-        data.put( "replicas", 0 );
-        data.put( "shards", 1 );
-        data.put( "writeConsistency", "one" );
-
-        UUID appId = this.context.getAppUuid();
-
-        // change the password as admin. The old password isn't required
-        JsonNode node = null;
-        try {
-            node = mapper.readTree(resource().path("/system/index/" + appId)
-                    .queryParam("access_token", superToken)
-                    .accept(MediaType.APPLICATION_JSON).type(MediaType.APPLICATION_JSON_TYPE)
-                    .post(String.class, data));
-        } catch (Exception e) {
-            LOG.error("failed", e);
-            fail(e.toString());
-        }
-        assertNull( getError( node ) );
-
-        refreshIndex("test-organization", "test-app");
+    public void testCaseReindexEndpoint() {
+
+        //Create Collection
+        Map payload = new HashMap<>(  );
+        payload.put( "name","wazer wifle!!" );
+        Entity payloadEntity = new Entity( payload );
+        Entity collectionResponse = this.clientSetup.getRestClient().org( clientSetup.getOrganizationName()
)
+                                                         .app( clientSetup.getAppName())
+                                                         .collection( "belp").post(payloadEntity);
+
+        assertNotNull( collectionResponse );
+
+        //try reindex endpoint with ALl mixed case characters
+        Token superUserToken = clientSetup.getRestClient().management().token().post(new
Token( clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword() )); //.get(new Token(clientSetup.getSuperuserName(),clientSetup.getSuperuserPassword()));
+
+        QueryParameters queryParameters = new QueryParameters();
+        queryParameters.addParam( "access_token",superUserToken.getAccessToken());
+        org.apache.usergrid.rest.test.resource2point0.model.ApiResponse result = this.clientSetup.getRestClient().system()
+                                             .addToPath( "index" ).addToPath( "rebuild" )
+                                             .addToPath( clientSetup.getAppUuid() ).addToPath(
"bElp" ).put();
+
+        assertNotNull(result);
+
+        queryParameters = new QueryParameters();
+        queryParameters.addParam( "access_token",superUserToken.getAccessToken());
+        result = this.clientSetup.getRestClient().system()
+                                 .addToPath( "index" ).addToPath( "rebuild" )
+                                 .addToPath( clientSetup.getAppUuid() ).addToPath( "belp"
).put();
+
+        assertNotNull( result );
 
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7fd643cd/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
index e033c2d..82e7c70 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/ClientSetup.java
@@ -22,8 +22,11 @@ package org.apache.usergrid.rest.test.resource2point0;
 
 
 import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.UUID;
 
 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.Token;
 import org.junit.rules.TestRule;
 import org.junit.runner.Description;
@@ -50,12 +53,13 @@ public class ClientSetup implements TestRule {
     protected String password;
     protected String orgName;
     protected String appName;
+    protected String appUuid;
     protected Token superuserToken;
     protected String superuserName = "superuser";
     protected String superuserPassword = "superpassword";
 
     protected Organization organization;
-    protected Application application;
+    protected Entity application;
 
 
     public ClientSetup (String serverUrl) {
@@ -114,7 +118,9 @@ public class ClientSetup implements TestRule {
 
         restClient.management().token().post(new Token(username,username));
 
-        restClient.management().orgs().organization(organization.getName()).app().post(new
Application(appName));
+        application = restClient.management().orgs().organization(organization.getName()).app().post(new
Application(appName));
+       // application = restClient.management().orgs().organization(organization.getName()).app().get();
+        appUuid = (String)((LinkedHashMap)application.getDynamicProperties().get( "data"
)).get( orgName+"/"+appName );
 
     }
 
@@ -130,6 +136,8 @@ public class ClientSetup implements TestRule {
 
     public String getAppName() {return appName;}
 
+    public String getAppUuid() {return appUuid;}
+
     public Token getSuperuserToken() {
         return superuserToken;
     }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7fd643cd/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/SystemResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/SystemResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/SystemResource.java
index e2bff1f..ee70942 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/SystemResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/SystemResource.java
@@ -18,6 +18,10 @@
 package org.apache.usergrid.rest.test.resource2point0.endpoints;
 
 
+import javax.ws.rs.core.MediaType;
+
+import org.apache.usergrid.rest.test.resource2point0.model.ApiResponse;
+import org.apache.usergrid.rest.test.resource2point0.model.Entity;
 import org.apache.usergrid.rest.test.resource2point0.state.ClientContext;
 
 
@@ -30,7 +34,24 @@ public class SystemResource extends NamedResource {
         super( "system",context, parent );
     }
 
+    //Dirty hack for path resource in new branch of two-dot-o
+    public SystemResource(final String name,final ClientContext context, final UrlResource
parent ) {
+        super( name,context, parent );
+    }
+
+
     public DatabaseResource database() {
         return new DatabaseResource(context, this);
     }
+
+    public SystemResource addToPath( String pathPart ) {
+        return new SystemResource( pathPart, context, this );
+    }
+
+    public ApiResponse put(){
+        ApiResponse
+            response = getResource(true).type( MediaType.APPLICATION_JSON_TYPE ).accept(MediaType.APPLICATION_JSON)
+                                        .put(ApiResponse.class);
+        return response;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7fd643cd/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
index 6b7742f..e9947e3 100644
--- a/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
+++ b/stack/rest/src/test/java/org/apache/usergrid/rest/test/resource2point0/endpoints/mgmt/ApplicationResource.java
@@ -46,9 +46,9 @@ public class ApplicationResource extends NamedResource {
     }
 
 
-    public void post(Application application) {
-        getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
-            .accept(MediaType.APPLICATION_JSON).post(application);
+    public Application post(Application application) {
+        return getResource(true).type(MediaType.APPLICATION_JSON_TYPE)
+            .accept(MediaType.APPLICATION_JSON).post(Application.class,application);
     }
 
     public Entity post(Entity payload){


Mime
View raw message