APISonar


org.sonar.api.issue.internal.IssueChangeContext.date

> org > sonar > api > issue > internal > IssueChangeContext > date
org APIs sonar APIs api APIs issue APIs internal APIs IssueChangeContext APIs date APIs

Example 1
public void test_scan_context() throws Exception {
    Date now = new Date();
    IssueChangeContext context = IssueChangeContext.createScan(now);

    assertThat(context.scan()).isTrue();
    assertThat(context.login()).isNull();
    assertThat(context.date()).isEqualTo(now);
  }
Example 2
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);
    }
  }
Example 3
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;
  }
Example 4
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;
  }
Example 5
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;
  }
Example 6
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;
  }
Example 7
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;
  }