Package org.sonar.api.issue.internal

Examples of org.sonar.api.issue.internal.DefaultIssue


  @Test
  public void show_issue_with_comments() throws Exception {
    Date date1 = DateUtils.parseDateTime("2014-02-22T19:10:03+0100");
    Date date2 = DateUtils.parseDateTime("2014-02-23T19:10:03+0100");

    DefaultIssue issue = createStandardIssue();
    when(issueService.getByKey(issue.key())).thenReturn(issue);

    when(commentService.findComments(issue.key())).thenReturn(newArrayList(
      new DefaultIssueComment()
        .setKey("COMMENT-ABCD")
        .setMarkdownText("*My comment*")
        .setUserLogin("john")
        .setCreatedAt(date1),
      new DefaultIssueComment()
        .setKey("COMMENT-ABCE")
        .setMarkdownText("Another comment")
        .setUserLogin("arthur")
        .setCreatedAt(date2)
      ));

    when(userFinder.findByLogin("john")).thenReturn(new DefaultUser().setLogin("john").setName("John"));
    when(userFinder.findByLogin("arthur")).thenReturn(new DefaultUser().setLogin("arthur").setName("Arthur"));

    when(i18n.ageFromNow(any(Locale.class), eq(date1))).thenReturn("9 days");
    when(i18n.ageFromNow(any(Locale.class), eq(date2))).thenReturn("10 days");

    MockUserSession.set().setLogin("arthur");
    WsTester.TestRequest request = tester.newGetRequest("api/issues", "show").setParam("key", issue.key());
    request.execute().assertJson(getClass(), "show_issue_with_comments.json");
  }
View Full Code Here


    request.execute().assertJson(getClass(), "show_issue_with_comments.json");
  }

  @Test
  public void show_issue_with_transitions() throws Exception {
    DefaultIssue issue = createStandardIssue()
      .setStatus("RESOLVED")
      .setResolution("FIXED");
    when(issueService.getByKey(issue.key())).thenReturn(issue);

    when(issueService.listTransitions(eq(issue))).thenReturn(newArrayList(Transition.create("reopen", "RESOLVED", "REOPEN")));

    MockUserSession.set().setLogin("john");
    WsTester.TestRequest request = tester.newGetRequest("api/issues", "show").setParam("key", issue.key());
    request.execute().assertJson(getClass(), "show_issue_with_transitions.json");
  }
View Full Code Here

    request.execute().assertJson(getClass(), "show_issue_with_transitions.json");
  }

  @Test
  public void show_issue_with_actions() throws Exception {
    DefaultIssue issue = createStandardIssue()
      .setStatus("OPEN");
    when(issueService.getByKey(issue.key())).thenReturn(issue);

    MockUserSession.set().setLogin("john");
    WsTester.TestRequest request = tester.newGetRequest("api/issues", "show").setParam("key", issue.key());
    request.execute().assertJson(getClass(), "show_issue_with_actions.json");
  }
View Full Code Here

    request.execute().assertJson(getClass(), "show_issue_with_actions.json");
  }

  @Test
  public void show_issue_with_changelog() throws Exception {
    DefaultIssue issue = createStandardIssue();
    when(issueService.getByKey(issue.key())).thenReturn(issue);

    Date date1 = DateUtils.parseDateTime("2014-02-22T19:10:03+0100");
    Date date2 = DateUtils.parseDateTime("2014-02-23T19:10:03+0100");

    List<User> users = Lists.<User>newArrayList(new DefaultUser().setLogin("john").setName("John"));
    FieldDiffs userChange = new FieldDiffs()
      .setUserLogin("john")
      .setDiff("actionPlan", null, "1.0")
      .setCreationDate(date1);
    FieldDiffs scanChange = new FieldDiffs()
      .setDiff("severity", "INFO", "BLOCKER")
      .setDiff("status", "REOPEN", "RESOLVED")
      .setCreationDate(date2);
    when(issueChangelogService.changelog(issue)).thenReturn(new IssueChangelog(newArrayList(userChange, scanChange), users));
    when(issueChangelogService.formatDiffs(userChange)).thenReturn(newArrayList("Action plan updated to 1.0"));
    when(issueChangelogService.formatDiffs(scanChange)).thenReturn(newArrayList("Severity updated from Info to Blocker", "Status updated from Reopen to Resolved"));

    when(i18n.formatDateTime(any(Locale.class), eq(date1))).thenReturn("Fev 22, 2014 10:03 AM");
    when(i18n.formatDateTime(any(Locale.class), eq(date2))).thenReturn("Fev 23, 2014 10:03 AM");

    MockUserSession.set();
    WsTester.TestRequest request = tester.newGetRequest("api/issues", "show").setParam("key", issue.key());
    request.execute().assertJson(getClass(), "show_issue_with_changelog.json");
  }
