@Test public void build_project_issue() { SensorStorage storage = mock(SensorStorage.class); DefaultIssue issue = new DefaultIssue(storage) .addLocation(new DefaultIssueLocation().onProject().message("Wrong way!")) .forRule(RuleKey.of("repo", "rule")) .effortToFix(10.0); assertThat(issue.locations().get(0).inputPath()).isNull(); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); assertThat(issue.locations().get(0).textRange()).isNull(); assertThat(issue.effortToFix()).isEqualTo(10.0); assertThat(issue.locations().get(0).message()).isEqualTo("Wrong way!"); issue.save(); verify(storage).store(issue); }
@Test public void build_directory_issue() { SensorStorage storage = mock(SensorStorage.class); DefaultIssue issue = new DefaultIssue(storage) .addLocation( new DefaultIssueLocation() .onDir(new DefaultInputDir("foo", "src")) .message("Wrong way!")) .forRule(RuleKey.of("repo", "rule")) .overrideSeverity(Severity.BLOCKER); assertThat(issue.locations().get(0).inputPath()).isEqualTo(new DefaultInputDir("foo", "src")); assertThat(issue.ruleKey()).isEqualTo(RuleKey.of("repo", "rule")); assertThat(issue.locations().get(0).textRange()).isNull(); assertThat(issue.locations().get(0).message()).isEqualTo("Wrong way!"); assertThat(issue.overriddenSeverity()).isEqualTo(Severity.BLOCKER); issue.save(); verify(storage).store(issue); }