Package play.mvc

Examples of play.mvc.Result


   
    FakeRequest request = new FakeRequest(DELETE, getRouteAddress()+"/"+toUnfollow);
    request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
    request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(follower, "passw1"));
   
    Result result = routeAndCall(request);
    assertRoute(result, "Delete friendship.", Status.NOT_FOUND, null, false);

   
  }
View Full Code Here


   
    FakeRequest request = new FakeRequest(POST, "/admin/collection/testFriendship");
    request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
    request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.AUTH_ADMIN_ENC);
   
    Result result = routeAndCall(request);
   
  }
View Full Code Here

   
    FakeRequest request = new FakeRequest(POST, "/document/testFriendship");
    request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
    request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(owner, "passw1"));
    request = request.withJsonBody(getPayload("/documentCreatePayload.json"));
    Result result = routeAndCall(request);
    assertRoute(result, "Create document.", Status.OK, null, false);
    return contentAsString(result);
   
  }
View Full Code Here

            String uuid = result.getJSONObject("data").getString("id");
            assertNotNull(uuid);
            FakeRequest fk = new FakeRequest(GET, "/document/testFriendship/"+uuid);
            fk = fk.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
            fk = fk.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(firstUser, "passw1"));
            Result getDocumentResult = routeAndCall(fk);
            assertRoute(getDocumentResult, "Get document by friend", Status.NOT_FOUND, null, false);
           
            //the owner of the doc gives grant to its friends
            fk = new FakeRequest(PUT, "/document/testFriendship/"+uuid+"/read/role/friends_of_"+secondUser);
            fk = fk.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
            fk = fk.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(secondUser, "passw1"));
            Result res = routeAndCall(fk);
            assertRoute(res, "Change the document permission", Status.OK, null, false);
           
            //now the friend reload the doc and read it
            fk = new FakeRequest(GET, "/document/testFriendship/"+uuid);
            fk = fk.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
            fk = fk.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(firstUser, "passw1"));
            getDocumentResult = routeAndCall(fk);
            assertRoute(getDocumentResult, "Get document by friend 2", Status.OK, null, false);
            JSONObject createdDocument = (JSONObject)toJSON(contentAsString(getDocumentResult));
            String author = createdDocument.getJSONObject("data").getString("_author");
            assertEquals(secondUser,author);
           
            FakeRequest theFolloweds = new FakeRequest(GET, "/following");
            theFolloweds = theFolloweds.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
            theFolloweds = theFolloweds.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(firstUser, "passw1"));
           
            Result getTheFollowedResult = routeAndCall(theFolloweds);
            JSONObject followedJson = (JSONObject)toJSON(contentAsString(getTheFollowedResult));
            String followed = followedJson.getJSONArray("data").getJSONObject(0).getJSONObject("user").getString("name");
            assertEquals(followed,secondUser);
           
            //check the followers
            FakeRequest followers = new FakeRequest(GET, "/followers");
            followers = followers.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
            followers = followers.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(secondUser, "passw1"));
            Result getFollowersResult = routeAndCall(followers);
            JSONObject followersJson = (JSONObject)toJSON(contentAsString(getFollowersResult));
            String follower = followersJson.getJSONArray("data").getJSONObject(0).getJSONObject("user").getString("name");
            assertEquals(follower,firstUser);
           
            //the first user get the followers of the second one
            followers = new FakeRequest(GET, "/followers/"+secondUser);
            followers = followers.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
            followers = followers.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(firstUser, "passw1"));
            getFollowersResult = routeAndCall(followers);
            followersJson = (JSONObject)toJSON(contentAsString(getFollowersResult));
            follower = followersJson.getJSONArray("data").getJSONObject(0).getJSONObject("user").getString("name");
            assertEquals("test: GET /followers/:secondUser firstUser="+firstUser+" secondUser="+secondUser,follower,firstUser);

            //the second user get the followed by the first one
            FakeRequest followeds = new FakeRequest(GET, "/following/"+firstUser);
            followeds = followeds.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
            followeds = followeds.withHeader(TestConfig.KEY_AUTH, TestConfig.encodeAuth(secondUser, "passw1"));
            Result getFollowedsResult = routeAndCall(followeds);
            JSONObject followedsJson = (JSONObject)toJSON(contentAsString(getFollowedsResult));
            followed = followedsJson.getJSONArray("data").getJSONObject(0).getJSONObject("user").getString("name");
            assertEquals("test: GET /following/:firstUser firstUser="+firstUser+" secondUser="+secondUser,followed,secondUser);
           
            routeDeleteFollowRelationship(firstUser,secondUser);
View Full Code Here

        {
          // Default user credentials
          FakeRequest request = new FakeRequest(getMethod(), getRouteAddress());
          request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
          request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.AUTH_DEFAULT_ENC);
          Result result = routeAndCall(request);
          assertRoute(result, "testRouteDefaultUser", FORBIDDEN, null, false);
        }
      }
    );   
  }
View Full Code Here

      {
        public void run()
        {
          // No AppCode, No Authorization
          FakeRequest request = new FakeRequest(getMethod(), getRouteAddress());
          Result result = routeAndCall(request);
          assertRoute(result, "No AppCode No Authorization", BAD_REQUEST, TestConfig.MSG_NO_APP_CODE_NO_AUTH, true);
 
         
          // Invalid AppCode
          request = request.withHeader(TestConfig.KEY_APPCODE, "12345890");
View Full Code Here

        public void run()
        {
          FakeRequest request = new FakeRequest(getMethod(), getRouteAddress());
          request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
          request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.AUTH_ADMIN_ENC);
          Result result = routeAndCall(request);
          assertRoute(result, "testRouteOK", OK, null, true);
        }
      }
    );   
  }
View Full Code Here

        {
          // Default user credentials
          FakeRequest request = new FakeRequest(getMethod(), getRouteAddress());
          request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
          request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.AUTH_DEFAULT_ENC);
          Result result = routeAndCall(request);
          assertRoute(result, "testRouteDefaultUser", FORBIDDEN, null, false);
        }
      }
    );   
  }
View Full Code Here

        {
          //load settings
          FakeRequest request = new FakeRequest(GET, "/admin/configuration/dump.json");
          request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
          request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.AUTH_ADMIN_ENC);
          Result result = routeAndCall(request);
          AbstractAdminTest.super.assertRoute(result, "checkSettingsBefore", OK, "application.name\":\"BaasBox\",\"description\":\"The App name\",\"type\":\"String\",\"editable\":true,\"visible\":true,\"overridden\":false", true);
        }
      }
      );
  }
View Full Code Here

        {
          //load settings
          FakeRequest request = new FakeRequest(GET, "/admin/configuration/dump.json");
          request = request.withHeader(TestConfig.KEY_APPCODE, TestConfig.VALUE_APPCODE);
          request = request.withHeader(TestConfig.KEY_AUTH, TestConfig.AUTH_ADMIN_ENC);
          Result result = routeAndCall(request);
          AbstractAdminTest.super.assertRoute(result, "checkSettingsAfter", OK, "application.name\":\"BaasBox\",\"description\":\"The App name\",\"type\":\"String\",\"editable\":true,\"visible\":true,\"overridden\":false", true);
        }
      }
      );
  }
View Full Code Here

TOP

Related Classes of play.mvc.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.