You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@usergrid.apache.org by GERey <gi...@git.apache.org> on 2014/12/02 18:14:49 UTC

[GitHub] incubator-usergrid pull request: Usergrid 256 api response impleme...

GitHub user GERey opened a pull request:

    https://github.com/apache/incubator-usergrid/pull/114

    Usergrid 256 api response implementation

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/apache/incubator-usergrid USERGRID-256-ApiResponseImplementation

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-usergrid/pull/114.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #114
    
----
commit 9ea4aeff94909e12b782df29db7811e631dd2feb
Author: grey <gr...@apigee.com>
Date:   2014-11-26T16:22:34Z

    Added working ApiResponse to different class called RevisedApiResponse. I'll be making my changes there then transfer them over.
    Fixed a RevisedApiResponse to use UserResourceIT and get back a valid RevisedApiREsponse that can than be deconstructed.

commit 0e82b18c02d40663bcb606ea1a1ed4e2d44305dc
Author: grey <gr...@apigee.com>
Date:   2014-11-26T17:56:11Z

    Add generics to the RevisedApiResponse class to start the first step of having generic types being returned

commit b2bdda4ee0f1089880ebf78f216194f5e624ac92
Author: grey <gr...@apigee.com>
Date:   2014-12-01T18:51:08Z

    Revert "Add generics to the RevisedApiResponse class to start the first step of having generic types being returned"
    
    This reverts commit 0e82b18c02d40663bcb606ea1a1ed4e2d44305dc.

commit 06f98cac0f3709a559ee91235066d5c9394b2602
Author: grey <gr...@apigee.com>
Date:   2014-12-02T00:44:58Z

    Created a ApiResponseCollection in order to hold the state from GET responses from the rest tests. Now the other rest classes are stateless ( except for context ) and testing will use the ApiResponseCollection to create tests.
    Created RevisedApiResponse because the ApiResponse is used heavily in the service tier and I don't want to make changes to two tiers at once by changing the api response.
    Added a collection level test
    Added RevisedApiResponses to the Value resource.
    Created ApiResponse Collection and fixed parts that weren't compiling ( with Todds help )
    Added a get to Collection.java ( so we could get the ApiResponse but this is still up in the air )
    Added a model call of what the ApiResponseCollection will look like when used for the GroupsCollection but currently not working.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-usergrid pull request: Usergrid 256 api response impleme...

