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