private void assertSingleIssue(Set<AnalyzerMessage> issues) { Preconditions.checkState( issues.size() == 1, "A single issue is expected with line " + expectFileIssueOnline); AnalyzerMessage issue = Iterables.getFirst(issues, null); assertThat(issue.getLine()).isEqualTo(expectFileIssueOnline); assertThat(issue.getMessage()).isEqualTo(expectFileIssue); }
private static void validateIssue( Multimap<Integer, Map<IssueAttribute, String>> expected, List<Integer> unexpectedLines, AnalyzerMessage issue, boolean isLinear) { int line = issue.getLine(); if (expected.containsKey(line)) { Map<IssueAttribute, String> attrs = Iterables.getLast(expected.get(line)); assertEquals(issue.getMessage(), attrs, IssueAttribute.MESSAGE); Double cost = issue.getCost(); if (cost != null) { assertEquals(Integer.toString(cost.intValue()), attrs, IssueAttribute.EFFORT_TO_FIX); } else if (isLinear) { Fail.fail("A cost should be provided for a rule with linear remediation function"); } validateAnalyzerMessage(attrs, issue); expected.remove(line, attrs); } else { unexpectedLines.add(line); } }