use of teammates.ui.controller.Action in project teammates by TEAMMATES.
the class BaseActionTest method verifyCannotAccess.
/**
* Verifies that the {@link Action} matching the {@code params} is not
* accessible to the logged in user.
* This could be one of the following ways:
* -> Unauthorised Access Exception
* ->
*/
protected void verifyCannotAccess(String... params) {
try {
Action c = gaeSimulation.getActionObject(getActionUri(), params);
ActionResult result = c.executeAndPostProcess();
String classNameOfResult = result.getClass().getName();
assertEquals(classNameOfResult, result.getClass().getName());
AssertHelper.assertContains("You are not registered in the course ", result.getStatusMessage());
} catch (UnauthorizedAccessException e) {
ignoreExpectedException();
}
}
use of teammates.ui.controller.Action in project teammates by TEAMMATES.
the class BaseActionTest method verifyRedirectTo.
/**
* Verifies that the {@link Action} matching the {@code params} is
* redirected to {@code expectedRedirectUrl}. Note that only the base
* URI is matched and parameters are ignored. E.g. "/page/studentHome"
* matches "/page/studentHome?user=abc".
*/
protected void verifyRedirectTo(String expectedRedirectUrl, String... params) {
Action c = gaeSimulation.getActionObject(getActionUri(), params);
RedirectResult r = getRedirectResult(c);
AssertHelper.assertContains(expectedRedirectUrl, r.destination);
}
use of teammates.ui.controller.Action in project teammates by TEAMMATES.
the class GaeSimulation method getActionObject.
/**
* Returns an {@link Action} object that matches the parameters given.
*
* @param parameters Parameters that appear in a HttpServletRequest received by the app.
*/
public Action getActionObject(String uri, String... parameters) {
HttpServletRequest req = createWebRequest(uri, parameters);
Action action = new ActionFactory().getAction(req);
action.setTaskQueuer(new MockTaskQueuer());
action.setEmailSender(new MockEmailSender());
return action;
}
use of teammates.ui.controller.Action in project teammates by TEAMMATES.
the class BaseActionTest method verifyCanAccess.
/*
* 'low-level' tests here it tests an action once with the given parameters.
* These methods are not aware of the user type.
*/
/**
* Verifies that the {@link Action} matching the {@code params} is
* accessible to the logged in user.
*/
protected void verifyCanAccess(String... params) {
Action c = gaeSimulation.getActionObject(getActionUri(), params);
assertTrue(c.isValidUser());
c.executeAndPostProcess();
}
use of teammates.ui.controller.Action in project teammates by TEAMMATES.
the class BaseActionTest method verifyRedirectToLoginOrUnauthorisedException.
private void verifyRedirectToLoginOrUnauthorisedException(String... params) {
try {
Action c = gaeSimulation.getActionObject(getActionUri(), params);
assertFalse(c.isValidUser());
} catch (UnauthorizedAccessException ue) {
ignoreExpectedException();
}
}
Aggregations