コード例 #1
0
  /** Test of getRoles method, of class SilverpeasWebUtil. */
  @Test
  public void testGetRoles() {
    HttpServletRequest request = mock(HttpServletRequest.class);
    HttpSession session = mock(HttpSession.class);
    MainSessionController controller = mock(MainSessionController.class);
    when(controller.getUserId()).thenReturn("18");
    when(session.getAttribute(MainSessionController.MAIN_SESSION_CONTROLLER_ATT))
        .thenReturn(controller);
    when(request.getSession()).thenReturn(session);
    when(request.getPathInfo()).thenReturn("/toolbox8/ViewAttachments");

    SilverpeasWebUtil util = new SilverpeasWebUtil();
    util.getRoles(request);
    verify(getOrganisationController()).getUserProfiles("18", "toolbox8");
  }