Package org.sonar.api.issue.internal

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


  @Test
  public void test_no_handlers() {
    IssueUpdater updater = mock(IssueUpdater.class);
    IssueHandlers handlers = new IssueHandlers(updater);
    handlers.execute(new DefaultIssue(), IssueChangeContext.createScan(new Date()));
    verifyZeroInteractions(updater);
  }
View Full Code Here


      mode, userFinder, rootModule, fileCache);
  }

  @Test
  public void should_write_json() throws Exception {
    DefaultIssue issue = new DefaultIssue()
      .setKey("200")
      .setComponentKey("struts:src/main/java/org/apache/struts/Action.java")
      .setRuleKey(RuleKey.of("squid", "AvoidCycles"))
      .setMessage("There are 2 cycles")
      .setSeverity("MINOR")
View Full Code Here

  }

  @Test
  public void should_exclude_resolved_issues() throws Exception {
    RuleKey ruleKey = RuleKey.of("squid", "AvoidCycles");
    DefaultIssue issue = new DefaultIssue()
      .setKey("200")
      .setComponentKey("struts:src/main/java/org/apache/struts/Action.java")
      .setRuleKey(ruleKey)
      .setStatus(Issue.STATUS_CLOSED)
      .setResolution(Issue.RESOLUTION_FIXED)
View Full Code Here

    when(index.getSource(project)).thenReturn(load("example2-v2"));
    sourceHashHolder = new SourceHashHolder(index, lastSnapshots, project);

    IssueDto referenceIssue1 = newReferenceIssue("SystemPrintln", 5, "squid", "AvoidCycle", null);

    DefaultIssue newIssue1 = newDefaultIssue("SystemPrintln", 6, RuleKey.of("squid", "AvoidCycle"), null);
    DefaultIssue newIssue2 = newDefaultIssue("SystemPrintln", 10, RuleKey.of("squid", "AvoidCycle"), null);
    DefaultIssue newIssue3 = newDefaultIssue("SystemPrintln", 14, RuleKey.of("squid", "AvoidCycle"), null);

    IssueTrackingResult result = new IssueTrackingResult();
    tracking.mapIssues(
      Arrays.asList(newIssue1, newIssue2, newIssue3),
      Arrays.asList(referenceIssue1),
View Full Code Here

    IssueDto referenceIssue2 = newReferenceIssue("Avoid unused private methods such as 'myMethod()'.", 13, "squid", "NullDeref", "ef23288705d1ef1e512448ace287586e");
    IssueDto referenceIssue3 = newReferenceIssue("Method 'avoidUtilityClass' is not designed for extension - needs to be abstract, final or empty.", 9, "pmd",
      "UnusedLocalVariable", "ed5cdd046fda82727d6fedd1d8e3a310");

    // New issue
    DefaultIssue newIssue1 = newDefaultIssue("Avoid unused local variables such as 'msg'.", 18, RuleKey.of("squid", "AvoidCycle"), "a24254126be2bf1a9b9a8db43f633733");
    // Same as referenceIssue2
    DefaultIssue newIssue2 = newDefaultIssue("Avoid unused private methods such as 'myMethod()'.", 13, RuleKey.of("squid", "NullDeref"), "ef23288705d1ef1e512448ace287586e");
    // Same as referenceIssue3
    DefaultIssue newIssue3 = newDefaultIssue("Method 'avoidUtilityClass' is not designed for extension - needs to be abstract, final or empty.", 9,
      RuleKey.of("pmd", "UnusedLocalVariable"), "ed5cdd046fda82727d6fedd1d8e3a310");
    // New issue
    DefaultIssue newIssue4 = newDefaultIssue("Method 'newViolation' is not designed for extension - needs to be abstract, final or empty.", 17,
      RuleKey.of("pmd", "UnusedLocalVariable"), "7d58ac9040c27e4ca2f11a0269e251e2");
    // Same as referenceIssue1
    DefaultIssue newIssue5 = newDefaultIssue("Avoid unused local variables such as 'j'.", 6, RuleKey.of("squid", "AvoidCycle"), "4432a2675ec3e1620daefe38386b51ef");

    IssueTrackingResult result = new IssueTrackingResult();
    tracking.mapIssues(
      Arrays.asList(newIssue1, newIssue2, newIssue3, newIssue4, newIssue5),
      Arrays.asList(referenceIssue1, referenceIssue2, referenceIssue3),
View Full Code Here

  private static String load(String name) throws IOException {
    return Resources.toString(IssueTrackingTest.class.getResource("IssueTrackingTest/" + name + ".txt"), Charsets.UTF_8);
  }

  private DefaultIssue newDefaultIssue(String message, Integer line, RuleKey ruleKey, String checksum) {
    return new DefaultIssue().setMessage(message).setLine(line).setRuleKey(ruleKey).setChecksum(checksum).setStatus(Issue.STATUS_OPEN);
  }
View Full Code Here

  }

  @Test
  public void should_process_open_issues() throws Exception {
    Resource file = new File("Action.java").setEffectiveKey("struts:Action.java").setId(123);
    final DefaultIssue issue = new DefaultIssue();

    // INPUT : one issue, no open issues during previous scan, no filtering
    when(issueCache.byComponent("struts:Action.java")).thenReturn(Arrays.asList(issue));
    List<IssueDto> dbIssues = Collections.emptyList();
    when(initialOpenIssues.selectAndRemoveIssues("struts:Action.java")).thenReturn(dbIssues);
View Full Code Here

    verify(handlers, times(1)).execute(any(DefaultIssue.class), any(IssueChangeContext.class));

    ArgumentCaptor<DefaultIssue> argument = ArgumentCaptor.forClass(DefaultIssue.class);
    verify(issueCache).put(argument.capture());

    DefaultIssue issue = argument.getValue();
    assertThat(issue.key()).isEqualTo("ABCDE");
    assertThat(issue.isNew()).isFalse();
    assertThat(issue.isEndOfLife()).isTrue();
  }
View Full Code Here

    verify(handlers, times(1)).execute(any(DefaultIssue.class), any(IssueChangeContext.class));

    ArgumentCaptor<DefaultIssue> argument = ArgumentCaptor.forClass(DefaultIssue.class);
    verify(issueCache).put(argument.capture());

    DefaultIssue issue = argument.getValue();
    assertThat(issue.line()).isEqualTo(2);
    assertThat(issue.key()).isEqualTo("ABCDE");
    assertThat(issue.isNew()).isFalse();
    assertThat(issue.isEndOfLife()).isFalse();
    assertThat(issue.isOnDisabledRule()).isFalse();
  }
View Full Code Here

    verify(handlers, times(1)).execute(any(DefaultIssue.class), any(IssueChangeContext.class));

    ArgumentCaptor<DefaultIssue> argument = ArgumentCaptor.forClass(DefaultIssue.class);
    verify(issueCache).put(argument.capture());

    DefaultIssue issue = argument.getValue();
    assertThat(issue.line()).isEqualTo(1);
    assertThat(issue.key()).isEqualTo("ABCDE");
    assertThat(issue.isNew()).isFalse();
    assertThat(issue.isEndOfLife()).isFalse();
    assertThat(issue.isOnDisabledRule()).isFalse();
    assertThat(issue.status()).isEqualTo("CLOSED");
  }
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.