@Test public void ignore_issue_from_common_rule() throws Exception { when(issueFilter.accept(any(DefaultIssue.class), eq(FILE))).thenReturn(false); fileSourceRepository.addLines(FILE_REF, "line 1;", "line 2;"); DefaultIssue ceIssue = new DefaultIssue() .setRuleKey( RuleKey.of(CommonRuleKeys.commonRepositoryForLang("java"), "InsufficientCoverage")) .setMessage("not enough coverage") .setGap(10.0); when(commonRuleEngine.process(FILE)).thenReturn(asList(ceIssue)); Input<DefaultIssue> input = underTest.create(FILE); assertThat(input.getIssues()).isEmpty(); }
@Test public void ignore_report_issues_on_common_rules() throws Exception { fileSourceRepository.addLines(FILE_REF, "line 1;", "line 2;"); ScannerReport.Issue reportIssue = ScannerReport.Issue.newBuilder() .setMsg("the message") .setRuleRepository(CommonRuleKeys.commonRepositoryForLang("java")) .setRuleKey("S001") .setSeverity(Constants.Severity.BLOCKER) .build(); reportReader.putIssues(FILE.getReportAttributes().getRef(), asList(reportIssue)); Input<DefaultIssue> input = underTest.create(FILE); assertThat(input.getIssues()).isEmpty(); }
@Test public void load_issues_of_compute_engine_common_rules() throws Exception { reportReader.putFileSourceLines(FILE.getRef(), "line 1;", "line 2;"); DefaultIssue ceIssue = new DefaultIssue() .setRuleKey( RuleKey.of(CommonRuleKeys.commonRepositoryForLang("java"), "InsufficientCoverage")) .setMessage("not enough coverage") .setEffortToFix(10.0); when(commonRuleEngine.process(FILE)).thenReturn(asList(ceIssue)); Input<DefaultIssue> input = underTest.create(FILE); assertThat(input.getIssues()).containsOnly(ceIssue); assertInitializedIssue(input.getIssues().iterator().next()); }
@Test public void load_issues_of_compute_engine_common_rules() throws Exception { when(issueFilter.accept(any(DefaultIssue.class), eq(FILE))).thenReturn(true); fileSourceRepository.addLines(FILE_REF, "line 1;", "line 2;"); DefaultIssue ceIssue = new DefaultIssue() .setRuleKey( RuleKey.of(CommonRuleKeys.commonRepositoryForLang("java"), "InsufficientCoverage")) .setMessage("not enough coverage") .setGap(10.0); when(commonRuleEngine.process(FILE)).thenReturn(asList(ceIssue)); Input<DefaultIssue> input = underTest.create(FILE); assertThat(input.getIssues()).containsOnly(ceIssue); assertInitializedIssue(input.getIssues().iterator().next()); }