Posted by GERey <gi...@git.apache.org>.
Github user GERey commented on a diff in the pull request:

    https://github.com/apache/incubator-usergrid/pull/114#discussion_r21175283
  
    --- Diff: stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java ---
    @@ -68,22 +73,82 @@
     
         private static Logger log = LoggerFactory.getLogger( UserResourceIT.class );
     
    +    @Rule
    +    public TestContextSetup context = new TestContextSetup( this );
    +
    +    @Test
    +    public void usernameQueryApiResource() throws IOException {
    +
    +        String username = "usernameQuery";
    +        String password = "password";
    +        String email = username + "@usergrid.com";
    +        String token = context.getActiveUser().getToken();
    +
    +        //        TestUser testUser = new TestAppUser( username, password, email );
    +        //
    +        //        context.withUser( testUser );
    +        //
    +        //        refreshIndex( context.getOrgName(), context.getAppName() );
    +        //
    +        String ql = "username = '"+context.getActiveUser().getUser()+"'";
    +
    +
    +        JsonNode node1 = mapper.readTree( resource().path( "/"+context.getOrgName()+"/"+context.getAppName()+"/users" ).queryParam( "ql", ql )
    +                                                   .queryParam( "access_token", context.getActiveUser().getToken() ).accept(
    +                        MediaType.APPLICATION_JSON )
    +                                                   .type( MediaType.APPLICATION_JSON_TYPE ).get( String.class ));
    +        //JsonNode node = context.collection( "users" ).query( ql,null,null ).;
    +        RevisedApiResponse node = null;
    +
    +        try {
    +            node = resource().path( "/"+context.getOrgName()+"/"+context.getAppName()+"/users" ).queryParam( "ql", ql )
    +                                                .queryParam( "access_token",
    +                                                        context.getActiveUser().getToken() ).accept(
    +                            MediaType.APPLICATION_JSON )
    +                                                .type( MediaType.APPLICATION_JSON_TYPE ).get( RevisedApiResponse.class );
    +        }catch(Exception e){
    +            e.printStackTrace();
    +            fail();
    +        }
    +
    +        assertNotNull( node );
    +
    +//        assertEquals( UserRepo.INSTANCE.getByUserName( "unq_user1" ), getIdFromSearchResults( node, 0 ) );
    +//        assertEquals( UserRepo.INSTANCE.getByUserName( "unq_user2" ), getIdFromSearchResults( node, 1 ) );
    +//        assertEquals( UserRepo.INSTANCE.getByUserName( "unq_user3" ), getIdFromSearchResults( node, 2 ) );
    +    }
    +
     
         @Test
         public void usernameQuery() throws IOException {
    --- End diff --
    
    This test has no comment and needs to be fixed/changed  so that it does its original user checking. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-usergrid pull request: Usergrid 256 api response impleme...

Posted by GERey <gi...@git.apache.org>.
Github user GERey commented on a diff in the pull request:

    https://github.com/apache/incubator-usergrid/pull/114#discussion_r21175297
  
    --- Diff: stack/rest/src/test/java/org/apache/usergrid/rest/applications/collection/users/UserResourceIT.java ---
    @@ -68,22 +73,82 @@
     
         private static Logger log = LoggerFactory.getLogger( UserResourceIT.class );
     
    +    @Rule
    +    public TestContextSetup context = new TestContextSetup( this );
    +
    +    @Test
    +    public void usernameQueryApiResource() throws IOException {
    --- End diff --
    
    We need to remove this test, just used as a proof of concept


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-usergrid pull request: Usergrid 256 api response impleme...

Posted by GERey <gi...@git.apache.org>.
Github user GERey closed the pull request at:

    https://github.com/apache/incubator-usergrid/pull/114


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-usergrid pull request: Usergrid 256 api response impleme...

Posted by GERey <gi...@git.apache.org>.
Github user GERey commented on a diff in the pull request:

    https://github.com/apache/incubator-usergrid/pull/114#discussion_r21175186
  
    --- Diff: stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java ---
    @@ -115,7 +115,7 @@ public String getError() {
             return error;
         }
    --- End diff --
    
    I don't think there is a client , server separation between the api response. Need to respond to this and investigate further.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-usergrid pull request: Usergrid 256 api response impleme...

Posted by GERey <gi...@git.apache.org>.
Github user GERey commented on a diff in the pull request:

    https://github.com/apache/incubator-usergrid/pull/114#discussion_r21174953
  
    --- Diff: stack/rest/src/main/java/org/apache/usergrid/rest/RevisedApiResponse.java ---
    @@ -0,0 +1,651 @@
    +/*
    + * 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;
    +
    +
    +import com.fasterxml.jackson.annotation.JsonAnyGetter;
    +import com.fasterxml.jackson.annotation.JsonAnySetter;
    +import com.fasterxml.jackson.annotation.JsonCreator;
    +import com.fasterxml.jackson.annotation.JsonProperty;
    +import com.fasterxml.jackson.annotation.JsonPropertyOrder;
    +import com.fasterxml.jackson.databind.annotation.JsonSerialize;
    +import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
    +import java.util.ArrayList;
    +import java.util.LinkedHashMap;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.TreeMap;
    +import java.util.UUID;
    +
    +import javax.xml.bind.annotation.XmlAnyElement;
    +import javax.xml.bind.annotation.XmlRootElement;
    +import org.springframework.beans.factory.annotation.Autowired;
    +import org.apache.usergrid.persistence.AggregateCounterSet;
    +import org.apache.usergrid.persistence.Entity;
    +import org.apache.usergrid.persistence.entities.Application;
    +import org.apache.usergrid.security.oauth.ClientCredentialsInfo;
    +import org.apache.usergrid.services.ServiceRequest;
    +import org.apache.usergrid.services.ServiceResults;
    +import org.apache.usergrid.utils.InflectionUtils;
    +
    +import org.apache.commons.lang.ClassUtils;
    +import org.apache.commons.lang.StringUtils;
    +
    +import static org.apache.usergrid.utils.InflectionUtils.pluralize;
    +
    --- End diff --
    
    This needs to be addressed, there is no comment describing what the class does


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-usergrid pull request: Usergrid 256 api response impleme...

Posted by GERey <gi...@git.apache.org>.
Github user GERey commented on a diff in the pull request:

    https://github.com/apache/incubator-usergrid/pull/114#discussion_r21174624
  
    --- Diff: stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java ---
    @@ -330,16 +330,20 @@ public String getOrganization() {
     
     
         /** Set the application and organization information */
    -    public void setApplication( Application app ) {
    -        this.organization = app.getOrganizationName();
    -        this.applicationName = app.getApplicationName();
    +    public void setApplication( Application app) {
             this.application = app.getUuid();
    -
    -        if ( esp != null ) {
    -            uri = createPath( esp.toString() );
    -        }
         }
     
    +    //    public void setApplication( Application app ) {
    --- End diff --
    
    Doesn't just set an Application, tries to get an application app. Isn't needed for restTests.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-usergrid pull request: Usergrid 256 api response impleme...

Posted by GERey <gi...@git.apache.org>.
Github user GERey commented on a diff in the pull request:

    https://github.com/apache/incubator-usergrid/pull/114#discussion_r21174901
  
    --- Diff: stack/rest/src/main/java/org/apache/usergrid/rest/ApiResponse.java ---
    @@ -227,7 +227,7 @@ public void setPath( String path ) {
                 uri = null;
             }
             this.path = path;
    -        uri = createPath( path );
    +        //uri = createPath( path );
    --- End diff --
    
    Trying to set the error, but sometimes the path is null or doesn't exist in the specific rest call. Its better to just wait for jackson to find the setPath or getPath.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---