Beispiel #1
0
 public void setCloseDate(DefaultIssue issue, @Nullable Date d, IssueChangeContext context) {
   Date dateWithoutMilliseconds = d == null ? null : DateUtils.truncate(d, Calendar.SECOND);
   if (!Objects.equal(dateWithoutMilliseconds, issue.closeDate())) {
     issue.setCloseDate(d);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
   }
 }
Beispiel #2
0
 public boolean setMessage(DefaultIssue issue, @Nullable String s, IssueChangeContext context) {
   if (!Objects.equal(s, issue.message())) {
     issue.setMessage(s);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     return true;
   }
   return false;
 }
 public boolean setProject(DefaultIssue issue, @Nullable String projectKey, IssueChangeContext context) {
   if (!Objects.equal(projectKey, issue.projectKey())) {
     issue.setProjectKey(projectKey);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     return true;
   }
   return false;
 }
Beispiel #4
0
 public boolean setStatus(DefaultIssue issue, String status, IssueChangeContext context) {
   if (!Objects.equal(status, issue.status())) {
     issue.setFieldChange(context, STATUS, issue.status(), status);
     issue.setStatus(status);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
 public boolean setAuthorLogin(DefaultIssue issue, @Nullable String authorLogin, IssueChangeContext context) {
   if (!Objects.equal(authorLogin, issue.authorLogin())) {
     issue.setFieldChange(context, AUTHOR, issue.authorLogin(), authorLogin);
     issue.setAuthorLogin(authorLogin);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     // do not send notifications to prevent spam when installing the developer cockpit plugin
     return true;
   }
   return false;
 }
Beispiel #6
0
 public boolean setTechnicalDebt(
     DefaultIssue issue, @Nullable TechnicalDebt value, IssueChangeContext context) {
   TechnicalDebt oldValue = issue.technicalDebt();
   if (!Objects.equal(value, oldValue)) {
     issue.setTechnicalDebt(value);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     return true;
   }
   return false;
 }
 public boolean setAttribute(DefaultIssue issue, String key, @Nullable String value, IssueChangeContext context) {
   String oldValue = issue.attribute(key);
   if (!Objects.equal(oldValue, value)) {
     issue.setFieldChange(context, key, oldValue, value);
     issue.setAttribute(key, value);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     return true;
   }
   return false;
 }
 public boolean setTechnicalDebt(DefaultIssue issue, @Nullable Duration value, IssueChangeContext context) {
   Duration oldValue = issue.debt();
   if (!Objects.equal(value, oldValue)) {
     issue.setDebt(value != null ? value : null);
     issue.setFieldChange(context, TECHNICAL_DEBT, oldValue != null ? oldValue.toMinutes() : null, value != null ? value.toMinutes() : null);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     return true;
   }
   return false;
 }
 public boolean setEffortToFix(DefaultIssue issue, @Nullable Double d, IssueChangeContext context) {
   if (!Objects.equal(d, issue.effortToFix())) {
     issue.setEffortToFix(d);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     // Do not send notifications to prevent spam when installing the SQALE plugin,
     // and do not complete the changelog (for the moment)
     return true;
   }
   return false;
 }
 public boolean setResolution(DefaultIssue issue, @Nullable String resolution, IssueChangeContext context) {
   if (!Objects.equal(resolution, issue.resolution())) {
     issue.setFieldChange(context, RESOLUTION, issue.resolution(), resolution);
     issue.setResolution(resolution);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
 public boolean setManualSeverity(DefaultIssue issue, String severity, IssueChangeContext context) {
   if (!issue.manualSeverity() || !Objects.equal(severity, issue.severity())) {
     issue.setFieldChange(context, SEVERITY, issue.severity(), severity);
     issue.setSeverity(severity);
     issue.setManualSeverity(true);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
Beispiel #12
0
 public boolean setSeverity(DefaultIssue issue, String severity, IssueChangeContext context) {
   if (issue.manualSeverity()) {
     throw new IllegalStateException("Severity can't be changed");
   }
   if (!Objects.equal(severity, issue.severity())) {
     issue.setFieldChange(context, SEVERITY, issue.severity(), severity);
     issue.setSeverity(severity);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     return true;
   }
   return false;
 }
 public IssueAutoAssignDecorator(
     Settings settings,
     Project project,
     IssueCache issueCache,
     IssueUpdater issueUpdater,
     ResourcePerspectives perspectives,
     UserDao userDao) {
   this.settings = settings;
   this.issueCache = issueCache;
   this.issueUpdater = issueUpdater;
   this.changeContext = IssueChangeContext.createScan(project.getAnalysisDate());
   this.perspectives = perspectives;
   this.userDao = userDao;
   this.enabled = settings.getBoolean(IssueAutoAssignPlugin.PROPERTY_PLUGIN_ENABLED);
 }
  @Test
  public void should_update_issues() throws Exception {
    setupData("should_update_issues");

    IssueChangeContext context = IssueChangeContext.createUser(new Date(), "emmerik");

    DefaultIssueComment comment = DefaultIssueComment.create("ABCDE", "emmerik", "the comment");
    // override generated key
    comment.setKey("FGHIJ");

    Date date = DateUtils.parseDate("2013-05-18");
    DefaultIssue issue =
        new DefaultIssue()
            .setKey("ABCDE")
            .setNew(false)
            .setChanged(true)

            // updated fields
            .setLine(5000)
            .setProjectUuid("CDEF")
            .setDebt(Duration.create(10L))
            .setChecksum("FFFFF")
            .setAuthorLogin("simon")
            .setAssignee("loic")
            .setFieldChange(context, "severity", "INFO", "BLOCKER")
            .setReporter("emmerik")
            .setResolution("FIXED")
            .setStatus("RESOLVED")
            .setSeverity("BLOCKER")
            .setAttribute("foo", "bar")
            .addComment(comment)
            .setCreationDate(date)
            .setUpdateDate(date)
            .setCloseDate(date)

            // unmodifiable fields
            .setRuleKey(RuleKey.of("xxx", "unknown"))
            .setComponentKey("struts:Action")
            .setProjectKey("struts");

    storage.save(issue);

    checkTables(
        "should_update_issues",
        new String[] {"id", "created_at", "updated_at", "issue_change_creation_date"},
        "issues",
        "issue_changes");
  }
Beispiel #15
0
 public boolean assign(DefaultIssue issue, @Nullable User user, IssueChangeContext context) {
   String sanitizedAssignee = null;
   if (user != null) {
     sanitizedAssignee = StringUtils.defaultIfBlank(user.login(), null);
   }
   if (!Objects.equal(sanitizedAssignee, issue.assignee())) {
     String newAssignee = user != null ? user.name() : null;
     issue.setFieldChange(context, ASSIGNEE, UNUSED, newAssignee);
     issue.setAssignee(sanitizedAssignee);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
 public boolean plan(DefaultIssue issue, @Nullable ActionPlan actionPlan, IssueChangeContext context) {
   String sanitizedActionPlanKey = null;
   if (actionPlan != null) {
     sanitizedActionPlanKey = StringUtils.defaultIfBlank(actionPlan.key(), null);
   }
   if (!Objects.equal(sanitizedActionPlanKey, issue.actionPlanKey())) {
     String newActionPlanName = actionPlan != null ? actionPlan.name() : null;
     issue.setFieldChange(context, ACTION_PLAN, UNUSED, newActionPlanName);
     issue.setActionPlanKey(sanitizedActionPlanKey);
     issue.setUpdateDate(context.date());
     issue.setChanged(true);
     issue.setSendNotifications(true);
     return true;
   }
   return false;
 }
Beispiel #17
0
 @Override
 public Function.Context setCloseDate(boolean b) {
   updater.setCloseDate(issue, b ? changeContext.date() : null, changeContext);
   return null;
 }
Beispiel #18
0
 public void addComment(DefaultIssue issue, String text, IssueChangeContext context) {
   issue.addComment(DefaultIssueComment.create(issue.key(), context.login(), text));
   issue.setUpdateDate(context.date());
   issue.setChanged(true);
 }