protected void setUp() throws Exception {
    super.setUp();
    bob = createMockUser("bob");
    bill = createMockUser("bill");
    issue =
        EntityUtils.createValue(
            "Issue",
            EasyMap.build(
                "id",
                new Long(1),
                "project",
                new Long(2),
                "workflowId",
                new Long(100),
                "reporter",
                "bob"));
    project = EntityUtils.createValue("Project", EasyMap.build("id", new Long(2)));

    condition = new AllowOnlyReporter();
    wfc = new Mock(WorkflowContext.class);
    wfe = new Mock(WorkflowEntry.class);

    args = EasyMap.build("permission", "create issue");
    transientVars = EasyMap.build("context", wfc.proxy(), "entry", wfe.proxy());
  }
  public Comment create(
      Issue issue,
      ApplicationUser author,
      ApplicationUser updateAuthor,
      String body,
      String groupLevel,
      Long roleLevelId,
      Date created,
      Date updated,
      Map<String, JSONObject> commentProperties,
      boolean dispatchEvent,
      boolean modifyIssueUpdateDate) {

    if (textFieldCharacterLengthValidator.isTextTooLong(body)) {
      final long maximumNumberOfCharacters =
          textFieldCharacterLengthValidator.getMaximumNumberOfCharacters();
      String errorMessage =
          getText("field.error.text.toolong", String.valueOf(maximumNumberOfCharacters));
      throw new IllegalArgumentException(errorMessage);
    }

    // create new instance of comment
    CommentImpl comment =
        new CommentImpl(
            projectRoleManager,
            author,
            updateAuthor,
            body,
            groupLevel,
            roleLevelId,
            created,
            updated,
            issue);

    // create persistable generic value
    Map<String, Object> fields = new HashMap<String, Object>();
    fields.put("issue", issue.getId());
    fields.put("type", ActionConstants.TYPE_COMMENT);

    ApplicationUser commentAuthor = comment.getAuthorApplicationUser();
    ApplicationUser commentUpdateAuthor = comment.getUpdateAuthorApplicationUser();
    fields.put("author", commentAuthor == null ? null : commentAuthor.getKey());
    fields.put("updateauthor", commentUpdateAuthor == null ? null : commentUpdateAuthor.getKey());
    fields.put("body", comment.getBody());
    fields.put("level", comment.getGroupLevel());
    fields.put("rolelevel", comment.getRoleLevelId());
    fields.put("created", new Timestamp(comment.getCreated().getTime()));
    fields.put("updated", new Timestamp(comment.getUpdated().getTime()));

    GenericValue commentGV = EntityUtils.createValue(COMMENT_ENTITY, fields);
    // set the ID on comment object
    comment.setId(commentGV.getLong(COMMENT_ID));

    // Update the issue object if required
    if (modifyIssueUpdateDate) {
      // JRA-36334: Only modify the Issue updated date if it would move forward - we don't want it
      // to go back in time
      if (comment.getUpdated().getTime() > issue.getUpdated().getTime()) {
        IssueFactory issueFactory = ComponentAccessor.getComponentOfType(IssueFactory.class);
        MutableIssue mutableIssue = issueFactory.getIssue(issue.getGenericValue());
        // JRA-15723: Use the comments updated time for the updated time of the issue.  This allows
        // users to
        // import old comments without setting the updated time on the issue to now, but to the date
        // of the old comments.
        mutableIssue.setUpdated(new Timestamp(comment.getUpdated().getTime()));
        issue.store();
      }
    }

    if (commentProperties != null) {
      setProperties(author, comment, commentProperties);
    }

    // Dispatch an event if required
    if (dispatchEvent) {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("eventsource", IssueEventSource.ACTION);
      dispatchIssueCommentAddedEvent(comment, params);
    }
    return comment;
  }