BAEL-6839: Updated pmd unit tests rule - Allow tests ending with "jmhTest" and disallow ones ending with "Tests" (#4411)

* BAEL-6839: Updated the unit tests convention pmd rule - Don't allow unit tests ending with "Tests" and allow the ones ending with "jmhTest" ("*jmhTest" are autogenerated)

* fixed formatting issue - Replaced tabs with spaces
This commit is contained in:
sachin29aug 2018-06-05 23:05:43 +05:30 committed by Grzegorz Piwowarek
parent 2e683411e2
commit eb746f5ac6
2 changed files with 5 additions and 6 deletions

Binary file not shown.

View File

@ -14,18 +14,17 @@ public class UnitTestNamingConventionRule extends AbstractJavaRule {
"ManualTest", "ManualTest",
"JdbcTest", "JdbcTest",
"LiveTest", "LiveTest",
"UnitTest"); "UnitTest",
"jmhTest");
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) { public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
String className = node.getImage(); String className = node.getImage();
Objects.requireNonNull(className); Objects.requireNonNull(className);
if (className.endsWith("Test") || className.endsWith("Tests")) { if (className.endsWith("Tests")
if (allowedEndings.stream() || (className.endsWith("Test") && allowedEndings.stream().noneMatch(className::endsWith))) {
.noneMatch(className::endsWith)) {
addViolation(data, node); addViolation(data, node);
} }
}
return data; return data;
} }