use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class AnnotationUtilTest method testContainsAnnotationListWithNoMatchingAnnotation.
@Test
public void testContainsAnnotationListWithNoMatchingAnnotation() {
final DetailAstImpl ast = new DetailAstImpl();
final DetailAstImpl modifiersAst = create(TokenTypes.MODIFIERS, create(TokenTypes.ANNOTATION, create(TokenTypes.DOT, create(TokenTypes.IDENT, "Override"))));
ast.addChild(modifiersAst);
final List<String> annotations = Collections.singletonList("Deprecated");
final boolean result = AnnotationUtil.containsAnnotation(ast, annotations);
assertWithMessage("No matching annotation found").that(result).isFalse();
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class AnnotationUtilTest method testContainsAnnotationFalse2.
@Test
public void testContainsAnnotationFalse2() {
final DetailAstImpl ast = new DetailAstImpl();
ast.setType(1);
final DetailAstImpl ast2 = new DetailAstImpl();
ast2.setType(TokenTypes.MODIFIERS);
ast.addChild(ast2);
assertWithMessage("AnnotationUtil should not contain " + ast).that(AnnotationUtil.containsAnnotation(ast)).isFalse();
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class AnnotationUtilTest method create.
private static DetailAstImpl create(int tokenType) {
final DetailAstImpl ast = new DetailAstImpl();
ast.setType(tokenType);
return ast;
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class AnnotationUtilTest method testAnnotationNull2.
@Test
public void testAnnotationNull2() {
try {
AnnotationUtil.getAnnotation(new DetailAstImpl(), null);
assertWithMessage("IllegalArgumentException is expected").fail();
} catch (IllegalArgumentException ex) {
assertWithMessage("Invalid exception message").that(ex.getMessage()).isEqualTo("the annotation is null");
}
}
use of com.puppycrawl.tools.checkstyle.DetailAstImpl in project checkstyle by checkstyle.
the class CheckUtilTest method testGetFirstNode1.
@Test
public void testGetFirstNode1() {
final DetailAstImpl child = new DetailAstImpl();
child.setLineNo(5);
child.setColumnNo(6);
final DetailAstImpl root = new DetailAstImpl();
root.setLineNo(5);
root.setColumnNo(6);
root.addChild(child);
final DetailAST firstNode = CheckUtil.getFirstNode(root);
assertWithMessage("Unexpected node").that(firstNode).isEqualTo(root);
}
Aggregations