Пример #1
0
  private void setPageSize() {
    int tmp = -1;
    RequestContext rctx = new RequestContext((HttpServletRequest) pageContext.getRequest());
    User user = rctx.getLoggedInUser();
    if (user != null) {
      tmp = user.getPageSize();
      if (tmp > 0) {
        pageSize = tmp;
      }
    }
    if (pageSize < 1) {
      pageSize = 10;
    }

    HttpServletRequest httpRequest = (HttpServletRequest) pageContext.getRequest();

    if (PageSizeDecorator.pageWidgetSelected(httpRequest, getUniqueName())) {
      int size = PageSizeDecorator.getSelectedPageSize(httpRequest, getUniqueName());
      List<Integer> pageSizes = PageSizeDecorator.getPageSizes();
      if (size < 1 || size > pageSizes.get(pageSizes.size() - 1)) {
        return;
      } else {
        pageSize = size;
      }
    }
  }
  public void testStore() {
    Org org = UserTestUtils.findNewOrg("testorg");

    String login = TestUtils.randomString();
    command.setLogin(login);
    command.setPassword("password");
    command.setEmail("*****@*****.**");
    command.setPrefix("Dr.");
    command.setFirstNames("Chuck Norris");
    command.setLastName("Texas Ranger");
    command.setOrg(org);
    command.setCompany("Test company");

    Object[] errors = command.validate();
    assertEquals(0, errors.length);

    command.storeNewUser();

    Long uid = command.getUser().getId();
    assertNotNull(uid);

    User result = UserFactory.lookupById(uid);
    assertEquals(login, result.getLogin());
    assertEquals(PageSizeDecorator.getDefaultPageSize(), result.getPageSize());
  }