AnyRuleIssueFilter extends BaseTreeVisitor implements JavaIssueFilter { public void excludeLines(Tree tree) { excludedLines.addAll(filteredLines(tree)); }  @Override void scanFile(JavaFileScannerContext context); @Override boolean accept(RuleKey ruleKey, AnalyzerMessage analyzerMessage); @Override final Set<Class<? extends JavaCheck>> filteredRules(); void excludeLines(Tree tree);  }
@Test void invalid_tree_does_not_exclude_lines() { assertThatIssueWillBeAccepted(7).isTrue(); Tree mockTree = mock(Tree.class); filter.excludeLines(mockTree); assertThatIssueWillBeAccepted(7).isTrue(); SyntaxToken mockFirstToken = mock(SyntaxToken.class); when(mockFirstToken.line()).thenReturn(7); when(mockTree.firstToken()).thenReturn(mockFirstToken); filter.excludeLines(mockTree); assertThatIssueWillBeAccepted(7).isTrue(); SyntaxToken mockLastToken = mock(SyntaxToken.class); when(mockLastToken.line()).thenReturn(7); when(mockTree.lastToken()).thenReturn(mockLastToken); filter.excludeLines(mockTree); assertThatIssueWillBeAccepted(7).isFalse(); }