Package org.sonar.api.issue.internal

Examples of org.sonar.api.issue.internal.FieldDiffs$Diff


    assertThat(message).isEqualTo("Severity changed to INFO (was BLOCKER)");
  }

  @Test
  public void format_field_diffs_with_only_new_value() {
    FieldDiffs diffs = new FieldDiffs();
    diffs.setDiff("severity", null, "INFO");

    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Severity", "INFO")).thenReturn("Severity changed to INFO");

    List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
View Full Code Here


    assertThat(message).isEqualTo("Severity changed to INFO");
  }

  @Test
  public void format_field_diffs_with_only_old_value() {
    FieldDiffs diffs = new FieldDiffs();
    diffs.setDiff("severity", "BLOCKER", null);

    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");
    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.was", null, "BLOCKER")).thenReturn("was BLOCKER");
View Full Code Here

    assertThat(message).isEqualTo("Severity removed (was BLOCKER)");
  }

  @Test
  public void format_field_diffs_without_value() {
    FieldDiffs diffs = new FieldDiffs();
    diffs.setDiff("severity", null, null);

    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");

    List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
View Full Code Here

    assertThat(message).isEqualTo("Severity removed");
  }

  @Test
  public void format_field_diffs_with_empty_old_value() {
    FieldDiffs diffs = new FieldDiffs();
    diffs.setDiff("severity", "", null);

    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.severity", null)).thenReturn("Severity");
    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Severity")).thenReturn("Severity removed");

    List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
View Full Code Here

    assertThat(message).isEqualTo("Severity removed");
  }

  @Test
  public void format_technical_debt_with_old_and_new_value() {
    FieldDiffs diffs = new FieldDiffs();
    diffs.setDiff("technicalDebt", "18000", "28800");

    when(durations.format(any(Locale.class), eq(Duration.create(18000L)), eq(Durations.DurationFormat.SHORT))).thenReturn("5 hours");
    when(durations.format(any(Locale.class), eq(Duration.create(28800L)), eq(Durations.DurationFormat.SHORT))).thenReturn("1 days");

    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
View Full Code Here

    assertThat(message).isEqualTo("Technical Debt changed to 1 days (was 5 hours)");
  }

  @Test
  public void format_technical_debt_with_new_value_only() {
    FieldDiffs diffs = new FieldDiffs();
    diffs.setDiff("technicalDebt", null, "28800");

    when(durations.format(any(Locale.class), eq(Duration.create(28800L)), eq(Durations.DurationFormat.SHORT))).thenReturn("1 days");

    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.changed_to", null, "Technical Debt", "1 days")).thenReturn("Technical Debt changed to 1 days");
View Full Code Here

    assertThat(message).isEqualTo("Technical Debt changed to 1 days");
  }

  @Test
  public void format_technical_debt_without_value() {
    FieldDiffs diffs = new FieldDiffs();
    diffs.setDiff("technicalDebt", null, null);

    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.field.technicalDebt", null)).thenReturn("Technical Debt");
    when(i18n.message(DEFAULT_LOCALE, "issue.changelog.removed", null, "Technical Debt")).thenReturn("Technical Debt removed");

    List<String> result = formatter.format(DEFAULT_LOCALE, diffs);
View Full Code Here

  @CheckForNull
  private Notification createChangeNotification(DefaultIssue issue, IssueChangeContext context, @Nullable Rule rule, Component project,
    @Nullable Component component, @Nullable String comment) {
    Notification notification = null;
    if (comment != null || issue.mustSendNotifications()) {
      FieldDiffs currentChange = issue.currentChange();
      notification = newNotification(project, "issue-changes");
      notification.setFieldValue("key", issue.key());
      notification.setFieldValue("changeAuthor", context.login());
      notification.setFieldValue("reporter", issue.reporter());
      notification.setFieldValue("assignee", issue.assignee());
      notification.setFieldValue("message", issue.message());
      notification.setFieldValue("ruleName", ruleName(rule));
      notification.setFieldValue("componentKey", issue.componentKey());
      if (component != null) {
        notification.setFieldValue("componentName", component.longName());
      }
      if (comment != null) {
        notification.setFieldValue("comment", comment);
      }

      if (currentChange != null) {
        for (Map.Entry<String, FieldDiffs.Diff> entry : currentChange.diffs().entrySet()) {
          String type = entry.getKey();
          FieldDiffs.Diff diff = entry.getValue();
          Serializable newValue = diff.newValue();
          Serializable oldValue = diff.oldValue();
          notification.setFieldValue("old." + type, oldValue != null ? oldValue.toString() : null);
View Full Code Here

  @Test
  public void save_on_one_issue_with_one_new_changelog() {
    Issue issue = new DefaultIssue().setKey("A").setCreationDate(tenDaysAgo).setDebt(Duration.create(TWO_DAYS_IN_MINUTES)).setChanges(
      newArrayList(
        // changelog created at is null because it has just been created on the current analysis
        new FieldDiffs().setDiff("technicalDebt", ONE_DAY_IN_MINUTES, TWO_DAYS_IN_MINUTES).setCreationDate(null)
      )
    );
    when(issuable.issues()).thenReturn(newArrayList(issue));

    decorator.decorate(resource, context);
View Full Code Here

  @Test
  public void save_on_one_issue_with_changelog() {
    Issue issue = new DefaultIssue().setKey("A").setCreationDate(tenDaysAgo).setDebt(Duration.create(FIVE_DAYS_IN_MINUTES)).setChanges(
      newArrayList(
        new FieldDiffs().setDiff("technicalDebt", TWO_DAYS_IN_MINUTES, FIVE_DAYS_IN_MINUTES).setCreationDate(null),
        new FieldDiffs().setDiff("technicalDebt", ONE_DAY_IN_MINUTES, TWO_DAYS_IN_MINUTES).setCreationDate(fourDaysAgo)
      )
    );
    when(issuable.issues()).thenReturn(newArrayList(issue));

    decorator.decorate(resource, context);
View Full Code Here

TOP

Related Classes of org.sonar.api.issue.internal.FieldDiffs$Diff

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.