コード例 #1
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  @Test
  public void testDenyWithProjectMember() throws ServletException, IOException {
    String pathInfo =
        ProjectLinkGenerator.generateDenyInvitationParams(
            "*****@*****.**", 1, 1, "*****@*****.**", "*****@*****.**");
    when(request.getPathInfo()).thenReturn(pathInfo);
    when(response.getWriter()).thenReturn(mock(PrintWriter.class));

    when(projectService.findById(1, 1)).thenReturn(new SimpleProject());
    when(projectMemberService.findMemberByUsername(
            any(String.class), any(Integer.class), any(Integer.class)))
        .thenReturn(new SimpleProjectMember());

    denyInvitationHandler.onHandleRequest(request, response);

    ArgumentCaptor<Locale> localeArgument = ArgumentCaptor.forClass(Locale.class);

    ArgumentCaptor<String> strArgument = ArgumentCaptor.forClass(String.class);

    ArgumentCaptor<Map> mapArgument = ArgumentCaptor.forClass(Map.class);

    verify(denyInvitationHandler)
        .generatePageByTemplate(
            localeArgument.capture(), strArgument.capture(), mapArgument.capture());
    Assert.assertEquals(
        DenyProjectInvitationHandler.REFUSE_MEMBER_DENY_TEMPLATE, strArgument.getValue());
  }
コード例 #2
0
    void displayPageInfo(Page beanItem) {
      MVerticalLayout header = new MVerticalLayout().withMargin(false);
      Label titleLbl = new Label(beanItem.getSubject());
      titleLbl.setStyleName("headerName");
      header.with(titleLbl);
      Div footer = new Div().setStyle("width:100%").setCSSClass("footer2");
      Span lastUpdatedTimeTxt =
          new Span()
              .appendText(
                  AppContext.getMessage(
                      DayI18nEnum.LAST_UPDATED_ON,
                      AppContext.formatPrettyTime(beanItem.getLastUpdatedTime().getTime())))
              .setTitle(AppContext.formatDateTime(beanItem.getLastUpdatedTime().getTime()));
      String uid = UUID.randomUUID().toString();
      ProjectMemberService projectMemberService =
          ApplicationContextUtil.getSpringBean(ProjectMemberService.class);
      SimpleProjectMember member =
          projectMemberService.findMemberByUsername(
              beanItem.getCreatedUser(),
              CurrentProjectVariables.getProjectId(),
              AppContext.getAccountId());
      if (member != null) {
        Img userAvatar =
            new Img("", StorageFactory.getInstance().getAvatarPath(member.getMemberAvatarId(), 16));
        A userLink =
            new A()
                .setId("tag" + uid)
                .setHref(
                    ProjectLinkBuilder.generateProjectMemberFullLink(
                        member.getProjectid(), member.getUsername()))
                .appendText(StringUtils.trim(member.getMemberFullName(), 30, true));
        userLink.setAttribute(
            "onmouseover", TooltipHelper.userHoverJsFunction(uid, member.getUsername()));
        userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction(uid));
        footer.appendChild(
            lastUpdatedTimeTxt,
            new Text("&nbsp;-&nbsp;Created by: "),
            userAvatar,
            DivLessFormatter.EMPTY_SPACE(),
            userLink,
            DivLessFormatter.EMPTY_SPACE(),
            TooltipHelper.buildDivTooltipEnable(uid));
      } else {
        footer.appendChild(lastUpdatedTimeTxt);
      }

      header.addComponent(new Label(footer.write(), ContentMode.HTML));
      this.addHeader(header);
    }