Search in sources :

Example 6 with UserInSession

use of edu.stanford.bmir.protege.web.shared.app.UserInSession in project webprotege by protegeproject.

the class DispatchServiceCallback_TestCase method shouldCall_handlePermissionDeniedException.

@Test
public void shouldCall_handlePermissionDeniedException() {
    PermissionDeniedException exception = mock(PermissionDeniedException.class);
    UserInSession userInSession = mock(UserInSession.class);
    when(userInSession.isGuest()).thenReturn(false);
    when(exception.getUserInSession()).thenReturn(userInSession);
    callback.onFailure(exception);
    verify(callback, times(1)).handlePermissionDeniedException(exception);
    verify(messageDisplay, times(1)).displayPermissionDeniedErrorMessage();
}
Also used : PermissionDeniedException(edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException) UserInSession(edu.stanford.bmir.protege.web.shared.app.UserInSession) Test(org.junit.Test)

Example 7 with UserInSession

use of edu.stanford.bmir.protege.web.shared.app.UserInSession in project webprotege by protegeproject.

the class GwtTest_UserInSessionDecoder method test_Decode.

public void test_Decode() {
    UserInSessionDecoder decoder = new UserInSessionDecoder();
    UserInSession userInSession = decoder.decode(new JSONObject(JsonUtils.safeEval(userInSessionJson)));
    assertEquals(userInSession, EXPECTED_SESSION_DATA);
    finishTest();
}
Also used : JSONObject(com.google.gwt.json.client.JSONObject) UserInSession(edu.stanford.bmir.protege.web.shared.app.UserInSession)

Example 8 with UserInSession

use of edu.stanford.bmir.protege.web.shared.app.UserInSession in project webprotege by protegeproject.

the class LoggedInUserManager method readUserInSession.

private void readUserInSession() {
    UserInSessionDecoder decoder = new UserInSessionDecoder();
    UserInSession userInSession = ClientObjectReader.create("userInSession", decoder).read();
    loggedInUser.setLoggedInUser(userInSession);
}
Also used : UserInSession(edu.stanford.bmir.protege.web.shared.app.UserInSession) UserInSessionDecoder(edu.stanford.bmir.protege.web.client.app.UserInSessionDecoder)

Example 9 with UserInSession

use of edu.stanford.bmir.protege.web.shared.app.UserInSession in project webprotege by protegeproject.

the class UserInSessionFactory_TestCase method shouldProvideUserInSessionForGuestUser.

@Test
public void shouldProvideUserInSessionForGuestUser() {
    UserInSession userInSession = factory.getUserInSession(UserId.getGuest());
    assertThat(userInSession.getUserDetails(), is(UserDetails.getGuestUserDetails()));
    assertThat(userInSession.getAllowedApplicationActions(), is(Collections.emptySet()));
}
Also used : UserInSession(edu.stanford.bmir.protege.web.shared.app.UserInSession) Test(org.junit.Test)

Example 10 with UserInSession

use of edu.stanford.bmir.protege.web.shared.app.UserInSession in project webprotege by protegeproject.

the class UserInSessionFactory_TestCase method shouldProvideUserInSessionForUnknownUser.

@Test
public void shouldProvideUserInSessionForUnknownUser() {
    UserInSession userInSession = factory.getUserInSession(UserId.getUserId("SomeOtherUserId"));
    assertThat(userInSession.getUserDetails(), is(UserDetails.getGuestUserDetails()));
    assertThat(userInSession.getAllowedApplicationActions(), is(Collections.emptySet()));
}
Also used : UserInSession(edu.stanford.bmir.protege.web.shared.app.UserInSession) Test(org.junit.Test)

Aggregations

UserInSession (edu.stanford.bmir.protege.web.shared.app.UserInSession)13 Test (org.junit.Test)5 PermissionDeniedException (edu.stanford.bmir.protege.web.shared.permissions.PermissionDeniedException)3 UserDetails (edu.stanford.bmir.protege.web.shared.user.UserDetails)3 JSONObject (com.google.gwt.json.client.JSONObject)2 ActionId (edu.stanford.bmir.protege.web.shared.access.ActionId)2 UserId (edu.stanford.bmir.protege.web.shared.user.UserId)2 Nonnull (javax.annotation.Nonnull)2 JSONArray (com.google.gwt.json.client.JSONArray)1 JSONString (com.google.gwt.json.client.JSONString)1 JSONValue (com.google.gwt.json.client.JSONValue)1 Place (com.google.gwt.place.shared.Place)1 UserInSessionDecoder (edu.stanford.bmir.protege.web.client.app.UserInSessionDecoder)1 UserInSessionEncoding (edu.stanford.bmir.protege.web.shared.app.UserInSessionEncoding)1 GetCurrentUserInSessionResult (edu.stanford.bmir.protege.web.shared.dispatch.actions.GetCurrentUserInSessionResult)1 HashSet (java.util.HashSet)1 Json (javax.json.Json)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 JsonObject (javax.json.JsonObject)1