Exemplo n.º 1
0
  /** Tests the body. */
  public void testBody() {
    comment.setBody("");
    assertEquals("", comment.getBody()); // FIXME should be null
    comment.setBody(null);
    assertEquals("", comment.getBody()); // FIXME should be null

    comment.setBody("Here is some text");
    assertEquals("Here is some text", comment.getBody());
  }
Exemplo n.º 2
0
  /** Tests that a comment can be cloned. */
  public void testClone() {
    Comment clonedComment = (Comment) comment.clone();

    assertEquals(comment.getTitle(), clonedComment.getTitle());
    assertEquals(comment.getBody(), clonedComment.getBody());
    assertEquals(comment.getWebsite(), clonedComment.getWebsite());
    assertEquals(comment.getAvatar(), clonedComment.getAvatar());
    assertEquals(comment.getAuthor(), clonedComment.getAuthor());
    assertEquals(comment.getIpAddress(), clonedComment.getIpAddress());
    assertEquals(comment.getDate(), clonedComment.getDate());
    assertEquals(comment.getId(), clonedComment.getId());
    assertEquals(comment.getState(), clonedComment.getState());
    assertEquals(comment.getParent(), clonedComment.getParent());
    assertEquals(comment.getBlogEntry(), clonedComment.getBlogEntry());
  }
 /**
  * Insert data.
  *
  * @param comment the comment
  * @return the number of inserted
  */
 public long insertComment(Comment comment) {
   this.insertComment.bindString(1, comment.getChatterId());
   this.insertComment.bindString(2, comment.getCommentId());
   this.insertComment.bindString(3, comment.getAuthor());
   this.insertComment.bindString(4, comment.getBody());
   return this.insertComment.executeInsert();
 }
Exemplo n.º 4
0
 private void populateGenericValueFromComment(Comment updatedComment, GenericValue commentGV) {
   ApplicationUser updateAuthor = updatedComment.getUpdateAuthorApplicationUser();
   commentGV.setString("updateauthor", updateAuthor == null ? null : updateAuthor.getKey());
   commentGV.setString("body", updatedComment.getBody());
   commentGV.setString("level", updatedComment.getGroupLevel());
   commentGV.set("rolelevel", updatedComment.getRoleLevelId());
   commentGV.set(
       "updated", JiraDateUtils.copyOrCreateTimestampNullsafe(updatedComment.getUpdated()));
 }
Exemplo n.º 5
0
 /** Test that a Comment instance can be created correctly. */
 public void testConstructionOfSimpleInstance() {
   assertNotNull(comment);
   assertEquals("Title", comment.getTitle());
   assertEquals("Body", comment.getBody());
   assertEquals("Author", comment.getAuthor());
   assertEquals("*****@*****.**", comment.getEmail());
   assertEquals("http://www.google.com", comment.getWebsite());
   assertEquals("http://graph.facebook.com/user/picture", comment.getAvatar());
   assertEquals("127.0.0.1", comment.getIpAddress());
   assertNotNull(comment.getDate());
   assertEquals(comment.getDate().getTime(), comment.getId());
   assertNotNull(comment.getBlogEntry());
   assertEquals(State.APPROVED, comment.getState());
   assertEquals("c/" + comment.getBlogEntry().getId() + "/" + comment.getId(), comment.getGuid());
 }
Exemplo n.º 6
0
  /**
   * Constructs an issue update bean for a comment delete. The comment text will be masked if the
   * security levels are set
   */
  ChangeItemBean constructChangeItemBeanForCommentDelete(Comment comment) {
    // Check the level of the comment, if the level is not null we need to override the comment
    // This is necessary as part of JRA-9394 to remove comment text from the change history for
    // security (or lack thereof)
    String message;
    final String groupLevel = comment.getGroupLevel();
    final String roleLevel =
        (comment.getRoleLevel() == null) ? null : comment.getRoleLevel().getName();
    final String actionLevel = groupLevel == null ? roleLevel : groupLevel;
    if (actionLevel != null) {
      message = getText("comment.manager.deleted.comment.with.restricted.level", actionLevel);
    } else {
      message = comment.getBody();
    }

    return new ChangeItemBean(ChangeItemBean.STATIC_FIELD, "Comment", message, null);
  }
Exemplo n.º 7
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    /*
     * This method is executed for each item in the list in order to populate it with related data.
     * */
    View row = convertView;
    Answer answer = answers.get(position);
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (answer != null) {
      row = inflater.inflate(R.layout.answer_row, parent, false);
      TextView answerBody = (TextView) row.findViewById(R.id.answerBody);

      int colorPos = position % colors.length;
      // The answer accepted as the Correct answer has a green background
      if (answer.is_accepted()) {
        row.setBackgroundColor(Color.parseColor("#59F059"));
        answerBody.setText(Html.fromHtml("<b>Accepted Answer</b><br/>" + answer.getBody()));
      } else {
        row.setBackgroundColor(Color.parseColor(colors[colorPos]));
        answerBody.setText(Html.fromHtml(answer.getBody()));
      }

      TextView answerOwner = (TextView) row.findViewById(R.id.answerBodyOwner);
      answerOwner.setText(
          Html.fromHtml(
              "answered: "
                  + answer.getCreation_date()
                  + "<br/>By: "
                  + answer.getOwner().getDisplay_name()));

      // display comments related to each answer if they exist.
      // In case they do not exist, hide the widgets used to display comments.
      if (answer.getComment_count() > 0) {
        TextView comments = (TextView) row.findViewById(R.id.answerComments);
        String comStr = "<b>Comments:</b><br/>";
        ArrayList<Comment> coms = answer.getComments();
        for (int i = 0; i < coms.size(); i++) {
          Comment c = coms.get(i);
          comStr +=
              (i + 1)
                  + ". "
                  + c.getBody()
                  + " <br/> By: "
                  + c.getOwner().getDisplay_name()
                  + " - "
                  + c.getCreation_date()
                  + "<br/><br/>";
        }
        comments.setText(Html.fromHtml(comStr));
      } else {
        TextView comments = (TextView) row.findViewById(R.id.answerComments);
        comments.setVisibility(View.INVISIBLE);
        View viewComments1 = row.findViewById(R.id.viewComments1);
        viewComments1.setVisibility(View.INVISIBLE);
        View viewComments2 = row.findViewById(R.id.viewComments2);
        viewComments2.setVisibility(View.INVISIBLE);
      }
    }

    return row;
  }
Exemplo n.º 8
0
 /**
  * Returns true if both comments have equal bodies, group levels and role level ids, false
  * otherwise.
  *
  * @param comment1 comment to compare
  * @param comment2 comment to compare
  * @return true if both comments have equal bodies, group levels and role level ids, false
  *     otherwise
  */
 private boolean areCommentsEquivalent(Comment comment1, Comment comment2) {
   return ObjectUtils.equalsNullSafe(comment1.getBody(), comment2.getBody())
       && ObjectUtils.equalsNullSafe(comment1.getGroupLevel(), comment2.getGroupLevel())
       && ObjectUtils.equalsNullSafe(comment1.getRoleLevelId(), comment2.getRoleLevelId());
 }