View Full Code Here

      .setComponentUuid(file.uuid())
      .setProjectUuid(project.uuid());
  }

  private DefaultIssue createIssue() {
    return new DefaultIssue()
      .setKey("ABCD")
      .setComponentKey("org.sonar.server.issue.IssueClient")
      .setProjectKey("org.sonar.Sonar")
      .setRuleKey(RuleKey.of("squid", "AvoidCycle"))
      .setCreationDate(issueCreationDate);
View Full Code Here

import org.sonar.api.issue.internal.DefaultIssue;

public class SetEndOfLifeResolution implements Function {
  @Override
  public void execute(Context context) {
    DefaultIssue issue = (DefaultIssue) context.issue();
    if (!issue.isEndOfLife()) {
      throw new IllegalStateException("Issue is still alive: " + issue);
    }
    if (issue.isOnDisabledRule()) {
      context.setResolution(Issue.RESOLUTION_REMOVED);
    } else {
      context.setResolution(Issue.RESOLUTION_FIXED);
    }
  }
View Full Code Here

  @Test
  public void merge_matched_issue() throws Exception {
    IssueDto previousIssue = new IssueDto().setKee("ABCDE").setResolution(null).setStatus("OPEN").setRuleKey("squid", "AvoidCycle")
      .setLine(10).setSeverity("MAJOR").setMessage("Message").setEffortToFix(1.5).setDebt(1L).setProjectKey("sample");
    DefaultIssue issue = new DefaultIssue();

    IssueTrackingResult trackingResult = mock(IssueTrackingResult.class);
    when(trackingResult.matched()).thenReturn(newArrayList(issue));
    when(trackingResult.matching(eq(issue))).thenReturn(previousIssue);
    decorator.mergeMatched(trackingResult);
View Full Code Here

  @Test
  public void merge_matched_issue_on_manual_severity() throws Exception {
    IssueDto previousIssue = new IssueDto().setKee("ABCDE").setResolution(null).setStatus("OPEN").setRuleKey("squid", "AvoidCycle")
      .setLine(10).setManualSeverity(true).setSeverity("MAJOR").setMessage("Message").setEffortToFix(1.5).setDebt(1L);
    DefaultIssue issue = new DefaultIssue();

    IssueTrackingResult trackingResult = mock(IssueTrackingResult.class);
    when(trackingResult.matched()).thenReturn(newArrayList(issue));
    when(trackingResult.matching(eq(issue))).thenReturn(previousIssue);
    decorator.mergeMatched(trackingResult);

    assertThat(issue.manualSeverity()).isTrue();
    assertThat(issue.severity()).isEqualTo("MAJOR");
    verify(updater, never()).setPastSeverity(eq(issue), anyString(), any(IssueChangeContext.class));
  }
View Full Code Here

  public void merge_issue_changelog_with_previous_changelog() throws Exception {
    when(initialOpenIssues.selectChangelog("ABCDE")).thenReturn(newArrayList(new IssueChangeDto().setIssueKey("ABCD")));

    IssueDto previousIssue = new IssueDto().setKee("ABCDE").setResolution(null).setStatus("OPEN").setRuleKey("squid", "AvoidCycle")
      .setLine(10).setMessage("Message").setEffortToFix(1.5).setDebt(1L);
    DefaultIssue issue = new DefaultIssue();

    IssueTrackingResult trackingResult = mock(IssueTrackingResult.class);
    when(trackingResult.matched()).thenReturn(newArrayList(issue));
    when(trackingResult.matching(eq(issue))).thenReturn(previousIssue);
    decorator.mergeMatched(trackingResult);

    assertThat(issue.changes()).hasSize(1);
  }
View Full Code Here

    IssueHandler h1 = mock(IssueHandler.class);
    IssueHandler h2 = mock(IssueHandler.class);
    IssueUpdater updater = mock(IssueUpdater.class);

    IssueHandlers handlers = new IssueHandlers(updater, new IssueHandler[]{h1, h2});
    final DefaultIssue issue = new DefaultIssue();
    handlers.execute(issue, IssueChangeContext.createScan(new Date()));

    verify(h1).onIssue(argThat(new ArgumentMatcher<IssueHandler.Context>() {
      @Override
      public boolean matches(Object o) {
View Full Code Here

TOP

Related Classes of org.sonar.api.issue.internal.DefaultIssue

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.