Search in sources :

Example 1 with RequestValidator

use of edu.stanford.bmir.protege.web.server.dispatch.RequestValidator in project webprotege by protegeproject.

the class GetApplicationPreferencesActionHandler_TestCase method shouldCheckForPermission.

@Test
public void shouldCheckForPermission() {
    RequestValidator validator = handler.getRequestValidator(action, requestContext);
    RequestValidationResult result = validator.validateAction();
    assertThat(result.isInvalid(), is(true));
    verify(accessManager, times(1)).hasPermission(forUser(userId), ApplicationResource.get(), EDIT_APPLICATION_SETTINGS.getActionId());
}
Also used : RequestValidationResult(edu.stanford.bmir.protege.web.server.dispatch.RequestValidationResult) RequestValidator(edu.stanford.bmir.protege.web.server.dispatch.RequestValidator) Test(org.junit.Test)

Example 2 with RequestValidator

use of edu.stanford.bmir.protege.web.server.dispatch.RequestValidator in project webprotege by protegeproject.

the class CreateNewProjectActionHandler_TestCase method shouldNotAllowGuestsToCreateProjects.

@Test
public void shouldNotAllowGuestsToCreateProjects() {
    when(userId.isGuest()).thenReturn(true);
    CreateNewProjectAction action = new CreateNewProjectAction(newProjectSettings);
    RequestValidator validator = handler.getRequestValidator(action, requestContext);
    RequestValidationResult validationResult = validator.validateAction();
    assertThat(validationResult.isValid(), is(false));
}
Also used : CreateNewProjectAction(edu.stanford.bmir.protege.web.shared.project.CreateNewProjectAction) RequestValidationResult(edu.stanford.bmir.protege.web.server.dispatch.RequestValidationResult) RequestValidator(edu.stanford.bmir.protege.web.server.dispatch.RequestValidator) Test(org.junit.Test)

Example 3 with RequestValidator

use of edu.stanford.bmir.protege.web.server.dispatch.RequestValidator in project webprotege by protegeproject.

the class GetProjectPermissionsActionHandler_TestCase method shouldAllowAnyOneToRetrievePermissions.

@Test
public void shouldAllowAnyOneToRetrievePermissions() {
    RequestContext requestContext = mock(RequestContext.class);
    when(requestContext.getUserId()).thenReturn(UserId.getGuest());
    RequestValidator validator = handler.getRequestValidator(action, requestContext);
    assertThat(validator.validateAction().isValid(), is(true));
}
Also used : RequestValidator(edu.stanford.bmir.protege.web.server.dispatch.RequestValidator) RequestContext(edu.stanford.bmir.protege.web.server.dispatch.RequestContext) Test(org.junit.Test)

Aggregations

RequestValidator (edu.stanford.bmir.protege.web.server.dispatch.RequestValidator)3 Test (org.junit.Test)3 RequestValidationResult (edu.stanford.bmir.protege.web.server.dispatch.RequestValidationResult)2 RequestContext (edu.stanford.bmir.protege.web.server.dispatch.RequestContext)1 CreateNewProjectAction (edu.stanford.bmir.protege.web.shared.project.CreateNewProjectAction)1