--- a/src/it/java/com/google/checkstyle/test/base/AbstractIndentationTestSupport.java +++ b/src/it/java/com/google/checkstyle/test/base/AbstractIndentationTestSupport.java @@ -19,12 +19,14 @@ package com.google.checkstyle.test.base; +import static com.google.common.base.Preconditions.checkState; +import static java.nio.charset.StandardCharsets.UTF_8; + import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.BufferedReader; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -71,8 +73,7 @@ public abstract class AbstractIndentationTestSupport extends AbstractGoogleModul private static Integer[] getLinesWithWarnAndCheckComments(String aFileName, final int tabWidth) throws IOException { final List result = new ArrayList<>(); - try (BufferedReader br = - Files.newBufferedReader(Paths.get(aFileName), StandardCharsets.UTF_8)) { + try (BufferedReader br = Files.newBufferedReader(Path.of(aFileName), UTF_8)) { int lineNumber = 1; for (String line = br.readLine(); line != null; line = br.readLine()) { final Matcher match = LINE_WITH_COMMENT_REGEX.matcher(line); @@ -81,30 +82,28 @@ public abstract class AbstractIndentationTestSupport extends AbstractGoogleModul final int indentInComment = getIndentFromComment(comment); final int actualIndent = getLineStart(line, tabWidth); - if (actualIndent != indentInComment) { - throw new IllegalStateException( - String.format( - Locale.ROOT, - "File \"%1$s\" has incorrect indentation in comment." - + "Line %2$d: comment:%3$d, actual:%4$d.", - aFileName, - lineNumber, - indentInComment, - actualIndent)); - } + checkState( + actualIndent == indentInComment, + String.format( + Locale.ROOT, + "File \"%1$s\" has incorrect indentation in comment." + + "Line %2$d: comment:%3$d, actual:%4$d.", + aFileName, + lineNumber, + indentInComment, + actualIndent)); if (isWarnComment(comment)) { result.add(lineNumber); } - if (!isCommentConsistent(comment)) { - throw new IllegalStateException( - String.format( - Locale.ROOT, - "File \"%1$s\" has inconsistent comment on line %2$d", - aFileName, - lineNumber)); - } + checkState( + isCommentConsistent(comment), + String.format( + Locale.ROOT, + "File \"%1$s\" has inconsistent comment on line %2$d", + aFileName, + lineNumber)); } else if (NONEMPTY_LINE_REGEX.matcher(line).matches()) { throw new IllegalStateException( String.format( --- a/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule21filename/OuterTypeFilenameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule21filename/OuterTypeFilenameTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class OuterTypeFilenameTest extends AbstractGoogleModuleTestSupport { +final class OuterTypeFilenameTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class OuterTypeFilenameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOuterTypeFilename1() throws Exception { + void outerTypeFilename1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("OuterTypeFilename"); @@ -46,7 +46,7 @@ public class OuterTypeFilenameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOuterTypeFilename2() throws Exception { + void outerTypeFilename2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("OuterTypeFilename"); @@ -57,7 +57,7 @@ public class OuterTypeFilenameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOuterTypeFilename3() throws Exception { + void outerTypeFilename3() throws Exception { final String[] expected = { "3:1: " + getCheckMessage(OuterTypeFilenameCheck.class, MSG_KEY), }; --- a/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule231filetab/FileTabCharacterTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule231filetab/FileTabCharacterTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck; import org.junit.jupiter.api.Test; -public class FileTabCharacterTest extends AbstractGoogleModuleTestSupport { +final class FileTabCharacterTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class FileTabCharacterTest extends AbstractGoogleModuleTestSupport { } @Test - public void testFileTab() throws Exception { + void fileTab() throws Exception { final String[] expected = { "8:25: " + getCheckMessage(FileTabCharacterCheck.class, "containsTab"), "51:5: " + getCheckMessage(FileTabCharacterCheck.class, "containsTab"), --- a/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule232specialescape/IllegalTokenTextTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule232specialescape/IllegalTokenTextTest.java @@ -23,7 +23,7 @@ import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.Configuration; import org.junit.jupiter.api.Test; -public class IllegalTokenTextTest extends AbstractGoogleModuleTestSupport { +final class IllegalTokenTextTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,7 +31,7 @@ public class IllegalTokenTextTest extends AbstractGoogleModuleTestSupport { } @Test - public void testIllegalTokens() throws Exception { + void illegalTokens() throws Exception { final String message = "Consider using special escape sequence instead of octal value or " + "Unicode escaped value."; --- a/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule233nonascii/AvoidEscapedUnicodeCharactersTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter2filebasic/rule233nonascii/AvoidEscapedUnicodeCharactersTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.AvoidEscapedUnicodeCharactersCheck; import org.junit.jupiter.api.Test; -public class AvoidEscapedUnicodeCharactersTest extends AbstractGoogleModuleTestSupport { +final class AvoidEscapedUnicodeCharactersTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class AvoidEscapedUnicodeCharactersTest extends AbstractGoogleModuleTestS } @Test - public void testUnicodeEscapes() throws Exception { + void unicodeEscapes() throws Exception { final String[] expected = { "5:42: " + getCheckMessage(AvoidEscapedUnicodeCharactersCheck.class, MSG_KEY), "15:38: " + getCheckMessage(AvoidEscapedUnicodeCharactersCheck.class, MSG_KEY), --- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule32packagestate/LineLengthTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule32packagestate/LineLengthTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck; import org.junit.jupiter.api.Test; -public class LineLengthTest extends AbstractGoogleModuleTestSupport { +final class LineLengthTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class LineLengthTest extends AbstractGoogleModuleTestSupport { } @Test - public void testLineLength() throws Exception { + void lineLength() throws Exception { final String[] expected = { "5: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 112), "29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 183), --- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule331nowildcard/AvoidStarImportTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule331nowildcard/AvoidStarImportTest.java @@ -23,7 +23,7 @@ import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.Configuration; import org.junit.jupiter.api.Test; -public class AvoidStarImportTest extends AbstractGoogleModuleTestSupport { +final class AvoidStarImportTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,7 +31,7 @@ public class AvoidStarImportTest extends AbstractGoogleModuleTestSupport { } @Test - public void testStarImport() throws Exception { + void starImport() throws Exception { final String[] expected = { "3:15: Using the '.*' form of import should be avoided - java.io.*.", "4:17: Using the '.*' form of import should be avoided - java.lang.*.", --- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule332nolinewrap/NoLineWrapTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule332nolinewrap/NoLineWrapTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.checks.whitespace.NoLineWrapCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NoLineWrapTest extends AbstractGoogleModuleTestSupport { +final class NoLineWrapTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class NoLineWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void testBadLineWrap() throws Exception { + void badLineWrap() throws Exception { final String[] expected = { "1:1: " + getCheckMessage(NoLineWrapCheck.class, "no.line.wrap", "package"), "6:1: " + getCheckMessage(NoLineWrapCheck.class, "no.line.wrap", "import"), @@ -49,7 +49,7 @@ public class NoLineWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void testGoodLineWrap() throws Exception { + void goodLineWrap() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("NoLineWrap"); @@ -60,7 +60,7 @@ public class NoLineWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void goodLineLength() throws Exception { + void goodLineLength() throws Exception { final int maxLineLength = 100; final String[] expected = { "5: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 112), --- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/CustomImportOrderTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule333orderingandspacing/CustomImportOrderTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { +final class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { /** Shortcuts to make code more compact. */ private static final String MSG_LINE_SEPARATOR = CustomImportOrderCheck.MSG_LINE_SEPARATOR; @@ -45,7 +45,7 @@ public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCustomImport1() throws Exception { + void customImport1() throws Exception { final String[] expected = { "4:1: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), @@ -68,7 +68,7 @@ public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCustomImport2() throws Exception { + void customImport2() throws Exception { final String[] expected = { "4:1: " + getCheckMessage(clazz, MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), @@ -113,7 +113,7 @@ public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCustomImport3() throws Exception { + void customImport3() throws Exception { final String[] expected = { "4:1: " + getCheckMessage(clazz, MSG_LINE_SEPARATOR, "java.awt.Dialog"), "5:1: " @@ -155,7 +155,7 @@ public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCustomImport4() throws Exception { + void customImport4() throws Exception { final String[] expected = { "7:1: " + getCheckMessage(clazz, MSG_SEPARATED_IN_GROUP, "javax.swing.WindowConstants.*"), "15:1: " + getCheckMessage(clazz, MSG_SEPARATED_IN_GROUP, "java.util.StringTokenizer"), @@ -172,7 +172,7 @@ public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCustomImport5() throws Exception { + void customImport5() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(clazz, MSG_SEPARATED_IN_GROUP, "javax.swing.WindowConstants.*"), "13:1: " @@ -195,7 +195,7 @@ public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testValid() throws Exception { + void valid() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("CustomImportOrder"); @@ -206,7 +206,7 @@ public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testValid2() throws Exception { + void valid2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("CustomImportOrder"); @@ -217,7 +217,7 @@ public class CustomImportOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testValidGoogleStyleOrderOfImports() throws Exception { + void validGoogleStyleOrderOfImports() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("CustomImportOrder"); --- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule341onetoplevel/OneTopLevelClassTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule341onetoplevel/OneTopLevelClassTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.design.OneTopLevelClassCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class OneTopLevelClassTest extends AbstractGoogleModuleTestSupport { +final class OneTopLevelClassTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class OneTopLevelClassTest extends AbstractGoogleModuleTestSupport { } @Test - public void testBad() throws Exception { + void bad() throws Exception { final Class clazz = OneTopLevelClassCheck.class; final String messageKey = "one.top.level.class"; @@ -54,7 +54,7 @@ public class OneTopLevelClassTest extends AbstractGoogleModuleTestSupport { } @Test - public void testGood() throws Exception { + void good() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("OneTopLevelClass"); @@ -65,7 +65,7 @@ public class OneTopLevelClassTest extends AbstractGoogleModuleTestSupport { } @Test - public void testBad1() throws Exception { + void bad1() throws Exception { final Class clazz = OneTopLevelClassCheck.class; final String messageKey = "one.top.level.class"; @@ -82,7 +82,7 @@ public class OneTopLevelClassTest extends AbstractGoogleModuleTestSupport { } @Test - public void testBad2() throws Exception { + void bad2() throws Exception { final Class clazz = OneTopLevelClassCheck.class; final String messageKey = "one.top.level.class"; --- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule3421overloadsplit/OverloadMethodsDeclarationOrderTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule3421overloadsplit/OverloadMethodsDeclarationOrderTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.coding.OverloadMethodsDeclarationO import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class OverloadMethodsDeclarationOrderTest extends AbstractGoogleModuleTestSupport { +final class OverloadMethodsDeclarationOrderTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class OverloadMethodsDeclarationOrderTest extends AbstractGoogleModuleTes } @Test - public void testOverloadMethods() throws Exception { + void overloadMethods() throws Exception { final Class clazz = OverloadMethodsDeclarationOrderCheck.class; final String messageKey = "overload.methods.declaration"; @@ -53,7 +53,7 @@ public class OverloadMethodsDeclarationOrderTest extends AbstractGoogleModuleTes } @Test - public void testOverloadMethodsDeclarationOrderPrivateAndStaticMethods() throws Exception { + void overloadMethodsDeclarationOrderPrivateAndStaticMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; --- a/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule3sourcefile/EmptyLineSeparatorTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter3filestructure/rule3sourcefile/EmptyLineSeparatorTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck; import org.junit.jupiter.api.Test; -public class EmptyLineSeparatorTest extends AbstractGoogleModuleTestSupport { +final class EmptyLineSeparatorTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class EmptyLineSeparatorTest extends AbstractGoogleModuleTestSupport { } @Test - public void testEmptyLineSeparator() throws Exception { + void emptyLineSeparator() throws Exception { final Class clazz = EmptyLineSeparatorCheck.class; final String messageKey = "empty.line.separator"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule411bracesareused/NeedBracesTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule411bracesareused/NeedBracesTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck; import org.junit.jupiter.api.Test; -public class NeedBracesTest extends AbstractGoogleModuleTestSupport { +final class NeedBracesTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class NeedBracesTest extends AbstractGoogleModuleTestSupport { } @Test - public void testNeedBraces() throws Exception { + void needBraces() throws Exception { final Class clazz = NeedBracesCheck.class; final String messageKey = "needBraces"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule412nonemptyblocks/LeftCurlyTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule412nonemptyblocks/LeftCurlyTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck; import org.junit.jupiter.api.Test; -public class LeftCurlyTest extends AbstractGoogleModuleTestSupport { +final class LeftCurlyTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class LeftCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testLeftCurlyBraces() throws Exception { + void leftCurlyBraces() throws Exception { final String[] expected = { "4:1: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 1), "7:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -53,7 +53,7 @@ public class LeftCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testLeftCurlyAnnotations() throws Exception { + void leftCurlyAnnotations() throws Exception { final String[] expected = { "10:1: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 1), "14:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -70,7 +70,7 @@ public class LeftCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testLeftCurlyMethods() throws Exception { + void leftCurlyMethods() throws Exception { final String[] expected = { "4:1: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 1), "9:5: " + getCheckMessage(LeftCurlyCheck.class, MSG_KEY_LINE_PREVIOUS, "{", 5), --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule412nonemptyblocks/RightCurlyTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule412nonemptyblocks/RightCurlyTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class RightCurlyTest extends AbstractGoogleModuleTestSupport { +final class RightCurlyTest extends AbstractGoogleModuleTestSupport { private static final String[] MODULES = { "RightCurlySame", "RightCurlyAlone", @@ -41,7 +41,7 @@ public class RightCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testRightCurly() throws Exception { + void rightCurly() throws Exception { final String[] expected = { "20:17: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 17), "32:13: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 13), @@ -58,7 +58,7 @@ public class RightCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testRightCurly2() throws Exception { + void rightCurly2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = createTreeWalkerConfig(getModuleConfigsByIds(MODULES)); @@ -69,7 +69,7 @@ public class RightCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testRightCurlyLiteralDoDefault() throws Exception { + void rightCurlyLiteralDoDefault() throws Exception { final String[] expected = { "62:9: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 9), "67:13: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 13), @@ -84,7 +84,7 @@ public class RightCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testRightCurlyOther() throws Exception { + void rightCurlyOther() throws Exception { final String[] expected = { "20:17: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 17), "32:13: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 13), @@ -101,7 +101,7 @@ public class RightCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testRightCurlyLiteralDo() throws Exception { + void rightCurlyLiteralDo() throws Exception { final String[] expected = { "62:9: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 9), "67:13: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_SAME, "}", 13), @@ -116,7 +116,7 @@ public class RightCurlyTest extends AbstractGoogleModuleTestSupport { } @Test - public void testRightCurlySwitch() throws Exception { + void rightCurlySwitch() throws Exception { final String[] expected = { "12:24: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_ALONE, "}", 24), "19:27: " + getCheckMessage(RightCurlyCheck.class, MSG_KEY_LINE_ALONE, "}", 27), --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule413emptyblocks/EmptyBlockTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule413emptyblocks/EmptyBlockTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck; import org.junit.jupiter.api.Test; -public class EmptyBlockTest extends AbstractGoogleModuleTestSupport { +final class EmptyBlockTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class EmptyBlockTest extends AbstractGoogleModuleTestSupport { } @Test - public void testEmptyBlock() throws Exception { + void emptyBlock() throws Exception { final String[] expected = { "19:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), "22:34: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "if"), @@ -77,7 +77,7 @@ public class EmptyBlockTest extends AbstractGoogleModuleTestSupport { } @Test - public void testEmptyBlockCatch() throws Exception { + void emptyBlockCatch() throws Exception { final String[] expected = { "29:17: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "finally"), "50:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "finally"), --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule413emptyblocks/EmptyCatchBlockTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule413emptyblocks/EmptyCatchBlockTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.blocks.EmptyCatchBlockCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class EmptyCatchBlockTest extends AbstractGoogleModuleTestSupport { +final class EmptyCatchBlockTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class EmptyCatchBlockTest extends AbstractGoogleModuleTestSupport { } @Test - public void testEmptyBlockCatch() throws Exception { + void emptyBlockCatch() throws Exception { final String[] expected = { "28:31: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), "49:35: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), @@ -50,7 +50,7 @@ public class EmptyCatchBlockTest extends AbstractGoogleModuleTestSupport { } @Test - public void testNoViolations() throws Exception { + void noViolations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("EmptyCatchBlock"); @@ -61,7 +61,7 @@ public class EmptyCatchBlockTest extends AbstractGoogleModuleTestSupport { } @Test - public void testViolationsByComment() throws Exception { + void violationsByComment() throws Exception { final String[] expected = { "20:9: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), "28:18: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), @@ -75,7 +75,7 @@ public class EmptyCatchBlockTest extends AbstractGoogleModuleTestSupport { } @Test - public void testViolationsByVariableName() throws Exception { + void violationsByVariableName() throws Exception { final String[] expected = { "20:9: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), "36:18: " + getCheckMessage(EmptyCatchBlockCheck.class, "catch.block.empty"), --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule43onestatement/OneStatementPerLineTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule43onestatement/OneStatementPerLineTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck; import org.junit.jupiter.api.Test; -public class OneStatementPerLineTest extends AbstractGoogleModuleTestSupport { +final class OneStatementPerLineTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class OneStatementPerLineTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOneStatement() throws Exception { + void oneStatement() throws Exception { final String msg = getCheckMessage(OneStatementPerLineCheck.class, "multiple.statements.line"); final String[] expected = { @@ -67,7 +67,7 @@ public class OneStatementPerLineTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOneStatementNonCompilableInput() throws Exception { + void oneStatementNonCompilableInput() throws Exception { final String msg = getCheckMessage(OneStatementPerLineCheck.class, "multiple.statements.line"); final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/LineLengthTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule44columnlimit/LineLengthTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck; import org.junit.jupiter.api.Test; -public class LineLengthTest extends AbstractGoogleModuleTestSupport { +final class LineLengthTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class LineLengthTest extends AbstractGoogleModuleTestSupport { } @Test - public void testLineLength() throws Exception { + void lineLength() throws Exception { final String[] expected = { "5: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 112), "29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 113), --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule451wheretobreak/MethodParamPadTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule451wheretobreak/MethodParamPadTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck; import org.junit.jupiter.api.Test; -public class MethodParamPadTest extends AbstractGoogleModuleTestSupport { +final class MethodParamPadTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class MethodParamPadTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOperatorWrap() throws Exception { + void operatorWrap() throws Exception { final Class clazz = MethodParamPadCheck.class; final String messageKeyPrevious = "line.previous"; final String messageKeyPreceded = "ws.preceded"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule451wheretobreak/OperatorWrapTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule451wheretobreak/OperatorWrapTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck; import org.junit.jupiter.api.Test; -public class OperatorWrapTest extends AbstractGoogleModuleTestSupport { +final class OperatorWrapTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class OperatorWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOperatorWrap() throws Exception { + void operatorWrap() throws Exception { final Class clazz = OperatorWrapCheck.class; final String messageKey = "line.new"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule451wheretobreak/SeparatorWrapTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule451wheretobreak/SeparatorWrapTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck; import org.junit.jupiter.api.Test; -public class SeparatorWrapTest extends AbstractGoogleModuleTestSupport { +final class SeparatorWrapTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class SeparatorWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void testSeparatorWrapDot() throws Exception { + void separatorWrapDot() throws Exception { final String[] expected = { "28:30: " + getCheckMessage(SeparatorWrapCheck.class, "line.new", "."), }; @@ -47,7 +47,7 @@ public class SeparatorWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void testSeparatorWrapComma() throws Exception { + void separatorWrapComma() throws Exception { final String[] expected = { "31:17: " + getCheckMessage(SeparatorWrapCheck.class, "line.previous", ","), }; @@ -60,7 +60,7 @@ public class SeparatorWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void testSeparatorWrapMethodRef() throws Exception { + void separatorWrapMethodRef() throws Exception { final String[] expected = { "17:49: " + getCheckMessage(SeparatorWrapCheck.class, MSG_LINE_NEW, "::"), }; @@ -73,7 +73,7 @@ public class SeparatorWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void testEllipsis() throws Exception { + void ellipsis() throws Exception { final String[] expected = { "11:13: " + getCheckMessage(SeparatorWrapCheck.class, "line.previous", "..."), }; @@ -86,7 +86,7 @@ public class SeparatorWrapTest extends AbstractGoogleModuleTestSupport { } @Test - public void testArrayDeclarator() throws Exception { + void arrayDeclarator() throws Exception { final String[] expected = { "9:13: " + getCheckMessage(SeparatorWrapCheck.class, "line.previous", "["), }; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule461verticalwhitespace/EmptyLineSeparatorTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule461verticalwhitespace/EmptyLineSeparatorTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck; import org.junit.jupiter.api.Test; -public class EmptyLineSeparatorTest extends AbstractGoogleModuleTestSupport { +final class EmptyLineSeparatorTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class EmptyLineSeparatorTest extends AbstractGoogleModuleTestSupport { } @Test - public void testEmptyLineSeparator() throws Exception { + void emptyLineSeparator() throws Exception { final Class clazz = EmptyLineSeparatorCheck.class; final String messageKey = "empty.line.separator"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/GenericWhitespaceTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/GenericWhitespaceTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.Map; import org.junit.jupiter.api.Test; -public class GenericWhitespaceTest extends AbstractGoogleModuleTestSupport { +final class GenericWhitespaceTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class GenericWhitespaceTest extends AbstractGoogleModuleTestSupport { } @Test - public void testWhitespaceAroundGenerics() throws Exception { + void whitespaceAroundGenerics() throws Exception { final String msgPreceded = "ws.preceded"; final String msgFollowed = "ws.followed"; final Configuration checkConfig = getModuleConfig("GenericWhitespace"); @@ -66,7 +66,7 @@ public class GenericWhitespaceTest extends AbstractGoogleModuleTestSupport { } @Test - public void testGenericWhitespace() throws Exception { + void genericWhitespace() throws Exception { final String msgPreceded = "ws.preceded"; final String msgFollowed = "ws.followed"; final String msgNotPreceded = "ws.notPreceded"; @@ -112,7 +112,7 @@ public class GenericWhitespaceTest extends AbstractGoogleModuleTestSupport { } @Test - public void genericEndsTheLine() throws Exception { + void genericEndsTheLine() throws Exception { final Configuration checkConfig = getModuleConfig("GenericWhitespace"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verify(checkConfig, getPath("InputGenericWhitespaceEndsTheLine.java"), expected); --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/MethodParamPadTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/MethodParamPadTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck; import org.junit.jupiter.api.Test; -public class MethodParamPadTest extends AbstractGoogleModuleTestSupport { +final class MethodParamPadTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class MethodParamPadTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOperatorWrap() throws Exception { + void operatorWrap() throws Exception { final Class clazz = MethodParamPadCheck.class; final String messageKeyPreceded = "ws.preceded"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/NoWhitespaceBeforeCaseDefaultColonTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/NoWhitespaceBeforeCaseDefaultColonTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck; import org.junit.jupiter.api.Test; -public class NoWhitespaceBeforeCaseDefaultColonTest extends AbstractGoogleModuleTestSupport { +final class NoWhitespaceBeforeCaseDefaultColonTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class NoWhitespaceBeforeCaseDefaultColonTest extends AbstractGoogleModule } @Test - public void test() throws Exception { + void test() throws Exception { final Class clazz = NoWhitespaceBeforeCheck.class; final String messageKeyPreceded = "ws.preceded"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/NoWhitespaceBeforeTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/NoWhitespaceBeforeTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NoWhitespaceBeforeTest extends AbstractGoogleModuleTestSupport { +final class NoWhitespaceBeforeTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class NoWhitespaceBeforeTest extends AbstractGoogleModuleTestSupport { } @Test - public void testEmptyForLoop() throws Exception { + void emptyForLoop() throws Exception { final Class clazz = NoWhitespaceBeforeCheck.class; final String messageKeyPreceded = "ws.preceded"; @@ -49,7 +49,7 @@ public class NoWhitespaceBeforeTest extends AbstractGoogleModuleTestSupport { } @Test - public void testColonOfLabel() throws Exception { + void colonOfLabel() throws Exception { final Class clazz = NoWhitespaceBeforeCheck.class; final String messageKeyPreceded = "ws.preceded"; @@ -64,7 +64,7 @@ public class NoWhitespaceBeforeTest extends AbstractGoogleModuleTestSupport { } @Test - public void testAnnotations() throws Exception { + void annotations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("NoWhitespaceBefore"); final String filePath = getPath("InputNoWhitespaceBeforeAnnotations.java"); --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/ParenPadTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/ParenPadTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck; import org.junit.jupiter.api.Test; -public class ParenPadTest extends AbstractGoogleModuleTestSupport { +final class ParenPadTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class ParenPadTest extends AbstractGoogleModuleTestSupport { } @Test - public void testMethodParen() throws Exception { + void methodParen() throws Exception { final Class clazz = ParenPadCheck.class; final String messageKeyPreceded = "ws.preceded"; final String messageKeyFollowed = "ws.followed"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/WhitespaceAfterTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/WhitespaceAfterTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class WhitespaceAfterTest extends AbstractGoogleModuleTestSupport { +final class WhitespaceAfterTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class WhitespaceAfterTest extends AbstractGoogleModuleTestSupport { } @Test - public void testWhitespaceAfterBad() throws Exception { + void whitespaceAfterBad() throws Exception { final Class clazz = WhitespaceAfterCheck.class; final String message = "ws.notFollowed"; @@ -70,7 +70,7 @@ public class WhitespaceAfterTest extends AbstractGoogleModuleTestSupport { } @Test - public void testWhitespaceAfterGood() throws Exception { + void whitespaceAfterGood() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("WhitespaceAfter"); final String filePath = getPath("InputWhitespaceAfterGood.java"); --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/WhitespaceAroundTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule462horizontalwhitespace/WhitespaceAroundTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.Map; import org.junit.jupiter.api.Test; -public class WhitespaceAroundTest extends AbstractGoogleModuleTestSupport { +final class WhitespaceAroundTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class WhitespaceAroundTest extends AbstractGoogleModuleTestSupport { } @Test - public void testWhitespaceAroundBasic() throws Exception { + void whitespaceAroundBasic() throws Exception { final Configuration checkConfig = getModuleConfig("WhitespaceAround"); final String msgPreceded = "ws.notPreceded"; final String msgFollowed = "ws.notFollowed"; @@ -75,7 +75,7 @@ public class WhitespaceAroundTest extends AbstractGoogleModuleTestSupport { } @Test - public void testWhitespaceAroundEmptyTypesCycles() throws Exception { + void whitespaceAroundEmptyTypesCycles() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("WhitespaceAround"); --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4821onevariableperline/MultipleVariableDeclarationsTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4821onevariableperline/MultipleVariableDeclarationsTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck; import org.junit.jupiter.api.Test; -public class MultipleVariableDeclarationsTest extends AbstractGoogleModuleTestSupport { +final class MultipleVariableDeclarationsTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class MultipleVariableDeclarationsTest extends AbstractGoogleModuleTestSu } @Test - public void testMultipleVariableDeclarations() throws Exception { + void multipleVariableDeclarations() throws Exception { final String msgComma = getCheckMessage( MultipleVariableDeclarationsCheck.class, "multiple.variable.declarations.comma"); --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4822variabledistance/VariableDeclarationUsageDistanceTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4822variabledistance/VariableDeclarationUsageDistanceTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.coding.VariableDeclarationUsageDistanceCheck; import org.junit.jupiter.api.Test; -public class VariableDeclarationUsageDistanceTest extends AbstractGoogleModuleTestSupport { +final class VariableDeclarationUsageDistanceTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class VariableDeclarationUsageDistanceTest extends AbstractGoogleModuleTe } @Test - public void testArrayTypeStyle() throws Exception { + void arrayTypeStyle() throws Exception { final String msgExt = "variable.declaration.usage.distance.extend"; final Class clazz = VariableDeclarationUsageDistanceCheck.class; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4832nocstylearray/ArrayTypeStyleTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4832nocstylearray/ArrayTypeStyleTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck; import org.junit.jupiter.api.Test; -public class ArrayTypeStyleTest extends AbstractGoogleModuleTestSupport { +final class ArrayTypeStyleTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class ArrayTypeStyleTest extends AbstractGoogleModuleTestSupport { } @Test - public void testArrayTypeStyle() throws Exception { + void arrayTypeStyle() throws Exception { final String[] expected = { "9:23: " + getCheckMessage(ArrayTypeStyleCheck.class, MSG_KEY), "15:44: " + getCheckMessage(ArrayTypeStyleCheck.class, MSG_KEY), --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4841indentation/IndentationTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4841indentation/IndentationTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class IndentationTest extends AbstractIndentationTestSupport { +final class IndentationTest extends AbstractIndentationTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectClass() throws Exception { + void correctClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -47,7 +47,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectField() throws Exception { + void correctField() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -58,7 +58,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectFor() throws Exception { + void correctFor() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -69,7 +69,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectIf() throws Exception { + void correctIf() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -80,7 +80,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectNewKeyword() throws Exception { + void correctNewKeyword() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -91,7 +91,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -102,7 +102,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectReturn() throws Exception { + void correctReturn() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -113,7 +113,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectWhile() throws Exception { + void correctWhile() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -124,7 +124,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectChained() throws Exception { + void correctChained() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); @@ -135,7 +135,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testWarnChained() throws Exception { + void warnChained() throws Exception { final String[] expected = { "18:5: " + getCheckMessage(IndentationCheck.class, MSG_CHILD_ERROR, "method call", 4, 8), "23:5: " + getCheckMessage(IndentationCheck.class, MSG_ERROR, ".", 4, 8), @@ -151,7 +151,7 @@ public class IndentationTest extends AbstractIndentationTestSupport { } @Test - public void testCorrectAnnotationArrayInit() throws Exception { + void correctAnnotationArrayInit() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("Indentation"); --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4842fallthrough/FallThroughTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4842fallthrough/FallThroughTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck; import org.junit.jupiter.api.Test; -public class FallThroughTest extends AbstractGoogleModuleTestSupport { +final class FallThroughTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class FallThroughTest extends AbstractGoogleModuleTestSupport { } @Test - public void testFallThrough() throws Exception { + void fallThrough() throws Exception { final String msg = getCheckMessage(FallThroughCheck.class, "fall.through"); final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4843defaultcasepresent/MissingSwitchDefaultTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4843defaultcasepresent/MissingSwitchDefaultTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.coding.MissingSwitchDefaultCheck; import org.junit.jupiter.api.Test; -public class MissingSwitchDefaultTest extends AbstractGoogleModuleTestSupport { +final class MissingSwitchDefaultTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class MissingSwitchDefaultTest extends AbstractGoogleModuleTestSupport { } @Test - public void testMissingSwitchDefault() throws Exception { + void missingSwitchDefault() throws Exception { final String msg = getCheckMessage(MissingSwitchDefaultCheck.class, "missing.switch.default"); final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule485annotations/AnnotationLocationTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule485annotations/AnnotationLocationTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck; import org.junit.jupiter.api.Test; -public class AnnotationLocationTest extends AbstractGoogleModuleTestSupport { +final class AnnotationLocationTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class AnnotationLocationTest extends AbstractGoogleModuleTestSupport { } @Test - public void testAnnotation() throws Exception { + void annotation() throws Exception { final Class clazz = AnnotationLocationCheck.class; getCheckMessage(clazz, "annotation.location.alone"); final Configuration checkConfig = @@ -62,7 +62,7 @@ public class AnnotationLocationTest extends AbstractGoogleModuleTestSupport { } @Test - public void testAnnotationVariables() throws Exception { + void annotationVariables() throws Exception { final Class clazz = AnnotationLocationCheck.class; getCheckMessage(clazz, "annotation.location.alone"); final Configuration checkConfig = --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4861blockcommentstyle/CommentsIndentationTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule4861blockcommentstyle/CommentsIndentationTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheck; import org.junit.jupiter.api.Test; -public class CommentsIndentationTest extends AbstractGoogleModuleTestSupport { +final class CommentsIndentationTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class CommentsIndentationTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCommentIsAtTheEndOfBlock() throws Exception { + void commentIsAtTheEndOfBlock() throws Exception { final String[] expected = { "18:26: " + getCheckMessage( @@ -125,7 +125,7 @@ public class CommentsIndentationTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCommentIsInsideSwitchBlock() throws Exception { + void commentIsInsideSwitchBlock() throws Exception { final String[] expected = { "19:13: " + getCheckMessage( @@ -228,7 +228,7 @@ public class CommentsIndentationTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCommentIsInsideEmptyBlock() throws Exception { + void commentIsInsideEmptyBlock() throws Exception { final String[] expected = { "9:20: " + getCheckMessage( @@ -255,7 +255,7 @@ public class CommentsIndentationTest extends AbstractGoogleModuleTestSupport { } @Test - public void testSurroundingCode() throws Exception { + void surroundingCode() throws Exception { final String[] expected = { "13:15: " + getCheckMessage( --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule487modifiers/ModifierOrderTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule487modifiers/ModifierOrderTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.modifier.ModifierOrderCheck; import org.junit.jupiter.api.Test; -public class ModifierOrderTest extends AbstractGoogleModuleTestSupport { +final class ModifierOrderTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class ModifierOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testModifierOrder() throws Exception { + void modifierOrder() throws Exception { final Class clazz = ModifierOrderCheck.class; final String msgMod = "mod.order"; final String msgAnnotation = "annotation.order"; --- a/src/it/java/com/google/checkstyle/test/chapter4formatting/rule488numericliterals/UpperEllTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter4formatting/rule488numericliterals/UpperEllTest.java @@ -23,7 +23,7 @@ import com.google.checkstyle.test.base.AbstractGoogleModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.Configuration; import org.junit.jupiter.api.Test; -public class UpperEllTest extends AbstractGoogleModuleTestSupport { +final class UpperEllTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,7 +31,7 @@ public class UpperEllTest extends AbstractGoogleModuleTestSupport { } @Test - public void testUpperEll() throws Exception { + void upperEll() throws Exception { final String[] expected = { "6:33: Should use uppercase 'L'.", "12:25: Should use uppercase 'L'.", --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule51identifiernames/CatchParameterNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule51identifiernames/CatchParameterNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class CatchParameterNameTest extends AbstractGoogleModuleTestSupport { +final class CatchParameterNameTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class CatchParameterNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCatchParameterName() throws Exception { + void catchParameterName() throws Exception { final String msgKey = "name.invalidPattern"; final Configuration checkConfig = getModuleConfig("CatchParameterName"); final String format = checkConfig.getProperty("format"); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule521packagenames/PackageNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule521packagenames/PackageNameTest.java @@ -26,7 +26,7 @@ import java.io.File; import java.io.IOException; import org.junit.jupiter.api.Test; -public class PackageNameTest extends AbstractGoogleModuleTestSupport { +final class PackageNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -40,7 +40,7 @@ public class PackageNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testGoodPackageName() throws Exception { + void goodPackageName() throws Exception { final Configuration checkConfig = getModuleConfig("PackageName"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -51,7 +51,7 @@ public class PackageNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testBadPackageName() throws Exception { + void badPackageName() throws Exception { final String packagePath = "com.google.checkstyle.test.chapter5naming.rule521packageNamesCamelCase"; final Configuration checkConfig = getModuleConfig("PackageName"); @@ -69,7 +69,7 @@ public class PackageNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testBadPackageName2() throws Exception { + void badPackageName2() throws Exception { final String packagePath = "com.google.checkstyle.test.chapter5naming.rule521_packagenames"; final Configuration checkConfig = getModuleConfig("PackageName"); final String format = checkConfig.getProperty("format"); @@ -86,7 +86,7 @@ public class PackageNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testBadPackageName3() throws Exception { + void badPackageName3() throws Exception { final String packagePath = "com.google.checkstyle.test.chapter5naming.rule521$packagenames"; final Configuration checkConfig = getModuleConfig("PackageName"); final String format = checkConfig.getProperty("format"); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule522typenames/TypeNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule522typenames/TypeNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class TypeNameTest extends AbstractGoogleModuleTestSupport { +final class TypeNameTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class TypeNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testTypeName() throws Exception { + void typeName() throws Exception { final Configuration checkConfig = getModuleConfig("TypeName"); final String msgKey = "name.invalidPattern"; final String format = "^[A-Z][a-zA-Z0-9]*$"; --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule523methodnames/MethodNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule523methodnames/MethodNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class MethodNameTest extends AbstractGoogleModuleTestSupport { +final class MethodNameTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class MethodNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testMethodName() throws Exception { + void methodName() throws Exception { final Configuration checkConfig = getModuleConfig("MethodName"); final String msgKey = "name.invalidPattern"; final String format = "^[a-z][a-z0-9]\\w*$"; --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule525nonconstantfieldnames/MemberNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule525nonconstantfieldnames/MemberNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class MemberNameTest extends AbstractGoogleModuleTestSupport { +final class MemberNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class MemberNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testMemberName() throws Exception { + void memberName() throws Exception { final Configuration checkConfig = getModuleConfig("MemberName"); final String format = checkConfig.getProperty("format"); final Map messages = checkConfig.getMessages(); @@ -61,7 +61,7 @@ public class MemberNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testSimple() throws Exception { + void simple() throws Exception { final Configuration checkConfig = getModuleConfig("MemberName"); final String format = checkConfig.getProperty("format"); final Map messages = checkConfig.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule526parameternames/LambdaParameterNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule526parameternames/LambdaParameterNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class LambdaParameterNameTest extends AbstractGoogleModuleTestSupport { +final class LambdaParameterNameTest extends AbstractGoogleModuleTestSupport { public static final String MSG_INVALID_PATTERN = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class LambdaParameterNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testLambdaParameterName() throws Exception { + void lambdaParameterName() throws Exception { final Configuration config = getModuleConfig("LambdaParameterName"); final String format = config.getProperty("format"); final Map messages = config.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule526parameternames/ParameterNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule526parameternames/ParameterNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class ParameterNameTest extends AbstractGoogleModuleTestSupport { +final class ParameterNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class ParameterNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testGeneralParameterName() throws Exception { + void generalParameterName() throws Exception { final Configuration config = getModuleConfig("ParameterName"); final String format = config.getProperty("format"); final Map messages = config.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule526parameternames/RecordComponentNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule526parameternames/RecordComponentNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class RecordComponentNameTest extends AbstractGoogleModuleTestSupport { +final class RecordComponentNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class RecordComponentNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testGeneralParameterName() throws Exception { + void generalParameterName() throws Exception { final Configuration config = getModuleConfig("RecordComponentName"); final String format = config.getProperty("format"); final Map messages = config.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule527localvariablenames/LocalVariableNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule527localvariablenames/LocalVariableNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class LocalVariableNameTest extends AbstractGoogleModuleTestSupport { +final class LocalVariableNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class LocalVariableNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testLocalVariableName() throws Exception { + void localVariableName() throws Exception { final Configuration checkConfig = getModuleConfig("LocalVariableName"); final String format = checkConfig.getProperty("format"); final Map messages = checkConfig.getMessages(); @@ -58,7 +58,7 @@ public class LocalVariableNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testOneChar() throws Exception { + void oneChar() throws Exception { final Configuration checkConfig = getModuleConfig("LocalVariableName"); final String format = checkConfig.getProperty("format"); final Map messages = checkConfig.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule527localvariablenames/PatternVariableNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule527localvariablenames/PatternVariableNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class PatternVariableNameTest extends AbstractGoogleModuleTestSupport { +final class PatternVariableNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class PatternVariableNameTest extends AbstractGoogleModuleTestSupport { } @Test - public void testPatternVariableName() throws Exception { + void patternVariableName() throws Exception { final Configuration checkConfig = getModuleConfig("PatternVariableName"); final String format = checkConfig.getProperty("format"); final Map messages = checkConfig.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/ClassTypeParameterNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/ClassTypeParameterNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class ClassTypeParameterNameTest extends AbstractGoogleModuleTestSupport { +final class ClassTypeParameterNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class ClassTypeParameterNameTest extends AbstractGoogleModuleTestSupport } @Test - public void testClassDefault() throws Exception { + void classDefault() throws Exception { final Configuration configuration = getModuleConfig("ClassTypeParameterName"); final String format = configuration.getProperty("format"); final Map messages = configuration.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/InterfaceTypeParameterNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/InterfaceTypeParameterNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class InterfaceTypeParameterNameTest extends AbstractGoogleModuleTestSupport { +final class InterfaceTypeParameterNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class InterfaceTypeParameterNameTest extends AbstractGoogleModuleTestSupp } @Test - public void testInterfaceDefault() throws Exception { + void interfaceDefault() throws Exception { final Configuration configuration = getModuleConfig("InterfaceTypeParameterName"); final String format = configuration.getProperty("format"); final Map messages = configuration.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/MethodTypeParameterNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/MethodTypeParameterNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class MethodTypeParameterNameTest extends AbstractGoogleModuleTestSupport { +final class MethodTypeParameterNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class MethodTypeParameterNameTest extends AbstractGoogleModuleTestSupport } @Test - public void testMethodDefault() throws Exception { + void methodDefault() throws Exception { final Configuration checkConfig = getModuleConfig("MethodTypeParameterName"); final String format = checkConfig.getProperty("format"); final Map messages = checkConfig.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/RecordTypeParameterNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule528typevariablenames/RecordTypeParameterNameTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import java.util.Map; import org.junit.jupiter.api.Test; -public class RecordTypeParameterNameTest extends AbstractGoogleModuleTestSupport { +final class RecordTypeParameterNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "name.invalidPattern"; @@ -34,7 +34,7 @@ public class RecordTypeParameterNameTest extends AbstractGoogleModuleTestSupport } @Test - public void testRecordDefault() throws Exception { + void recordDefault() throws Exception { final Configuration configuration = getModuleConfig("RecordTypeParameterName"); final String format = configuration.getProperty("format"); final Map messages = configuration.getMessages(); --- a/src/it/java/com/google/checkstyle/test/chapter5naming/rule53camelcase/AbbreviationAsWordInNameTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter5naming/rule53camelcase/AbbreviationAsWordInNameTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.naming.AbbreviationAsWordInNameChe import java.io.IOException; import org.junit.jupiter.api.Test; -public class AbbreviationAsWordInNameTest extends AbstractGoogleModuleTestSupport { +final class AbbreviationAsWordInNameTest extends AbstractGoogleModuleTestSupport { private static final String MSG_KEY = "abbreviation.as.word"; private final Class clazz = AbbreviationAsWordInNameCheck.class; @@ -36,7 +36,7 @@ public class AbbreviationAsWordInNameTest extends AbstractGoogleModuleTestSuppor } @Test - public void testAbbreviationAsWordInName() throws Exception { + void abbreviationAsWordInName() throws Exception { final int maxCapitalCount = 1; final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter6programpractice/rule62donotignoreexceptions/EmptyBlockTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter6programpractice/rule62donotignoreexceptions/EmptyBlockTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck; import org.junit.jupiter.api.Test; -public class EmptyBlockTest extends AbstractGoogleModuleTestSupport { +final class EmptyBlockTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class EmptyBlockTest extends AbstractGoogleModuleTestSupport { } @Test - public void testEmptyBlockCatch() throws Exception { + void emptyBlockCatch() throws Exception { final String[] expected = { "29:17: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "finally"), "50:21: " + getCheckMessage(EmptyBlockCheck.class, "block.empty", "finally"), --- a/src/it/java/com/google/checkstyle/test/chapter6programpractice/rule64finalizers/NoFinalizerTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter6programpractice/rule64finalizers/NoFinalizerTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.coding.NoFinalizerCheck; import org.junit.jupiter.api.Test; -public class NoFinalizerTest extends AbstractGoogleModuleTestSupport { +final class NoFinalizerTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class NoFinalizerTest extends AbstractGoogleModuleTestSupport { } @Test - public void testNoFinalizerBasic() throws Exception { + void noFinalizerBasic() throws Exception { final String msg = getCheckMessage(NoFinalizerCheck.class, "avoid.finalizer.method"); final String[] expected = { @@ -47,7 +47,7 @@ public class NoFinalizerTest extends AbstractGoogleModuleTestSupport { } @Test - public void testNoFinalizerExtended() throws Exception { + void noFinalizerExtended() throws Exception { final String msg = getCheckMessage(NoFinalizerCheck.class, "avoid.finalizer.method"); final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule711generalform/InvalidJavadocPositionTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule711generalform/InvalidJavadocPositionTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck; import org.junit.jupiter.api.Test; -public class InvalidJavadocPositionTest extends AbstractGoogleModuleTestSupport { +final class InvalidJavadocPositionTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class InvalidJavadocPositionTest extends AbstractGoogleModuleTestSupport } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String message = getCheckMessage(InvalidJavadocPositionCheck.class, "invalid.position"); final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule711generalform/SingleLineJavadocTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule711generalform/SingleLineJavadocTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.javadoc.SingleLineJavadocCheck; import org.junit.jupiter.api.Test; -public class SingleLineJavadocTest extends AbstractGoogleModuleTestSupport { +final class SingleLineJavadocTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class SingleLineJavadocTest extends AbstractGoogleModuleTestSupport { } @Test - public void testSingleLineJavadoc() throws Exception { + void singleLineJavadoc() throws Exception { final String msg = getCheckMessage(SingleLineJavadocCheck.class, "singleline.javadoc"); final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule712paragraphs/JavadocParagraphTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule712paragraphs/JavadocParagraphTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocParagraphTest extends AbstractGoogleModuleTestSupport { +final class JavadocParagraphTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class JavadocParagraphTest extends AbstractGoogleModuleTestSupport { } @Test - public void testJavadocParagraphCorrect() throws Exception { + void javadocParagraphCorrect() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("JavadocParagraph"); @@ -44,7 +44,7 @@ public class JavadocParagraphTest extends AbstractGoogleModuleTestSupport { } @Test - public void testJavadocParagraphIncorrect() throws Exception { + void javadocParagraphIncorrect() throws Exception { final String msgBefore = getCheckMessage(JavadocParagraphCheck.class, "javadoc.paragraph.line.before"); final String msgRed = --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule712paragraphs/RequireEmptyLineBeforeBlockTagGroupTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule712paragraphs/RequireEmptyLineBeforeBlockTagGroupTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.IOException; import org.junit.jupiter.api.Test; -public class RequireEmptyLineBeforeBlockTagGroupTest extends AbstractGoogleModuleTestSupport { +final class RequireEmptyLineBeforeBlockTagGroupTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class RequireEmptyLineBeforeBlockTagGroupTest extends AbstractGoogleModul } @Test - public void testJavadocParagraphCorrect() throws Exception { + void javadocParagraphCorrect() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("RequireEmptyLineBeforeBlockTagGroup"); @@ -45,7 +45,7 @@ public class RequireEmptyLineBeforeBlockTagGroupTest extends AbstractGoogleModul } @Test - public void testJavadocParagraphIncorrect() throws Exception { + void javadocParagraphIncorrect() throws Exception { final String[] expected = { "5: " + getTagCheckMessage("@since"), "11: " + getTagCheckMessage("@param"), --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule713atclauses/AtclauseOrderTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule713atclauses/AtclauseOrderTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.javadoc.AtclauseOrderCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class AtclauseOrderTest extends AbstractGoogleModuleTestSupport { +final class AtclauseOrderTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class AtclauseOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCorrect1() throws Exception { + void correct1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("AtclauseOrder"); @@ -44,7 +44,7 @@ public class AtclauseOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCorrect2() throws Exception { + void correct2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("AtclauseOrder"); @@ -55,7 +55,7 @@ public class AtclauseOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCorrect3() throws Exception { + void correct3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("AtclauseOrder"); @@ -66,7 +66,7 @@ public class AtclauseOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testIncorrect1() throws Exception { + void incorrect1() throws Exception { final String tagOrder = "[@param, @return, @throws, @deprecated]"; final String msg = getCheckMessage(AtclauseOrderCheck.class, "at.clause.order", tagOrder); @@ -90,7 +90,7 @@ public class AtclauseOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testIncorrect2() throws Exception { + void incorrect2() throws Exception { final String tagOrder = "[@param, @return, @throws, @deprecated]"; final String msg = getCheckMessage(AtclauseOrderCheck.class, "at.clause.order", tagOrder); @@ -112,7 +112,7 @@ public class AtclauseOrderTest extends AbstractGoogleModuleTestSupport { } @Test - public void testIncorrect3() throws Exception { + void incorrect3() throws Exception { final String tagOrder = "[@param, @return, @throws, @deprecated]"; final String msg = getCheckMessage(AtclauseOrderCheck.class, "at.clause.order", tagOrder); --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule713atclauses/JavadocTagContinuationIndentationTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule713atclauses/JavadocTagContinuationIndentationTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTagContinuationIndentationCheck; import org.junit.jupiter.api.Test; -public class JavadocTagContinuationIndentationTest extends AbstractGoogleModuleTestSupport { +final class JavadocTagContinuationIndentationTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class JavadocTagContinuationIndentationTest extends AbstractGoogleModuleT } @Test - public void testWithDefaultConfiguration() throws Exception { + void withDefaultConfiguration() throws Exception { final String msg = getCheckMessage(JavadocTagContinuationIndentationCheck.class, "tag.continuation.indent", 4); --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule713atclauses/NonEmptyAtclauseDescriptionTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule713atclauses/NonEmptyAtclauseDescriptionTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.javadoc.NonEmptyAtclauseDescriptionCheck; import org.junit.jupiter.api.Test; -public class NonEmptyAtclauseDescriptionTest extends AbstractGoogleModuleTestSupport { +final class NonEmptyAtclauseDescriptionTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class NonEmptyAtclauseDescriptionTest extends AbstractGoogleModuleTestSup } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String msg = getCheckMessage(NonEmptyAtclauseDescriptionCheck.class, "non.empty.atclause"); @@ -58,7 +58,7 @@ public class NonEmptyAtclauseDescriptionTest extends AbstractGoogleModuleTestSup } @Test - public void testSpaceSequence() throws Exception { + void spaceSequence() throws Exception { final String msg = getCheckMessage(NonEmptyAtclauseDescriptionCheck.class, "non.empty.atclause"); --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule72thesummaryfragment/SummaryJavadocTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule72thesummaryfragment/SummaryJavadocTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class SummaryJavadocTest extends AbstractGoogleModuleTestSupport { +final class SummaryJavadocTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class SummaryJavadocTest extends AbstractGoogleModuleTestSupport { } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final Configuration checkConfig = getModuleConfig("SummaryJavadoc"); @@ -44,7 +44,7 @@ public class SummaryJavadocTest extends AbstractGoogleModuleTestSupport { } @Test - public void testIncorrect() throws Exception { + void incorrect() throws Exception { final String msgFirstSentence = getCheckMessage(SummaryJavadocCheck.class, "summary.first.sentence"); final String msgForbiddenFragment = --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule731selfexplanatory/JavadocMethodTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule731selfexplanatory/JavadocMethodTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocMethodTest extends AbstractGoogleModuleTestSupport { +final class JavadocMethodTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class JavadocMethodTest extends AbstractGoogleModuleTestSupport { } @Test - public void testJavadocMethod() throws Exception { + void javadocMethod() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule731selfexplanatory/MissingJavadocMethodTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule731selfexplanatory/MissingJavadocMethodTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck; import org.junit.jupiter.api.Test; -public class MissingJavadocMethodTest extends AbstractGoogleModuleTestSupport { +final class MissingJavadocMethodTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class MissingJavadocMethodTest extends AbstractGoogleModuleTestSupport { } @Test - public void testJavadocMethod() throws Exception { + void javadocMethod() throws Exception { final String msg = getCheckMessage(MissingJavadocMethodCheck.class, "javadoc.missing"); final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule734nonrequiredjavadoc/InvalidJavadocPositionTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule734nonrequiredjavadoc/InvalidJavadocPositionTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck; import org.junit.jupiter.api.Test; -public class InvalidJavadocPositionTest extends AbstractGoogleModuleTestSupport { +final class InvalidJavadocPositionTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class InvalidJavadocPositionTest extends AbstractGoogleModuleTestSupport } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String message = getCheckMessage(InvalidJavadocPositionCheck.class, "invalid.position"); final String[] expected = { --- a/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule73wherejavadocrequired/MissingJavadocTypeTest.java +++ b/src/it/java/com/google/checkstyle/test/chapter7javadoc/rule73wherejavadocrequired/MissingJavadocTypeTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocTypeCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MissingJavadocTypeTest extends AbstractGoogleModuleTestSupport { +final class MissingJavadocTypeTest extends AbstractGoogleModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class MissingJavadocTypeTest extends AbstractGoogleModuleTestSupport { } @Test - public void testJavadocType() throws Exception { + void javadocType() throws Exception { final String[] expected = { "3:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), @@ -58,7 +58,7 @@ public class MissingJavadocTypeTest extends AbstractGoogleModuleTestSupport { } @Test - public void testJavadocTypeNoViolations() throws Exception { + void javadocTypeNoViolations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; --- a/src/it/java/com/sun/checkstyle/test/chapter5comments/rule52documentationcomments/InvalidJavadocPositionTest.java +++ b/src/it/java/com/sun/checkstyle/test/chapter5comments/rule52documentationcomments/InvalidJavadocPositionTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionChec import com.sun.checkstyle.test.base.AbstractSunModuleTestSupport; import org.junit.jupiter.api.Test; -public class InvalidJavadocPositionTest extends AbstractSunModuleTestSupport { +final class InvalidJavadocPositionTest extends AbstractSunModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class InvalidJavadocPositionTest extends AbstractSunModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String message = getCheckMessage(InvalidJavadocPositionCheck.class, "invalid.position"); final String[] expected = { --- a/src/it/java/com/sun/checkstyle/test/chapter6declarations/rule61numberperline/MultipleVariableDeclarationsTest.java +++ b/src/it/java/com/sun/checkstyle/test/chapter6declarations/rule61numberperline/MultipleVariableDeclarationsTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclaration import com.sun.checkstyle.test.base.AbstractSunModuleTestSupport; import org.junit.jupiter.api.Test; -public class MultipleVariableDeclarationsTest extends AbstractSunModuleTestSupport { +final class MultipleVariableDeclarationsTest extends AbstractSunModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class MultipleVariableDeclarationsTest extends AbstractSunModuleTestSuppo } @Test - public void testMultipleVariableDeclarations() throws Exception { + void multipleVariableDeclarations() throws Exception { final String msgComma = getCheckMessage( MultipleVariableDeclarationsCheck.class, "multiple.variable.declarations.comma"); --- a/src/it/java/org/checkstyle/base/AbstractItModuleTestSupport.java +++ b/src/it/java/org/checkstyle/base/AbstractItModuleTestSupport.java @@ -20,6 +20,7 @@ package org.checkstyle.base; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractPathTestSupport; import com.puppycrawl.tools.checkstyle.Checker; @@ -39,7 +40,7 @@ import java.io.InputStreamReader; import java.io.LineNumberReader; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collections; @@ -397,8 +398,7 @@ public abstract class AbstractItModuleTestSupport extends AbstractPathTestSuppor // process each of the lines try (ByteArrayInputStream inputStream = new ByteArrayInputStream(stream.toByteArray()); - LineNumberReader lnr = - new LineNumberReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { + LineNumberReader lnr = new LineNumberReader(new InputStreamReader(inputStream, UTF_8))) { int previousLineNumber = 0; for (int index = 0; index < expected.length; index++) { final String expectedResult = messageFileName + ":" + expected[index]; @@ -493,7 +493,7 @@ public abstract class AbstractItModuleTestSupport extends AbstractPathTestSuppor */ protected Integer[] getLinesWithWarn(String fileName) throws IOException { final List result = new ArrayList<>(); - try (BufferedReader br = Files.newBufferedReader(Paths.get(fileName), StandardCharsets.UTF_8)) { + try (BufferedReader br = Files.newBufferedReader(Path.of(fileName), UTF_8)) { int lineNumber = 1; while (true) { final String line = br.readLine(); --- a/src/it/java/org/checkstyle/checks/imports/ImportOrderTest.java +++ b/src/it/java/org/checkstyle/checks/imports/ImportOrderTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.checkstyle.base.AbstractCheckstyleModuleTestSupport; import org.junit.jupiter.api.Test; -public class ImportOrderTest extends AbstractCheckstyleModuleTestSupport { +final class ImportOrderTest extends AbstractCheckstyleModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class ImportOrderTest extends AbstractCheckstyleModuleTestSupport { } @Test - public void testAndroid() throws Exception { + void android() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); checkConfig.addProperty( "groups", "android,androidx,com.android,dalvik,com,gov,junit,libcore,net,org,java,javax"); @@ -52,7 +52,7 @@ public class ImportOrderTest extends AbstractCheckstyleModuleTestSupport { } @Test - public void testSpotify() throws Exception { + void spotify() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); checkConfig.addProperty("groups", "android,com,net,junit,org,java,javax"); checkConfig.addProperty("option", "bottom"); @@ -68,7 +68,7 @@ public class ImportOrderTest extends AbstractCheckstyleModuleTestSupport { } @Test - public void testTwitter() throws Exception { + void twitter() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); checkConfig.addProperty("caseSensitive", "true"); checkConfig.addProperty("groups", "android,com.twitter,com,junit,net,org,java,javax"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/AbstractXpathTestSupport.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/AbstractXpathTestSupport.java @@ -20,6 +20,7 @@ package org.checkstyle.suppressionxpathfilter; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.JavaParser; @@ -114,7 +115,7 @@ public abstract class AbstractXpathTestSupport extends AbstractCheckstyleModuleT private String createSuppressionsXpathConfigFile(String checkName, List xpathQueries) throws Exception { final Path suppressionsXpathConfigPath = Files.createTempFile(temporaryFolder, "", ""); - try (Writer bw = Files.newBufferedWriter(suppressionsXpathConfigPath, StandardCharsets.UTF_8)) { + try (Writer bw = Files.newBufferedWriter(suppressionsXpathConfigPath, UTF_8)) { bw.write("\n"); bw.write(" expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameAnnotation']]" + "/OBJBLOCK/ANNOTATION_DEF/IDENT[@text='ANNOTATION']"); @@ -62,7 +62,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe } @Test - public void testAnnotationField() throws Exception { + void annotationField() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbbreviationAsWordInNameAnnotationField.java")); @@ -79,7 +79,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/ANNOTATION_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameAnnotationField']]" + "/OBJBLOCK/ANNOTATION_FIELD_DEF/IDENT[@text='ANNOTATION_FIELD']"); @@ -88,7 +88,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe } @Test - public void testClass() throws Exception { + void testClass() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbbreviationAsWordInNameClass.java")); @@ -105,7 +105,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameClass']]" + "/OBJBLOCK/CLASS_DEF/IDENT[@text='CLASS']"); @@ -114,7 +114,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe } @Test - public void testEnum() throws Exception { + void testEnum() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbbreviationAsWordInNameEnum.java")); @@ -131,7 +131,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameEnum']]" + "/OBJBLOCK/ENUM_DEF/IDENT[@text='ENUMERATION']"); @@ -140,7 +140,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe } @Test - public void testField() throws Exception { + void field() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbbreviationAsWordInNameField.java")); @@ -157,7 +157,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameField']]" + "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='FIELD']"); @@ -166,7 +166,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe } @Test - public void testInterface() throws Exception { + void testInterface() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbbreviationAsWordInNameInterface.java")); @@ -183,7 +183,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameInterface']]" + "/OBJBLOCK/INTERFACE_DEF/IDENT[@text='INTERFACE']"); @@ -192,7 +192,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe } @Test - public void testMethod() throws Exception { + void method() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbbreviationAsWordInNameMethod.java")); @@ -209,7 +209,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/INTERFACE_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameMethod']]" + "/OBJBLOCK/METHOD_DEF/IDENT[@text='METHOD']"); @@ -218,7 +218,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe } @Test - public void testParameter() throws Exception { + void parameter() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbbreviationAsWordInNameParameter.java")); @@ -235,7 +235,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/INTERFACE_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameParameter']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]" @@ -245,7 +245,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe } @Test - public void testVariable() throws Exception { + void variable() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbbreviationAsWordInNameVariable.java")); @@ -262,7 +262,7 @@ public class XpathRegressionAbbreviationAsWordInNameTest extends AbstractXpathTe }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionAbbreviationAsWordInNameVariable']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAbstractClassNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAbstractClassNameTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAbstractClassNameTest extends AbstractXpathTestSupport { +final class XpathRegressionAbstractClassNameTest extends AbstractXpathTestSupport { private final String checkName = AbstractClassNameCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionAbstractClassNameTest extends AbstractXpathTestSuppo } @Test - public void testClassNameTop() throws Exception { + void classNameTop() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbstractClassNameTop.java")); @@ -66,7 +66,7 @@ public class XpathRegressionAbstractClassNameTest extends AbstractXpathTestSuppo } @Test - public void testClassNameInner() throws Exception { + void classNameInner() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbstractClassNameInner.java")); @@ -97,7 +97,7 @@ public class XpathRegressionAbstractClassNameTest extends AbstractXpathTestSuppo } @Test - public void testClassNameNoModifier() throws Exception { + void classNameNoModifier() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAbstractClassNameNoModifier.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAnnotationLocationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAnnotationLocationTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAnnotationLocationTest extends AbstractXpathTestSupport { +final class XpathRegressionAnnotationLocationTest extends AbstractXpathTestSupport { private final String checkName = AnnotationLocationCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionAnnotationLocationTest extends AbstractXpathTestSupp } @Test - public void testClass() throws Exception { + void testClass() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationLocationClass.java")); @@ -68,7 +68,7 @@ public class XpathRegressionAnnotationLocationTest extends AbstractXpathTestSupp } @Test - public void testInterface() throws Exception { + void testInterface() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationLocationInterface.java")); @@ -101,7 +101,7 @@ public class XpathRegressionAnnotationLocationTest extends AbstractXpathTestSupp } @Test - public void testEnum() throws Exception { + void testEnum() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationLocationEnum.java")); @@ -133,7 +133,7 @@ public class XpathRegressionAnnotationLocationTest extends AbstractXpathTestSupp } @Test - public void testMethod() throws Exception { + void method() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationLocationMethod.java")); @@ -169,7 +169,7 @@ public class XpathRegressionAnnotationLocationTest extends AbstractXpathTestSupp } @Test - public void testVariable() throws Exception { + void variable() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationLocationVariable.java")); @@ -205,7 +205,7 @@ public class XpathRegressionAnnotationLocationTest extends AbstractXpathTestSupp } @Test - public void testConstructor() throws Exception { + void constructor() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationLocationCTOR.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAnnotationOnSameLineTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAnnotationOnSameLineTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAnnotationOnSameLineTest extends AbstractXpathTestSupport { +final class XpathRegressionAnnotationOnSameLineTest extends AbstractXpathTestSupport { private final String checkName = AnnotationOnSameLineCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionAnnotationOnSameLineTest extends AbstractXpathTestSu } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationOnSameLineOne.java")); @@ -78,7 +78,7 @@ public class XpathRegressionAnnotationOnSameLineTest extends AbstractXpathTestSu } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationOnSameLineTwo.java")); @@ -113,7 +113,7 @@ public class XpathRegressionAnnotationOnSameLineTest extends AbstractXpathTestSu } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationOnSameLineThree.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAnnotationUseStyleTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAnnotationUseStyleTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseStyleCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupport { +final class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupport { private final String checkName = AnnotationUseStyleCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationUseStyleOne.java")); @@ -64,7 +64,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationUseStyleTwo.java")); @@ -99,7 +99,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationUseStyleThree.java")); @@ -136,7 +136,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationUseStyleFour.java")); @@ -154,7 +154,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionAnnotationUseStyleFour']]" + "/MODIFIERS/ANNOTATION[./IDENT[@text='SuppressWarnings']]" @@ -164,7 +164,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationUseStyleFive.java")); @@ -200,7 +200,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp } @Test - public void testSix() throws Exception { + void six() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationUseStyleSix.java")); @@ -236,7 +236,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp } @Test - public void testSeven() throws Exception { + void seven() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationUseStyleSeven.java")); @@ -263,7 +263,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp } @Test - public void testEight() throws Exception { + void eight() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnnotationUseStyleEight.java")); @@ -281,7 +281,7 @@ public class XpathRegressionAnnotationUseStyleTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionAnnotationUseStyleEight']]" + "/MODIFIERS/ANNOTATION[./IDENT[@text='SuppressWarnings']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAnonInnerLengthTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAnonInnerLengthTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAnonInnerLengthTest extends AbstractXpathTestSupport { +final class XpathRegressionAnonInnerLengthTest extends AbstractXpathTestSupport { private final String checkName = AnonInnerLengthCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionAnonInnerLengthTest extends AbstractXpathTestSupport } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnonInnerLengthDefault.java")); @@ -63,7 +63,7 @@ public class XpathRegressionAnonInnerLengthTest extends AbstractXpathTestSupport } @Test - public void testMaxLength() throws Exception { + void maxLength() throws Exception { final int maxLen = 5; final File fileToProcess = new File(getPath("SuppressionXpathRegressionAnonInnerLength.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionArrayTrailingCommaTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionArrayTrailingCommaTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.ArrayTrailingCommaCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionArrayTrailingCommaTest extends AbstractXpathTestSupport { +final class XpathRegressionArrayTrailingCommaTest extends AbstractXpathTestSupport { private final String checkName = ArrayTrailingCommaCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionArrayTrailingCommaTest extends AbstractXpathTestSupp } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionArrayTrailingCommaOne.java")); @@ -62,7 +62,7 @@ public class XpathRegressionArrayTrailingCommaTest extends AbstractXpathTestSupp } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionArrayTrailingCommaTwo.java")); @@ -73,7 +73,7 @@ public class XpathRegressionArrayTrailingCommaTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionArrayTrailingCommaTwo']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='d2']]/ASSIGN/EXPR/LITERAL_NEW" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionArrayTypeStyleTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionArrayTypeStyleTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionArrayTypeStyleTest extends AbstractXpathTestSupport { +final class XpathRegressionArrayTypeStyleTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +34,7 @@ public class XpathRegressionArrayTypeStyleTest extends AbstractXpathTestSupport } @Test - public void testVariable() throws Exception { + void variable() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionArrayTypeStyleVariable.java")); @@ -45,7 +45,7 @@ public class XpathRegressionArrayTypeStyleTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionArrayTypeStyleVariable']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='strings']]/TYPE[" @@ -55,7 +55,7 @@ public class XpathRegressionArrayTypeStyleTest extends AbstractXpathTestSupport } @Test - public void testMethodDef() throws Exception { + void methodDef() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionArrayTypeStyleMethodDef.java")); @@ -66,7 +66,7 @@ public class XpathRegressionArrayTypeStyleTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionArrayTypeStyleMethodDef']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='getData']]/TYPE/ARRAY_DECLARATOR"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidDoubleBraceInitializationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidDoubleBraceInitializationTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAvoidDoubleBraceInitializationTest extends AbstractXpathTestSupport { +final class XpathRegressionAvoidDoubleBraceInitializationTest extends AbstractXpathTestSupport { private final Class clazz = AvoidDoubleBraceInitializationCheck.class; @@ -37,7 +37,7 @@ public class XpathRegressionAvoidDoubleBraceInitializationTest extends AbstractX } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidDoubleBraceInitialization.java")); @@ -62,7 +62,7 @@ public class XpathRegressionAvoidDoubleBraceInitializationTest extends AbstractX } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidDoubleBraceInitializationTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidEscapedUnicodeCharactersTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidEscapedUnicodeCharactersTest.java @@ -28,7 +28,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAvoidEscapedUnicodeCharactersTest extends AbstractXpathTestSupport { +final class XpathRegressionAvoidEscapedUnicodeCharactersTest extends AbstractXpathTestSupport { private final String checkName = AvoidEscapedUnicodeCharactersCheck.class.getSimpleName(); @Override @@ -37,7 +37,7 @@ public class XpathRegressionAvoidEscapedUnicodeCharactersTest extends AbstractXp } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidEscapedUnicodeCharactersDefault.java")); @@ -63,7 +63,7 @@ public class XpathRegressionAvoidEscapedUnicodeCharactersTest extends AbstractXp } @Test - public void testControlCharacters() throws Exception { + void controlCharacters() throws Exception { final File fileToProcess = new File( getPath( @@ -94,7 +94,7 @@ public class XpathRegressionAvoidEscapedUnicodeCharactersTest extends AbstractXp } @Test - public void testTailComment() throws Exception { + void tailComment() throws Exception { final File fileToProcess = new File( getPath("SuppressionXpathRegressionAvoidEscapedUnicodeCharactersTailComment.java")); @@ -124,7 +124,7 @@ public class XpathRegressionAvoidEscapedUnicodeCharactersTest extends AbstractXp } @Test - public void testAllCharactersEscaped() throws Exception { + void allCharactersEscaped() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidEscapedUnicodeCharactersAllEscaped.java")); @@ -153,7 +153,7 @@ public class XpathRegressionAvoidEscapedUnicodeCharactersTest extends AbstractXp } @Test - public void testNonPrintableCharacters() throws Exception { + void nonPrintableCharacters() throws Exception { final File fileToProcess = new File( getPath("SuppressionXpathRegressionAvoidEscapedUnicodeCharactersNonPrintable.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidInlineConditionalsTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidInlineConditionalsTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.AvoidInlineConditionalsCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAvoidInlineConditionalsTest extends AbstractXpathTestSupport { +final class XpathRegressionAvoidInlineConditionalsTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -35,7 +35,7 @@ public class XpathRegressionAvoidInlineConditionalsTest extends AbstractXpathTes } @Test - public void testInlineConditionalsVariableDef() throws Exception { + void inlineConditionalsVariableDef() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidInlineConditionalsVariableDef.java")); @@ -63,7 +63,7 @@ public class XpathRegressionAvoidInlineConditionalsTest extends AbstractXpathTes } @Test - public void testInlineConditionalsAssign() throws Exception { + void inlineConditionalsAssign() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidInlineConditionalsAssign.java")); @@ -77,7 +77,7 @@ public class XpathRegressionAvoidInlineConditionalsTest extends AbstractXpathTes }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='" + "SuppressionXpathRegressionAvoidInlineConditionalsAssign']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='setB']]/SLIST" @@ -87,7 +87,7 @@ public class XpathRegressionAvoidInlineConditionalsTest extends AbstractXpathTes } @Test - public void testInlineConditionalsAssert() throws Exception { + void inlineConditionalsAssert() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidInlineConditionalsAssert.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidNestedBlocksTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidNestedBlocksTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAvoidNestedBlocksTest extends AbstractXpathTestSupport { +final class XpathRegressionAvoidNestedBlocksTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -35,7 +35,7 @@ public class XpathRegressionAvoidNestedBlocksTest extends AbstractXpathTestSuppo } @Test - public void testEmpty() throws Exception { + void empty() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidNestedBlocksEmpty.java")); @@ -48,7 +48,7 @@ public class XpathRegressionAvoidNestedBlocksTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionAvoidNestedBlocksEmpty']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='empty']]/SLIST/SLIST"); @@ -57,7 +57,7 @@ public class XpathRegressionAvoidNestedBlocksTest extends AbstractXpathTestSuppo } @Test - public void testVariableAssignment() throws Exception { + void variableAssignment() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidNestedBlocksVariable.java")); @@ -70,7 +70,7 @@ public class XpathRegressionAvoidNestedBlocksTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionAvoidNestedBlocksVariable']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='varAssign']]/SLIST/SLIST"); @@ -79,7 +79,7 @@ public class XpathRegressionAvoidNestedBlocksTest extends AbstractXpathTestSuppo } @Test - public void testSwitchAllowInSwitchCaseFalse() throws Exception { + void switchAllowInSwitchCaseFalse() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidNestedBlocksSwitch1.java")); @@ -112,7 +112,7 @@ public class XpathRegressionAvoidNestedBlocksTest extends AbstractXpathTestSuppo } @Test - public void testSwitchAllowInSwitchCaseTrue() throws Exception { + void switchAllowInSwitchCaseTrue() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidNestedBlocksSwitch2.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidNoArgumentSuperConstructorCallTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidNoArgumentSuperConstructorCallTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.AvoidNoArgumentSuperConstructorCallCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAvoidNoArgumentSuperConstructorCallTest +final class XpathRegressionAvoidNoArgumentSuperConstructorCallTest extends AbstractXpathTestSupport { private static final Class CLASS = @@ -38,7 +38,7 @@ public class XpathRegressionAvoidNoArgumentSuperConstructorCallTest } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidNoArgumentSuperConstructorCall.java")); @@ -49,7 +49,7 @@ public class XpathRegressionAvoidNoArgumentSuperConstructorCallTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionAvoidNoArgumentSuperConstructorCall']]" + "/OBJBLOCK/CTOR_DEF[./IDENT[" @@ -60,7 +60,7 @@ public class XpathRegressionAvoidNoArgumentSuperConstructorCallTest } @Test - public void testInnerClass() throws Exception { + void innerClass() throws Exception { final File fileToProcess = new File( getPath( @@ -73,7 +73,7 @@ public class XpathRegressionAvoidNoArgumentSuperConstructorCallTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionAvoidNoArgumentSuperConstructorCallInnerClass']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidStarImportTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidStarImportTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAvoidStarImportTest extends AbstractXpathTestSupport { +final class XpathRegressionAvoidStarImportTest extends AbstractXpathTestSupport { private static final Class CLASS = AvoidStarImportCheck.class; @@ -36,7 +36,7 @@ public class XpathRegressionAvoidStarImportTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidStarImport1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(CLASS); @@ -47,13 +47,13 @@ public class XpathRegressionAvoidStarImportTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/STATIC_IMPORT/DOT"); + ImmutableList.of("/COMPILATION_UNIT/STATIC_IMPORT/DOT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidStarImport2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(CLASS); @@ -62,8 +62,7 @@ public class XpathRegressionAvoidStarImportTest extends AbstractXpathTestSupport "4:15: " + getCheckMessage(CLASS, AvoidStarImportCheck.MSG_KEY, "java.io.*"), }; - final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT/DOT"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/IMPORT/DOT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidStaticImportTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionAvoidStaticImportTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.imports.AvoidStaticImportCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionAvoidStaticImportTest extends AbstractXpathTestSupport { +final class XpathRegressionAvoidStaticImportTest extends AbstractXpathTestSupport { private static final Class CLASS = AvoidStaticImportCheck.class; @@ -36,7 +36,7 @@ public class XpathRegressionAvoidStaticImportTest extends AbstractXpathTestSuppo } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidStaticImport1.java")); @@ -48,13 +48,13 @@ public class XpathRegressionAvoidStaticImportTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/STATIC_IMPORT/DOT"); + ImmutableList.of("/COMPILATION_UNIT/STATIC_IMPORT/DOT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionAvoidStaticImport2.java")); @@ -66,8 +66,7 @@ public class XpathRegressionAvoidStaticImportTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( - "/COMPILATION_UNIT/STATIC_IMPORT/DOT[./IDENT[@text='createTempFile']]"); + ImmutableList.of("/COMPILATION_UNIT/STATIC_IMPORT/DOT[./IDENT[@text='createTempFile']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionBooleanExpressionComplexityTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionBooleanExpressionComplexityTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.metrics.BooleanExpressionComplexityCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionBooleanExpressionComplexityTest extends AbstractXpathTestSupport { +final class XpathRegressionBooleanExpressionComplexityTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +34,7 @@ public class XpathRegressionBooleanExpressionComplexityTest extends AbstractXpat } @Test - public void testMethodOne() throws Exception { + void methodOne() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionBooleanExpressionComplexityOne.java")); @@ -51,7 +51,7 @@ public class XpathRegressionBooleanExpressionComplexityTest extends AbstractXpat }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionBooleanExpressionComplexityOne']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodOne']]/SLIST" @@ -62,7 +62,7 @@ public class XpathRegressionBooleanExpressionComplexityTest extends AbstractXpat } @Test - public void testMethodTwo() throws Exception { + void methodTwo() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionBooleanExpressionComplexityTwo.java")); @@ -79,7 +79,7 @@ public class XpathRegressionBooleanExpressionComplexityTest extends AbstractXpat }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionBooleanExpressionComplexityTwo']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodTwo']]/SLIST/VARIABLE_DEF" @@ -89,7 +89,7 @@ public class XpathRegressionBooleanExpressionComplexityTest extends AbstractXpat } @Test - public void testMethodThree() throws Exception { + void methodThree() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionBoolean" + "ExpressionComplexityThree.java")); @@ -106,7 +106,7 @@ public class XpathRegressionBooleanExpressionComplexityTest extends AbstractXpat }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionBooleanExpressionComplexityThree']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='methodThree']]/SLIST/LITERAL_IF"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCatchParameterNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCatchParameterNameTest.java @@ -21,14 +21,14 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.CatchParameterNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupport { +final class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupport { private final String checkName = CatchParameterNameCheck.class.getSimpleName(); @Override @@ -37,7 +37,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp } @Test - public void testSimple() throws Exception { + void simple() throws Exception { final String pattern = "^(e|t|ex|[a-z][a-z][a-zA-Z]+)$"; final DefaultConfiguration moduleConfig = createModuleConfig(CatchParameterNameCheck.class); @@ -50,7 +50,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCatchParameterNameSimple']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]" @@ -60,7 +60,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp } @Test - public void testNested() throws Exception { + void nested() throws Exception { final String pattern = "^(e|t|ex|[a-z][a-z][a-zA-Z]+)$"; final DefaultConfiguration moduleConfig = createModuleConfig(CatchParameterNameCheck.class); @@ -73,7 +73,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCatchParameterNameNested']]" + "/OBJBLOCK/CLASS_DEF[./IDENT[@text='NestedClass']]" @@ -85,7 +85,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp } @Test - public void testStaticInit() throws Exception { + void staticInit() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]+$"; final DefaultConfiguration moduleConfig = createModuleConfig(CatchParameterNameCheck.class); @@ -99,7 +99,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCatchParameterNameStaticInit']]" + "/OBJBLOCK/STATIC_INIT/SLIST" @@ -109,7 +109,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp } @Test - public void testAnonymous() throws Exception { + void anonymous() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]+$"; final DefaultConfiguration moduleConfig = createModuleConfig(CatchParameterNameCheck.class); @@ -124,7 +124,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCatchParameterNameAnonymous']]" + "/OBJBLOCK/CLASS_DEF[./IDENT[@text='InnerClass']]" @@ -137,7 +137,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp } @Test - public void testLambda() throws Exception { + void lambda() throws Exception { final String pattern = "^[A-Z][a-z]+$"; final DefaultConfiguration moduleConfig = createModuleConfig(CatchParameterNameCheck.class); @@ -151,7 +151,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCatchParameterNameLambda']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='lambdaFunction']]" @@ -163,7 +163,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp } @Test - public void testEnum() throws Exception { + void testEnum() throws Exception { final String pattern = "^[A-Z][a-z]+$"; final DefaultConfiguration moduleConfig = createModuleConfig(CatchParameterNameCheck.class); @@ -178,7 +178,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/ENUM_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCatchParameterNameEnum']]" + "/OBJBLOCK/ENUM_CONSTANT_DEF[./IDENT[@text='VALUE']]" @@ -190,7 +190,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp } @Test - public void testInterface() throws Exception { + void testInterface() throws Exception { final String pattern = "^[A-Z][a-z]+$"; final DefaultConfiguration moduleConfig = createModuleConfig(CatchParameterNameCheck.class); @@ -204,7 +204,7 @@ public class XpathRegressionCatchParameterNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/INTERFACE_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCatchParameterNameInterface']]" + "/OBJBLOCK/INTERFACE_DEF[./IDENT[@text='InnerInterface']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionClassMemberImpliedModifierTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionClassMemberImpliedModifierTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionClassMemberImpliedModifierTest extends AbstractXpathTestSupport { +final class XpathRegressionClassMemberImpliedModifierTest extends AbstractXpathTestSupport { private final String checkName = ClassMemberImpliedModifierCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionClassMemberImpliedModifierTest extends AbstractXpath } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionClassMemberImpliedModifierOne.java")); @@ -68,7 +68,7 @@ public class XpathRegressionClassMemberImpliedModifierTest extends AbstractXpath } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionClassMemberImpliedModifierTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCommentsIndentationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCommentsIndentationTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSupport { +final class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSupport { private final String checkName = CommentsIndentationCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup } @Test - public void testSingleLine() throws Exception { + void singleLine() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCommentsIndentation" + "SingleLine.java")); @@ -48,7 +48,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionCommentsIndentationSingleLine']]" + "/OBJBLOCK/SINGLE_LINE_COMMENT[./COMMENT_CONTENT[@text=' Comment // warn\\n']]"); @@ -57,7 +57,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup } @Test - public void testBlock() throws Exception { + void block() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCommentsIndentation" + "Block.java")); @@ -69,7 +69,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionCommentsIndentationBlock']]/OBJBLOCK/" + "VARIABLE_DEF[./IDENT[@text='f']]/TYPE/BLOCK_COMMENT_BEGIN[./COMMENT_CONTENT" @@ -79,7 +79,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup } @Test - public void testSeparator() throws Exception { + void separator() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCommentsIndentation" + "Separator.java")); @@ -92,7 +92,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionCommentsIndentationSeparator']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/MODIFIERS/SINGLE_LINE_COMMENT" @@ -102,7 +102,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup } @Test - public void testDistributedStatement() throws Exception { + void distributedStatement() throws Exception { final File fileToProcess = new File( getPath("SuppressionXpathRegressionCommentsIndentation" + "DistributedStatement.java")); @@ -116,7 +116,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionCommentsIndentationDistributedStatement']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/SLIST/SINGLE_LINE_COMMENT" @@ -126,7 +126,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup } @Test - public void testSingleLineBlock() throws Exception { + void singleLineBlock() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCommentsIndentation" + "SingleLineBlock.java")); @@ -138,7 +138,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionCommentsIndentationSingleLineBlock']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/SLIST/SINGLE_LINE_COMMENT" @@ -148,7 +148,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup } @Test - public void testNonEmptyCase() throws Exception { + void nonEmptyCase() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCommentsIndentation" + "NonEmptyCase.java")); @@ -161,7 +161,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionCommentsIndentationNonEmptyCase']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/SLIST/LITERAL_SWITCH/" @@ -171,7 +171,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup } @Test - public void testEmptyCase() throws Exception { + void emptyCase() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCommentsIndentation" + "EmptyCase.java")); @@ -184,7 +184,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionCommentsIndentationEmptyCase']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/SLIST/LITERAL_SWITCH/" @@ -194,7 +194,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup } @Test - public void testWithinBlockStatement() throws Exception { + void withinBlockStatement() throws Exception { final File fileToProcess = new File( getPath("SuppressionXpathRegressionCommentsIndentation" + "WithinBlockStatement.java")); @@ -208,7 +208,7 @@ public class XpathRegressionCommentsIndentationTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionCommentsIndentationWithinBlockStatement']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/SLIST/VARIABLE_DEF" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionConstantNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionConstantNameTest.java @@ -21,14 +21,14 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { +final class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { private static final Class CLASS = ConstantNameCheck.class; private static final String PATTERN = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -40,7 +40,7 @@ public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { } @Test - public void testLowercase() throws Exception { + void lowercase() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionConstantNameLowercase.java")); @@ -51,7 +51,7 @@ public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionConstantNameLowercase']]" + "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='number']"); @@ -60,7 +60,7 @@ public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { } @Test - public void testCamelCase() throws Exception { + void camelCase() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionConstantNameCamelCase.java")); @@ -71,7 +71,7 @@ public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionConstantNameCamelCase']]" + "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='badConstant']"); @@ -80,7 +80,7 @@ public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { } @Test - public void testWithBeginningUnderscore() throws Exception { + void withBeginningUnderscore() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionConstantNameWithBeginningUnderscore.java")); @@ -91,7 +91,7 @@ public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionConstantNameWithBeginningUnderscore']]" + "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='_CONSTANT']"); @@ -100,7 +100,7 @@ public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { } @Test - public void testWithTwoUnderscores() throws Exception { + void withTwoUnderscores() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionConstantNameWithTwoUnderscores.java")); @@ -111,7 +111,7 @@ public class XpathRegressionConstantNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionConstantNameWithTwoUnderscores']]" + "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='BAD__NAME']"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCovariantEqualsTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCovariantEqualsTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionCovariantEqualsTest extends AbstractXpathTestSupport { +final class XpathRegressionCovariantEqualsTest extends AbstractXpathTestSupport { private final String checkName = CovariantEqualsCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionCovariantEqualsTest extends AbstractXpathTestSupport } @Test - public void testCovariantEqualsInClass() throws Exception { + void covariantEqualsInClass() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCovariantEqualsInClass.java")); @@ -47,7 +47,7 @@ public class XpathRegressionCovariantEqualsTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCovariantEqualsInClass']]" + "/OBJBLOCK/METHOD_DEF/IDENT[@text='equals']"); @@ -56,7 +56,7 @@ public class XpathRegressionCovariantEqualsTest extends AbstractXpathTestSupport } @Test - public void testCovariantEqualsInEnum() throws Exception { + void covariantEqualsInEnum() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCovariantEqualsInEnum.java")); @@ -67,7 +67,7 @@ public class XpathRegressionCovariantEqualsTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/ENUM_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCovariantEqualsInEnum']]" + "/OBJBLOCK/METHOD_DEF/IDENT[@text='equals']"); @@ -76,7 +76,7 @@ public class XpathRegressionCovariantEqualsTest extends AbstractXpathTestSupport } @Test - public void testCovariantEqualsInRecord() throws Exception { + void covariantEqualsInRecord() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionCovariantEqualsInRecord.java")); @@ -87,7 +87,7 @@ public class XpathRegressionCovariantEqualsTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/RECORD_DEF" + "[./IDENT[@text='SuppressionXpathRegressionCovariantEqualsInRecord']]" + "/OBJBLOCK/METHOD_DEF/IDENT[@text='equals']"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCustomImportOrderTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCustomImportOrderTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.imports.CustomImportOrderCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSupport { +final class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSupport { private final String checkName = CustomImportOrderCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSuppo } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCustomImportOrderOne.java")); @@ -54,13 +54,13 @@ public class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/STATIC_IMPORT[./DOT/IDENT[@text='PI']]"); + ImmutableList.of("/COMPILATION_UNIT/STATIC_IMPORT[./DOT/IDENT[@text='PI']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCustomImportOrderTwo.java")); @@ -76,13 +76,13 @@ public class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='File']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='File']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCustomImportOrderThree.java")); @@ -98,13 +98,13 @@ public class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/STATIC_IMPORT[./DOT/IDENT[@text='PI']]"); + ImmutableList.of("/COMPILATION_UNIT/STATIC_IMPORT[./DOT/IDENT[@text='PI']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCustomImportOrderFour.java")); @@ -120,13 +120,13 @@ public class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='DetailAST']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='DetailAST']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCustomImportOrderFive.java")); @@ -143,13 +143,13 @@ public class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/STATIC_IMPORT[./DOT/IDENT[@text='PI']]"); + ImmutableList.of("/COMPILATION_UNIT/STATIC_IMPORT[./DOT/IDENT[@text='PI']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testSix() throws Exception { + void six() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCustomImportOrderSix.java")); @@ -168,7 +168,7 @@ public class XpathRegressionCustomImportOrderTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='DetailAST']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='DetailAST']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCyclomaticComplexityTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionCyclomaticComplexityTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionCyclomaticComplexityTest extends AbstractXpathTestSupport { +final class XpathRegressionCyclomaticComplexityTest extends AbstractXpathTestSupport { private final String checkName = CyclomaticComplexityCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionCyclomaticComplexityTest extends AbstractXpathTestSu } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCyclomaticComplexityOne.java")); @@ -66,7 +66,7 @@ public class XpathRegressionCyclomaticComplexityTest extends AbstractXpathTestSu } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionCyclomaticComplexityTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionDeclarationOrderTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionDeclarationOrderTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionDeclarationOrderTest extends AbstractXpathTestSupport { +final class XpathRegressionDeclarationOrderTest extends AbstractXpathTestSupport { private final String checkName = DeclarationOrderCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionDeclarationOrderTest extends AbstractXpathTestSuppor } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionDeclarationOrderOne.java")); @@ -62,7 +62,7 @@ public class XpathRegressionDeclarationOrderTest extends AbstractXpathTestSuppor } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionDeclarationOrderTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionDefaultComesLastTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionDefaultComesLastTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.DefaultComesLastCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionDefaultComesLastTest extends AbstractXpathTestSupport { +final class XpathRegressionDefaultComesLastTest extends AbstractXpathTestSupport { private final String checkName = DefaultComesLastCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionDefaultComesLastTest extends AbstractXpathTestSuppor } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionDefaultComesLastOne.java")); @@ -62,7 +62,7 @@ public class XpathRegressionDefaultComesLastTest extends AbstractXpathTestSuppor } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionDefaultComesLastTwo.java")); @@ -77,7 +77,7 @@ public class XpathRegressionDefaultComesLastTest extends AbstractXpathTestSuppor }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionDefaultComesLastTwo']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_SWITCH/CASE_GROUP" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyBlockTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyBlockTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionEmptyBlockTest extends AbstractXpathTestSupport { +final class XpathRegressionEmptyBlockTest extends AbstractXpathTestSupport { private final String checkName = EmptyBlockCheck.class.getSimpleName(); @Override @@ -35,7 +35,7 @@ public class XpathRegressionEmptyBlockTest extends AbstractXpathTestSupport { } @Test - public void testEmptyForLoopEmptyBlock() throws Exception { + void emptyForLoopEmptyBlock() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyBlockEmpty.java")); final DefaultConfiguration moduleConfig = createModuleConfig(EmptyBlockCheck.class); moduleConfig.addProperty("option", "TEXT"); @@ -43,7 +43,7 @@ public class XpathRegressionEmptyBlockTest extends AbstractXpathTestSupport { "5:38: " + getCheckMessage(EmptyBlockCheck.class, EmptyBlockCheck.MSG_KEY_BLOCK_EMPTY, "for"), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionEmptyBlockEmpty']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='emptyLoop']]" @@ -52,14 +52,14 @@ public class XpathRegressionEmptyBlockTest extends AbstractXpathTestSupport { } @Test - public void testEmptyForLoopEmptyStatement() throws Exception { + void emptyForLoopEmptyStatement() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyBlockEmpty.java")); final DefaultConfiguration moduleConfig = createModuleConfig(EmptyBlockCheck.class); final String[] expectedViolation = { "5:38: " + getCheckMessage(EmptyBlockCheck.class, EmptyBlockCheck.MSG_KEY_BLOCK_NO_STATEMENT), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionEmptyBlockEmpty']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='emptyLoop']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyCatchBlockTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyCatchBlockTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.blocks.EmptyCatchBlockCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionEmptyCatchBlockTest extends AbstractXpathTestSupport { +final class XpathRegressionEmptyCatchBlockTest extends AbstractXpathTestSupport { private final Class clazz = EmptyCatchBlockCheck.class; @@ -36,7 +36,7 @@ public class XpathRegressionEmptyCatchBlockTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyCatchBlock1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(clazz); @@ -46,7 +46,7 @@ public class XpathRegressionEmptyCatchBlockTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionEmptyCatchBlock1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='main']]" @@ -56,7 +56,7 @@ public class XpathRegressionEmptyCatchBlockTest extends AbstractXpathTestSupport } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyCatchBlock2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(clazz); @@ -66,7 +66,7 @@ public class XpathRegressionEmptyCatchBlockTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionEmptyCatchBlock2']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='main']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyForInitializerPadTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyForInitializerPadTest.java @@ -27,7 +27,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionEmptyForInitializerPadTest extends AbstractXpathTestSupport { +final class XpathRegressionEmptyForInitializerPadTest extends AbstractXpathTestSupport { private final String checkName = EmptyForInitializerPadCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionEmptyForInitializerPadTest extends AbstractXpathTest } @Test - public void testPreceded() throws Exception { + void preceded() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyForInitializerPadPreceded.java")); @@ -62,7 +62,7 @@ public class XpathRegressionEmptyForInitializerPadTest extends AbstractXpathTest } @Test - public void testNotPreceded() throws Exception { + void notPreceded() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyForInitializerPadNotPreceded.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyForIteratorPadTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyForIteratorPadTest.java @@ -27,7 +27,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionEmptyForIteratorPadTest extends AbstractXpathTestSupport { +final class XpathRegressionEmptyForIteratorPadTest extends AbstractXpathTestSupport { private final String checkName = EmptyForIteratorPadCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionEmptyForIteratorPadTest extends AbstractXpathTestSup } @Test - public void testFollowed() throws Exception { + void followed() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyForIteratorPadFollowed.java")); @@ -62,7 +62,7 @@ public class XpathRegressionEmptyForIteratorPadTest extends AbstractXpathTestSup } @Test - public void testNotFollowed() throws Exception { + void notFollowed() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyForIteratorPadNotFollowed.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyLineSeparatorTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyLineSeparatorTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupport { +final class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -35,7 +35,7 @@ public class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupp } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyLineSeparator1.java")); @@ -57,7 +57,7 @@ public class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupp } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyLineSeparator2.java")); @@ -77,7 +77,7 @@ public class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupp } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyLineSeparator3.java")); @@ -110,7 +110,7 @@ public class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupp } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyLineSeparator4.java")); @@ -124,7 +124,7 @@ public class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionEmptyLineSeparator4']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo1']]/SLIST/RCURLY"); @@ -133,7 +133,7 @@ public class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupp } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyLineSeparator5.java")); @@ -148,7 +148,7 @@ public class XpathRegressionEmptyLineSeparatorTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionEmptyLineSeparator5']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo1']]/SLIST/LITERAL_TRY/SLIST" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyStatementTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEmptyStatementTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionEmptyStatementTest extends AbstractXpathTestSupport { +final class XpathRegressionEmptyStatementTest extends AbstractXpathTestSupport { private final String checkName = EmptyStatementCheck.class.getSimpleName(); @@ -36,14 +36,14 @@ public class XpathRegressionEmptyStatementTest extends AbstractXpathTestSupport } @Test - public void testForLoopEmptyStatement() throws Exception { + void forLoopEmptyStatement() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyStatement1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(EmptyStatementCheck.class); final String[] expectedViolation = { "5:36: " + getCheckMessage(EmptyStatementCheck.class, EmptyStatementCheck.MSG_KEY), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionEmptyStatement1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]" @@ -52,14 +52,14 @@ public class XpathRegressionEmptyStatementTest extends AbstractXpathTestSupport } @Test - public void testIfBlockEmptyStatement() throws Exception { + void ifBlockEmptyStatement() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEmptyStatement2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(EmptyStatementCheck.class); final String[] expectedViolation = { "6:19: " + getCheckMessage(EmptyStatementCheck.class, EmptyStatementCheck.MSG_KEY), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionEmptyStatement2']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEqualsAvoidNullTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEqualsAvoidNullTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionEqualsAvoidNullTest extends AbstractXpathTestSupport { +final class XpathRegressionEqualsAvoidNullTest extends AbstractXpathTestSupport { private final Class clazz = EqualsAvoidNullCheck.class; @@ -36,7 +36,7 @@ public class XpathRegressionEqualsAvoidNullTest extends AbstractXpathTestSupport } @Test - public void testEquals() throws Exception { + void testEquals() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEqualsAvoidNull.java")); final DefaultConfiguration moduleConfig = createModuleConfig(clazz); @@ -58,7 +58,7 @@ public class XpathRegressionEqualsAvoidNullTest extends AbstractXpathTestSupport } @Test - public void testEqualsIgnoreCase() throws Exception { + void equalsIgnoreCase() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEqualsAvoidNullIgnoreCase.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEqualsHashCodeTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionEqualsHashCodeTest.java @@ -26,14 +26,14 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionEqualsHashCodeTest extends AbstractXpathTestSupport { +final class XpathRegressionEqualsHashCodeTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { return EqualsHashCodeCheck.class.getSimpleName(); } @Test - public void testEqualsOnly() throws Exception { + void equalsOnly() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEqualsHashCode1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(EqualsHashCodeCheck.class); @@ -58,7 +58,7 @@ public class XpathRegressionEqualsHashCodeTest extends AbstractXpathTestSupport } @Test - public void testHashCodeOnly() throws Exception { + void hashCodeOnly() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEqualsHashCode2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(EqualsHashCodeCheck.class); @@ -83,7 +83,7 @@ public class XpathRegressionEqualsHashCodeTest extends AbstractXpathTestSupport } @Test - public void testNestedCase() throws Exception { + void nestedCase() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionEqualsHashCodeNestedCase.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionExplicitInitializationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionExplicitInitializationTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializationCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionExplicitInitializationTest extends AbstractXpathTestSupport { +final class XpathRegressionExplicitInitializationTest extends AbstractXpathTestSupport { private final String checkName = ExplicitInitializationCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionExplicitInitializationTest extends AbstractXpathTest } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionExplicitInitializationOne.java")); @@ -49,7 +49,7 @@ public class XpathRegressionExplicitInitializationTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionExplicitInitializationOne']]" + "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='a']"); @@ -58,7 +58,7 @@ public class XpathRegressionExplicitInitializationTest extends AbstractXpathTest } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionExplicitInitializationTwo.java")); @@ -74,7 +74,7 @@ public class XpathRegressionExplicitInitializationTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionExplicitInitializationTwo']]" + "/OBJBLOCK/VARIABLE_DEF/IDENT[@text='bar']"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionFallThroughTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionFallThroughTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionFallThroughTest extends AbstractXpathTestSupport { +final class XpathRegressionFallThroughTest extends AbstractXpathTestSupport { private final String checkName = FallThroughCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionFallThroughTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFallThroughOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(FallThroughCheck.class); @@ -59,7 +59,7 @@ public class XpathRegressionFallThroughTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFallThroughTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(FallThroughCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionFinalClassTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionFinalClassTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionFinalClassTest extends AbstractXpathTestSupport { +final class XpathRegressionFinalClassTest extends AbstractXpathTestSupport { private final String checkName = FinalClassCheck.class.getSimpleName(); @Override @@ -35,7 +35,7 @@ public class XpathRegressionFinalClassTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalClass1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(FinalClassCheck.class); @@ -61,7 +61,7 @@ public class XpathRegressionFinalClassTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalClass2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(FinalClassCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionFinalLocalVariableTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionFinalLocalVariableTest.java @@ -19,13 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.FinalLocalVariableCheck; import java.io.File; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupport { +final class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupport { private final String checkName = FinalLocalVariableCheck.class.getSimpleName(); @@ -35,7 +36,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable1.java")); @@ -47,7 +48,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalLocalVariable1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='testMethod']]" @@ -57,7 +58,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable2.java")); @@ -69,7 +70,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalLocalVariable2']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method2']]/SLIST/" @@ -79,7 +80,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable3.java")); @@ -91,7 +92,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalLocalVariable3']]" + "/OBJBLOCK/CLASS_DEF[./IDENT[@text='InnerClass']]" @@ -102,7 +103,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable4.java")); @@ -115,7 +116,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalLocalVariable4']]" + "/OBJBLOCK/CLASS_DEF[./IDENT[@text='InnerClass']]" @@ -126,7 +127,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable5.java")); @@ -139,7 +140,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalLocalVariable5']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]" @@ -149,7 +150,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testSix() throws Exception { + void six() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable6.java")); @@ -162,7 +163,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionFinalLocalVariable6']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method1']]" @@ -172,7 +173,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testSeven() throws Exception { + void seven() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable7.java")); @@ -185,7 +186,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionFinalLocalVariable7']]" + "/OBJBLOCK/CTOR_DEF[./IDENT" @@ -196,7 +197,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testEight() throws Exception { + void eight() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable8.java")); @@ -209,7 +210,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalLocalVariable8']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='checkCodeBlock']]" @@ -219,7 +220,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp } @Test - public void testNine() throws Exception { + void nine() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalLocalVariable9.java")); @@ -231,7 +232,7 @@ public class XpathRegressionFinalLocalVariableTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionFinalLocalVariable9']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='checkCodeBlock']]/SLIST/LITERAL_TRY" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionFinalParametersTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionFinalParametersTest.java @@ -19,13 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck; import java.io.File; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionFinalParametersTest extends AbstractXpathTestSupport { +final class XpathRegressionFinalParametersTest extends AbstractXpathTestSupport { private final String checkName = FinalParametersCheck.class.getSimpleName(); @@ -35,7 +36,7 @@ public class XpathRegressionFinalParametersTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalParameters1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(FinalParametersCheck.class); @@ -46,7 +47,7 @@ public class XpathRegressionFinalParametersTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalParameters1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]" @@ -72,7 +73,7 @@ public class XpathRegressionFinalParametersTest extends AbstractXpathTestSupport } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalParameters2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(FinalParametersCheck.class); @@ -85,7 +86,7 @@ public class XpathRegressionFinalParametersTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalParameters2']]" + "/OBJBLOCK/CTOR_DEF[./IDENT[" @@ -116,7 +117,7 @@ public class XpathRegressionFinalParametersTest extends AbstractXpathTestSupport } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionFinalParameters3.java")); final DefaultConfiguration moduleConfig = createModuleConfig(FinalParametersCheck.class); @@ -129,7 +130,7 @@ public class XpathRegressionFinalParametersTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionFinalParameters3']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='createClass']]/SLIST/" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionGenericWhitespaceTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionGenericWhitespaceTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSupport { +final class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSupport { private final String checkName = GenericWhitespaceCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessEnd() throws Exception { + void processEnd() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceEnd.java")); @@ -50,7 +50,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionGenericWhitespaceEnd']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='bad']]" @@ -61,7 +61,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessNestedGenericsOne() throws Exception { + void processNestedGenericsOne() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceNestedGenericsOne.java")); @@ -74,7 +74,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionGenericWhitespaceNestedGenericsOne']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='bad']]/TYPE_PARAMETERS" @@ -85,7 +85,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessNestedGenericsTwo() throws Exception { + void processNestedGenericsTwo() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceNestedGenericsTwo.java")); @@ -98,7 +98,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionGenericWhitespaceNestedGenericsTwo']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='bad']]/TYPE_PARAMETERS" @@ -109,7 +109,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessNestedGenericsThree() throws Exception { + void processNestedGenericsThree() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceNestedGenericsThree.java")); @@ -122,7 +122,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionGenericWhitespaceNestedGenericsThree']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='bad']]/TYPE_PARAMETERS" @@ -133,7 +133,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessSingleGenericOne() throws Exception { + void processSingleGenericOne() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceSingleGenericOne.java")); @@ -146,7 +146,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionGenericWhitespaceSingleGenericOne']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/EXPR/METHOD_CALL" @@ -157,7 +157,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessSingleGenericTwo() throws Exception { + void processSingleGenericTwo() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceSingleGenericTwo.java")); @@ -170,7 +170,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionGenericWhitespaceSingleGenericTwo']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='bad']]/TYPE_PARAMETERS/GENERIC_END"); @@ -179,7 +179,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessStartOne() throws Exception { + void processStartOne() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceStartOne.java")); @@ -204,7 +204,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessStartTwo() throws Exception { + void processStartTwo() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceStartTwo.java")); @@ -233,7 +233,7 @@ public class XpathRegressionGenericWhitespaceTest extends AbstractXpathTestSuppo } @Test - public void testProcessStartThree() throws Exception { + void processStartThree() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionGenericWhitespaceStartThree.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionHiddenFieldTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionHiddenFieldTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionHiddenFieldTest extends AbstractXpathTestSupport { +final class XpathRegressionHiddenFieldTest extends AbstractXpathTestSupport { private final String checkName = HiddenFieldCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionHiddenFieldTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionHiddenFieldOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(HiddenFieldCheck.class); @@ -46,7 +46,7 @@ public class XpathRegressionHiddenFieldTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionHiddenFieldOne']]/OBJBLOCK" + "/INSTANCE_INIT/SLIST/EXPR/METHOD_CALL/ELIST/LAMBDA/PARAMETERS" @@ -56,7 +56,7 @@ public class XpathRegressionHiddenFieldTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionHiddenFieldTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(HiddenFieldCheck.class); @@ -66,7 +66,7 @@ public class XpathRegressionHiddenFieldTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionHiddenFieldTwo']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='method']]/PARAMETERS/PARAMETER_DEF" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalCatchTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalCatchTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.IllegalCatchCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIllegalCatchTest extends AbstractXpathTestSupport { +final class XpathRegressionIllegalCatchTest extends AbstractXpathTestSupport { private final String checkName = IllegalCatchCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionIllegalCatchTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalCatchOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalCatchCheck.class); @@ -47,7 +47,7 @@ public class XpathRegressionIllegalCatchTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIllegalCatchOne']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='fun']]/SLIST" @@ -57,7 +57,7 @@ public class XpathRegressionIllegalCatchTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalCatchTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalCatchCheck.class); @@ -69,7 +69,7 @@ public class XpathRegressionIllegalCatchTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIllegalCatchTwo']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='methodTwo']]/SLIST" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalIdentifierNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalIdentifierNameTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.IllegalIdentifierNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIllegalIdentifierNameTest extends AbstractXpathTestSupport { +final class XpathRegressionIllegalIdentifierNameTest extends AbstractXpathTestSupport { private final String checkName = IllegalIdentifierNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionIllegalIdentifierNameTest extends AbstractXpathTestS } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File( getNonCompilablePath("SuppressionXpathRegressionIllegalIdentifierNameTestOne.java")); @@ -56,7 +56,7 @@ public class XpathRegressionIllegalIdentifierNameTest extends AbstractXpathTestS }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/RECORD_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIllegalIdentifierNameTestOne'" + "]]/RECORD_COMPONENTS/RECORD_COMPONENT_DEF/IDENT[@text='yield']"); @@ -65,7 +65,7 @@ public class XpathRegressionIllegalIdentifierNameTest extends AbstractXpathTestS } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File( getNonCompilablePath("SuppressionXpathRegressionIllegalIdentifierNameTestTwo.java")); @@ -84,7 +84,7 @@ public class XpathRegressionIllegalIdentifierNameTest extends AbstractXpathTestS }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIllegalIdentifierNameTestTwo']" + "]/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]/PARAMETERS/PARAMETER_DEF" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalImportTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalImportTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIllegalImportTest extends AbstractXpathTestSupport { +final class XpathRegressionIllegalImportTest extends AbstractXpathTestSupport { private final String checkName = IllegalImportCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionIllegalImportTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalImportOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalImportCheck.class); moduleConfig.addProperty("illegalPkgs", "java.util"); @@ -44,13 +44,13 @@ public class XpathRegressionIllegalImportTest extends AbstractXpathTestSupport { "3:1: " + getCheckMessage(IllegalImportCheck.class, IllegalImportCheck.MSG_KEY, "java.util.List"), }; - final List expectedXpathQueries = Collections.singletonList("/COMPILATION_UNIT/IMPORT"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/IMPORT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalImportTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalImportCheck.class); @@ -61,8 +61,7 @@ public class XpathRegressionIllegalImportTest extends AbstractXpathTestSupport { + getCheckMessage( IllegalImportCheck.class, IllegalImportCheck.MSG_KEY, "java.lang.Math.pow"), }; - final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/STATIC_IMPORT"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/STATIC_IMPORT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalInstantiationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalInstantiationTest.java @@ -28,14 +28,14 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIllegalInstantiationTest extends AbstractXpathTestSupport { +final class XpathRegressionIllegalInstantiationTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { return IllegalInstantiationCheck.class.getSimpleName(); } @Test - public void testSimple() throws Exception { + void simple() throws Exception { final String fileName = "SuppressionXpathRegressionIllegalInstantiationSimple.java"; final File fileToProcess = new File(getNonCompilablePath(fileName)); @@ -61,7 +61,7 @@ public class XpathRegressionIllegalInstantiationTest extends AbstractXpathTestSu } @Test - public void testAnonymous() throws Exception { + void anonymous() throws Exception { final String fileName = "SuppressionXpathRegressionIllegalInstantiationAnonymous.java"; final File fileToProcess = new File(getNonCompilablePath(fileName)); @@ -88,7 +88,7 @@ public class XpathRegressionIllegalInstantiationTest extends AbstractXpathTestSu } @Test - public void testInterface() throws Exception { + void testInterface() throws Exception { final String fileName = "SuppressionXpathRegressionIllegalInstantiationInterface.java"; final File fileToProcess = new File(getNonCompilablePath(fileName)); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalThrowsTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalThrowsTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.IllegalThrowsCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIllegalThrowsTest extends AbstractXpathTestSupport { +final class XpathRegressionIllegalThrowsTest extends AbstractXpathTestSupport { private final String checkName = IllegalThrowsCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionIllegalThrowsTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalThrowsOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalThrowsCheck.class); @@ -48,7 +48,7 @@ public class XpathRegressionIllegalThrowsTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIllegalThrowsOne']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='sayHello']]/LITERAL_THROWS" @@ -58,7 +58,7 @@ public class XpathRegressionIllegalThrowsTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalThrowsTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalThrowsCheck.class); @@ -70,7 +70,7 @@ public class XpathRegressionIllegalThrowsTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIllegalThrowsTwo']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='methodTwo']]/LITERAL_THROWS" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalTokenTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalTokenTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIllegalTokenTest extends AbstractXpathTestSupport { +final class XpathRegressionIllegalTokenTest extends AbstractXpathTestSupport { private final String checkName = IllegalTokenCheck.class.getSimpleName(); @@ -36,14 +36,14 @@ public class XpathRegressionIllegalTokenTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalToken1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalTokenCheck.class); final String[] expectedViolation = { "5:10: " + getCheckMessage(IllegalTokenCheck.class, IllegalTokenCheck.MSG_KEY, "outer:"), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalToken1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myTest']]" @@ -53,7 +53,7 @@ public class XpathRegressionIllegalTokenTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalToken2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalTokenCheck.class); @@ -63,7 +63,7 @@ public class XpathRegressionIllegalTokenTest extends AbstractXpathTestSupport { "4:10: " + getCheckMessage(IllegalTokenCheck.class, IllegalTokenCheck.MSG_KEY, "native"), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalToken2']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myTest']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalTokenTextTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalTokenTextTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIllegalTokenTextTest extends AbstractXpathTestSupport { +final class XpathRegressionIllegalTokenTextTest extends AbstractXpathTestSupport { private final String checkName = IllegalTokenTextCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionIllegalTokenTextTest extends AbstractXpathTestSuppor } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalTokenText1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalTokenTextCheck.class); @@ -62,7 +62,7 @@ public class XpathRegressionIllegalTokenTextTest extends AbstractXpathTestSuppor } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalTokenText2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalTokenTextCheck.class); @@ -90,7 +90,7 @@ public class XpathRegressionIllegalTokenTextTest extends AbstractXpathTestSuppor } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalTokenText3.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalTokenTextCheck.class); @@ -102,7 +102,7 @@ public class XpathRegressionIllegalTokenTextTest extends AbstractXpathTestSuppor IllegalTokenTextCheck.class, IllegalTokenTextCheck.MSG_KEY, "invalidIdentifier"), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/INTERFACE_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalTokenText3']]" + "/OBJBLOCK/METHOD_DEF/IDENT[@text='invalidIdentifier']"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalTypeTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIllegalTypeTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.IllegalTypeCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIllegalTypeTest extends AbstractXpathTestSupport { +final class XpathRegressionIllegalTypeTest extends AbstractXpathTestSupport { private final String checkName = IllegalTypeCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionIllegalTypeTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalTypeOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalTypeCheck.class); moduleConfig.addProperty("tokens", "METHOD_DEF"); @@ -45,7 +45,7 @@ public class XpathRegressionIllegalTypeTest extends AbstractXpathTestSupport { + getCheckMessage(IllegalTypeCheck.class, IllegalTypeCheck.MSG_KEY, "java.util.HashSet"), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalTypeOne']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='typeParam']]/TYPE_PARAMETERS/TYPE_PARAMETER" @@ -56,7 +56,7 @@ public class XpathRegressionIllegalTypeTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIllegalTypeTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(IllegalTypeCheck.class); @@ -66,7 +66,7 @@ public class XpathRegressionIllegalTypeTest extends AbstractXpathTestSupport { "6:20: " + getCheckMessage(IllegalTypeCheck.class, IllegalTypeCheck.MSG_KEY, "Boolean"), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionIllegalTypeTwo']" + "]/OBJBLOCK/METHOD_DEF[./IDENT[@text='typeParam']]/TYPE_PARAMETERS/" + "TYPE_PARAMETER[./IDENT[@text='T']]/TYPE_UPPER_BOUNDS/IDENT[@text='Boolean']"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionImportControlTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionImportControlTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.imports.ImportControlCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionImportControlTest extends AbstractXpathTestSupport { +final class XpathRegressionImportControlTest extends AbstractXpathTestSupport { private final String checkName = ImportControlCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionImportControlTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportControlOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ImportControlCheck.class); @@ -49,13 +49,13 @@ public class XpathRegressionImportControlTest extends AbstractXpathTestSupport { ImportControlCheck.class, ImportControlCheck.MSG_DISALLOWED, "java.util.Scanner"), }; - final List expectedXpathQueries = Collections.singletonList("/COMPILATION_UNIT/IMPORT"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/IMPORT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportControlTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ImportControlCheck.class); @@ -72,7 +72,7 @@ public class XpathRegressionImportControlTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportControlThree.java")); @@ -89,7 +89,7 @@ public class XpathRegressionImportControlTest extends AbstractXpathTestSupport { } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportControlFour.java")); @@ -103,7 +103,7 @@ public class XpathRegressionImportControlTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Scanner']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Scanner']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionImportOrderTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionImportOrderTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionImportOrderTest extends AbstractXpathTestSupport { +final class XpathRegressionImportOrderTest extends AbstractXpathTestSupport { private final String checkName = ImportOrderCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionImportOrderTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportOrderOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ImportOrderCheck.class); @@ -46,13 +46,13 @@ public class XpathRegressionImportOrderTest extends AbstractXpathTestSupport { + getCheckMessage(ImportOrderCheck.class, ImportOrderCheck.MSG_ORDERING, "java.util.Set"), }; - final List expectedXpathQueries = Collections.singletonList("/COMPILATION_UNIT/IMPORT"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/IMPORT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportOrderTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ImportOrderCheck.class); @@ -64,13 +64,13 @@ public class XpathRegressionImportOrderTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Set']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Set']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportOrderThree.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ImportOrderCheck.class); @@ -83,13 +83,13 @@ public class XpathRegressionImportOrderTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/DOT/IDENT[@text='org']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/DOT/IDENT[@text='org']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportOrderFour.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ImportOrderCheck.class); @@ -101,14 +101,13 @@ public class XpathRegressionImportOrderTest extends AbstractXpathTestSupport { ImportOrderCheck.class, ImportOrderCheck.MSG_ORDERING, "java.lang.Math.PI"), }; - final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/STATIC_IMPORT"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/STATIC_IMPORT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionImportOrderFive.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ImportOrderCheck.class); @@ -121,7 +120,7 @@ public class XpathRegressionImportOrderTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Date']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Date']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIndentationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionIndentationTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { +final class XpathRegressionIndentationTest extends AbstractXpathTestSupport { private final String checkName = IndentationCheck.class.getSimpleName(); @Override @@ -36,7 +36,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIndentationTestOne.java")); @@ -67,7 +67,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { } @Test - public void testBasicOffset() throws Exception { + void basicOffset() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIndentationTestTwo.java")); @@ -106,7 +106,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { } @Test - public void testCaseIndent() throws Exception { + void caseIndent() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIndentationTestThree.java")); @@ -141,7 +141,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { } @Test - public void testLambda() throws Exception { + void lambda() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIndentationLambdaTest1.java")); @@ -160,7 +160,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIndentationLambdaTest1" + "']]/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/VARIABLE_DEF" @@ -170,7 +170,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { } @Test - public void testLambda2() throws Exception { + void lambda2() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIndentationLambdaTest2.java")); @@ -195,7 +195,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIndentationLambdaTest2']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/VARIABLE_DEF[" @@ -205,7 +205,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { } @Test - public void testIfWithNoCurlies() throws Exception { + void ifWithNoCurlies() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIndentationIfWithoutCurly.java")); @@ -226,7 +226,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIndentationIfWithoutCurly']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_IF/EXPR/" @@ -236,7 +236,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { } @Test - public void testElseWithNoCurlies() throws Exception { + void elseWithNoCurlies() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionIndentationElseWithoutCurly.java")); @@ -258,7 +258,7 @@ public class XpathRegressionIndentationTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionIndentationElseWithoutCurly']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_IF/LITERAL_ELSE" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInnerAssignmentTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInnerAssignmentTest.java @@ -19,6 +19,7 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck; import java.io.File; @@ -26,7 +27,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionInnerAssignmentTest extends AbstractXpathTestSupport { +final class XpathRegressionInnerAssignmentTest extends AbstractXpathTestSupport { private final String checkName = InnerAssignmentCheck.class.getSimpleName(); @@ -36,7 +37,7 @@ public class XpathRegressionInnerAssignmentTest extends AbstractXpathTestSupport } @Test - public void testFile1() throws Exception { + void file1() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInnerAssignment1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(InnerAssignmentCheck.class); @@ -46,7 +47,7 @@ public class XpathRegressionInnerAssignmentTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionInnerAssignment1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='testMethod']]" @@ -56,7 +57,7 @@ public class XpathRegressionInnerAssignmentTest extends AbstractXpathTestSupport } @Test - public void testFile2() throws Exception { + void file2() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInnerAssignment2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(InnerAssignmentCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInnerTypeLastTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInnerTypeLastTest.java @@ -28,7 +28,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionInnerTypeLastTest extends AbstractXpathTestSupport { +final class XpathRegressionInnerTypeLastTest extends AbstractXpathTestSupport { private final String checkName = InnerTypeLastCheck.class.getSimpleName(); @@ -38,7 +38,7 @@ public class XpathRegressionInnerTypeLastTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInnerTypeLastOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(InnerTypeLastCheck.class); @@ -68,7 +68,7 @@ public class XpathRegressionInnerTypeLastTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInnerTypeLastTwo.java")); @@ -99,7 +99,7 @@ public class XpathRegressionInnerTypeLastTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInnerTypeLastThree.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInterfaceIsTypeTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInterfaceIsTypeTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionInterfaceIsTypeTest extends AbstractXpathTestSupport { +final class XpathRegressionInterfaceIsTypeTest extends AbstractXpathTestSupport { private final String checkName = InterfaceIsTypeCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionInterfaceIsTypeTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInterfaceIsType1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(InterfaceIsTypeCheck.class); @@ -59,7 +59,7 @@ public class XpathRegressionInterfaceIsTypeTest extends AbstractXpathTestSupport } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInterfaceIsType2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(InterfaceIsTypeCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInterfaceMemberImpliedModifierTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInterfaceMemberImpliedModifierTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionInterfaceMemberImpliedModifierTest extends AbstractXpathTestSupport { +final class XpathRegressionInterfaceMemberImpliedModifierTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +34,7 @@ public class XpathRegressionInterfaceMemberImpliedModifierTest extends AbstractX } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInterfaceMemberImpliedModifier1.java")); @@ -67,7 +67,7 @@ public class XpathRegressionInterfaceMemberImpliedModifierTest extends AbstractX } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInterfaceMemberImpliedModifier2.java")); @@ -100,7 +100,7 @@ public class XpathRegressionInterfaceMemberImpliedModifierTest extends AbstractX } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInterfaceMemberImpliedModifier3.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInvalidJavadocPositionTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionInvalidJavadocPositionTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPositionCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTestSupport { +final class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTestSupport { private final String checkName = InvalidJavadocPositionCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInvalidJavadocPositionOne.java")); @@ -48,7 +48,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionInvalidJavadocPositionOne']]" + "/MODIFIERS/BLOCK_COMMENT_BEGIN[./COMMENT_CONTENT" @@ -58,7 +58,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInvalidJavadocPositionTwo.java")); @@ -70,7 +70,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionInvalidJavadocPositionTwo']]" + "/OBJBLOCK/BLOCK_COMMENT_BEGIN[./COMMENT_CONTENT" @@ -80,7 +80,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInvalidJavadocPositionThree.java")); @@ -92,7 +92,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionInvalidJavadocPositionThree']]/" + "OBJBLOCK/BLOCK_COMMENT_BEGIN[./COMMENT_CONTENT" @@ -102,7 +102,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInvalidJavadocPositionFour.java")); @@ -114,7 +114,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionInvalidJavadocPositionFour']]" + "/OBJBLOCK/BLOCK_COMMENT_BEGIN[./COMMENT_CONTENT" @@ -124,7 +124,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInvalidJavadocPositionFive.java")); @@ -136,7 +136,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionInvalidJavadocPositionFive']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]" @@ -147,7 +147,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest } @Test - public void testSix() throws Exception { + void six() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionInvalidJavadocPositionSix.java")); @@ -159,7 +159,7 @@ public class XpathRegressionInvalidJavadocPositionTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionInvalidJavadocPositionSix']]" + "/OBJBLOCK/BLOCK_COMMENT_BEGIN[./COMMENT_CONTENT" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavaNCSSTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavaNCSSTest.java @@ -19,6 +19,7 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.metrics.JavaNCSSCheck; import java.io.File; @@ -26,7 +27,7 @@ import java.util.List; import org.junit.jupiter.api.Test; // -@cs[AbbreviationAsWordInName] Test should be named as its main class. -public class XpathRegressionJavaNCSSTest extends AbstractXpathTestSupport { +final class XpathRegressionJavaNCSSTest extends AbstractXpathTestSupport { private final String checkName = JavaNCSSCheck.class.getSimpleName(); @@ -36,7 +37,7 @@ public class XpathRegressionJavaNCSSTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavaNCSSOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(JavaNCSSCheck.class); @@ -46,7 +47,7 @@ public class XpathRegressionJavaNCSSTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionJavaNCSSOne']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]", @@ -61,7 +62,7 @@ public class XpathRegressionJavaNCSSTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavaNCSSTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(JavaNCSSCheck.class); @@ -73,7 +74,7 @@ public class XpathRegressionJavaNCSSTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionJavaNCSSTwo']]", "/COMPILATION_UNIT/CLASS_DEF" @@ -86,7 +87,7 @@ public class XpathRegressionJavaNCSSTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavaNCSSThree.java")); final DefaultConfiguration moduleConfig = createModuleConfig(JavaNCSSCheck.class); @@ -98,7 +99,7 @@ public class XpathRegressionJavaNCSSTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - List.of("/COMPILATION_UNIT", "/COMPILATION_UNIT/PACKAGE_DEF"); + ImmutableList.of("/COMPILATION_UNIT", "/COMPILATION_UNIT/PACKAGE_DEF"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavadocContentLocationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavadocContentLocationTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocContentLocationCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionJavadocContentLocationTest extends AbstractXpathTestSupport { +final class XpathRegressionJavadocContentLocationTest extends AbstractXpathTestSupport { private final String checkName = JavadocContentLocationCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionJavadocContentLocationTest extends AbstractXpathTest } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocContentLocationOne.java")); @@ -50,7 +50,7 @@ public class XpathRegressionJavadocContentLocationTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/INTERFACE_DEF" + "[./IDENT[@text='SuppressionXpathRegressionJavadocContentLocationOne']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/TYPE/BLOCK_COMMENT_BEGIN" @@ -60,7 +60,7 @@ public class XpathRegressionJavadocContentLocationTest extends AbstractXpathTest } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocContentLocationTwo.java")); @@ -76,7 +76,7 @@ public class XpathRegressionJavadocContentLocationTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/INTERFACE_DEF[./IDENT" + "[@text='SuppressionXpathRegressionJavadocContentLocationTwo']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/TYPE/BLOCK_COMMENT_BEGIN" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavadocMethodTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavadocMethodTest.java @@ -22,15 +22,15 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_EXPECTED_TAG; import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck.MSG_INVALID_INHERIT_DOC; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { +final class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { private final String checkName = JavadocMethodCheck.class.getSimpleName(); @@ -40,7 +40,7 @@ public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocMethodOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(JavadocMethodCheck.class); @@ -66,7 +66,7 @@ public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocMethodTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(JavadocMethodCheck.class); @@ -76,7 +76,7 @@ public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionJavadocMethodTwo']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='checkParam']]/PARAMETERS" @@ -86,7 +86,7 @@ public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocMethodThree.java")); @@ -111,7 +111,7 @@ public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocMethodFour.java")); @@ -125,7 +125,7 @@ public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionJavadocMethodFour']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]" @@ -135,7 +135,7 @@ public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocMethodFive.java")); @@ -153,7 +153,7 @@ public class XpathRegressionJavadocMethodTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionJavadocMethodFive']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='bar']]/SLIST" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavadocTypeTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavadocTypeTest.java @@ -30,7 +30,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionJavadocTypeTest extends AbstractXpathTestSupport { +final class XpathRegressionJavadocTypeTest extends AbstractXpathTestSupport { private final String checkName = JavadocTypeCheck.class.getSimpleName(); @@ -40,7 +40,7 @@ public class XpathRegressionJavadocTypeTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocTypeOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(JavadocTypeCheck.class); @@ -66,7 +66,7 @@ public class XpathRegressionJavadocTypeTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocTypeTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(JavadocTypeCheck.class); @@ -91,7 +91,7 @@ public class XpathRegressionJavadocTypeTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocTypeThree.java")); final DefaultConfiguration moduleConfig = createModuleConfig(JavadocTypeCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavadocVariableTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionJavadocVariableTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionJavadocVariableTest extends AbstractXpathTestSupport { +final class XpathRegressionJavadocVariableTest extends AbstractXpathTestSupport { private final String checkName = JavadocVariableCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionJavadocVariableTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocVariableOne.java")); @@ -63,7 +63,7 @@ public class XpathRegressionJavadocVariableTest extends AbstractXpathTestSupport } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionJavadocVariableTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionLambdaBodyLengthTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionLambdaBodyLengthTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.sizes.LambdaBodyLengthCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionLambdaBodyLengthTest extends AbstractXpathTestSupport { +final class XpathRegressionLambdaBodyLengthTest extends AbstractXpathTestSupport { private static final Class CLASS = LambdaBodyLengthCheck.class; @@ -36,7 +36,7 @@ public class XpathRegressionLambdaBodyLengthTest extends AbstractXpathTestSuppor } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionLambdaBodyLength1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(CLASS); @@ -45,7 +45,7 @@ public class XpathRegressionLambdaBodyLengthTest extends AbstractXpathTestSuppor }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionLambdaBodyLength1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST" @@ -55,7 +55,7 @@ public class XpathRegressionLambdaBodyLengthTest extends AbstractXpathTestSuppor } @Test - public void testMaxIsNotDefault() throws Exception { + void maxIsNotDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionLambdaBodyLength2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(CLASS); @@ -65,7 +65,7 @@ public class XpathRegressionLambdaBodyLengthTest extends AbstractXpathTestSuppor }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionLambdaBodyLength2']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionLambdaParameterNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionLambdaParameterNameTest.java @@ -19,16 +19,16 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.LambdaParameterNameCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionLambdaParameterNameTest extends AbstractXpathTestSupport { +final class XpathRegressionLambdaParameterNameTest extends AbstractXpathTestSupport { private final String checkName = LambdaParameterNameCheck.class.getSimpleName(); @@ -38,7 +38,7 @@ public class XpathRegressionLambdaParameterNameTest extends AbstractXpathTestSup } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionLambdaParameterName1.java")); @@ -55,7 +55,7 @@ public class XpathRegressionLambdaParameterNameTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionLambdaParameterName1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/VARIABLE_DEF[" @@ -65,7 +65,7 @@ public class XpathRegressionLambdaParameterNameTest extends AbstractXpathTestSup } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionLambdaParameterName2.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionLeftCurlyTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionLeftCurlyTest.java @@ -19,16 +19,16 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck; import com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyOption; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionLeftCurlyTest extends AbstractXpathTestSupport { +final class XpathRegressionLeftCurlyTest extends AbstractXpathTestSupport { private final String checkName = LeftCurlyCheck.class.getSimpleName(); @@ -38,7 +38,7 @@ public class XpathRegressionLeftCurlyTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionLeftCurlyOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(LeftCurlyCheck.class); @@ -58,7 +58,7 @@ public class XpathRegressionLeftCurlyTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionLeftCurlyTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(LeftCurlyCheck.class); @@ -79,7 +79,7 @@ public class XpathRegressionLeftCurlyTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionLeftCurlyThree.java")); final DefaultConfiguration moduleConfig = createModuleConfig(LeftCurlyCheck.class); @@ -90,7 +90,7 @@ public class XpathRegressionLeftCurlyTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionLeftCurlyThree']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='sample']]/SLIST/LITERAL_IF/SLIST"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMagicNumberTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMagicNumberTest.java @@ -19,6 +19,7 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck; import java.io.File; @@ -26,7 +27,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMagicNumberTest extends AbstractXpathTestSupport { +final class XpathRegressionMagicNumberTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +35,7 @@ public class XpathRegressionMagicNumberTest extends AbstractXpathTestSupport { } @Test - public void testVariable() throws Exception { + void variable() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMagicNumberVariable.java")); @@ -59,7 +60,7 @@ public class XpathRegressionMagicNumberTest extends AbstractXpathTestSupport { } @Test - public void testMethodDef() throws Exception { + void methodDef() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMagicNumberMethodDef.java")); @@ -85,7 +86,7 @@ public class XpathRegressionMagicNumberTest extends AbstractXpathTestSupport { } @Test - public void testAnotherVariable() throws Exception { + void anotherVariable() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMagicNumberAnotherVariable.java")); @@ -96,7 +97,7 @@ public class XpathRegressionMagicNumberTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionMagicNumberAnotherVariable']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='performOperation']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMatchXpathTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMatchXpathTest.java @@ -19,16 +19,16 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck; import com.puppycrawl.tools.checkstyle.checks.coding.MatchXpathCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { +final class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { private final String checkName = MatchXpathCheck.class.getSimpleName(); @@ -38,7 +38,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MatchXpathCheck.class); @@ -61,7 +61,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MatchXpathCheck.class); @@ -75,7 +75,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionMatchXpathTwo']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='func1']]" @@ -85,7 +85,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedQuoteString() throws Exception { + void encodedQuoteString() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedQuoteString.java")); @@ -113,7 +113,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedLessString() throws Exception { + void encodedLessString() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedLessString.java")); @@ -140,7 +140,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedNewLineString() throws Exception { + void encodedNewLineString() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedNewLineString.java")); @@ -167,7 +167,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testGreaterString() throws Exception { + void greaterString() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedGreaterString.java")); @@ -194,7 +194,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedAmpString() throws Exception { + void encodedAmpString() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedAmpString.java")); @@ -221,7 +221,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedAposString() throws Exception { + void encodedAposString() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedAposString.java")); @@ -249,7 +249,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedCarriageString() throws Exception { + void encodedCarriageString() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedCarriageString.java")); @@ -277,7 +277,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedAmpersandChars() throws Exception { + void encodedAmpersandChars() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedAmpChar.java")); @@ -307,7 +307,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedQuoteChar() throws Exception { + void encodedQuoteChar() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedQuotChar.java")); @@ -334,7 +334,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedLessChar() throws Exception { + void encodedLessChar() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedLessChar.java")); @@ -361,7 +361,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedAposChar() throws Exception { + void encodedAposChar() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedAposChar.java")); @@ -388,7 +388,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testEncodedGreaterChar() throws Exception { + void encodedGreaterChar() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathEncodedGreaterChar.java")); @@ -417,7 +417,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { } @Test - public void testFollowing() throws Exception { + void following() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMatchXpathThree.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MatchXpathCheck.class); @@ -428,7 +428,7 @@ public class XpathRegressionMatchXpathTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionMatchXpathThree']]" + "/OBJBLOCK/RCURLY"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMemberNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMemberNameTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMemberNameTest extends AbstractXpathTestSupport { +final class XpathRegressionMemberNameTest extends AbstractXpathTestSupport { private final String checkName = MemberNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionMemberNameTest extends AbstractXpathTestSupport { } @Test - public void test1() throws Exception { + void test1() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMemberName1.java")); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -50,7 +50,7 @@ public class XpathRegressionMemberNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionMemberName1']]" @@ -59,7 +59,7 @@ public class XpathRegressionMemberNameTest extends AbstractXpathTestSupport { } @Test - public void test2() throws Exception { + void test2() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMemberName2.java")); final String pattern = "^m[A-Z][a-zA-Z0-9]*$"; @@ -75,7 +75,7 @@ public class XpathRegressionMemberNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionMemberName2']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMethodCountTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMethodCountTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMethodCountTest extends AbstractXpathTestSupport { +final class XpathRegressionMethodCountTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +34,7 @@ public class XpathRegressionMethodCountTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodCount1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MethodCountCheck.class); @@ -59,7 +59,7 @@ public class XpathRegressionMethodCountTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodCount2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MethodCountCheck.class); @@ -84,7 +84,7 @@ public class XpathRegressionMethodCountTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodCount1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MethodCountCheck.class); @@ -109,7 +109,7 @@ public class XpathRegressionMethodCountTest extends AbstractXpathTestSupport { } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodCount3.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MethodCountCheck.class); @@ -135,7 +135,7 @@ public class XpathRegressionMethodCountTest extends AbstractXpathTestSupport { } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodCount4.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MethodCountCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMethodLengthTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMethodLengthTest.java @@ -28,7 +28,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMethodLengthTest extends AbstractXpathTestSupport { +final class XpathRegressionMethodLengthTest extends AbstractXpathTestSupport { private final String checkName = MethodLengthCheck.class.getSimpleName(); @@ -38,7 +38,7 @@ public class XpathRegressionMethodLengthTest extends AbstractXpathTestSupport { } @Test - public void testSimple() throws Exception { + void simple() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodLengthSimple.java")); @@ -75,7 +75,7 @@ public class XpathRegressionMethodLengthTest extends AbstractXpathTestSupport { } @Test - public void testNoEmptyLines() throws Exception { + void noEmptyLines() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodLengthNoEmptyLines.java")); @@ -105,7 +105,7 @@ public class XpathRegressionMethodLengthTest extends AbstractXpathTestSupport { } @Test - public void testSingleToken() throws Exception { + void singleToken() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodLengthSingleToken.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMethodNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMethodNameTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMethodNameTest extends AbstractXpathTestSupport { +final class XpathRegressionMethodNameTest extends AbstractXpathTestSupport { private final String checkName = MethodNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionMethodNameTest extends AbstractXpathTestSupport { } @Test - public void test1() throws Exception { + void test1() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodName1.java")); final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -53,7 +53,7 @@ public class XpathRegressionMethodNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionMethodName1']]" @@ -62,7 +62,7 @@ public class XpathRegressionMethodNameTest extends AbstractXpathTestSupport { } @Test - public void test2() throws Exception { + void test2() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodName2.java")); final String pattern = "^[a-z](_?[a-zA-Z0-9]+)*$"; @@ -76,7 +76,7 @@ public class XpathRegressionMethodNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionMethodName2']]" @@ -86,7 +86,7 @@ public class XpathRegressionMethodNameTest extends AbstractXpathTestSupport { } @Test - public void test3() throws Exception { + void test3() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodName3.java")); final String pattern = "^[a-z](_?[a-zA-Z0-9]+)*$"; @@ -102,7 +102,7 @@ public class XpathRegressionMethodNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/INTERFACE_DEF[./IDENT[@text='Check']]" + "/OBJBLOCK/METHOD_DEF/IDENT[@text='ThirdMethod']"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMethodParamPadTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMethodParamPadTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMethodParamPadTest extends AbstractXpathTestSupport { +final class XpathRegressionMethodParamPadTest extends AbstractXpathTestSupport { private final String checkName = MethodParamPadCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionMethodParamPadTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodParamPadOne.java")); @@ -48,7 +48,7 @@ public class XpathRegressionMethodParamPadTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionMethodParamPadOne']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='InputMethodParamPad']]/LPAREN"); @@ -57,7 +57,7 @@ public class XpathRegressionMethodParamPadTest extends AbstractXpathTestSupport } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodParamPadTwo.java")); @@ -69,7 +69,7 @@ public class XpathRegressionMethodParamPadTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionMethodParamPadTwo']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='sayHello']]/LPAREN"); @@ -78,7 +78,7 @@ public class XpathRegressionMethodParamPadTest extends AbstractXpathTestSupport } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMethodParamPadThree.java")); @@ -92,7 +92,7 @@ public class XpathRegressionMethodParamPadTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionMethodParamPadThree']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='sayHello']]/LPAREN"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingCtorTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingCtorTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMissingCtorTest extends AbstractXpathTestSupport { +final class XpathRegressionMissingCtorTest extends AbstractXpathTestSupport { private final String checkName = MissingCtorCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionMissingCtorTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingCtor1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MissingCtorCheck.class); @@ -58,7 +58,7 @@ public class XpathRegressionMissingCtorTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingCtor2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MissingCtorCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingJavadocMethodTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingJavadocMethodTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMissingJavadocMethodTest extends AbstractXpathTestSupport { +final class XpathRegressionMissingJavadocMethodTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +34,7 @@ public class XpathRegressionMissingJavadocMethodTest extends AbstractXpathTestSu } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingJavadocMethod1.java")); @@ -68,7 +68,7 @@ public class XpathRegressionMissingJavadocMethodTest extends AbstractXpathTestSu } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingJavadocMethod2.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingJavadocPackageTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingJavadocPackageTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMissingJavadocPackageTest extends AbstractXpathTestSupport { +final class XpathRegressionMissingJavadocPackageTest extends AbstractXpathTestSupport { private final String checkName = MissingJavadocPackageCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionMissingJavadocPackageTest extends AbstractXpathTestS } @Test - public void testBlockComment() throws Exception { + void blockComment() throws Exception { final File fileToProcess = new File(getPath("blockcomment/package-info.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MissingJavadocPackageCheck.class); @@ -53,7 +53,7 @@ public class XpathRegressionMissingJavadocPackageTest extends AbstractXpathTestS } @Test - public void testNoJavadoc() throws Exception { + void noJavadoc() throws Exception { final File fileToProcess = new File(getPath("nojavadoc/package-info.java")); final DefaultConfiguration moduleConfig = createModuleConfig(MissingJavadocPackageCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingJavadocTypeTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingJavadocTypeTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMissingJavadocTypeTest extends AbstractXpathTestSupport { +final class XpathRegressionMissingJavadocTypeTest extends AbstractXpathTestSupport { private final String checkName = MissingJavadocTypeCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionMissingJavadocTypeTest extends AbstractXpathTestSupp } @Test - public void testClass() throws Exception { + void testClass() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingJavadocTypeClass.java")); @@ -65,7 +65,7 @@ public class XpathRegressionMissingJavadocTypeTest extends AbstractXpathTestSupp } @Test - public void testScope() throws Exception { + void scope() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingJavadocTypeScope.java")); @@ -96,7 +96,7 @@ public class XpathRegressionMissingJavadocTypeTest extends AbstractXpathTestSupp } @Test - public void testExcluded() throws Exception { + void excluded() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingJavadocTypeExcluded.java")); @@ -128,7 +128,7 @@ public class XpathRegressionMissingJavadocTypeTest extends AbstractXpathTestSupp } @Test - public void testAnnotation() throws Exception { + void annotation() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingJavadocTypeAnnotation.java")); @@ -164,7 +164,7 @@ public class XpathRegressionMissingJavadocTypeTest extends AbstractXpathTestSupp } @Test - public void testToken() throws Exception { + void token() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingJavadocTypeToken.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingOverrideTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingOverrideTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport { +final class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport { private final String checkName = MissingOverrideCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport } @Test - public void testClass() throws Exception { + void testClass() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingOverrideClass.java")); @@ -64,7 +64,7 @@ public class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport } @Test - public void testInterface() throws Exception { + void testInterface() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingOverrideInterface.java")); @@ -95,7 +95,7 @@ public class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport } @Test - public void testAnonymous() throws Exception { + void anonymous() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingOverrideAnonymous.java")); @@ -129,7 +129,7 @@ public class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport } @Test - public void testInheritDocInvalid1() throws Exception { + void inheritDocInvalid1() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingOverrideInheritDocInvalid1.java")); @@ -159,7 +159,7 @@ public class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport } @Test - public void testInheritDocInvalid2() throws Exception { + void inheritDocInvalid2() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingOverrideInheritDocInvalid2.java")); @@ -189,7 +189,7 @@ public class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport } @Test - public void testJavaFiveCompatibility1() throws Exception { + void javaFiveCompatibility1() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingOverrideClass.java")); @@ -218,7 +218,7 @@ public class XpathRegressionMissingOverrideTest extends AbstractXpathTestSupport } @Test - public void testJavaFiveCompatibility2() throws Exception { + void javaFiveCompatibility2() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingOverrideInterface.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingSwitchDefaultTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMissingSwitchDefaultTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.MissingSwitchDefaultCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMissingSwitchDefaultTest extends AbstractXpathTestSupport { +final class XpathRegressionMissingSwitchDefaultTest extends AbstractXpathTestSupport { private final Class clss = MissingSwitchDefaultCheck.class; @@ -37,7 +37,7 @@ public class XpathRegressionMissingSwitchDefaultTest extends AbstractXpathTestSu } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingSwitchDefaultOne.java")); @@ -47,7 +47,7 @@ public class XpathRegressionMissingSwitchDefaultTest extends AbstractXpathTestSu }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionMissingSwitchDefaultOne']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test1']]" @@ -57,7 +57,7 @@ public class XpathRegressionMissingSwitchDefaultTest extends AbstractXpathTestSu } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMissingSwitchDefaultTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionModifierOrderTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionModifierOrderTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.modifier.ModifierOrderCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionModifierOrderTest extends AbstractXpathTestSupport { +final class XpathRegressionModifierOrderTest extends AbstractXpathTestSupport { private final Class clazz = ModifierOrderCheck.class; @@ -37,7 +37,7 @@ public class XpathRegressionModifierOrderTest extends AbstractXpathTestSupport { } @Test - public void testMethod() throws Exception { + void method() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionModifierOrderMethod.java")); @@ -63,7 +63,7 @@ public class XpathRegressionModifierOrderTest extends AbstractXpathTestSupport { } @Test - public void testVariable() throws Exception { + void variable() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionModifierOrderVariable.java")); @@ -74,7 +74,7 @@ public class XpathRegressionModifierOrderTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionModifierOrderVariable']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='var']]/MODIFIERS/LITERAL_PRIVATE"); @@ -83,7 +83,7 @@ public class XpathRegressionModifierOrderTest extends AbstractXpathTestSupport { } @Test - public void testAnnotation() throws Exception { + void annotation() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionModifierOrderAnnotation.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMultipleStringLiteralsTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMultipleStringLiteralsTest.java @@ -21,15 +21,15 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.MultipleStringLiteralsCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMultipleStringLiteralsTest extends AbstractXpathTestSupport { +final class XpathRegressionMultipleStringLiteralsTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -38,7 +38,7 @@ public class XpathRegressionMultipleStringLiteralsTest extends AbstractXpathTest } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMultipleStringLiteralsDefault.java")); @@ -64,7 +64,7 @@ public class XpathRegressionMultipleStringLiteralsTest extends AbstractXpathTest } @Test - public void testAllowDuplicates() throws Exception { + void allowDuplicates() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMultipleStringLiteralsAllowDuplicates.java")); @@ -76,7 +76,7 @@ public class XpathRegressionMultipleStringLiteralsTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionMultipleStringLiteralsAllowDuplicates']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myTest']]/SLIST/VARIABLE_DEF" @@ -87,7 +87,7 @@ public class XpathRegressionMultipleStringLiteralsTest extends AbstractXpathTest } @Test - public void testIgnoreRegexp() throws Exception { + void ignoreRegexp() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMultipleStringLiteralsIgnoreRegexp.java")); @@ -99,7 +99,7 @@ public class XpathRegressionMultipleStringLiteralsTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionMultipleStringLiteralsIgnoreRegexp']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myTest']]/SLIST/VARIABLE_DEF" @@ -109,7 +109,7 @@ public class XpathRegressionMultipleStringLiteralsTest extends AbstractXpathTest } @Test - public void testIgnoreOccurrenceContext() throws Exception { + void ignoreOccurrenceContext() throws Exception { final String filePath = "SuppressionXpathRegressionMultipleStringLiteralsIgnoreOccurrenceContext.java"; final File fileToProcess = new File(getPath(filePath)); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMultipleVariableDeclarationsTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionMultipleVariableDeclarationsTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionMultipleVariableDeclarationsTest extends AbstractXpathTestSupport { +final class XpathRegressionMultipleVariableDeclarationsTest extends AbstractXpathTestSupport { private final String checkName = MultipleVariableDeclarationsCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionMultipleVariableDeclarationsTest extends AbstractXpa } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMultipleVariableDeclarationsOne.java")); @@ -81,7 +81,7 @@ public class XpathRegressionMultipleVariableDeclarationsTest extends AbstractXpa } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionMultipleVariableDeclarationsTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNPathComplexityTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNPathComplexityTest.java @@ -19,16 +19,16 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.metrics.NPathComplexityCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; // -@cs[AbbreviationAsWordInName] Test should be named as its main class. -public class XpathRegressionNPathComplexityTest extends AbstractXpathTestSupport { +final class XpathRegressionNPathComplexityTest extends AbstractXpathTestSupport { private final String checkName = NPathComplexityCheck.class.getSimpleName(); @@ -38,7 +38,7 @@ public class XpathRegressionNPathComplexityTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNPathComplexityOne.java")); @@ -65,7 +65,7 @@ public class XpathRegressionNPathComplexityTest extends AbstractXpathTestSupport } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNPathComplexityTwo.java")); @@ -77,7 +77,7 @@ public class XpathRegressionNPathComplexityTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNPathComplexityTwo']]" + "/OBJBLOCK/STATIC_INIT"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNeedBracesTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNeedBracesTest.java @@ -21,14 +21,14 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck.MSG_KEY_NEED_BRACES; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { +final class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { private final String checkName = NeedBracesCheck.class.getSimpleName(); @Override @@ -37,7 +37,7 @@ public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { } @Test - public void testDo() throws Exception { + void testDo() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNeedBracesDo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NeedBracesCheck.class); @@ -47,7 +47,7 @@ public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNeedBracesDo']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_DO"); @@ -56,7 +56,7 @@ public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { } @Test - public void testSingleLine() throws Exception { + void singleLine() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNeedBracesSingleLine.java")); @@ -68,7 +68,7 @@ public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNeedBracesSingleLine']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_IF"); @@ -77,7 +77,7 @@ public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { } @Test - public void testSingleLineLambda() throws Exception { + void singleLineLambda() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNeedBracesSingleLineLambda.java")); @@ -90,7 +90,7 @@ public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNeedBracesSingleLineLambda']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='r3']]/ASSIGN/LAMBDA"); @@ -99,7 +99,7 @@ public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { } @Test - public void testEmptyLoopBody() throws Exception { + void emptyLoopBody() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNeedBracesEmptyLoopBody.java")); @@ -110,7 +110,7 @@ public class XpathRegressionNeedBracesTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNeedBracesEmptyLoopBody']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_WHILE"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNestedForDepthTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNestedForDepthTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.NestedForDepthCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNestedForDepthTest extends AbstractXpathTestSupport { +final class XpathRegressionNestedForDepthTest extends AbstractXpathTestSupport { private final String checkName = NestedForDepthCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionNestedForDepthTest extends AbstractXpathTestSupport } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNestedForDepth.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NestedForDepthCheck.class); @@ -46,7 +46,7 @@ public class XpathRegressionNestedForDepthTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNestedForDepth']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_FOR" @@ -56,7 +56,7 @@ public class XpathRegressionNestedForDepthTest extends AbstractXpathTestSupport } @Test - public void testMax() throws Exception { + void max() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNestedForDepthMax.java")); @@ -68,7 +68,7 @@ public class XpathRegressionNestedForDepthTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNestedForDepthMax']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNestedIfDepthTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNestedIfDepthTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNestedIfDepthTest extends AbstractXpathTestSupport { +final class XpathRegressionNestedIfDepthTest extends AbstractXpathTestSupport { private final String checkName = NestedIfDepthCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionNestedIfDepthTest extends AbstractXpathTestSupport { } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNestedIfDepth.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NestedIfDepthCheck.class); @@ -46,7 +46,7 @@ public class XpathRegressionNestedIfDepthTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNestedIfDepth']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_IF" @@ -56,7 +56,7 @@ public class XpathRegressionNestedIfDepthTest extends AbstractXpathTestSupport { } @Test - public void testMax() throws Exception { + void max() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNestedIfDepthMax.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NestedIfDepthCheck.class); @@ -67,7 +67,7 @@ public class XpathRegressionNestedIfDepthTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNestedIfDepthMax']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNestedTryDepthTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNestedTryDepthTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNestedTryDepthTest extends AbstractXpathTestSupport { +final class XpathRegressionNestedTryDepthTest extends AbstractXpathTestSupport { private final String checkName = NestedTryDepthCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionNestedTryDepthTest extends AbstractXpathTestSupport } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNestedTryDepth.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NestedTryDepthCheck.class); @@ -46,7 +46,7 @@ public class XpathRegressionNestedTryDepthTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNestedTryDepth']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_TRY/SLIST" @@ -56,7 +56,7 @@ public class XpathRegressionNestedTryDepthTest extends AbstractXpathTestSupport } @Test - public void testMax() throws Exception { + void max() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNestedTryDepthMax.java")); @@ -68,7 +68,7 @@ public class XpathRegressionNestedTryDepthTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNestedTryDepthMax']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoArrayTrailingCommaTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoArrayTrailingCommaTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.NoArrayTrailingCommaCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNoArrayTrailingCommaTest extends AbstractXpathTestSupport { +final class XpathRegressionNoArrayTrailingCommaTest extends AbstractXpathTestSupport { private final String checkName = NoArrayTrailingCommaCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionNoArrayTrailingCommaTest extends AbstractXpathTestSu } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoArrayTrailingCommaOne.java")); @@ -48,7 +48,7 @@ public class XpathRegressionNoArrayTrailingCommaTest extends AbstractXpathTestSu }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionNoArrayTrailingCommaOne']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='t1']]/ASSIGN/EXPR" @@ -58,7 +58,7 @@ public class XpathRegressionNoArrayTrailingCommaTest extends AbstractXpathTestSu } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoArrayTrailingCommaTwo.java")); @@ -70,7 +70,7 @@ public class XpathRegressionNoArrayTrailingCommaTest extends AbstractXpathTestSu }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNoArrayTrailingCommaTwo']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='t4']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoCloneTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoCloneTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNoCloneTest extends AbstractXpathTestSupport { +final class XpathRegressionNoCloneTest extends AbstractXpathTestSupport { private final String checkName = NoCloneCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionNoCloneTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoCloneOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NoCloneCheck.class); @@ -61,7 +61,7 @@ public class XpathRegressionNoCloneTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoCloneTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NoCloneCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoEnumTrailingCommaTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoEnumTrailingCommaTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.NoEnumTrailingCommaCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNoEnumTrailingCommaTest extends AbstractXpathTestSupport { +final class XpathRegressionNoEnumTrailingCommaTest extends AbstractXpathTestSupport { private final String checkName = NoEnumTrailingCommaCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionNoEnumTrailingCommaTest extends AbstractXpathTestSup } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoEnumTrailingCommaOne.java")); @@ -47,7 +47,7 @@ public class XpathRegressionNoEnumTrailingCommaTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNoEnumTrailingCommaOne']]" + "/OBJBLOCK/ENUM_DEF[./IDENT[@text='Foo3']]/OBJBLOCK/COMMA[2]"); @@ -56,7 +56,7 @@ public class XpathRegressionNoEnumTrailingCommaTest extends AbstractXpathTestSup } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoEnumTrailingCommaTwo.java")); @@ -67,7 +67,7 @@ public class XpathRegressionNoEnumTrailingCommaTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNoEnumTrailingCommaTwo']]" + "/OBJBLOCK/ENUM_DEF[./IDENT[@text='Foo6']]/OBJBLOCK/COMMA[2]"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoFinalizerTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoFinalizerTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNoFinalizerTest extends AbstractXpathTestSupport { +final class XpathRegressionNoFinalizerTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +34,7 @@ public class XpathRegressionNoFinalizerTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoFinalizer1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NoFinalizerCheck.class); @@ -59,7 +59,7 @@ public class XpathRegressionNoFinalizerTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoFinalizer2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NoFinalizerCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoLineWrapTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoLineWrapTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNoLineWrapTest extends AbstractXpathTestSupport { +final class XpathRegressionNoLineWrapTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +34,7 @@ public class XpathRegressionNoLineWrapTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoLineWrap1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NoLineWrapCheck.class); @@ -50,7 +50,7 @@ public class XpathRegressionNoLineWrapTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoLineWrap2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NoLineWrapCheck.class); @@ -78,7 +78,7 @@ public class XpathRegressionNoLineWrapTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoLineWrap3.java")); final DefaultConfiguration moduleConfig = createModuleConfig(NoLineWrapCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoWhitespaceAfterTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoWhitespaceAfterTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNoWhitespaceAfterTest extends AbstractXpathTestSupport { +final class XpathRegressionNoWhitespaceAfterTest extends AbstractXpathTestSupport { private final String checkName = NoWhitespaceAfterCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionNoWhitespaceAfterTest extends AbstractXpathTestSuppo } @Test - public void testNoWhitespaceAfter() throws Exception { + void noWhitespaceAfter() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceAfter.java")); @@ -61,7 +61,7 @@ public class XpathRegressionNoWhitespaceAfterTest extends AbstractXpathTestSuppo } @Test - public void testTokens() throws Exception { + void tokens() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceAfterTokens.java")); @@ -73,7 +73,7 @@ public class XpathRegressionNoWhitespaceAfterTest extends AbstractXpathTestSuppo }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNoWhitespaceAfterTokens']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]" @@ -84,7 +84,7 @@ public class XpathRegressionNoWhitespaceAfterTest extends AbstractXpathTestSuppo } @Test - public void testAllowLineBreaks() throws Exception { + void allowLineBreaks() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceAfterLineBreaks.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest.java @@ -19,15 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest - extends AbstractXpathTestSupport { +final class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest extends AbstractXpathTestSupport { private final String checkName = NoWhitespaceBeforeCaseDefaultColonCheck.class.getSimpleName(); @@ -37,7 +36,7 @@ public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceBeforeCaseDefaultColonOne.java")); @@ -53,7 +52,7 @@ public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionNoWhitespaceBeforeCaseDefaultColonOne']]" + "/OBJBLOCK/INSTANCE_INIT/SLIST/LITERAL_SWITCH/CASE_GROUP/LITERAL_CASE/COLON"); @@ -62,7 +61,7 @@ public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceBeforeCaseDefaultColonTwo.java")); @@ -78,7 +77,7 @@ public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionNoWhitespaceBeforeCaseDefaultColonTwo']]" + "/OBJBLOCK/INSTANCE_INIT/SLIST/LITERAL_SWITCH/CASE_GROUP" @@ -88,7 +87,7 @@ public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceBeforeCaseDefaultColonThree.java")); @@ -104,7 +103,7 @@ public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionNoWhitespaceBeforeCaseDefaultColonThree']]" + "/OBJBLOCK/INSTANCE_INIT/SLIST/LITERAL_SWITCH/CASE_GROUP" @@ -114,7 +113,7 @@ public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceBeforeCaseDefaultColonFour.java")); @@ -130,7 +129,7 @@ public class XpathRegressionNoWhitespaceBeforeCaseDefaultColonTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionNoWhitespaceBeforeCaseDefaultColonFour']]" + "/OBJBLOCK/INSTANCE_INIT/SLIST/LITERAL_SWITCH/CASE_GROUP" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoWhitespaceBeforeTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionNoWhitespaceBeforeTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionNoWhitespaceBeforeTest extends AbstractXpathTestSupport { +final class XpathRegressionNoWhitespaceBeforeTest extends AbstractXpathTestSupport { private final String checkName = NoWhitespaceBeforeCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionNoWhitespaceBeforeTest extends AbstractXpathTestSupp } @Test - public void testNoWhitespaceBefore() throws Exception { + void noWhitespaceBefore() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceBefore.java")); @@ -48,7 +48,7 @@ public class XpathRegressionNoWhitespaceBeforeTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNoWhitespaceBefore']]/OBJBLOCK" + "/VARIABLE_DEF[./IDENT[@text='bad']]/SEMI"); @@ -57,7 +57,7 @@ public class XpathRegressionNoWhitespaceBeforeTest extends AbstractXpathTestSupp } @Test - public void testTokens() throws Exception { + void tokens() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceBeforeTokens.java")); @@ -70,7 +70,7 @@ public class XpathRegressionNoWhitespaceBeforeTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNoWhitespaceBeforeTokens']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]" @@ -81,7 +81,7 @@ public class XpathRegressionNoWhitespaceBeforeTest extends AbstractXpathTestSupp } @Test - public void testAllowLineBreaks() throws Exception { + void allowLineBreaks() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionNoWhitespaceBeforeLineBreaks.java")); @@ -94,7 +94,7 @@ public class XpathRegressionNoWhitespaceBeforeTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionNoWhitespaceBeforeLineBreaks']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOneStatementPerLineTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOneStatementPerLineTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionOneStatementPerLineTest extends AbstractXpathTestSupport { +final class XpathRegressionOneStatementPerLineTest extends AbstractXpathTestSupport { private final String checkName = OneStatementPerLineCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionOneStatementPerLineTest extends AbstractXpathTestSup } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOneStatementPerLineOne.java")); @@ -47,7 +47,7 @@ public class XpathRegressionOneStatementPerLineTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionOneStatementPerLineOne']]/OBJBLOCK" + "/VARIABLE_DEF[./IDENT[@text='j']]/SEMI"); @@ -56,7 +56,7 @@ public class XpathRegressionOneStatementPerLineTest extends AbstractXpathTestSup } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOneStatementPerLineTwo.java")); @@ -67,7 +67,7 @@ public class XpathRegressionOneStatementPerLineTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionOneStatementPerLineTwo']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='foo5']]/SLIST/LITERAL_FOR/SLIST/SEMI[2]"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOneTopLevelClassTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOneTopLevelClassTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionOneTopLevelClassTest extends AbstractXpathTestSupport { +final class XpathRegressionOneTopLevelClassTest extends AbstractXpathTestSupport { private final String checkName = OneTopLevelClassCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionOneTopLevelClassTest extends AbstractXpathTestSuppor } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOneTopLevelClassFirst.java")); @@ -58,7 +58,7 @@ public class XpathRegressionOneTopLevelClassTest extends AbstractXpathTestSuppor } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOneTopLevelClassSecond.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOperatorWrapTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOperatorWrapTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionOperatorWrapTest extends AbstractXpathTestSupport { +final class XpathRegressionOperatorWrapTest extends AbstractXpathTestSupport { private final String checkName = OperatorWrapCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionOperatorWrapTest extends AbstractXpathTestSupport { } @Test - public void testOperatorWrapNewLine() throws Exception { + void operatorWrapNewLine() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOperatorWrapNewLine.java")); @@ -47,7 +47,7 @@ public class XpathRegressionOperatorWrapTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionOperatorWrapNewLine']]" @@ -60,7 +60,7 @@ public class XpathRegressionOperatorWrapTest extends AbstractXpathTestSupport { } @Test - public void testOperatorWrapPreviousLine() throws Exception { + void operatorWrapPreviousLine() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOperatorWrapPreviousLine.java")); @@ -73,7 +73,7 @@ public class XpathRegressionOperatorWrapTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionOperatorWrapPreviousLine']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='b']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOuterTypeFilenameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOuterTypeFilenameTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionOuterTypeFilenameTest extends AbstractXpathTestSupport { +final class XpathRegressionOuterTypeFilenameTest extends AbstractXpathTestSupport { private final String checkName = OuterTypeFilenameCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionOuterTypeFilenameTest extends AbstractXpathTestSuppo } @Test - public void testNoPublic() throws Exception { + void noPublic() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOuterTypeFilename1.java")); @@ -56,7 +56,7 @@ public class XpathRegressionOuterTypeFilenameTest extends AbstractXpathTestSuppo } @Test - public void testNested() throws Exception { + void nested() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOuterTypeFilename2.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOuterTypeNumberTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOuterTypeNumberTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionOuterTypeNumberTest extends AbstractXpathTestSupport { +final class XpathRegressionOuterTypeNumberTest extends AbstractXpathTestSupport { private final String checkName = OuterTypeNumberCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionOuterTypeNumberTest extends AbstractXpathTestSupport } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOuterTypeNumberDefault.java")); @@ -53,7 +53,7 @@ public class XpathRegressionOuterTypeNumberTest extends AbstractXpathTestSupport } @Test - public void testMax() throws Exception { + void max() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOuterTypeNumber.java")); final DefaultConfiguration moduleConfig = createModuleConfig(OuterTypeNumberCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOverloadMethodsDeclarationOrderTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionOverloadMethodsDeclarationOrderTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionOverloadMethodsDeclarationOrderTest extends AbstractXpathTestSupport { +final class XpathRegressionOverloadMethodsDeclarationOrderTest extends AbstractXpathTestSupport { private final Class clazz = OverloadMethodsDeclarationOrderCheck.class; @@ -37,7 +37,7 @@ public class XpathRegressionOverloadMethodsDeclarationOrderTest extends Abstract } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOverloadMethodsDeclarationOrder1.java")); @@ -64,7 +64,7 @@ public class XpathRegressionOverloadMethodsDeclarationOrderTest extends Abstract } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionOverloadMethodsDeclarationOrder2.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionPackageAnnotationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionPackageAnnotationTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionPackageAnnotationTest extends AbstractXpathTestSupport { +final class XpathRegressionPackageAnnotationTest extends AbstractXpathTestSupport { private final String checkName = PackageAnnotationCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionPackageAnnotationTest extends AbstractXpathTestSuppo } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionPackageAnnotationOne.java")); @@ -53,7 +53,7 @@ public class XpathRegressionPackageAnnotationTest extends AbstractXpathTestSuppo } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionPackageAnnotationTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionPackageDeclarationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionPackageDeclarationTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionPackageDeclarationTest extends AbstractXpathTestSupport { +final class XpathRegressionPackageDeclarationTest extends AbstractXpathTestSupport { private final String checkName = PackageDeclarationCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionPackageDeclarationTest extends AbstractXpathTestSupp } @Test - public void test1() throws Exception { + void test1() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegression1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(PackageDeclarationCheck.class); @@ -54,7 +54,7 @@ public class XpathRegressionPackageDeclarationTest extends AbstractXpathTestSupp } @Test - public void test2() throws Exception { + void test2() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegression2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(PackageDeclarationCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionPackageNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionPackageNameTest.java @@ -21,14 +21,14 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.PackageNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionPackageNameTest extends AbstractXpathTestSupport { +final class XpathRegressionPackageNameTest extends AbstractXpathTestSupport { private final String checkName = PackageNameCheck.class.getSimpleName(); @@ -38,7 +38,7 @@ public class XpathRegressionPackageNameTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionPackageNameOne.java")); @@ -57,7 +57,7 @@ public class XpathRegressionPackageNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/PACKAGE_DEF/DOT" + "[./IDENT[@text='packagename']]/DOT" + "[./IDENT[@text='suppressionxpathfilter']]" @@ -67,7 +67,7 @@ public class XpathRegressionPackageNameTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionPackageName.java")); @@ -86,7 +86,7 @@ public class XpathRegressionPackageNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/PACKAGE_DEF/DOT[./IDENT" + "[@text='PACKAGENAME']]/DOT[./IDENT" + "[@text='suppressionxpathfilter']]" @@ -96,7 +96,7 @@ public class XpathRegressionPackageNameTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionPackageNameTwo.java")); @@ -115,7 +115,7 @@ public class XpathRegressionPackageNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/PACKAGE_DEF/DOT" + "[./IDENT[@text='packagename']]/DOT" + "[./IDENT[@text='suppressionxpathfilter']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionParameterNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionParameterNameTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { +final class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { private final String checkName = ParameterNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { } @Test - public void testDefaultPattern() throws Exception { + void defaultPattern() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParameterNameDefaultPattern.java")); @@ -51,7 +51,7 @@ public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionParameterNameDefaultPattern']]" @@ -61,7 +61,7 @@ public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { } @Test - public void testDifferentPattern() throws Exception { + void differentPattern() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParameterNameDifferentPattern.java")); @@ -76,7 +76,7 @@ public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionParameterNameDifferentPattern']]" @@ -86,7 +86,7 @@ public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { } @Test - public void testIgnoreOverridden() throws Exception { + void ignoreOverridden() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParameterNameIgnoreOverridden.java")); @@ -101,7 +101,7 @@ public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionParameterNameIgnoreOverridden']]" @@ -111,7 +111,7 @@ public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { } @Test - public void testAccessModifiers() throws Exception { + void accessModifiers() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParameterNameAccessModifier.java")); @@ -127,7 +127,7 @@ public class XpathRegressionParameterNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionParameterNameAccessModifier']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionParameterNumberTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionParameterNumberTest.java @@ -21,14 +21,14 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionParameterNumberTest extends AbstractXpathTestSupport { +final class XpathRegressionParameterNumberTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -36,7 +36,7 @@ public class XpathRegressionParameterNumberTest extends AbstractXpathTestSupport } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParameterNumberDefault.java")); @@ -47,7 +47,7 @@ public class XpathRegressionParameterNumberTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionParameterNumberDefault']]" + "/OBJBLOCK/METHOD_DEF/IDENT[@text='myMethod']"); @@ -56,7 +56,7 @@ public class XpathRegressionParameterNumberTest extends AbstractXpathTestSupport } @Test - public void testMethods() throws Exception { + void methods() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParameterNumberMethods.java")); @@ -69,7 +69,7 @@ public class XpathRegressionParameterNumberTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionParameterNumberMethods']]" + "/OBJBLOCK/METHOD_DEF/IDENT[@text='myMethod']"); @@ -78,7 +78,7 @@ public class XpathRegressionParameterNumberTest extends AbstractXpathTestSupport } @Test - public void testIgnoreOverriddenMethods() throws Exception { + void ignoreOverriddenMethods() throws Exception { final String filePath = getPath("SuppressionXpathRegressionParameterNumberIgnoreOverriddenMethods.java"); final File fileToProcess = new File(filePath); @@ -91,7 +91,7 @@ public class XpathRegressionParameterNumberTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionParameterNumberIgnoreOverriddenMethods']]" + "/OBJBLOCK/CTOR_DEF/IDENT" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionParenPadTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionParenPadTest.java @@ -19,16 +19,16 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck; import com.puppycrawl.tools.checkstyle.checks.whitespace.PadOption; import com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { +final class XpathRegressionParenPadTest extends AbstractXpathTestSupport { private final String checkName = ParenPadCheck.class.getSimpleName(); @@ -38,7 +38,7 @@ public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { } @Test - public void testLeftFollowed() throws Exception { + void leftFollowed() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParenPadLeftFollowed.java")); @@ -49,7 +49,7 @@ public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionParenPadLeftFollowed']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_IF/LPAREN"); @@ -58,7 +58,7 @@ public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { } @Test - public void testLeftNotFollowed() throws Exception { + void leftNotFollowed() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParenPadLeftNotFollowed.java")); @@ -71,7 +71,7 @@ public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionParenPadLeftNotFollowed']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_IF/LPAREN"); @@ -80,7 +80,7 @@ public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { } @Test - public void testRightPreceded() throws Exception { + void rightPreceded() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParenPadRightPreceded.java")); @@ -91,7 +91,7 @@ public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionParenPadRightPreceded']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_IF/RPAREN"); @@ -100,7 +100,7 @@ public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { } @Test - public void testRightNotPreceded() throws Exception { + void rightNotPreceded() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionParenPadRightNotPreceded.java")); @@ -113,7 +113,7 @@ public class XpathRegressionParenPadTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionParenPadRightNotPreceded']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='method']]/SLIST/LITERAL_IF/RPAREN"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionPatternVariableNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionPatternVariableNameTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.PatternVariableNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSupport { +final class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSupport { private final String checkName = PatternVariableNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSup } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionPatternVariableName1.java")); @@ -54,7 +54,7 @@ public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionPatternVariableName1']]" + "/OBJBLOCK/CTOR_DEF[./IDENT[@text='MyClass']]/SLIST/LITERAL_IF/EXPR/" @@ -65,7 +65,7 @@ public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSup } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionPatternVariableName2.java")); @@ -84,7 +84,7 @@ public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionPatternVariableName2']]" + "/OBJBLOCK/CTOR_DEF[./IDENT[@text='MyClass']]/SLIST/LITERAL_IF/EXPR/" @@ -95,7 +95,7 @@ public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSup } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionPatternVariableName3.java")); @@ -114,7 +114,7 @@ public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionPatternVariableName3']]" + "/OBJBLOCK/CTOR_DEF[./IDENT[@text='MyClass']]/SLIST/LITERAL_IF/" @@ -125,7 +125,7 @@ public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSup } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionPatternVariableName4.java")); @@ -144,7 +144,7 @@ public class XpathRegressionPatternVariableNameTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionPatternVariableName1']]" + "/OBJBLOCK/CTOR_DEF[./IDENT[@text='MyClass']]/SLIST/LITERAL_IF/EXPR/" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRecordComponentNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRecordComponentNameTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.RecordComponentNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionRecordComponentNameTest extends AbstractXpathTestSupport { +final class XpathRegressionRecordComponentNameTest extends AbstractXpathTestSupport { private final String checkName = RecordComponentNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionRecordComponentNameTest extends AbstractXpathTestSup } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRecordComponentName1.java")); @@ -53,7 +53,7 @@ public class XpathRegressionRecordComponentNameTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/RECORD_DEF[./IDENT[@text='SuppressionXpathRecordComponentName1']]" + "/RECORD_COMPONENTS/RECORD_COMPONENT_DEF/IDENT[@text='_value']"); @@ -61,7 +61,7 @@ public class XpathRegressionRecordComponentNameTest extends AbstractXpathTestSup } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRecordComponentName2.java")); @@ -78,7 +78,7 @@ public class XpathRegressionRecordComponentNameTest extends AbstractXpathTestSup }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRecordComponentName2']]/OBJBLOCK" + "/RECORD_DEF[./IDENT[@text='MyRecord']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRecordComponentNumberTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRecordComponentNumberTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionRecordComponentNumberTest extends AbstractXpathTestSupport { +final class XpathRegressionRecordComponentNumberTest extends AbstractXpathTestSupport { private final String checkName = RecordComponentNumberCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionRecordComponentNumberTest extends AbstractXpathTestS } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRecordComponentNumber1.java")); @@ -60,7 +60,7 @@ public class XpathRegressionRecordComponentNumberTest extends AbstractXpathTestS } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRecordComponentNumber2.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRecordTypeParameterNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRecordTypeParameterNameTest.java @@ -27,7 +27,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionRecordTypeParameterNameTest extends AbstractXpathTestSupport { +final class XpathRegressionRecordTypeParameterNameTest extends AbstractXpathTestSupport { private final String checkName = RecordTypeParameterNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionRecordTypeParameterNameTest extends AbstractXpathTes } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionRecordTypeParameterName1.java")); @@ -66,7 +66,7 @@ public class XpathRegressionRecordTypeParameterNameTest extends AbstractXpathTes } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionRecordTypeParameterName2.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRedundantImportTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRedundantImportTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionRedundantImportTest extends AbstractXpathTestSupport { +final class XpathRegressionRedundantImportTest extends AbstractXpathTestSupport { private final String checkName = RedundantImportCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionRedundantImportTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRedundantImport1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RedundantImportCheck.class); final String[] expectedViolation = { @@ -47,13 +47,13 @@ public class XpathRegressionRedundantImportTest extends AbstractXpathTestSupport "org.checkstyle.suppressionxpathfilter" + ".redundantimport.SuppressionXpathRegressionRedundantImport1"), }; - final List expectedXpathQueries = Collections.singletonList("/COMPILATION_UNIT/IMPORT"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/IMPORT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRedundantImport2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RedundantImportCheck.class); final String[] expectedViolation = { @@ -61,13 +61,13 @@ public class XpathRegressionRedundantImportTest extends AbstractXpathTestSupport + getCheckMessage( RedundantImportCheck.class, RedundantImportCheck.MSG_LANG, "java.lang.String"), }; - final List expectedXpathQueries = Collections.singletonList("/COMPILATION_UNIT/IMPORT"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/IMPORT"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRedundantImport3.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RedundantImportCheck.class); final String[] expectedViolation = { @@ -79,7 +79,7 @@ public class XpathRegressionRedundantImportTest extends AbstractXpathTestSupport "java.util.Scanner"), }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Scanner']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Scanner']]"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRequireThisTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRequireThisTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionRequireThisTest extends AbstractXpathTestSupport { +final class XpathRegressionRequireThisTest extends AbstractXpathTestSupport { private final String checkName = RequireThisCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionRequireThisTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRequireThisOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RequireThisCheck.class); @@ -47,7 +47,7 @@ public class XpathRegressionRequireThisTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionRequireThisOne']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='changeAge']]/SLIST/EXPR/ASSIGN" @@ -57,7 +57,7 @@ public class XpathRegressionRequireThisTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRequireThisTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RequireThisCheck.class); @@ -68,7 +68,7 @@ public class XpathRegressionRequireThisTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionRequireThisTwo']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='method2']]/SLIST/EXPR" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionReturnCountTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionReturnCountTest.java @@ -19,6 +19,7 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.ReturnCountCheck; import java.io.File; @@ -26,7 +27,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { +final class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -34,7 +35,7 @@ public class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionReturnCount1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ReturnCountCheck.class); @@ -62,7 +63,7 @@ public class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionReturnCount1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ReturnCountCheck.class); @@ -92,7 +93,7 @@ public class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionReturnCount2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ReturnCountCheck.class); @@ -120,7 +121,7 @@ public class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionReturnCount2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ReturnCountCheck.class); @@ -150,7 +151,7 @@ public class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionReturnCount3.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ReturnCountCheck.class); @@ -176,7 +177,7 @@ public class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { } @Test - public void testSix() throws Exception { + void six() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionReturnCount4.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ReturnCountCheck.class); @@ -186,7 +187,7 @@ public class XpathRegressionReturnCountTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionReturnCount4']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='testLambda']]/SLIST" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRightCurlyTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionRightCurlyTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck; import com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyOption; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { +final class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { private final String checkName = RightCurlyCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRightCurlyOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RightCurlyCheck.class); @@ -47,7 +47,7 @@ public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionRightCurlyOne']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='test']]/SLIST/LITERAL_IF/SLIST/RCURLY"); @@ -56,7 +56,7 @@ public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRightCurlyTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RightCurlyCheck.class); @@ -68,7 +68,7 @@ public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionRightCurlyTwo']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='fooMethod']]/SLIST/LITERAL_TRY/SLIST/RCURLY"); @@ -77,7 +77,7 @@ public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRightCurlyThree.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RightCurlyCheck.class); @@ -89,7 +89,7 @@ public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionRightCurlyThree']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='sample']]/SLIST/LITERAL_IF/SLIST/RCURLY"); @@ -98,7 +98,7 @@ public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionRightCurlyFour.java")); final DefaultConfiguration moduleConfig = createModuleConfig(RightCurlyCheck.class); @@ -111,7 +111,7 @@ public class XpathRegressionRightCurlyTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionRightCurlyFour']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='sample']]/SLIST/LITERAL_IF/SLIST/RCURLY"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionSimplifyBooleanExpressionTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionSimplifyBooleanExpressionTest.java @@ -21,15 +21,15 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionSimplifyBooleanExpressionTest extends AbstractXpathTestSupport { +final class XpathRegressionSimplifyBooleanExpressionTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -37,7 +37,7 @@ public class XpathRegressionSimplifyBooleanExpressionTest extends AbstractXpathT } @Test - public void testSimple() throws Exception { + void simple() throws Exception { final String fileName = "SuppressionXpathRegressionSimplifyBooleanExpressionSimple.java"; final File fileToProcess = new File(getPath(fileName)); @@ -61,7 +61,7 @@ public class XpathRegressionSimplifyBooleanExpressionTest extends AbstractXpathT } @Test - public void testAnonymous() throws Exception { + void anonymous() throws Exception { final String fileName = "SuppressionXpathRegressionSimplifyBooleanExpressionAnonymous.java"; final File fileToProcess = new File(getPath(fileName)); @@ -87,7 +87,7 @@ public class XpathRegressionSimplifyBooleanExpressionTest extends AbstractXpathT } @Test - public void testInterface() throws Exception { + void testInterface() throws Exception { final String fileName = "SuppressionXpathRegressionSimplifyBooleanExpressionInterface.java"; final File fileToProcess = new File(getPath(fileName)); @@ -99,7 +99,7 @@ public class XpathRegressionSimplifyBooleanExpressionTest extends AbstractXpathT }; final List expectedXpathQuery = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text='SuppressionXpathRegressionSimplifyBooleanExpressionInterface']]" + "/OBJBLOCK/INTERFACE_DEF[./IDENT[@text='Inner']]/OBJBLOCK/METHOD_DEF[./IDENT" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionSimplifyBooleanReturnTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionSimplifyBooleanReturnTest.java @@ -21,14 +21,14 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionSimplifyBooleanReturnTest extends AbstractXpathTestSupport { +final class XpathRegressionSimplifyBooleanReturnTest extends AbstractXpathTestSupport { private static final Class CLASS = SimplifyBooleanReturnCheck.class; private final String checkName = CLASS.getSimpleName(); @@ -39,7 +39,7 @@ public class XpathRegressionSimplifyBooleanReturnTest extends AbstractXpathTestS } @Test - public void testIfBooleanEqualsBoolean() throws Exception { + void ifBooleanEqualsBoolean() throws Exception { final File fileToProcess = new File( getPath("SuppressionXpathRegressionSimplifyBooleanReturnIfBooleanEqualsBoolean.java")); @@ -51,7 +51,7 @@ public class XpathRegressionSimplifyBooleanReturnTest extends AbstractXpathTestS }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionSimplifyBooleanReturnIfBooleanEqualsBoolean']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='toTest']]/SLIST/LITERAL_IF"); @@ -60,7 +60,7 @@ public class XpathRegressionSimplifyBooleanReturnTest extends AbstractXpathTestS } @Test - public void testIfBooleanReturnBoolean() throws Exception { + void ifBooleanReturnBoolean() throws Exception { final File fileToProcess = new File( getPath("SuppressionXpathRegressionSimplifyBooleanReturnIfBooleanReturnBoolean.java")); @@ -72,7 +72,7 @@ public class XpathRegressionSimplifyBooleanReturnTest extends AbstractXpathTestS }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionSimplifyBooleanReturnIfBooleanReturnBoolean']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='toTest']]/SLIST/EXPR/METHOD_CALL/ELIST" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionSingleSpaceSeparatorTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionSingleSpaceSeparatorTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.SingleSpaceSeparatorCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionSingleSpaceSeparatorTest extends AbstractXpathTestSupport { +final class XpathRegressionSingleSpaceSeparatorTest extends AbstractXpathTestSupport { private final String checkName = SingleSpaceSeparatorCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionSingleSpaceSeparatorTest extends AbstractXpathTestSu } @Test - public void testSingleSpaceSeparator() throws Exception { + void singleSpaceSeparator() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionSingleSpaceSeparator.java")); @@ -48,7 +48,7 @@ public class XpathRegressionSingleSpaceSeparatorTest extends AbstractXpathTestSu }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionSingleSpaceSeparator']]/OBJBLOCK" + "/VARIABLE_DEF/IDENT[@text='bad']"); @@ -57,7 +57,7 @@ public class XpathRegressionSingleSpaceSeparatorTest extends AbstractXpathTestSu } @Test - public void testValidateComments() throws Exception { + void validateComments() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionSingleSpaceSeparatorValidateComments.java")); @@ -70,7 +70,7 @@ public class XpathRegressionSingleSpaceSeparatorTest extends AbstractXpathTestSu }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[." + "/IDENT[@text='SuppressionXpathRegressionSingleSpaceSeparatorValidateComments']]" + "/OBJBLOCK/SINGLE_LINE_COMMENT[./COMMENT_CONTENT" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionStaticVariableNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionStaticVariableNameTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.StaticVariableNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionStaticVariableNameTest extends AbstractXpathTestSupport { +final class XpathRegressionStaticVariableNameTest extends AbstractXpathTestSupport { private final String checkName = StaticVariableNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionStaticVariableNameTest extends AbstractXpathTestSupp } @Test - public void test1() throws Exception { + void test1() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionStaticVariableName1.java")); @@ -54,7 +54,7 @@ public class XpathRegressionStaticVariableNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionStaticVariableName1']]" @@ -63,7 +63,7 @@ public class XpathRegressionStaticVariableNameTest extends AbstractXpathTestSupp } @Test - public void test2() throws Exception { + void test2() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionStaticVariableName2.java")); @@ -80,7 +80,7 @@ public class XpathRegressionStaticVariableNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionStaticVariableName2']]" @@ -91,7 +91,7 @@ public class XpathRegressionStaticVariableNameTest extends AbstractXpathTestSupp } @Test - public void test3() throws Exception { + void test3() throws Exception { final File fileToProcess = new File(getNonCompilablePath("SuppressionXpathRegressionStaticVariableName3.java")); @@ -108,7 +108,7 @@ public class XpathRegressionStaticVariableNameTest extends AbstractXpathTestSupp }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionStaticVariableName2']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionStringLiteralEqualityTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionStringLiteralEqualityTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualityCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionStringLiteralEqualityTest extends AbstractXpathTestSupport { +final class XpathRegressionStringLiteralEqualityTest extends AbstractXpathTestSupport { private final String checkName = StringLiteralEqualityCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionStringLiteralEqualityTest extends AbstractXpathTestS } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionStringLiteralEquality.java")); final DefaultConfiguration moduleConfig = createModuleConfig(StringLiteralEqualityCheck.class); @@ -61,7 +61,7 @@ public class XpathRegressionStringLiteralEqualityTest extends AbstractXpathTestS } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionStringLiteralEquality1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(StringLiteralEqualityCheck.class); @@ -85,7 +85,7 @@ public class XpathRegressionStringLiteralEqualityTest extends AbstractXpathTestS } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionStringLiteralEquality2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(StringLiteralEqualityCheck.class); @@ -95,7 +95,7 @@ public class XpathRegressionStringLiteralEqualityTest extends AbstractXpathTestS StringLiteralEqualityCheck.class, StringLiteralEqualityCheck.MSG_KEY, "=="), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionStringLiteralEquality2']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myFunction']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionSuperCloneTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionSuperCloneTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.AbstractSuperCheck; import com.puppycrawl.tools.checkstyle.checks.coding.SuperCloneCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionSuperCloneTest extends AbstractXpathTestSupport { +final class XpathRegressionSuperCloneTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -35,7 +35,7 @@ public class XpathRegressionSuperCloneTest extends AbstractXpathTestSupport { } @Test - public void testInnerClone() throws Exception { + void innerClone() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionSuperCloneInnerClone.java")); @@ -46,7 +46,7 @@ public class XpathRegressionSuperCloneTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpath" + "RegressionSuperCloneInnerClone']]" @@ -57,7 +57,7 @@ public class XpathRegressionSuperCloneTest extends AbstractXpathTestSupport { } @Test - public void testNoSuperClone() throws Exception { + void noSuperClone() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionSuperCloneNoSuperClone.java")); @@ -68,7 +68,7 @@ public class XpathRegressionSuperCloneTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpath" + "RegressionSuperCloneNoSuperClone']]" @@ -79,7 +79,7 @@ public class XpathRegressionSuperCloneTest extends AbstractXpathTestSupport { } @Test - public void testPlainAndSubclasses() throws Exception { + void plainAndSubclasses() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionSuperClonePlainAndSubclasses.java")); @@ -90,7 +90,7 @@ public class XpathRegressionSuperCloneTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpath" + "RegressionSuperClonePlainAndSubclasses']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionThrowsCountTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionThrowsCountTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.design.ThrowsCountCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionThrowsCountTest extends AbstractXpathTestSupport { +final class XpathRegressionThrowsCountTest extends AbstractXpathTestSupport { private final String checkName = ThrowsCountCheck.class.getSimpleName(); @@ -36,14 +36,14 @@ public class XpathRegressionThrowsCountTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionThrowsCount1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ThrowsCountCheck.class); final String[] expectedViolation = { "4:30: " + getCheckMessage(ThrowsCountCheck.class, ThrowsCountCheck.MSG_KEY, 5, 4), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionThrowsCount1']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myFunction']]" @@ -53,7 +53,7 @@ public class XpathRegressionThrowsCountTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionThrowsCount2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ThrowsCountCheck.class); @@ -63,7 +63,7 @@ public class XpathRegressionThrowsCountTest extends AbstractXpathTestSupport { "4:30: " + getCheckMessage(ThrowsCountCheck.class, ThrowsCountCheck.MSG_KEY, 3, 2), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/INTERFACE_DEF[./IDENT[@text='SuppressionXpathRegressionThrowsCount2']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myFunction']]" @@ -73,7 +73,7 @@ public class XpathRegressionThrowsCountTest extends AbstractXpathTestSupport { } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionThrowsCount3.java")); final DefaultConfiguration moduleConfig = createModuleConfig(ThrowsCountCheck.class); @@ -83,7 +83,7 @@ public class XpathRegressionThrowsCountTest extends AbstractXpathTestSupport { "9:40: " + getCheckMessage(ThrowsCountCheck.class, ThrowsCountCheck.MSG_KEY, 5, 4), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text='SuppressionXpathRegressionThrowsCount3']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='myFunc']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionTodoCommentTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionTodoCommentTest.java @@ -21,14 +21,14 @@ package org.checkstyle.suppressionxpathfilter; import static com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionTodoCommentTest extends AbstractXpathTestSupport { +final class XpathRegressionTodoCommentTest extends AbstractXpathTestSupport { private final String checkName = TodoCommentCheck.class.getSimpleName(); @Override @@ -37,7 +37,7 @@ public class XpathRegressionTodoCommentTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTodoCommentOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(TodoCommentCheck.class); @@ -48,7 +48,7 @@ public class XpathRegressionTodoCommentTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionTodoCommentOne']]/OBJBLOCK/" + "SINGLE_LINE_COMMENT/COMMENT_CONTENT[@text=' warn FIXME:\\n']"); @@ -57,7 +57,7 @@ public class XpathRegressionTodoCommentTest extends AbstractXpathTestSupport { } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTodoCommentTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(TodoCommentCheck.class); @@ -68,7 +68,7 @@ public class XpathRegressionTodoCommentTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionTodoCommentTwo']]/" + "OBJBLOCK/BLOCK_COMMENT_BEGIN/COMMENT_CONTENT" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionTrailingCommentTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionTrailingCommentTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.TrailingCommentCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionTrailingCommentTest extends AbstractXpathTestSupport { +final class XpathRegressionTrailingCommentTest extends AbstractXpathTestSupport { private final String checkName = TrailingCommentCheck.class.getSimpleName(); @Override @@ -35,7 +35,7 @@ public class XpathRegressionTrailingCommentTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTrailingComment1.java")); final DefaultConfiguration moduleConfig = createModuleConfig(TrailingCommentCheck.class); @@ -45,7 +45,7 @@ public class XpathRegressionTrailingCommentTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionTrailingComment1']]/" + "OBJBLOCK/SINGLE_LINE_COMMENT[./COMMENT_CONTENT[@text=' don'" @@ -55,7 +55,7 @@ public class XpathRegressionTrailingCommentTest extends AbstractXpathTestSupport } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTrailingComment2.java")); final DefaultConfiguration moduleConfig = createModuleConfig(TrailingCommentCheck.class); @@ -65,7 +65,7 @@ public class XpathRegressionTrailingCommentTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionTrailingComment2']]" + "/OBJBLOCK/SINGLE_LINE_COMMENT[./COMMENT_CONTENT[@text=' warn\\n']]"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionTypeNameTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionTypeNameTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck; import com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionTypeNameTest extends AbstractXpathTestSupport { +final class XpathRegressionTypeNameTest extends AbstractXpathTestSupport { private final String checkName = TypeNameCheck.class.getSimpleName(); @@ -37,7 +37,7 @@ public class XpathRegressionTypeNameTest extends AbstractXpathTestSupport { } @Test - public void test1() throws Exception { + void test1() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTypeName1.java")); final String pattern = "^[A-Z][a-zA-Z0-9]*$"; @@ -50,7 +50,7 @@ public class XpathRegressionTypeNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionTypeName1']]" @@ -59,7 +59,7 @@ public class XpathRegressionTypeNameTest extends AbstractXpathTestSupport { } @Test - public void test2() throws Exception { + void test2() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTypeName2.java")); final String pattern = "^I_[a-zA-Z0-9]*$"; @@ -74,7 +74,7 @@ public class XpathRegressionTypeNameTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT" + "/CLASS_DEF[./IDENT[@text" + "='SuppressionXpathRegressionTypeName2']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionTypecastParenPadTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionTypecastParenPadTest.java @@ -19,17 +19,17 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck; import com.puppycrawl.tools.checkstyle.checks.whitespace.PadOption; import com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionTypecastParenPadTest extends AbstractXpathTestSupport { +final class XpathRegressionTypecastParenPadTest extends AbstractXpathTestSupport { private final String checkName = TypecastParenPadCheck.class.getSimpleName(); @@ -39,7 +39,7 @@ public class XpathRegressionTypecastParenPadTest extends AbstractXpathTestSuppor } @Test - public void testLeftFollowed() throws Exception { + void leftFollowed() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTypecastParenPadLeftFollowed.java")); @@ -64,7 +64,7 @@ public class XpathRegressionTypecastParenPadTest extends AbstractXpathTestSuppor } @Test - public void testLeftNotFollowed() throws Exception { + void leftNotFollowed() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTypecastParenPadLeftNotFollowed.java")); @@ -90,7 +90,7 @@ public class XpathRegressionTypecastParenPadTest extends AbstractXpathTestSuppor } @Test - public void testRightPreceded() throws Exception { + void rightPreceded() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTypecastParenPadRightPreceded.java")); @@ -103,7 +103,7 @@ public class XpathRegressionTypecastParenPadTest extends AbstractXpathTestSuppor }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionTypecastParenPadRightPreceded']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/EXPR/TYPECAST/RPAREN"); @@ -112,7 +112,7 @@ public class XpathRegressionTypecastParenPadTest extends AbstractXpathTestSuppor } @Test - public void testRightNotPreceded() throws Exception { + void rightNotPreceded() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionTypecastParenPadRightNotPreceded.java")); @@ -126,7 +126,7 @@ public class XpathRegressionTypecastParenPadTest extends AbstractXpathTestSuppor }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionTypecastParenPadRightNotPreceded']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/EXPR/TYPECAST/RPAREN"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUncommentedMainTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUncommentedMainTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUncommentedMainTest extends AbstractXpathTestSupport { +final class XpathRegressionUncommentedMainTest extends AbstractXpathTestSupport { private final Class clazz = UncommentedMainCheck.class; @@ -36,7 +36,7 @@ public class XpathRegressionUncommentedMainTest extends AbstractXpathTestSupport } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUncommentedMain.java")); final DefaultConfiguration moduleConfig = createModuleConfig(UncommentedMainCheck.class); @@ -61,7 +61,7 @@ public class XpathRegressionUncommentedMainTest extends AbstractXpathTestSupport } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUncommentedMainTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessaryParenthesesTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessaryParenthesesTest.java @@ -19,15 +19,15 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthesesCheck; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTestSupport { +final class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTestSupport { @Override protected String getCheckName() { @@ -35,7 +35,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessaryParentheses1.java")); @@ -62,7 +62,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessaryParentheses2.java")); @@ -89,7 +89,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest } @Test - public void testThree() throws Exception { + void three() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessaryParentheses3.java")); @@ -102,7 +102,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionUnnecessaryParentheses3']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='predicate']]" @@ -112,7 +112,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest } @Test - public void testFour() throws Exception { + void four() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessaryParentheses4.java")); @@ -125,7 +125,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionUnnecessaryParentheses4']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]" @@ -136,7 +136,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest } @Test - public void testFive() throws Exception { + void five() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessaryParentheses5.java")); @@ -151,7 +151,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionUnnecessaryParentheses5']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]" @@ -162,7 +162,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest } @Test - public void testSix() throws Exception { + void six() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessaryParentheses6.java")); @@ -175,7 +175,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='SuppressionXpathRegressionUnnecessaryParentheses6']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='foo']]" @@ -186,7 +186,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest } @Test - public void testSeven() throws Exception { + void seven() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessaryParentheses7.java")); @@ -213,7 +213,7 @@ public class XpathRegressionUnnecessaryParenthesesTest extends AbstractXpathTest } @Test - public void testEight() throws Exception { + void eight() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessaryParentheses8.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessarySemicolonAfterOuterTypeDeclarationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessarySemicolonAfterOuterTypeDeclarationTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterOuterTypeDeclarationCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUnnecessarySemicolonAfterOuterTypeDeclarationTest +final class XpathRegressionUnnecessarySemicolonAfterOuterTypeDeclarationTest extends AbstractXpathTestSupport { private static final Class CLASS = @@ -38,7 +38,7 @@ public class XpathRegressionUnnecessarySemicolonAfterOuterTypeDeclarationTest } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File( getPath( @@ -48,13 +48,13 @@ public class XpathRegressionUnnecessarySemicolonAfterOuterTypeDeclarationTest "5:2: " + getCheckMessage(CLASS, UnnecessarySemicolonAfterOuterTypeDeclarationCheck.MSG_SEMI), }; - final List expectedXpathQueries = Collections.singletonList("/COMPILATION_UNIT/SEMI"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/SEMI"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File( getPath( @@ -66,7 +66,7 @@ public class XpathRegressionUnnecessarySemicolonAfterOuterTypeDeclarationTest + getCheckMessage(CLASS, UnnecessarySemicolonAfterOuterTypeDeclarationCheck.MSG_SEMI), }; - final List expectedXpathQueries = Collections.singletonList("/COMPILATION_UNIT/SEMI"); + final List expectedXpathQueries = ImmutableList.of("/COMPILATION_UNIT/SEMI"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonAfterTypeMemberDeclarationCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTest +final class XpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTest extends AbstractXpathTestSupport { private static final Class CLASS = @@ -38,7 +38,7 @@ public class XpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTest } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File( getPath( @@ -50,7 +50,7 @@ public class XpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT" + "[@text=" + "'SuppressionXpathRegressionUnnecessarySemicolonAfterTypeMemberDeclaration']]" @@ -60,7 +60,7 @@ public class XpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTest } @Test - public void testTokens() throws Exception { + void tokens() throws Exception { final File fileToProcess = new File( getPath( @@ -75,7 +75,7 @@ public class XpathRegressionUnnecessarySemicolonAfterTypeMemberDeclarationTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[." + "/IDENT[@text='SuppressionXpathRegressionUnnecessarySemicolonAfterTypeMember" + "DeclarationTokens']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessarySemicolonInEnumerationTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessarySemicolonInEnumerationTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonInEnumerationCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUnnecessarySemicolonInEnumerationTest extends AbstractXpathTestSupport { +final class XpathRegressionUnnecessarySemicolonInEnumerationTest extends AbstractXpathTestSupport { private final String checkName = UnnecessarySemicolonInEnumerationCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionUnnecessarySemicolonInEnumerationTest extends Abstra } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessarySemicolonInEnumeration.java")); @@ -51,13 +51,13 @@ public class XpathRegressionUnnecessarySemicolonInEnumerationTest extends Abstra }; final List expectedXpathQueries = - Collections.singletonList("/COMPILATION_UNIT/ENUM_DEF[./IDENT[@text='Bad']]/OBJBLOCK/SEMI"); + ImmutableList.of("/COMPILATION_UNIT/ENUM_DEF[./IDENT[@text='Bad']]/OBJBLOCK/SEMI"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessarySemicolonInEnumerationAll.java")); @@ -72,7 +72,7 @@ public class XpathRegressionUnnecessarySemicolonInEnumerationTest extends Abstra }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/ENUM_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionUnnecessarySemicolonInEnumerationAll']]" + "/OBJBLOCK/SEMI"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessarySemicolonInTryWithResourcesTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnnecessarySemicolonInTryWithResourcesTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.coding.UnnecessarySemicolonInTryWithResourcesCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUnnecessarySemicolonInTryWithResourcesTest +final class XpathRegressionUnnecessarySemicolonInTryWithResourcesTest extends AbstractXpathTestSupport { private final String checkName = @@ -38,7 +38,7 @@ public class XpathRegressionUnnecessarySemicolonInTryWithResourcesTest } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnnecessarySemicolonInTryWithResources.java")); final DefaultConfiguration moduleConfig = @@ -54,7 +54,7 @@ public class XpathRegressionUnnecessarySemicolonInTryWithResourcesTest UnnecessarySemicolonInTryWithResourcesCheck.MSG_SEMI), }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionUnnecessarySemicolonInTryWithResources']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='m']]/SLIST/LITERAL_TRY" @@ -63,7 +63,7 @@ public class XpathRegressionUnnecessarySemicolonInTryWithResourcesTest } @Test - public void testAllowWhenNoBraceAfterSemicolon() throws Exception { + void allowWhenNoBraceAfterSemicolon() throws Exception { final File fileToProcess = new File( getPath( @@ -81,7 +81,7 @@ public class XpathRegressionUnnecessarySemicolonInTryWithResourcesTest }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text=" + "'SuppressionXpathRegressionUnnecessarySemicolonInTryWithResourcesNoBrace']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='test']]" --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnusedImportsTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnusedImportsTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUnusedImportsTest extends AbstractXpathTestSupport { +final class XpathRegressionUnusedImportsTest extends AbstractXpathTestSupport { private final String checkName = UnusedImportsCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionUnusedImportsTest extends AbstractXpathTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnusedImportsOne.java")); final DefaultConfiguration moduleConfig = createModuleConfig(UnusedImportsCheck.class); @@ -47,14 +47,14 @@ public class XpathRegressionUnusedImportsTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/IMPORT/DOT[./IDENT[@text='List']]/DOT/IDENT[@text='java']"); runVerifications(moduleConfig, fileToProcess, expectedViolation, expectedXpathQueries); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnusedImportsTwo.java")); final DefaultConfiguration moduleConfig = createModuleConfig(UnusedImportsCheck.class); @@ -66,7 +66,7 @@ public class XpathRegressionUnusedImportsTest extends AbstractXpathTestSupport { }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/STATIC_IMPORT/DOT" + "[./IDENT[@text='Entry']]/DOT[./IDENT[@text='Map']]" + "/DOT/IDENT[@text='java']"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnusedLocalVariableTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUnusedLocalVariableTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUnusedLocalVariableTest extends AbstractXpathTestSupport { +final class XpathRegressionUnusedLocalVariableTest extends AbstractXpathTestSupport { private final String checkName = UnusedLocalVariableCheck.class.getSimpleName(); @Override @@ -35,7 +35,7 @@ public class XpathRegressionUnusedLocalVariableTest extends AbstractXpathTestSup } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnusedLocalVariableOne.java")); @@ -71,7 +71,7 @@ public class XpathRegressionUnusedLocalVariableTest extends AbstractXpathTestSup } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUnusedLocalVariableTwo.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUpperEllTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionUpperEllTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionUpperEllTest extends AbstractXpathTestSupport { +final class XpathRegressionUpperEllTest extends AbstractXpathTestSupport { private final String checkName = UpperEllCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionUpperEllTest extends AbstractXpathTestSupport { } @Test - public void testUpperEllOne() throws Exception { + void upperEllOne() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUpperEllFirst.java")); final DefaultConfiguration moduleConfig = createModuleConfig(UpperEllCheck.class); @@ -59,7 +59,7 @@ public class XpathRegressionUpperEllTest extends AbstractXpathTestSupport { } @Test - public void testUpperEllTwo() throws Exception { + void upperEllTwo() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionUpperEllSecond.java")); final DefaultConfiguration moduleConfig = createModuleConfig(UpperEllCheck.class); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionVariableDeclarationUsageDistanceTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionVariableDeclarationUsageDistanceTest.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionVariableDeclarationUsageDistanceTest extends AbstractXpathTestSupport { +final class XpathRegressionVariableDeclarationUsageDistanceTest extends AbstractXpathTestSupport { private final String checkName = VariableDeclarationUsageDistanceCheck.class.getSimpleName(); @Override @@ -35,7 +35,7 @@ public class XpathRegressionVariableDeclarationUsageDistanceTest extends Abstrac } @Test - public void testOne() throws Exception { + void one() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionVariableDeclarationUsageDistance1.java")); @@ -79,7 +79,7 @@ public class XpathRegressionVariableDeclarationUsageDistanceTest extends Abstrac } @Test - public void testTwo() throws Exception { + void two() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionVariableDeclarationUsageDistance2.java")); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionWhitespaceAfterTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionWhitespaceAfterTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionWhitespaceAfterTest extends AbstractXpathTestSupport { +final class XpathRegressionWhitespaceAfterTest extends AbstractXpathTestSupport { private final String checkName = WhitespaceAfterCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionWhitespaceAfterTest extends AbstractXpathTestSupport } @Test - public void testWhitespaceAfterTypecast() throws Exception { + void whitespaceAfterTypecast() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionWhitespaceAfterTypecast.java")); @@ -48,7 +48,7 @@ public class XpathRegressionWhitespaceAfterTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionWhitespaceAfterTypecast']]/OBJBLOCK" + "/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/EXPR/TYPECAST/RPAREN"); @@ -57,7 +57,7 @@ public class XpathRegressionWhitespaceAfterTest extends AbstractXpathTestSupport } @Test - public void testWhitespaceAfterNotFollowed() throws Exception { + void whitespaceAfterNotFollowed() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionWhitespaceAfterNotFollowed.java")); @@ -70,7 +70,7 @@ public class XpathRegressionWhitespaceAfterTest extends AbstractXpathTestSupport }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionWhitespaceAfterNotFollowed']]/OBJBLOCK" + "/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN/ARRAY_INIT/COMMA"); --- a/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionWhitespaceAroundTest.java +++ b/src/it/java/org/checkstyle/suppressionxpathfilter/XpathRegressionWhitespaceAroundTest.java @@ -19,14 +19,14 @@ package org.checkstyle.suppressionxpathfilter; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck; import java.io.File; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class XpathRegressionWhitespaceAroundTest extends AbstractXpathTestSupport { +final class XpathRegressionWhitespaceAroundTest extends AbstractXpathTestSupport { private final String checkName = WhitespaceAroundCheck.class.getSimpleName(); @@ -36,7 +36,7 @@ public class XpathRegressionWhitespaceAroundTest extends AbstractXpathTestSuppor } @Test - public void testWhitespaceAroundNotPreceded() throws Exception { + void whitespaceAroundNotPreceded() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionWhitespaceAroundNotPreceded.java")); @@ -49,7 +49,7 @@ public class XpathRegressionWhitespaceAroundTest extends AbstractXpathTestSuppor }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionWhitespaceAroundNotPreceded']]/OBJBLOCK" + "/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN"); @@ -58,7 +58,7 @@ public class XpathRegressionWhitespaceAroundTest extends AbstractXpathTestSuppor } @Test - public void testWhitespaceAroundNotFollowed() throws Exception { + void whitespaceAroundNotFollowed() throws Exception { final File fileToProcess = new File(getPath("SuppressionXpathRegressionWhitespaceAroundNotFollowed.java")); @@ -71,7 +71,7 @@ public class XpathRegressionWhitespaceAroundTest extends AbstractXpathTestSuppor }; final List expectedXpathQueries = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[" + "@text='SuppressionXpathRegressionWhitespaceAroundNotFollowed']]/OBJBLOCK" + "/VARIABLE_DEF[./IDENT[@text='bad']]/ASSIGN"); --- a/src/main/java/com/puppycrawl/tools/checkstyle/AbstractAutomaticBean.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/AbstractAutomaticBean.java @@ -276,8 +276,8 @@ public abstract class AbstractAutomaticBean implements Configurable, Contextuali /** A converter that converts a string to a pattern. */ private static final class PatternConverter implements Converter { - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") public Object convert(Class type, Object value) { return CommonUtil.createPattern(value.toString()); } @@ -286,8 +286,8 @@ public abstract class AbstractAutomaticBean implements Configurable, Contextuali /** A converter that converts strings to severity level. */ private static final class SeverityLevelConverter implements Converter { - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") public Object convert(Class type, Object value) { return SeverityLevel.getInstance(value.toString()); } @@ -296,8 +296,8 @@ public abstract class AbstractAutomaticBean implements Configurable, Contextuali /** A converter that converts strings to scope. */ private static final class ScopeConverter implements Converter { - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") public Object convert(Class type, Object value) { return Scope.getInstance(value.toString()); } @@ -306,9 +306,9 @@ public abstract class AbstractAutomaticBean implements Configurable, Contextuali /** A converter that converts strings to uri. */ private static final class UriConverter implements Converter { - @SuppressWarnings("unchecked") - @Override @Nullable + @Override + @SuppressWarnings("unchecked") public Object convert(Class type, Object value) { final String url = value.toString(); URI result = null; @@ -331,8 +331,8 @@ public abstract class AbstractAutomaticBean implements Configurable, Contextuali */ private static final class RelaxedStringArrayConverter implements Converter { - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") public Object convert(Class type, Object value) { final StringTokenizer tokenizer = new StringTokenizer(value.toString().trim(), COMMA_SEPARATOR); @@ -357,8 +357,8 @@ public abstract class AbstractAutomaticBean implements Configurable, Contextuali /** Constant for optimization. */ private static final AccessModifierOption[] EMPTY_MODIFIER_ARRAY = new AccessModifierOption[0]; - @SuppressWarnings("unchecked") @Override + @SuppressWarnings("unchecked") public Object convert(Class type, Object value) { // Converts to a String and trims it for the tokenizer. final StringTokenizer tokenizer = --- a/src/main/java/com/puppycrawl/tools/checkstyle/Checker.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/Checker.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle; +import static java.util.stream.Collectors.toUnmodifiableList; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.AuditListener; import com.puppycrawl.tools.checkstyle.api.BeforeExecutionFileFilter; @@ -50,7 +53,6 @@ import java.util.Locale; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -215,7 +217,7 @@ public class Checker extends AbstractAutomaticBean implements MessageDispatcher, final List targetFiles = files.stream() .filter(file -> CommonUtil.matchesFileExtension(file, fileExtensions)) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); processFiles(targetFiles); // Finish up @@ -244,7 +246,7 @@ public class Checker extends AbstractAutomaticBean implements MessageDispatcher, resource -> { return ((ExternalResourceHolder) resource).getExternalResourceLocations().stream(); }) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } /** Notify all listeners about the audit start. */ --- a/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/ConfigurationLoader.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle; +import static com.google.common.base.Preconditions.checkState; + import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.api.SeverityLevel; @@ -523,9 +525,7 @@ public final class ConfigurationLoader { final DefaultConfiguration top = configStack.peek(); top.addMessage(key, value); } else { - if (!METADATA.equals(qName)) { - throw new IllegalStateException("Unknown name:" + qName + "."); - } + checkState(METADATA.equals(qName), "Unknown name:%s.", qName); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/DefaultLogger.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/DefaultLogger.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle; +import static com.google.common.base.Preconditions.checkArgument; +import static java.nio.charset.StandardCharsets.UTF_8; + import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.AuditListener; import com.puppycrawl.tools.checkstyle.api.AutomaticBean; @@ -27,7 +30,6 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; -import java.nio.charset.StandardCharsets; /** * Simple plain logger for text output. This is maybe not very suitable for a text output into a @@ -126,21 +128,17 @@ public class DefaultLogger extends AbstractAutomaticBean implements AuditListene OutputStream errorStream, OutputStreamOptions errorStreamOptions, AuditEventFormatter messageFormatter) { - if (infoStreamOptions == null) { - throw new IllegalArgumentException("Parameter infoStreamOptions can not be null"); - } + checkArgument(infoStreamOptions != null, "Parameter infoStreamOptions can not be null"); closeInfo = infoStreamOptions == OutputStreamOptions.CLOSE; - if (errorStreamOptions == null) { - throw new IllegalArgumentException("Parameter errorStreamOptions can not be null"); - } + checkArgument(errorStreamOptions != null, "Parameter errorStreamOptions can not be null"); closeError = errorStreamOptions == OutputStreamOptions.CLOSE; - final Writer infoStreamWriter = new OutputStreamWriter(infoStream, StandardCharsets.UTF_8); + final Writer infoStreamWriter = new OutputStreamWriter(infoStream, UTF_8); infoWriter = new PrintWriter(infoStreamWriter); if (infoStream == errorStream) { errorWriter = infoWriter; } else { - final Writer errorStreamWriter = new OutputStreamWriter(errorStream, StandardCharsets.UTF_8); + final Writer errorStreamWriter = new OutputStreamWriter(errorStream, UTF_8); errorWriter = new PrintWriter(errorStreamWriter); } formatter = messageFormatter; --- a/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/Definitions.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle; +import com.google.common.collect.ImmutableSet; import java.util.Set; /** Contains constant definitions common to the package. */ @@ -29,7 +30,7 @@ public final class Definitions { /** Name of modules which are not checks, but are internal modules. */ public static final Set INTERNAL_MODULES = - Set.of( + ImmutableSet.of( "com.puppycrawl.tools.checkstyle.meta.JavadocMetadataScraper", "com.puppycrawl.tools.checkstyle.site.ClassAndPropertiesSettersJavadocScraper"); --- a/src/main/java/com/puppycrawl/tools/checkstyle/JavaAstVisitor.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/JavaAstVisitor.java @@ -19,20 +19,22 @@ package com.puppycrawl.tools.checkstyle; +import static java.util.Objects.requireNonNullElseGet; +import static java.util.stream.Collectors.toCollection; +import static java.util.stream.Collectors.toUnmodifiableList; + +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.grammar.java.JavaLanguageLexer; import com.puppycrawl.tools.checkstyle.grammar.java.JavaLanguageParser; import com.puppycrawl.tools.checkstyle.grammar.java.JavaLanguageParserBaseVisitor; import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.util.ArrayList; -import java.util.Collections; import java.util.Iterator; import java.util.List; -import java.util.Objects; import java.util.Optional; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.stream.Collectors; import org.antlr.v4.runtime.BufferedTokenStream; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.ParserRuleContext; @@ -416,7 +418,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor !(child instanceof JavaLanguageParser.ArrayDeclaratorContext)) - .collect(Collectors.toUnmodifiableList())); + .collect(toUnmodifiableList())); // We add C style array declarator brackets to TYPE ast final DetailAstImpl typeAst = (DetailAstImpl) methodDef.findFirstToken(TokenTypes.TYPE); @@ -479,7 +481,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor children = ctx.children.stream() .filter(child -> !(child instanceof JavaLanguageParser.ArrayDeclaratorContext)) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); processChildren(methodDef, children); // We add C style array declarator brackets to TYPE ast @@ -790,7 +792,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor !(child instanceof JavaLanguageParser.ArrayDeclaratorContext)) - .collect(Collectors.toUnmodifiableList())); + .collect(toUnmodifiableList())); // We add C style array declarator brackets to TYPE ast final DetailAstImpl typeAst = @@ -862,7 +864,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor !child.equals(ctx.LITERAL_SUPER())) - .collect(Collectors.toUnmodifiableList())); + .collect(toUnmodifiableList())); return primaryCtorCall; } @@ -1100,7 +1102,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor !(child instanceof JavaLanguageParser.VariableModifierContext)) - .collect(Collectors.toUnmodifiableList())); + .collect(toUnmodifiableList())); return catchParameterDef; } @@ -1431,8 +1433,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor createImaginary(TokenTypes.ELIST)); + requireNonNullElseGet(visit(ctx.expressionList()), () -> createImaginary(TokenTypes.ELIST)); DetailAstPair.addAstChild(currentAst, expressionList); DetailAstPair.addAstChild(currentAst, create(ctx.RPAREN())); @@ -1458,8 +1459,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor createImaginary(TokenTypes.ELIST)); + requireNonNullElseGet(visit(ctx.expressionList()), () -> createImaginary(TokenTypes.ELIST)); methodCall.addChild(expressionList); methodCall.addChild(create((Token) ctx.RPAREN().getPayload())); @@ -1526,7 +1526,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor children = ctx.children.stream() .filter(child -> !child.equals(ctx.DOUBLE_COLON())) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); processChildren(doubleColon, children); return doubleColon; } @@ -1538,7 +1538,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor !child.equals(ctx.QUESTION())) - .collect(Collectors.toUnmodifiableList())); + .collect(toUnmodifiableList())); return root; } @@ -1565,7 +1565,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor descendantList = binOpList.parallelStream() .map(this::getInnerBopAst) - .collect(Collectors.toCollection(ConcurrentLinkedQueue::new)); + .collect(toCollection(ConcurrentLinkedQueue::new)); bop.addChild(descendantList.poll()); DetailAstImpl pointer = bop.getFirstChild(); @@ -1602,8 +1602,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor createImaginary(TokenTypes.ELIST)); + requireNonNullElseGet(visit(ctx.expressionList()), () -> createImaginary(TokenTypes.ELIST)); final DetailAstImpl dot = create(ctx.DOT()); dot.addChild(visit(ctx.expr())); @@ -1636,8 +1635,8 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor createImaginary(TokenTypes.PARAMETERS)); + requireNonNullElseGet( + visit(ctx.formalParameterList()), () -> createImaginary(TokenTypes.PARAMETERS)); addLastSibling(lparen, parameters); addLastSibling(lparen, create(ctx.RPAREN())); return lparen; @@ -1717,7 +1716,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor buildSimpleStringTemplateArgument(ctx)); } @@ -1773,7 +1772,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor createImaginary(TokenTypes.ELIST)); + requireNonNullElseGet( + visit(ctx.expressionList()), () -> createImaginary(TokenTypes.ELIST)); root.addChild(expressionList); root.addChild(create(ctx.RPAREN())); @@ -2127,8 +2126,7 @@ public final class JavaAstVisitor extends JavaLanguageParserBaseVisitor createImaginary(TokenTypes.ELIST)); + requireNonNullElseGet(visit(ctx.expressionList()), () -> createImaginary(TokenTypes.ELIST)); addLastSibling(lparen, expressionList); addLastSibling(lparen, create(ctx.RPAREN())); return lparen; --- a/src/main/java/com/puppycrawl/tools/checkstyle/JavadocPropertiesGenerator.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/JavadocPropertiesGenerator.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle; +import static java.nio.charset.StandardCharsets.UTF_8; + import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.DetailNode; @@ -28,7 +30,6 @@ import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; import java.io.File; import java.io.IOException; import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -92,7 +93,7 @@ public final class JavadocPropertiesGenerator { * @throws CheckstyleException if a javadoc comment can not be parsed */ private static void writePropertiesFile(CliOptions options) throws CheckstyleException { - try (PrintWriter writer = new PrintWriter(options.outputFile, StandardCharsets.UTF_8)) { + try (PrintWriter writer = new PrintWriter(options.outputFile, UTF_8)) { final DetailAST top = JavaParser.parseFile(options.inputFile, JavaParser.Options.WITH_COMMENTS).getFirstChild(); final DetailAST objBlock = getClassBody(top); --- a/src/main/java/com/puppycrawl/tools/checkstyle/LocalizedMessage.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/LocalizedMessage.java @@ -19,13 +19,14 @@ package com.puppycrawl.tools.checkstyle; +import static java.nio.charset.StandardCharsets.UTF_8; + import com.puppycrawl.tools.checkstyle.utils.UnmodifiableCollectionUtil; import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.net.URLConnection; -import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.Locale; import java.util.MissingResourceException; @@ -147,8 +148,7 @@ public class LocalizedMessage { final URLConnection connection = url.openConnection(); if (connection != null) { connection.setUseCaches(!reload); - try (Reader streamReader = - new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8)) { + try (Reader streamReader = new InputStreamReader(connection.getInputStream(), UTF_8)) { // Only this line is changed to make it read property files as UTF-8. resourceBundle = new PropertyResourceBundle(streamReader); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/Main.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/Main.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle; +import static java.util.stream.Collectors.toCollection; + import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.OutputStreamOptions; import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.AuditListener; @@ -38,7 +40,6 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Locale; -import java.util.Objects; import java.util.Properties; import java.util.logging.ConsoleHandler; import java.util.logging.Filter; @@ -46,7 +47,6 @@ import java.util.logging.Level; import java.util.logging.LogRecord; import java.util.logging.Logger; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import picocli.CommandLine; @@ -274,7 +274,7 @@ public final class Main { final String stringAst = AstTreeStringPrinter.printFileAst(file, JavaParser.Options.WITHOUT_COMMENTS); System.out.print(stringAst); - } else if (Objects.nonNull(options.xpath)) { + } else if (options.xpath != null) { final String branch = XpathUtil.printXpathBranch(options.xpath, filesToProcess.get(0)); System.out.print(branch); } else if (options.printAstWithComments) { @@ -789,7 +789,7 @@ public final class Main { .map(File::getAbsolutePath) .map(Pattern::quote) .map(pattern -> Pattern.compile("^" + pattern + "$")) - .collect(Collectors.toCollection(ArrayList::new)); + .collect(toCollection(ArrayList::new)); result.addAll(excludeRegex); return result; } --- a/src/main/java/com/puppycrawl/tools/checkstyle/MetadataGeneratorLogger.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/MetadataGeneratorLogger.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle; +import static java.nio.charset.StandardCharsets.UTF_8; + import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.AuditListener; import com.puppycrawl.tools.checkstyle.api.SeverityLevel; @@ -26,7 +28,6 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; -import java.nio.charset.StandardCharsets; /** Simple logger for metadata generator util. */ public class MetadataGeneratorLogger extends AbstractAutomaticBean implements AuditListener { @@ -48,7 +49,7 @@ public class MetadataGeneratorLogger extends AbstractAutomaticBean implements Au */ public MetadataGeneratorLogger( OutputStream outputStream, OutputStreamOptions outputStreamOptions) { - final Writer errorStreamWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8); + final Writer errorStreamWriter = new OutputStreamWriter(outputStream, UTF_8); errorWriter = new PrintWriter(errorStreamWriter); formatter = new AuditEventDefaultFormatter(); closeErrorWriter = outputStreamOptions == OutputStreamOptions.CLOSE; --- a/src/main/java/com/puppycrawl/tools/checkstyle/PackageNamesLoader.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/PackageNamesLoader.java @@ -19,13 +19,14 @@ package com.puppycrawl.tools.checkstyle; +import static java.util.Collections.unmodifiableSet; + import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.util.ArrayDeque; -import java.util.Collections; import java.util.Deque; import java.util.Enumeration; import java.util.HashMap; @@ -137,7 +138,7 @@ public final class PackageNamesLoader extends XmlLoader { throw new CheckstyleException("unable to open one of package files", ex); } - return Collections.unmodifiableSet(result); + return unmodifiableSet(result); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/PackageObjectFactory.java @@ -19,10 +19,18 @@ package com.puppycrawl.tools.checkstyle; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.stream.Collectors.groupingBy; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.mapping; +import static java.util.stream.Collectors.toCollection; +import static java.util.stream.Collectors.toUnmodifiableList; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.utils.ModuleReflectionUtil; import java.io.IOException; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; @@ -31,7 +39,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.function.Supplier; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -126,12 +133,8 @@ public class PackageObjectFactory implements ModuleFactory { */ public PackageObjectFactory( Set packageNames, ClassLoader moduleClassLoader, ModuleLoadOption moduleLoadOption) { - if (moduleClassLoader == null) { - throw new IllegalArgumentException(NULL_LOADER_MESSAGE); - } - if (packageNames.contains(null)) { - throw new IllegalArgumentException(NULL_PACKAGE_MESSAGE); - } + checkArgument(moduleClassLoader != null, NULL_LOADER_MESSAGE); + checkArgument(!packageNames.contains(null), NULL_PACKAGE_MESSAGE); // create a copy of the given set, but retain ordering packages = new LinkedHashSet<>(packageNames); @@ -147,14 +150,10 @@ public class PackageObjectFactory implements ModuleFactory { * @throws IllegalArgumentException if moduleClassLoader is null or packageNames is null */ public PackageObjectFactory(String packageName, ClassLoader moduleClassLoader) { - if (moduleClassLoader == null) { - throw new IllegalArgumentException(NULL_LOADER_MESSAGE); - } - if (packageName == null) { - throw new IllegalArgumentException(NULL_PACKAGE_MESSAGE); - } + checkArgument(moduleClassLoader != null, NULL_LOADER_MESSAGE); + checkArgument(packageName != null, NULL_PACKAGE_MESSAGE); - packages = Collections.singleton(packageName); + packages = ImmutableSet.of(packageName); this.moduleClassLoader = moduleClassLoader; } @@ -272,7 +271,7 @@ public class PackageObjectFactory implements ModuleFactory { returnValue = createObject(fullModuleNames.iterator().next()); } else { final String optionalNames = - fullModuleNames.stream().sorted().collect(Collectors.joining(STRING_SEPARATOR)); + fullModuleNames.stream().sorted().collect(joining(STRING_SEPARATOR)); final LocalizedMessage exceptionMessage = new LocalizedMessage( Definitions.CHECKSTYLE_BUNDLE, @@ -299,12 +298,11 @@ public class PackageObjectFactory implements ModuleFactory { returnValue = ModuleReflectionUtil.getCheckstyleModules(packages, loader).stream() .collect( - Collectors.groupingBy( + groupingBy( Class::getSimpleName, - Collectors.mapping( - Class::getCanonicalName, Collectors.toCollection(HashSet::new)))); + mapping(Class::getCanonicalName, toCollection(HashSet::new)))); } catch (IOException ignore) { - returnValue = Collections.emptyMap(); + returnValue = ImmutableMap.of(); } return returnValue; } @@ -318,8 +316,8 @@ public class PackageObjectFactory implements ModuleFactory { public static String getShortFromFullModuleNames(String fullName) { return NAME_TO_FULL_MODULE_NAME.entrySet().stream() .filter(entry -> entry.getValue().equals(fullName)) - .map(Entry::getKey) .findFirst() + .map(Entry::getKey) .orElse(fullName); } @@ -333,7 +331,7 @@ public class PackageObjectFactory implements ModuleFactory { private static String joinPackageNamesWithClassName(String className, Set packages) { return packages.stream() .collect( - Collectors.joining( + joining( PACKAGE_SEPARATOR + className + STRING_SEPARATOR, "", PACKAGE_SEPARATOR + className)); @@ -381,7 +379,7 @@ public class PackageObjectFactory implements ModuleFactory { packages.stream() .map(packageName -> packageName + PACKAGE_SEPARATOR + name) .flatMap(className -> Stream.of(className, className + CHECK_SUFFIX)) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); Object instance = null; for (String possibleName : possibleNames) { instance = createObject(possibleName); --- a/src/main/java/com/puppycrawl/tools/checkstyle/PropertiesExpander.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/PropertiesExpander.java @@ -19,10 +19,12 @@ package com.puppycrawl.tools.checkstyle; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.toUnmodifiableMap; + import java.util.Map; import java.util.Properties; -import java.util.function.Function; -import java.util.stream.Collectors; /** Resolves external properties from an underlying {@code Properties} object. */ public final class PropertiesExpander implements PropertyResolver { @@ -37,12 +39,10 @@ public final class PropertiesExpander implements PropertyResolver { * @throws IllegalArgumentException when properties argument is null */ public PropertiesExpander(Properties properties) { - if (properties == null) { - throw new IllegalArgumentException("cannot pass null"); - } + checkArgument(properties != null, "cannot pass null"); values = properties.stringPropertyNames().stream() - .collect(Collectors.toUnmodifiableMap(Function.identity(), properties::getProperty)); + .collect(toUnmodifiableMap(identity(), properties::getProperty)); } @Override --- a/src/main/java/com/puppycrawl/tools/checkstyle/PropertyCacheFile.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/PropertyCacheFile.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle; +import static com.google.common.base.Preconditions.checkArgument; + import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -33,7 +35,6 @@ import java.math.BigInteger; import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.HashSet; @@ -94,12 +95,8 @@ public final class PropertyCacheFile { * @throws IllegalArgumentException when either arguments are null */ public PropertyCacheFile(Configuration config, String fileName) { - if (config == null) { - throw new IllegalArgumentException("config can not be null"); - } - if (fileName == null) { - throw new IllegalArgumentException("fileName can not be null"); - } + checkArgument(config != null, "config can not be null"); + checkArgument(fileName != null, "fileName can not be null"); this.config = config; this.fileName = fileName; } @@ -135,7 +132,7 @@ public final class PropertyCacheFile { * @throws IOException when there is a problems with file save */ public void persist() throws IOException { - final Path path = Paths.get(fileName); + final Path path = Path.of(fileName); final Path directory = path.getParent(); if (directory != null) { --- a/src/main/java/com/puppycrawl/tools/checkstyle/SarifLogger.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/SarifLogger.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle; +import static com.google.common.base.Preconditions.checkArgument; +import static java.nio.charset.StandardCharsets.UTF_8; + import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.AuditListener; import com.puppycrawl.tools.checkstyle.api.SeverityLevel; @@ -29,7 +32,6 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StringWriter; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -107,10 +109,8 @@ public class SarifLogger extends AbstractAutomaticBean implements AuditListener */ public SarifLogger(OutputStream outputStream, OutputStreamOptions outputStreamOptions) throws IOException { - if (outputStreamOptions == null) { - throw new IllegalArgumentException("Parameter outputStreamOptions can not be null"); - } - writer = new PrintWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)); + checkArgument(outputStreamOptions != null, "Parameter outputStreamOptions can not be null"); + writer = new PrintWriter(new OutputStreamWriter(outputStream, UTF_8)); closeStream = outputStreamOptions == OutputStreamOptions.CLOSE; report = readResource("/com/puppycrawl/tools/checkstyle/sarif/SarifReport.template"); resultLineColumn = @@ -307,7 +307,7 @@ public class SarifLogger extends AbstractAutomaticBean implements AuditListener result.write(buffer, 0, length); length = inputStream.read(buffer); } - return result.toString(StandardCharsets.UTF_8); + return result.toString(UTF_8); } } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/SuppressionsStringPrinter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/SuppressionsStringPrinter.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle; +import static java.util.stream.Collectors.joining; + import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.FileText; @@ -30,7 +32,6 @@ import java.util.List; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** Class for constructing xpath queries to suppress nodes with specified line and column number. */ public final class SuppressionsStringPrinter { @@ -98,6 +99,6 @@ public final class SuppressionsStringPrinter { final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(detailAST, lineNumber, columnNumber, fileText, tabWidth); final List suppressions = queryGenerator.generate(); - return suppressions.stream().collect(Collectors.joining(LINE_SEPARATOR, "", LINE_SEPARATOR)); + return suppressions.stream().collect(joining(LINE_SEPARATOR, "", LINE_SEPARATOR)); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/ThreadModeSettings.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/ThreadModeSettings.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle; +import static com.google.common.base.Preconditions.checkArgument; + import java.io.Serializable; /** @@ -93,14 +95,12 @@ public class ThreadModeSettings implements Serializable { */ public final String resolveName(String name) { if (checkerThreadsNumber > 1) { - if (CHECKER_MODULE_NAME.equals(name)) { - throw new IllegalArgumentException( - "Multi thread mode for Checker module is not implemented"); - } - if (TREE_WALKER_MODULE_NAME.equals(name)) { - throw new IllegalArgumentException( - "Multi thread mode for TreeWalker module is not implemented"); - } + checkArgument( + !CHECKER_MODULE_NAME.equals(name), + "Multi thread mode for Checker module is not implemented"); + checkArgument( + !TREE_WALKER_MODULE_NAME.equals(name), + "Multi thread mode for TreeWalker module is not implemented"); } return name; --- a/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/TreeWalker.java @@ -19,6 +19,10 @@ package com.puppycrawl.tools.checkstyle; +import static java.util.Comparator.naturalOrder; +import static java.util.Comparator.nullsLast; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; @@ -41,7 +45,6 @@ import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.stream.Collectors; import java.util.stream.Stream; /** Responsible for walking an abstract syntax tree and notifying interested checks at each node. */ @@ -371,7 +374,7 @@ public final class TreeWalker extends AbstractFileSetCheck implements ExternalRe resource -> { return ((ExternalResourceHolder) resource).getExternalResourceLocations().stream(); }) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } /** @@ -403,7 +406,7 @@ public final class TreeWalker extends AbstractFileSetCheck implements ExternalRe private static SortedSet createNewCheckSortedSet() { return new TreeSet<>( Comparator.comparing(check -> check.getClass().getName()) - .thenComparing(AbstractCheck::getId, Comparator.nullsLast(Comparator.naturalOrder())) + .thenComparing(AbstractCheck::getId, nullsLast(naturalOrder())) .thenComparingInt(AbstractCheck::hashCode)); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/XMLLogger.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/XMLLogger.java @@ -19,6 +19,11 @@ package com.puppycrawl.tools.checkstyle; +import static com.google.common.base.Preconditions.checkArgument; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Collections.synchronizedList; +import static java.util.Collections.unmodifiableList; + import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.AuditListener; import com.puppycrawl.tools.checkstyle.api.AutomaticBean; @@ -27,9 +32,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.StringWriter; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -89,10 +92,8 @@ public class XMLLogger extends AbstractAutomaticBean implements AuditListener { * @throws IllegalArgumentException if outputStreamOptions is null. */ public XMLLogger(OutputStream outputStream, OutputStreamOptions outputStreamOptions) { - writer = new PrintWriter(new OutputStreamWriter(outputStream, StandardCharsets.UTF_8)); - if (outputStreamOptions == null) { - throw new IllegalArgumentException("Parameter outputStreamOptions can not be null"); - } + writer = new PrintWriter(new OutputStreamWriter(outputStream, UTF_8)); + checkArgument(outputStreamOptions != null, "Parameter outputStreamOptions can not be null"); closeStream = outputStreamOptions == OutputStreamOptions.CLOSE; } @@ -327,10 +328,10 @@ public class XMLLogger extends AbstractAutomaticBean implements AuditListener { private static final class FileMessages { /** The file error events. */ - private final List errors = Collections.synchronizedList(new ArrayList<>()); + private final List errors = synchronizedList(new ArrayList<>()); /** The file exceptions. */ - private final List exceptions = Collections.synchronizedList(new ArrayList<>()); + private final List exceptions = synchronizedList(new ArrayList<>()); /** * Returns the file error events. @@ -338,7 +339,7 @@ public class XMLLogger extends AbstractAutomaticBean implements AuditListener { * @return the file error events. */ public List getErrors() { - return Collections.unmodifiableList(errors); + return unmodifiableList(errors); } /** @@ -356,7 +357,7 @@ public class XMLLogger extends AbstractAutomaticBean implements AuditListener { * @return the file exceptions. */ public List getExceptions() { - return Collections.unmodifiableList(exceptions); + return unmodifiableList(exceptions); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/XpathFileGeneratorAuditListener.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/XpathFileGeneratorAuditListener.java @@ -19,13 +19,14 @@ package com.puppycrawl.tools.checkstyle; +import static java.nio.charset.StandardCharsets.UTF_8; + import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.AuditListener; import java.io.File; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; /** * Generates suppressions.xml file, based on violations occurred. See issue scanner.getBasedir() + File.separator + name) .map(File::new) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); } /** Poor man enumeration for the formatter types. */ --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/AbstractCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/AbstractCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.api; +import static java.util.Collections.unmodifiableSet; + import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.Collections; import java.util.HashSet; @@ -107,7 +109,7 @@ public abstract class AbstractCheck extends AbstractViolationReporter { * @return the set of token names */ public final Set getTokenNames() { - return Collections.unmodifiableSet(tokens); + return unmodifiableSet(tokens); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/AbstractFileSetCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/AbstractFileSetCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.api; +import static com.google.common.base.Preconditions.checkArgument; + import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import java.util.Arrays; @@ -164,9 +166,7 @@ public abstract class AbstractFileSetCheck extends AbstractViolationReporter * @throws IllegalArgumentException is argument is null */ public final void setFileExtensions(String... extensions) { - if (extensions == null) { - throw new IllegalArgumentException("Extensions array can not be null"); - } + checkArgument(extensions != null, "Extensions array can not be null"); fileExtensions = new String[extensions.length]; for (int i = 0; i < extensions.length; i++) { --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/AuditEvent.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/AuditEvent.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.api; +import static com.google.common.base.Preconditions.checkArgument; + /** * Raw event for audit. * @@ -69,9 +71,7 @@ public final class AuditEvent { * @throws IllegalArgumentException if {@code src} is {@code null}. */ public AuditEvent(Object src, String fileName, Violation violation) { - if (src == null) { - throw new IllegalArgumentException("null source"); - } + checkArgument(src != null, "null source"); source = src; this.fileName = fileName; --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/BeforeExecutionFileFilterSet.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/BeforeExecutionFileFilterSet.java @@ -19,7 +19,8 @@ package com.puppycrawl.tools.checkstyle.api; -import java.util.Collections; +import static java.util.Collections.unmodifiableSet; + import java.util.HashSet; import java.util.Set; @@ -56,7 +57,7 @@ public final class BeforeExecutionFileFilterSet implements BeforeExecutionFileFi * @return the Filters of the filter set. */ public Set getBeforeExecutionFileFilters() { - return Collections.unmodifiableSet(beforeExecutionFileFilters); + return unmodifiableSet(beforeExecutionFileFilters); } @Override --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/FileContents.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/FileContents.java @@ -19,12 +19,13 @@ package com.puppycrawl.tools.checkstyle.api; +import static java.util.Collections.unmodifiableMap; + import com.puppycrawl.tools.checkstyle.grammar.CommentListener; import com.puppycrawl.tools.checkstyle.utils.CheckUtil; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -293,7 +294,7 @@ public final class FileContents implements CommentListener { * @return the Map of comments */ public Map getSingleLineComments() { - return Collections.unmodifiableMap(cppComments); + return unmodifiableMap(cppComments); } /** @@ -303,7 +304,7 @@ public final class FileContents implements CommentListener { * @return the map of comments */ public Map> getBlockComments() { - return Collections.unmodifiableMap(clangComments); + return unmodifiableMap(clangComments); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/FilterSet.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/FilterSet.java @@ -19,7 +19,8 @@ package com.puppycrawl.tools.checkstyle.api; -import java.util.Collections; +import static java.util.Collections.unmodifiableSet; + import java.util.HashSet; import java.util.Set; @@ -56,7 +57,7 @@ public class FilterSet implements Filter { * @return the Filters of the filter set. */ public Set getFilters() { - return Collections.unmodifiableSet(filters); + return unmodifiableSet(filters); } @Override --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/SeverityLevelCounter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/SeverityLevelCounter.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.api; +import static com.google.common.base.Preconditions.checkArgument; + import java.util.concurrent.atomic.AtomicInteger; /** @@ -40,9 +42,7 @@ public final class SeverityLevelCounter implements AuditListener { * @throws IllegalArgumentException when level is null */ public SeverityLevelCounter(SeverityLevel level) { - if (level == null) { - throw new IllegalArgumentException("'level' cannot be null"); - } + checkArgument(level != null, "'level' cannot be null"); this.level = level; } --- a/src/main/java/com/puppycrawl/tools/checkstyle/api/Violation.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/api/Violation.java @@ -385,7 +385,7 @@ public final class Violation implements Comparable { && Objects.equals(columnNo, violation.columnNo) && Objects.equals(columnCharIndex, violation.columnCharIndex) && Objects.equals(tokenType, violation.tokenType) - && Objects.equals(severityLevel, violation.severityLevel) + && severityLevel == violation.severityLevel && Objects.equals(moduleId, violation.moduleId) && Objects.equals(key, violation.key) && Objects.equals(bundle, violation.bundle) --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheck.java @@ -265,8 +265,8 @@ public class AvoidEscapedUnicodeCharactersCheck extends AbstractCheck { } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public void beginTree(DetailAST rootAST) { singlelineComments = getFileContents().getSingleLineComments(); blockComments = getFileContents().getBlockComments(); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/LineSeparatorOption.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/LineSeparatorOption.java @@ -19,7 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks; -import java.nio.charset.StandardCharsets; +import static java.nio.charset.StandardCharsets.US_ASCII; + import java.util.Arrays; /** @@ -55,7 +56,7 @@ public enum LineSeparatorOption { * @param sep the line separator, e.g. "\r\n" */ LineSeparatorOption(String sep) { - lineSeparator = sep.getBytes(StandardCharsets.US_ASCII); + lineSeparator = sep.getBytes(US_ASCII); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/OrderedPropertiesCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/OrderedPropertiesCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks; +import static java.util.Collections.enumeration; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; import com.puppycrawl.tools.checkstyle.api.FileText; @@ -27,7 +29,6 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Collections; import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -191,7 +192,7 @@ public class OrderedPropertiesCheck extends AbstractFileSetCheck { /** Returns a copy of the keys. */ @Override public Enumeration keys() { - return Collections.enumeration(keyList); + return enumeration(keyList); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java @@ -19,12 +19,14 @@ package com.puppycrawl.tools.checkstyle.checks; +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.AuditEvent; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -296,7 +298,7 @@ public class SuppressWarningsHolder extends AbstractCheck { */ private static List getAllAnnotationValues(DetailAST ast) { // get values of annotation - List values = Collections.emptyList(); + List values = ImmutableList.of(); final DetailAST lparenAST = ast.findFirstToken(TokenTypes.LPAREN); if (lparenAST != null) { final DetailAST nextAST = lparenAST.getNextSibling(); @@ -378,9 +380,7 @@ public class SuppressWarningsHolder extends AbstractCheck { * @throws IllegalArgumentException if the AST is invalid */ private static String getIdentifier(DetailAST ast) { - if (ast == null) { - throw new IllegalArgumentException("Identifier AST expected, but get null."); - } + checkArgument(ast != null, "Identifier AST expected, but get null."); final String identifier; if (ast.getType() == TokenTypes.IDENT) { identifier = ast.getText(); @@ -436,7 +436,7 @@ public class SuppressWarningsHolder extends AbstractCheck { final List annotationValues; switch (ast.getType()) { case TokenTypes.EXPR: - annotationValues = Collections.singletonList(getStringExpr(ast)); + annotationValues = ImmutableList.of(getStringExpr(ast)); break; case TokenTypes.ANNOTATION_ARRAY_INIT: annotationValues = findAllExpressionsInChildren(ast); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheck.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.checks; +import static java.util.Collections.unmodifiableSet; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.Definitions; import com.puppycrawl.tools.checkstyle.GlobalStatefulCheck; import com.puppycrawl.tools.checkstyle.LocalizedMessage; @@ -32,7 +35,6 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.Locale; import java.util.Map; @@ -46,7 +48,6 @@ import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -228,7 +229,7 @@ public class TranslationCheck extends AbstractFileSetCheck { * @since 6.11 */ public void setRequiredTranslations(String... translationCodes) { - requiredTranslations = Arrays.stream(translationCodes).collect(Collectors.toUnmodifiableSet()); + requiredTranslations = Arrays.stream(translationCodes).collect(toUnmodifiableSet()); validateUserSpecifiedLanguageCodes(requiredTranslations); } @@ -501,7 +502,7 @@ public class TranslationCheck extends AbstractFileSetCheck { final Set missingKeys = keysThatMustExist.stream() .filter(key -> !currentFileKeys.contains(key)) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); if (!missingKeys.isEmpty()) { final MessageDispatcher dispatcher = getMessageDispatcher(); final String path = fileKey.getKey().getAbsolutePath(); @@ -622,7 +623,7 @@ public class TranslationCheck extends AbstractFileSetCheck { * @return the set of files */ public Set getFiles() { - return Collections.unmodifiableSet(files); + return unmodifiableSet(files); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheck.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -60,7 +61,7 @@ public class UncommentedMainCheck extends AbstractCheck { /** Set of possible String array types. */ private static final Set STRING_PARAMETER_NAMES = - Set.of( + ImmutableSet.of( String[].class.getCanonicalName(), String.class.getCanonicalName(), String[].class.getSimpleName(), --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.annotation; +import static java.util.Objects.requireNonNullElse; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -152,8 +154,7 @@ public final class MissingOverrideCheck extends AbstractCheck { final DetailAST startNode; if (modifiers.hasChildren()) { startNode = - Optional.ofNullable(ast.getFirstChild().findFirstToken(TokenTypes.ANNOTATION)) - .orElse(modifiers); + requireNonNullElse(ast.getFirstChild().findFirstToken(TokenTypes.ANNOTATION), modifiers); } else { startNode = ast.findFirstToken(TokenTypes.TYPE); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheck.java @@ -19,13 +19,14 @@ package com.puppycrawl.tools.checkstyle.checks.annotation; +import static java.util.Objects.requireNonNullElse; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.AnnotationUtil; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; -import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -162,7 +163,7 @@ public class SuppressWarningsCheck extends AbstractCheck { final DetailAST token = warningHolder.findFirstToken(TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR); // case like '@SuppressWarnings(value = UNUSED)' - final DetailAST parent = Objects.requireNonNullElse(token, warningHolder); + final DetailAST parent = requireNonNullElse(token, warningHolder); DetailAST warning = parent.findFirstToken(TokenTypes.EXPR); // rare case with empty array ex: @SuppressWarnings({}) @@ -242,10 +243,10 @@ public class SuppressWarningsCheck extends AbstractCheck { final DetailAST annValuePair = annotation.findFirstToken(TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR); - final DetailAST annArrayInitParent = Objects.requireNonNullElse(annValuePair, annotation); + final DetailAST annArrayInitParent = requireNonNullElse(annValuePair, annotation); final DetailAST annArrayInit = annArrayInitParent.findFirstToken(TokenTypes.ANNOTATION_ARRAY_INIT); - return Objects.requireNonNullElse(annArrayInit, annotation); + return requireNonNullElse(annArrayInit, annotation); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheck.java @@ -19,12 +19,13 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import static java.util.Collections.unmodifiableSet; + import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CheckUtil; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -552,7 +553,7 @@ public class EqualsAvoidNullCheck extends AbstractCheck { * @return children of this frame. */ public Set getChildren() { - return Collections.unmodifiableSet(children); + return unmodifiableSet(children); } /** @@ -618,7 +619,7 @@ public class EqualsAvoidNullCheck extends AbstractCheck { * @return method calls of this frame. */ public Set getMethodCalls() { - return Collections.unmodifiableSet(methodCalls); + return unmodifiableSet(methodCalls); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheck.java @@ -370,7 +370,7 @@ public class FallThroughCheck extends AbstractCheck { return Optional.ofNullable(getNextNonCommentAst(ast)) .map(DetailAST::getPreviousSibling) .map(previous -> previous.getFirstChild().getText()) - .map(text -> reliefPattern.matcher(text).find()) - .orElse(Boolean.FALSE); + .filter(text -> reliefPattern.matcher(text).find()) + .isPresent(); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import static java.util.stream.Collectors.toCollection; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -28,7 +30,6 @@ import com.puppycrawl.tools.checkstyle.utils.CheckUtil; import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import java.util.stream.Collectors; /** * Checks that certain exception types do not appear in a {@code catch} statement. @@ -74,7 +75,7 @@ public final class IllegalCatchCheck extends AbstractCheck { "java.lang.RuntimeException", "java.lang.Throwable", }) - .collect(Collectors.toCollection(HashSet::new)); + .collect(toCollection(HashSet::new)); /** * Setter to specify exception class names to reject. --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -28,7 +30,6 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import java.util.stream.Collectors; /** * Checks for illegal instantiations where a factory method is preferred. @@ -314,6 +315,6 @@ public class IllegalInstantiationCheck extends AbstractCheck { * @since 3.0 */ public void setClasses(String... names) { - classes = Arrays.stream(names).collect(Collectors.toUnmodifiableSet()); + classes = Arrays.stream(names).collect(toUnmodifiableSet()); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import static java.util.stream.Collectors.toCollection; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -30,7 +32,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.Set; -import java.util.stream.Collectors; /** * Checks that specified types are not declared to be thrown. Declaring that a method throws {@code @@ -69,7 +70,7 @@ public final class IllegalThrowsCheck extends AbstractCheck { new String[] { "finalize", }) - .collect(Collectors.toCollection(HashSet::new)); + .collect(toCollection(HashSet::new)); /** Specify throw class names to reject. */ private final Set illegalClassNames = @@ -82,7 +83,7 @@ public final class IllegalThrowsCheck extends AbstractCheck { "java.lang.RuntimeException", "java.lang.Throwable", }) - .collect(Collectors.toCollection(HashSet::new)); + .collect(toCollection(HashSet::new)); /** * Allow to ignore checking overridden methods (marked with {@code Override} or {@code --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheck.java @@ -19,12 +19,14 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import static java.util.Objects.requireNonNullElse; +import static java.util.regex.Pattern.CASE_INSENSITIVE; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; -import java.util.Objects; import java.util.regex.Pattern; /** @@ -125,7 +127,7 @@ public class IllegalTokenTextCheck extends AbstractCheck { * @since 3.2 */ public void setMessage(String message) { - this.message = Objects.requireNonNullElse(message, ""); + this.message = requireNonNullElse(message, ""); } /** @@ -157,7 +159,7 @@ public class IllegalTokenTextCheck extends AbstractCheck { private void updateRegexp() { final int compileFlags; if (ignoreCase) { - compileFlags = Pattern.CASE_INSENSITIVE; + compileFlags = CASE_INSENSITIVE; } else { compileFlags = 0; } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import static java.util.stream.Collectors.toUnmodifiableList; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -26,7 +28,6 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import com.puppycrawl.tools.checkstyle.xpath.AbstractNode; import com.puppycrawl.tools.checkstyle.xpath.RootNode; import java.util.List; -import java.util.stream.Collectors; import net.sf.saxon.Configuration; import net.sf.saxon.om.Item; import net.sf.saxon.sxpath.XPathDynamicContext; @@ -142,7 +143,7 @@ public class MatchXpathCheck extends AbstractCheck { final List matchingItems = xpathExpression.evaluate(xpathDynamicContext); return matchingItems.stream() .map(item -> (DetailAST) ((AbstractNode) item).getUnderlyingNode()) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); } catch (XPathException ex) { throw new IllegalStateException("Evaluation of Xpath query failed: " + query, ex); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -31,7 +33,6 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; /** * Checks that for loop control variables are not modified inside the for block. An example is: @@ -295,7 +296,7 @@ public final class ModifiedControlVariableCheck extends AbstractCheck { final Set iteratingVariables = getForIteratorVariables(ast); return initializedVariables.stream() .filter(iteratingVariables::contains) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheck.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -26,7 +27,6 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CheckUtil; import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.util.ArrayDeque; -import java.util.Collections; import java.util.Deque; import java.util.HashSet; import java.util.Set; @@ -99,7 +99,7 @@ public final class ParameterAssignmentCheck extends AbstractCheck { public void beginTree(DetailAST rootAST) { // clear data parameterNamesStack.clear(); - parameterNames = Collections.emptySet(); + parameterNames = ImmutableSet.of(); } @Override --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/UnusedLocalVariableCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/coding/UnusedLocalVariableCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.coding; +import static java.util.stream.Collectors.toUnmodifiableList; + import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -36,7 +38,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.stream.Collectors; /** * Checks that a local variable is declared and/or assigned, but not used. Doesn't support { return hasSameNameAsSuperClass(superClassName, typeDeclDesc); }) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheck.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.checks.design; +import static java.util.Objects.requireNonNullElse; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -28,13 +31,11 @@ import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; import com.puppycrawl.tools.checkstyle.utils.ScopeUtil; import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.util.Arrays; -import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.Predicate; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** * Checks that classes are designed for extension (subclass creation). @@ -180,7 +181,7 @@ public class DesignForExtensionCheck extends AbstractCheck { new String[] { "Test", "Before", "After", "BeforeClass", "AfterClass", }) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); /** * Specify the comment text pattern which qualifies a method as designed for extension. Supports @@ -195,8 +196,7 @@ public class DesignForExtensionCheck extends AbstractCheck { * @since 7.2 */ public void setIgnoredAnnotations(String... ignoredAnnotations) { - this.ignoredAnnotations = - Arrays.stream(ignoredAnnotations).collect(Collectors.toUnmodifiableSet()); + this.ignoredAnnotations = Arrays.stream(ignoredAnnotations).collect(toUnmodifiableSet()); } /** @@ -397,7 +397,7 @@ public class DesignForExtensionCheck extends AbstractCheck { */ private static String getAnnotationName(DetailAST annotation) { final DetailAST dotAst = annotation.findFirstToken(TokenTypes.DOT); - final DetailAST parent = Objects.requireNonNullElse(dotAst, annotation); + final DetailAST parent = requireNonNullElse(dotAst, annotation); return parent.findFirstToken(TokenTypes.IDENT).getText(); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.design; +import static java.util.Comparator.comparingInt; + import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -310,7 +312,7 @@ public class FinalClassCheck extends AbstractCheck { private Optional getNearestClassWithSameName( String className, ToIntFunction countProvider) { final String dotAndClassName = PACKAGE_SEPARATOR.concat(className); - final Comparator longestMatch = Comparator.comparingInt(countProvider); + final Comparator longestMatch = comparingInt(countProvider); return innerClasses.entrySet().stream() .filter(entry -> entry.getKey().endsWith(dotAndClassName)) .map(Map.Entry::getValue) --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheck.java @@ -19,11 +19,12 @@ package com.puppycrawl.tools.checkstyle.checks.design; +import static java.util.Objects.requireNonNullElse; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; -import java.util.Objects; /** * Restricts throws statements to a specified count. Methods with "Override" or "java.lang.Override" @@ -167,7 +168,7 @@ public final class ThrowsCountCheck extends AbstractCheck { */ private static String getAnnotationName(DetailAST annotation) { final DetailAST dotAst = annotation.findFirstToken(TokenTypes.DOT); - final DetailAST parent = Objects.requireNonNullElse(dotAst, annotation); + final DetailAST parent = requireNonNullElse(dotAst, annotation); return parent.findFirstToken(TokenTypes.IDENT).getText(); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheck.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.checks.design; +import static java.util.stream.Collectors.toCollection; + +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -33,7 +36,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** * Checks visibility of class members. Only static final, immutable or annotated by specified @@ -152,7 +154,7 @@ public class VisibilityModifierCheck extends AbstractCheck { /** Default ignore annotations canonical names. */ private static final Set DEFAULT_IGNORE_ANNOTATIONS = - Set.of( + ImmutableSet.of( "org.junit.Rule", "org.junit.ClassRule", "com.google.common.annotations.VisibleForTesting"); @@ -685,7 +687,7 @@ public class VisibilityModifierCheck extends AbstractCheck { private static Set getClassShortNames(Set canonicalClassNames) { return canonicalClassNames.stream() .map(CommonUtil::baseClassName) - .collect(Collectors.toCollection(HashSet::new)); + .collect(toCollection(HashSet::new)); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/header/AbstractHeaderCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/header/AbstractHeaderCheck.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.checks.header; +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.PropertyType; import com.puppycrawl.tools.checkstyle.XdocsPropertyType; import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; @@ -35,7 +38,6 @@ import java.net.URI; import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Set; import java.util.regex.Pattern; @@ -116,10 +118,9 @@ public abstract class AbstractHeaderCheck extends AbstractFileSetCheck * @throws IllegalArgumentException if header has already been set */ private void checkHeaderNotInitialized() { - if (!readerLines.isEmpty()) { - throw new IllegalArgumentException( - "header has already been set - " + "set either header or headerFile, not both"); - } + checkArgument( + readerLines.isEmpty(), + "header has already been set - " + "set either header or headerFile, not both"); } /** @@ -190,9 +191,9 @@ public abstract class AbstractHeaderCheck extends AbstractFileSetCheck final Set result; if (headerFile == null) { - result = Collections.emptySet(); + result = ImmutableSet.of(); } else { - result = Collections.singleton(headerFile.toString()); + result = ImmutableSet.of(headerFile.toString()); } return result; --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.header; +import static com.google.common.base.Preconditions.checkArgument; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.FileText; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -263,9 +265,7 @@ public class RegexpHeaderCheck extends AbstractHeaderCheck { @Override public void setHeader(String header) { if (!CommonUtil.isBlank(header)) { - if (!CommonUtil.isPatternValid(header)) { - throw new IllegalArgumentException("Unable to parse format: " + header); - } + checkArgument(CommonUtil.isPatternValid(header), "Unable to parse format: %s", header); super.setHeader(header); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.imports; +import static com.google.common.base.Preconditions.checkArgument; + import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -649,10 +651,10 @@ public class CustomImportOrderCheck extends AbstractCheck { } else if (ruleStr.startsWith(SAME_PACKAGE_RULE_GROUP)) { final String rule = ruleStr.substring(ruleStr.indexOf('(') + 1, ruleStr.indexOf(')')); samePackageMatchingDepth = Integer.parseInt(rule); - if (samePackageMatchingDepth <= 0) { - throw new IllegalArgumentException( - "SAME_PACKAGE rule parameter should be positive integer: " + ruleStr); - } + checkArgument( + samePackageMatchingDepth > 0, + "SAME_PACKAGE rule parameter should be positive integer: %s", + ruleStr); customImportOrderRules.add(SAME_PACKAGE_RULE_GROUP); } else { throw new IllegalStateException("Unexpected rule: " + ruleStr); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheck.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks.imports; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; @@ -27,7 +28,6 @@ import com.puppycrawl.tools.checkstyle.api.ExternalResourceHolder; import com.puppycrawl.tools.checkstyle.api.FullIdent; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import java.net.URI; -import java.util.Collections; import java.util.Set; import java.util.regex.Pattern; @@ -167,8 +167,8 @@ public class ImportControlCheck extends AbstractCheck implements ExternalResourc } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public void beginTree(DetailAST rootAST) { currentImportControl = null; processCurrentFile = path.matcher(getFilePath()).find(); @@ -207,7 +207,7 @@ public class ImportControlCheck extends AbstractCheck implements ExternalResourc @Override public Set getExternalResourceLocations() { - return Collections.singleton(file.toString()); + return ImmutableSet.of(file.toString()); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.imports; +import static com.google.common.base.Preconditions.checkArgument; + import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -658,9 +660,7 @@ public class ImportOrderCheck extends AbstractCheck { // matches any package grp = Pattern.compile(""); } else if (pkg.startsWith(FORWARD_SLASH)) { - if (!pkg.endsWith(FORWARD_SLASH)) { - throw new IllegalArgumentException("Invalid group: " + pkg); - } + checkArgument(pkg.endsWith(FORWARD_SLASH), "Invalid group: %s", pkg); pkg = pkg.substring(1, pkg.length() - 1); grp = Pattern.compile(pkg); } else { --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; +import static java.util.stream.Collectors.toUnmodifiableList; + import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser; import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseErrorMessage; import com.puppycrawl.tools.checkstyle.JavadocDetailNodeParser.ParseStatus; @@ -36,7 +38,6 @@ import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; /** * Base class for Checks that process Javadoc comments. @@ -182,9 +183,7 @@ public abstract class AbstractJavadocCheck extends AbstractCheck { validateDefaultJavadocTokens(); if (javadocTokens.isEmpty()) { javadocTokens.addAll( - Arrays.stream(getDefaultJavadocTokens()) - .boxed() - .collect(Collectors.toUnmodifiableList())); + Arrays.stream(getDefaultJavadocTokens()).boxed().collect(toUnmodifiableList())); } else { final int[] acceptableJavadocTokens = getAcceptableJavadocTokens(); Arrays.sort(acceptableJavadocTokens); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.DetailNode; import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; @@ -26,7 +28,6 @@ import java.util.Arrays; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** * Checks that a allowedAnnotations = Set.of("Override"); + private Set allowedAnnotations = ImmutableSet.of("Override"); /** * Setter to control whether to validate {@code throws} tags. --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheck.java @@ -257,8 +257,8 @@ public class JavadocStyleCheck extends AbstractCheck { } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public void visitToken(DetailAST ast) { if (shouldCheck(ast)) { final FileContents contents = getFileContents(); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfo.java @@ -19,6 +19,10 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.toUnmodifiableMap; + import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.Scope; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -27,8 +31,6 @@ import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.util.Arrays; import java.util.BitSet; import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; /** * This enum defines the various Javadoc tags and their properties. @@ -299,11 +301,9 @@ public enum JavadocTagInfo { static { final JavadocTagInfo[] values = values(); TEXT_TO_TAG = - Arrays.stream(values) - .collect(Collectors.toUnmodifiableMap(JavadocTagInfo::getText, Function.identity())); + Arrays.stream(values).collect(toUnmodifiableMap(JavadocTagInfo::getText, identity())); NAME_TO_TAG = - Arrays.stream(values) - .collect(Collectors.toUnmodifiableMap(JavadocTagInfo::getName, Function.identity())); + Arrays.stream(values).collect(toUnmodifiableMap(JavadocTagInfo::getName, identity())); } /** The tag text. * */ @@ -376,15 +376,11 @@ public enum JavadocTagInfo { * @throws IllegalArgumentException if the text is not a valid tag */ public static JavadocTagInfo fromText(final String text) { - if (text == null) { - throw new IllegalArgumentException("the text is null"); - } + checkArgument(text != null, "the text is null"); final JavadocTagInfo tag = TEXT_TO_TAG.get(text); - if (tag == null) { - throw new IllegalArgumentException("the text [" + text + "] is not a valid Javadoc tag text"); - } + checkArgument(tag != null, "the text [%s] is not a valid Javadoc tag text", text); return tag; } @@ -399,15 +395,11 @@ public enum JavadocTagInfo { * {@link JavadocTagInfo#isValidName(String)} */ public static JavadocTagInfo fromName(final String name) { - if (name == null) { - throw new IllegalArgumentException("the name is null"); - } + checkArgument(name != null, "the name is null"); final JavadocTagInfo tag = NAME_TO_TAG.get(name); - if (tag == null) { - throw new IllegalArgumentException("the name [" + name + "] is not a valid Javadoc tag name"); - } + checkArgument(tag != null, "the name [%s] is not a valid Javadoc tag name", name); return tag; } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheck.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -160,7 +161,7 @@ public class JavadocTypeCheck extends AbstractCheck { * Specify annotations that allow skipping validation at all. Only short names are allowed, e.g. * {@code Generated}. */ - private Set allowedAnnotations = Set.of("Generated"); + private Set allowedAnnotations = ImmutableSet.of("Generated"); /** * Setter to specify the visibility scope where Javadoc comments are checked. @@ -256,8 +257,8 @@ public class JavadocTypeCheck extends AbstractCheck { } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public void visitToken(DetailAST ast) { if (shouldCheck(ast)) { final FileContents contents = getFileContents(); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheck.java @@ -126,8 +126,8 @@ public class JavadocVariableCheck extends AbstractCheck { } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public void visitToken(DetailAST ast) { if (shouldCheck(ast)) { final FileContents contents = getFileContents(); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheck.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -141,7 +142,7 @@ public class MissingJavadocMethodCheck extends AbstractCheck { private Pattern ignoreMethodNamesRegex; /** Configure annotations that allow missed documentation. */ - private Set allowedAnnotations = Set.of("Override"); + private Set allowedAnnotations = ImmutableSet.of("Override"); /** * Setter to configure annotations that allow missed documentation. @@ -225,8 +226,8 @@ public class MissingJavadocMethodCheck extends AbstractCheck { } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public final void visitToken(DetailAST ast) { final Scope theScope = ScopeUtil.getScope(ast); if (shouldCheck(ast, theScope)) { --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheck.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -87,7 +88,7 @@ public class MissingJavadocTypeCheck extends AbstractCheck { * Specify annotations that allow missed documentation. If annotation is present in target sources * in multiple forms of qualified name, all forms should be listed in this property. */ - private Set skipAnnotations = Set.of("Generated"); + private Set skipAnnotations = ImmutableSet.of("Generated"); /** * Setter to specify the visibility scope where Javadoc comments are checked. @@ -143,8 +144,8 @@ public class MissingJavadocTypeCheck extends AbstractCheck { } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public void visitToken(DetailAST ast) { if (shouldCheck(ast)) { final FileContents contents = getFileContents(); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheck.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.DetailNode; @@ -70,7 +71,7 @@ public class SingleLineJavadocCheck extends AbstractJavadocCheck { * href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#CHDBEFIF"> * block tags which are ignored by the check. */ - private Set ignoredTags = Set.of(); + private Set ignoredTags = ImmutableSet.of(); /** * Control whether extractInlineTags(String... lines) { for (String line : lines) { - if (line.indexOf(LINE_FEED) != -1 || line.indexOf(CARRIAGE_RETURN) != -1) { - throw new IllegalArgumentException("comment lines cannot contain newlines"); - } + checkArgument( + line.indexOf(LINE_FEED) == -1 && line.indexOf(CARRIAGE_RETURN) == -1, + "comment lines cannot contain newlines"); } final String commentText = convertLinesToString(lines); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/AbstractClassCouplingCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/AbstractClassCouplingCheck.java @@ -19,6 +19,11 @@ package com.puppycrawl.tools.checkstyle.checks.metrics; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.function.Predicate.not; +import static java.util.stream.Collectors.toUnmodifiableList; + +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -29,7 +34,6 @@ import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.List; @@ -37,9 +41,7 @@ import java.util.Map; import java.util.Optional; import java.util.Set; import java.util.TreeSet; -import java.util.function.Predicate; import java.util.regex.Pattern; -import java.util.stream.Collectors; /** Base class for coupling calculation. */ @FileStatefulCheck @@ -124,7 +126,7 @@ public abstract class AbstractClassCouplingCheck extends AbstractCheck { "Stream"); /** Package names to ignore. */ - private static final Set DEFAULT_EXCLUDED_PACKAGES = Collections.emptySet(); + private static final Set DEFAULT_EXCLUDED_PACKAGES = ImmutableSet.of(); /** Pattern to match brackets in a full type name. */ private static final Pattern BRACKET_PATTERN = Pattern.compile("\\[[^]]*]"); @@ -208,12 +210,12 @@ public abstract class AbstractClassCouplingCheck extends AbstractCheck { public final void setExcludedPackages(String... excludedPackages) { final List invalidIdentifiers = Arrays.stream(excludedPackages) - .filter(Predicate.not(CommonUtil::isName)) - .collect(Collectors.toUnmodifiableList()); - if (!invalidIdentifiers.isEmpty()) { - throw new IllegalArgumentException( - "the following values are not valid identifiers: " + invalidIdentifiers); - } + .filter(not(CommonUtil::isName)) + .collect(toUnmodifiableList()); + checkArgument( + invalidIdentifiers.isEmpty(), + "the following values are not valid identifiers: %s", + invalidIdentifiers); this.excludedPackages = Set.of(excludedPackages); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheck.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.checks.naming; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -30,7 +32,6 @@ import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; /** * Validates abbreviations (consecutive capital letters) length in identifier name, it also allows @@ -199,8 +200,7 @@ public class AbbreviationAsWordInNameCheck extends AbstractCheck { */ public void setAllowedAbbreviations(String... allowedAbbreviations) { if (allowedAbbreviations != null) { - this.allowedAbbreviations = - Arrays.stream(allowedAbbreviations).collect(Collectors.toUnmodifiableSet()); + this.allowedAbbreviations = Arrays.stream(allowedAbbreviations).collect(toUnmodifiableSet()); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheck.java @@ -22,7 +22,6 @@ package com.puppycrawl.tools.checkstyle.checks.naming; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.TokenUtil; -import java.util.Objects; /** * Checks lambda parameter names. @@ -70,7 +69,7 @@ public class LambdaParameterNameCheck extends AbstractNameCheck { public void visitToken(DetailAST ast) { final boolean isInSwitchRule = ast.getParent().getType() == TokenTypes.SWITCH_RULE; - if (Objects.nonNull(ast.findFirstToken(TokenTypes.PARAMETERS))) { + if (ast.findFirstToken(TokenTypes.PARAMETERS) != null) { final DetailAST parametersNode = ast.findFirstToken(TokenTypes.PARAMETERS); TokenUtil.forEachChild(parametersNode, TokenTypes.PARAMETER_DEF, super::visitToken); } else if (!isInSwitchRule) { --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/DetectorOptions.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/DetectorOptions.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.checks.regexp; +import static java.util.Objects.requireNonNullElse; +import static java.util.regex.Pattern.CASE_INSENSITIVE; + import com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter; import java.util.Optional; import java.util.regex.Pattern; @@ -242,8 +245,8 @@ public final class DetectorOptions { * @return DetectorOptions instance. */ public DetectorOptions build() { - message = Optional.ofNullable(message).orElse(""); - suppressor = Optional.ofNullable(suppressor).orElse(NeverSuppress.INSTANCE); + message = requireNonNullElse(message, ""); + suppressor = requireNonNullElse(suppressor, NeverSuppress.INSTANCE); pattern = Optional.ofNullable(format).map(this::createPattern).orElse(null); return DetectorOptions.this; } @@ -257,7 +260,7 @@ public final class DetectorOptions { private Pattern createPattern(String formatValue) { int options = compileFlags; if (ignoreCase) { - options |= Pattern.CASE_INSENSITIVE; + options |= CASE_INSENSITIVE; } return Pattern.compile(formatValue, options); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/MultilineDetector.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/MultilineDetector.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.checks.regexp; +import com.google.common.base.Strings; import com.puppycrawl.tools.checkstyle.api.FileText; import com.puppycrawl.tools.checkstyle.api.LineColumn; import java.util.regex.Matcher; @@ -69,7 +70,7 @@ class MultilineDetector { resetState(); final String format = options.getFormat(); - if (format == null || format.isEmpty()) { + if (Strings.isNullOrEmpty(format)) { options.getReporter().log(1, MSG_EMPTY); } else { matcher = options.getPattern().matcher(fileText.getFullText()); --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheck.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.checks.regexp; +import static java.util.regex.Pattern.MULTILINE; + +import com.google.common.base.Strings; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -151,7 +154,7 @@ public class RegexpCheck extends AbstractCheck { private int errorCount; /** Specify the pattern to match against. */ - private Pattern format = Pattern.compile("^$", Pattern.MULTILINE); + private Pattern format = Pattern.compile("^$", MULTILINE); /** The matcher. */ private Matcher matcher; @@ -218,7 +221,7 @@ public class RegexpCheck extends AbstractCheck { * @since 4.0 */ public final void setFormat(Pattern pattern) { - format = CommonUtil.createPattern(pattern.pattern(), Pattern.MULTILINE); + format = CommonUtil.createPattern(pattern.pattern(), MULTILINE); } @Override @@ -237,8 +240,8 @@ public class RegexpCheck extends AbstractCheck { } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public void beginTree(DetailAST rootAST) { matcher = format.matcher(getFileContents().getText().getFullText()); matchCount = 0; @@ -336,7 +339,7 @@ public class RegexpCheck extends AbstractCheck { private String getMessage() { String msg; - if (message == null || message.isEmpty()) { + if (Strings.isNullOrEmpty(message)) { msg = format.pattern(); } else { msg = message; --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheck.java @@ -19,13 +19,15 @@ package com.puppycrawl.tools.checkstyle.checks.regexp; +import static java.util.regex.Pattern.DOTALL; +import static java.util.regex.Pattern.MULTILINE; + import com.puppycrawl.tools.checkstyle.PropertyType; import com.puppycrawl.tools.checkstyle.StatelessCheck; import com.puppycrawl.tools.checkstyle.XdocsPropertyType; import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; import com.puppycrawl.tools.checkstyle.api.FileText; import java.io.File; -import java.util.regex.Pattern; /** * Checks that a specified pattern matches across multiple lines in any file type. @@ -121,9 +123,9 @@ public class RegexpMultilineCheck extends AbstractFileSetCheck { final int result; if (matchAcrossLines) { - result = Pattern.DOTALL; + result = DOTALL; } else { - result = Pattern.MULTILINE; + result = MULTILINE; } return result; --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheck.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheck.java @@ -102,8 +102,8 @@ public class RegexpSinglelineJavaCheck extends AbstractCheck { } // suppress deprecation until https://github.com/checkstyle/checkstyle/issues/11166 - @SuppressWarnings("deprecation") @Override + @SuppressWarnings("deprecation") public void beginTree(DetailAST rootAST) { MatchSuppressor suppressor = null; if (ignoreComments) { --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/CsvFilterElement.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/CsvFilterElement.java @@ -19,7 +19,8 @@ package com.puppycrawl.tools.checkstyle.filters; -import java.util.Collections; +import static java.util.Collections.unmodifiableSet; + import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -73,7 +74,7 @@ class CsvFilterElement implements IntFilterElement { * @return the IntFilters of the filter set. */ protected Set getFilters() { - return Collections.unmodifiableSet(filters); + return unmodifiableSet(filters); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilter.java @@ -356,7 +356,7 @@ public class SuppressWithPlainTextCommentFilter extends AbstractAutomaticBean im } final Suppression suppression = (Suppression) other; return Objects.equals(lineNo, suppression.lineNo) - && Objects.equals(suppressionType, suppression.suppressionType) + && suppressionType == suppression.suppressionType && Objects.equals(eventSourceRegexp, suppression.eventSourceRegexp) && Objects.equals(eventMessageRegexp, suppression.eventMessageRegexp) && Objects.equals(eventIdRegexp, suppression.eventIdRegexp); --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilter.java @@ -483,7 +483,7 @@ public class SuppressionCommentFilter extends AbstractAutomaticBean implements T final Tag tag = (Tag) other; return Objects.equals(line, tag.line) && Objects.equals(column, tag.column) - && Objects.equals(tagType, tag.tagType) + && tagType == tag.tagType && Objects.equals(text, tag.text) && Objects.equals(tagCheckRegexp, tag.tagCheckRegexp) && Objects.equals(tagMessageRegexp, tag.tagMessageRegexp) --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilter.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilter.java @@ -19,13 +19,13 @@ package com.puppycrawl.tools.checkstyle.filters; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean; import com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent; import com.puppycrawl.tools.checkstyle.TreeWalkerFilter; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.ExternalResourceHolder; import com.puppycrawl.tools.checkstyle.utils.FilterUtil; -import java.util.Collections; import java.util.HashSet; import java.util.Objects; import java.util.Set; @@ -186,7 +186,7 @@ public class SuppressionXpathFilter extends AbstractAutomaticBean @Override public Set getExternalResourceLocations() { - return Collections.singleton(file); + return ImmutableSet.of(file); } @Override --- a/src/main/java/com/puppycrawl/tools/checkstyle/filters/XpathFilterElement.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/filters/XpathFilterElement.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.filters; +import static java.util.stream.Collectors.toUnmodifiableList; + import com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent; import com.puppycrawl.tools.checkstyle.TreeWalkerFilter; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; @@ -28,7 +30,6 @@ import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.regex.Pattern; -import java.util.stream.Collectors; import net.sf.saxon.Configuration; import net.sf.saxon.om.Item; import net.sf.saxon.sxpath.XPathDynamicContext; @@ -163,9 +164,7 @@ public class XpathFilterElement implements TreeWalkerFilter { } else { isMatching = false; final List nodes = - getItems(event).stream() - .map(AbstractNode.class::cast) - .collect(Collectors.toUnmodifiableList()); + getItems(event).stream().map(AbstractNode.class::cast).collect(toUnmodifiableList()); for (AbstractNode abstractNode : nodes) { isMatching = abstractNode.getTokenType() == event.getTokenType() --- a/src/main/java/com/puppycrawl/tools/checkstyle/gui/TreeTable.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/gui/TreeTable.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.gui; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toCollection; + import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.utils.XpathUtil; import com.puppycrawl.tools.checkstyle.xpath.ElementNode; @@ -36,7 +39,6 @@ import java.util.Collection; import java.util.Deque; import java.util.EventObject; import java.util.List; -import java.util.stream.Collectors; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.JTable; @@ -203,7 +205,7 @@ public final class TreeTable extends JTable { XpathUtil.getXpathItems(xpath, new RootNode(rootAST)).stream() .map(ElementNode.class::cast) .map(ElementNode::getUnderlyingNode) - .collect(Collectors.toCollection(ArrayDeque::new)); + .collect(toCollection(ArrayDeque::new)); updateTreeTable(xpath, nodes); } catch (XPathException exception) { xpathEditor.setText(xpathEditor.getText() + NEWLINE + exception.getMessage()); @@ -254,7 +256,7 @@ public final class TreeTable extends JTable { private static String getAllMatchingXpathQueriesText(Deque nodes) { return nodes.stream() .map(XpathQueryGenerator::generateXpathQuery) - .collect(Collectors.joining(NEWLINE, "", NEWLINE)); + .collect(joining(NEWLINE, "", NEWLINE)); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/meta/JavadocMetadataScraper.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/meta/JavadocMetadataScraper.java @@ -19,6 +19,10 @@ package com.puppycrawl.tools.checkstyle.meta; +import static java.util.Collections.unmodifiableMap; +import static java.util.stream.Collectors.joining; + +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.DetailNode; @@ -28,7 +32,6 @@ import com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck; import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.util.ArrayDeque; import java.util.Arrays; -import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; @@ -39,7 +42,6 @@ import java.util.Optional; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; @@ -98,7 +100,7 @@ public class JavadocMetadataScraper extends AbstractJavadocCheck { * files. */ private static final Set PROPERTIES_TO_NOT_WRITE = - Set.of( + ImmutableSet.of( "null", "the charset property of the parent Checker module"); @@ -477,7 +479,7 @@ public class JavadocMetadataScraper extends AbstractJavadocCheck { return Arrays.stream(parentNode.getChildren()) .filter(child -> child.getType() == JavadocTokenTypes.TEXT) .map(node -> QUOTE_PATTERN.matcher(node.getText().trim()).replaceAll("")) - .collect(Collectors.joining(" ")); + .collect(joining(" ")); } /** @@ -594,7 +596,7 @@ public class JavadocMetadataScraper extends AbstractJavadocCheck { * @return map containing module details of supplied checks. */ public static Map getModuleDetailsStore() { - return Collections.unmodifiableMap(MODULE_DETAILS_STORE); + return unmodifiableMap(MODULE_DETAILS_STORE); } /** Reset the module detail store of any previous information. */ @@ -673,7 +675,7 @@ public class JavadocMetadataScraper extends AbstractJavadocCheck { return getFirstChildOfType(ast, JavadocTokenTypes.TEXT, 0) .map(DetailNode::getText) .map(pattern::matcher) - .map(Matcher::matches) - .orElse(Boolean.FALSE); + .filter(Matcher::matches) + .isPresent(); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtil.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.meta; +import static java.util.stream.Collectors.toUnmodifiableList; + import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.OutputStreamOptions; import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -31,10 +33,8 @@ import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; import java.util.stream.Stream; /** Class which handles all the metadata generation and writing calls. */ @@ -87,7 +87,7 @@ public final class MetadataGeneratorUtil { throws IOException { final List validFiles = new ArrayList<>(); for (String folder : moduleFolders) { - try (Stream files = Files.walk(Paths.get(path + "/" + folder))) { + try (Stream files = Files.walk(Path.of(path + "/" + folder))) { validFiles.addAll( files .map(Path::toFile) @@ -98,7 +98,7 @@ public final class MetadataGeneratorUtil { || fileName.endsWith("Check.java") || fileName.endsWith("Filter.java"); }) - .collect(Collectors.toUnmodifiableList())); + .collect(toUnmodifiableList())); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/meta/ModuleDetails.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/meta/ModuleDetails.java @@ -19,8 +19,9 @@ package com.puppycrawl.tools.checkstyle.meta; +import static java.util.Collections.unmodifiableList; + import java.util.ArrayList; -import java.util.Collections; import java.util.List; /** Simple POJO class for module details. */ @@ -125,7 +126,7 @@ public final class ModuleDetails { * @return property list of module */ public List getProperties() { - return Collections.unmodifiableList(properties); + return unmodifiableList(properties); } /** @@ -152,7 +153,7 @@ public final class ModuleDetails { * @return violation message keys of module */ public List getViolationMessageKeys() { - return Collections.unmodifiableList(violationMessageKeys); + return unmodifiableList(violationMessageKeys); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/ClassAndPropertiesSettersJavadocScraper.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.site; +import static java.util.Collections.unmodifiableMap; + import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.DetailNode; @@ -27,7 +29,6 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck; import com.puppycrawl.tools.checkstyle.utils.BlockCommentPosition; import java.beans.Introspector; -import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.regex.Pattern; @@ -65,7 +66,7 @@ public class ClassAndPropertiesSettersJavadocScraper extends AbstractJavadocChec * @return the javadocs. */ public static Map getJavadocsForModuleOrProperty() { - return Collections.unmodifiableMap(JAVADOC_FOR_MODULE_OR_PROPERTY); + return unmodifiableMap(JAVADOC_FOR_MODULE_OR_PROPERTY); } @Override --- a/src/main/java/com/puppycrawl/tools/checkstyle/site/ExampleMacro.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/ExampleMacro.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.site; +import static java.util.stream.Collectors.joining; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -26,7 +28,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Locale; -import java.util.stream.Collectors; import org.apache.maven.doxia.macro.AbstractMacro; import org.apache.maven.doxia.macro.Macro; import org.apache.maven.doxia.macro.MacroExecutionException; @@ -142,7 +143,7 @@ public class ExampleMacro extends AbstractMacro { .dropWhile(line -> !XML_CONFIG_START.equals(line)) .skip(1) .takeWhile(line -> !XML_CONFIG_END.equals(line)) - .collect(Collectors.joining(NEWLINE)); + .collect(joining(NEWLINE)); } /** @@ -157,7 +158,7 @@ public class ExampleMacro extends AbstractMacro { .dropWhile(line -> !line.contains(CODE_SNIPPET_START)) .skip(1) .takeWhile(line -> !line.contains(CODE_SNIPPET_END)) - .collect(Collectors.joining(NEWLINE)); + .collect(joining(NEWLINE)); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/site/ParentModuleMacro.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/ParentModuleMacro.java @@ -20,7 +20,6 @@ package com.puppycrawl.tools.checkstyle.site; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Locale; import org.apache.maven.doxia.macro.AbstractMacro; import org.apache.maven.doxia.macro.Macro; @@ -91,7 +90,7 @@ public class ParentModuleMacro extends AbstractMacro { throw new MacroExecutionException("Failed to get parent path for " + templatePath); } return templatePathParent - .relativize(Paths.get("src", "xdocs", "config.xml")) + .relativize(Path.of("src", "xdocs", "config.xml")) .toString() .replace(".xml", ".html") .replace('\\', '/') --- a/src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/PropertiesMacro.java @@ -19,6 +19,10 @@ package com.puppycrawl.tools.checkstyle.site; +import static java.util.Collections.unmodifiableSet; +import static java.util.stream.Collectors.toUnmodifiableList; + +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.PropertyType; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailNode; @@ -29,14 +33,12 @@ import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.io.File; import java.lang.reflect.Field; import java.util.Arrays; -import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.apache.maven.doxia.macro.AbstractMacro; import org.apache.maven.doxia.macro.Macro; import org.apache.maven.doxia.macro.MacroExecutionException; @@ -54,16 +56,15 @@ public class PropertiesMacro extends AbstractMacro { /** Set of properties not inherited from the base token configuration. */ public static final Set NON_BASE_TOKEN_PROPERTIES = - Collections.unmodifiableSet( - Arrays.stream( - new String[] { - "AtclauseOrder - target", - "DescendantToken - limitedTokens", - "IllegalType - memberModifiers", - "MagicNumber - constantWaiverParentToken", - "MultipleStringLiterals - ignoreOccurrenceContext", - }) - .collect(Collectors.toSet())); + unmodifiableSet( + ImmutableSet.copyOf( + new String[] { + "AtclauseOrder - target", + "DescendantToken - limitedTokens", + "IllegalType - memberModifiers", + "MagicNumber - constantWaiverParentToken", + "MultipleStringLiterals - ignoreOccurrenceContext", + })); /** The precompiled pattern for a comma followed by a space. */ private static final Pattern COMMA_SPACE_PATTERN = Pattern.compile(", "); @@ -334,7 +335,7 @@ public class PropertiesMacro extends AbstractMacro { final List configurableTokens = SiteUtil.getDifference(check.getAcceptableTokens(), check.getRequiredTokens()).stream() .map(TokenUtil::getTokenName) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); sink.text("subset of tokens"); writeTokensList(sink, configurableTokens, SiteUtil.PATH_TO_TOKEN_TYPES, true); @@ -346,7 +347,7 @@ public class PropertiesMacro extends AbstractMacro { check.getAcceptableJavadocTokens(), check.getRequiredJavadocTokens()) .stream() .map(JavadocUtil::getTokenName) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); sink.text("subset of javadoc tokens"); writeTokensList(sink, configurableTokens, SiteUtil.PATH_TO_JAVADOC_TOKEN_TYPES, true); } else { @@ -473,7 +474,7 @@ public class PropertiesMacro extends AbstractMacro { final List configurableTokens = SiteUtil.getDifference(check.getDefaultTokens(), check.getRequiredTokens()).stream() .map(TokenUtil::getTokenName) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); writeTokensList(sink, configurableTokens, SiteUtil.PATH_TO_TOKEN_TYPES, true); } } else if (SiteUtil.JAVADOC_TOKENS.equals(propertyName)) { @@ -482,7 +483,7 @@ public class PropertiesMacro extends AbstractMacro { SiteUtil.getDifference(check.getDefaultJavadocTokens(), check.getRequiredJavadocTokens()) .stream() .map(JavadocUtil::getTokenName) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); writeTokensList(sink, configurableTokens, SiteUtil.PATH_TO_JAVADOC_TOKEN_TYPES, true); } else { final String defaultValue = getDefaultValue(propertyName, field, instance); --- a/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/SiteUtil.java @@ -19,6 +19,14 @@ package com.puppycrawl.tools.checkstyle.site; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toCollection; +import static java.util.stream.Collectors.toUnmodifiableList; +import static java.util.stream.Collectors.toUnmodifiableSet; + +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -55,7 +63,6 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @@ -72,7 +79,6 @@ import java.util.Optional; import java.util.Set; import java.util.TreeSet; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import javax.annotation.Nullable; @@ -156,7 +162,7 @@ public final class SiteUtil { /** Set of properties that are undocumented. Those are internal properties. */ private static final Set UNDOCUMENTED_PROPERTIES = - Set.of( + ImmutableSet.of( "SuppressWithNearbyCommentFilter.fileContents", "SuppressionCommentFilter.fileContents"); /** Properties that can not be gathered from class instance. */ @@ -291,27 +297,25 @@ public final class SiteUtil { /** Path to main source code folder. */ private static final String MAIN_FOLDER_PATH = - Paths.get(SRC, "main", "java", "com", "puppycrawl", "tools", "checkstyle").toString(); + Path.of(SRC, "main", "java", "com", "puppycrawl", "tools", "checkstyle").toString(); /** List of files who are superclasses and contain certain properties that checks inherit. */ private static final List MODULE_SUPER_CLASS_FILES = List.of( new File( - Paths.get(MAIN_FOLDER_PATH, CHECKS, NAMING, "AbstractAccessControlNameCheck.java") + Path.of(MAIN_FOLDER_PATH, CHECKS, NAMING, "AbstractAccessControlNameCheck.java") .toString()), + new File(Path.of(MAIN_FOLDER_PATH, CHECKS, NAMING, "AbstractNameCheck.java").toString()), new File( - Paths.get(MAIN_FOLDER_PATH, CHECKS, NAMING, "AbstractNameCheck.java").toString()), - new File( - Paths.get(MAIN_FOLDER_PATH, CHECKS, "javadoc", "AbstractJavadocCheck.java") - .toString()), - new File(Paths.get(MAIN_FOLDER_PATH, "api", "AbstractFileSetCheck.java").toString()), + Path.of(MAIN_FOLDER_PATH, CHECKS, "javadoc", "AbstractJavadocCheck.java").toString()), + new File(Path.of(MAIN_FOLDER_PATH, "api", "AbstractFileSetCheck.java").toString()), new File( - Paths.get(MAIN_FOLDER_PATH, CHECKS, "header", "AbstractHeaderCheck.java").toString()), + Path.of(MAIN_FOLDER_PATH, CHECKS, "header", "AbstractHeaderCheck.java").toString()), new File( - Paths.get(MAIN_FOLDER_PATH, CHECKS, "metrics", "AbstractClassCouplingCheck.java") + Path.of(MAIN_FOLDER_PATH, CHECKS, "metrics", "AbstractClassCouplingCheck.java") .toString()), new File( - Paths.get(MAIN_FOLDER_PATH, CHECKS, "whitespace", "AbstractParenPadCheck.java") + Path.of(MAIN_FOLDER_PATH, CHECKS, "whitespace", "AbstractParenPadCheck.java") .toString())); /** Private utility constructor. */ @@ -472,7 +476,7 @@ public final class SiteUtil { * @throws MacroExecutionException if an I/O error occurs. */ public static Set getXdocsTemplatesFilePaths() throws MacroExecutionException { - final Path directory = Paths.get("src/xdocs"); + final Path directory = Path.of("src/xdocs"); try (Stream stream = Files.find( directory, @@ -480,7 +484,7 @@ public final class SiteUtil { (path, attr) -> { return attr.isRegularFile() && path.toString().endsWith(".xml.template"); })) { - return stream.collect(Collectors.toUnmodifiableSet()); + return stream.collect(toUnmodifiableSet()); } catch (IOException ioException) { throw new MacroExecutionException("Failed to find xdocs templates", ioException); } @@ -507,7 +511,7 @@ public final class SiteUtil { } // If parent class is not found, check interfaces - if (parentModuleName == null || parentModuleName.isEmpty()) { + if (Strings.isNullOrEmpty(parentModuleName)) { final Class[] interfaces = moduleClass.getInterfaces(); for (Class interfaceClass : interfaces) { parentModuleName = CLASS_TO_PARENT_MODULE.get(interfaceClass); @@ -517,7 +521,7 @@ public final class SiteUtil { } } - if (parentModuleName == null || parentModuleName.isEmpty()) { + if (Strings.isNullOrEmpty(parentModuleName)) { final String message = String.format( Locale.ROOT, "Failed to find parent module for %s", moduleClass.getSimpleName()); @@ -541,7 +545,7 @@ public final class SiteUtil { prop -> { return !isGlobalProperty(clss, prop) && !isUndocumentedProperty(clss, prop); }) - .collect(Collectors.toCollection(HashSet::new)); + .collect(toCollection(HashSet::new)); properties.addAll(getNonExplicitProperties(instance, clss)); return new TreeSet<>(properties); } @@ -660,7 +664,7 @@ public final class SiteUtil { treeWalkerConfig.addChild(scraperCheckConfig); try { checker.configure(defaultConfiguration); - final List filesToProcess = List.of(moduleFile); + final List filesToProcess = ImmutableList.of(moduleFile); checker.process(filesToProcess); checker.destroy(); } catch (CheckstyleException checkstyleException) { @@ -983,9 +987,7 @@ public final class SiteUtil { if (value != null && Array.getLength(value) > 0) { result = removeSquareBrackets( - Arrays.stream((Pattern[]) value) - .map(Pattern::pattern) - .collect(Collectors.joining(COMMA_SPACE))); + Arrays.stream((Pattern[]) value).map(Pattern::pattern).collect(joining(COMMA_SPACE))); } if (result.isEmpty()) { @@ -1017,8 +1019,7 @@ public final class SiteUtil { result = ""; } else { try (Stream valuesStream = getValuesStream(value)) { - result = - valuesStream.map(String.class::cast).sorted().collect(Collectors.joining(COMMA_SPACE)); + result = valuesStream.map(String.class::cast).sorted().collect(joining(COMMA_SPACE)); } } @@ -1059,10 +1060,7 @@ public final class SiteUtil { private static String getIntArrayPropertyValue(Object value) { try (IntStream stream = getIntStream(value)) { String result = - stream - .mapToObj(TokenUtil::getTokenName) - .sorted() - .collect(Collectors.joining(COMMA_SPACE)); + stream.mapToObj(TokenUtil::getTokenName).sorted().collect(joining(COMMA_SPACE)); if (result.isEmpty()) { result = CURLY_BRACKETS; } @@ -1168,11 +1166,11 @@ public final class SiteUtil { */ public static List getDifference(int[] tokens, int... subtractions) { final Set subtractionsSet = - Arrays.stream(subtractions).boxed().collect(Collectors.toUnmodifiableSet()); + Arrays.stream(subtractions).boxed().collect(toUnmodifiableSet()); return Arrays.stream(tokens) .boxed() .filter(token -> !subtractionsSet.contains(token)) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); } /** @@ -1219,7 +1217,7 @@ public final class SiteUtil { throw new MacroExecutionException("Failed to get parent path for " + templatePath); } return templatePathParent - .relativize(Paths.get(SRC, "xdocs", document)) + .relativize(Path.of(SRC, "xdocs", document)) .toString() .replace(".xml", ".html") .replace('\\', '/'); --- a/src/main/java/com/puppycrawl/tools/checkstyle/site/XdocsTemplateParser.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/site/XdocsTemplateParser.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.site; +import com.google.common.base.Strings; import java.io.File; import java.io.IOException; import java.io.Reader; @@ -119,7 +120,7 @@ public class XdocsTemplateParser extends XdocParser { private void processMacroStart(XmlPullParser parser) throws MacroExecutionException { macroName = parser.getAttributeValue(null, Attribute.NAME.toString()); - if (macroName == null || macroName.isEmpty()) { + if (Strings.isNullOrEmpty(macroName)) { final String message = String.format( Locale.ROOT, @@ -138,7 +139,7 @@ public class XdocsTemplateParser extends XdocParser { * @throws MacroExecutionException if the parameter name or value is not specified. */ private void processParamStart(XmlPullParser parser, Sink sink) throws MacroExecutionException { - if (macroName != null && !macroName.isEmpty()) { + if (!Strings.isNullOrEmpty(macroName)) { final String paramName = parser.getAttributeValue(null, Attribute.NAME.toString()); final String paramValue = parser.getAttributeValue(null, Attribute.VALUE.toString()); --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/AnnotationUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/AnnotationUtil.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.utils; +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.FullIdent; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -38,7 +41,7 @@ public final class AnnotationUtil { private static final String FQ_OVERRIDE = "java.lang." + OVERRIDE; /** Simple and fully-qualified {@link Override Override} annotation names. */ - private static final Set OVERRIDE_ANNOTATIONS = Set.of(OVERRIDE, FQ_OVERRIDE); + private static final Set OVERRIDE_ANNOTATIONS = ImmutableSet.of(OVERRIDE, FQ_OVERRIDE); /** * Private utility constructor. @@ -92,9 +95,7 @@ public final class AnnotationUtil { * @throws IllegalArgumentException when ast or annotations are null */ public static boolean containsAnnotation(DetailAST ast, Set annotations) { - if (annotations == null) { - throw new IllegalArgumentException("annotations cannot be null"); - } + checkArgument(annotations != null, "annotations cannot be null"); boolean result = false; if (!annotations.isEmpty()) { final DetailAST firstMatchingAnnotation = @@ -150,9 +151,7 @@ public final class AnnotationUtil { * @throws IllegalArgumentException when ast is null */ public static DetailAST getAnnotationHolder(DetailAST ast) { - if (ast == null) { - throw new IllegalArgumentException(THE_AST_IS_NULL); - } + checkArgument(ast != null, THE_AST_IS_NULL); final DetailAST annotationHolder; @@ -182,17 +181,11 @@ public final class AnnotationUtil { * @throws IllegalArgumentException when ast or annotations are null; when annotation is blank */ public static DetailAST getAnnotation(final DetailAST ast, String annotation) { - if (ast == null) { - throw new IllegalArgumentException(THE_AST_IS_NULL); - } + checkArgument(ast != null, THE_AST_IS_NULL); - if (annotation == null) { - throw new IllegalArgumentException("the annotation is null"); - } + checkArgument(annotation != null, "the annotation is null"); - if (CommonUtil.isBlank(annotation)) { - throw new IllegalArgumentException("the annotation is empty or spaces"); - } + checkArgument(!CommonUtil.isBlank(annotation), "the annotation is empty or spaces"); return findFirstAnnotation( ast, --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/CheckUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/CheckUtil.java @@ -19,6 +19,11 @@ package com.puppycrawl.tools.checkstyle.utils; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.function.Predicate.not; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.FullIdent; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -29,9 +34,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Set; -import java.util.function.Predicate; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.Stream; /** Contains utility methods for the checks. */ @@ -315,9 +318,7 @@ public final class CheckUtil { */ private static AccessModifierOption getAccessModifierFromModifiersTokenDirectly( DetailAST modifiersToken) { - if (modifiersToken == null) { - throw new IllegalArgumentException("expected non-null AST-token with type 'MODIFIERS'"); - } + checkArgument(modifiersToken != null, "expected non-null AST-token with type 'MODIFIERS'"); AccessModifierOption accessModifier = AccessModifierOption.PACKAGE; for (DetailAST token = modifiersToken.getFirstChild(); @@ -369,8 +370,8 @@ public final class CheckUtil { public static Set parseClassNames(String... classNames) { return Arrays.stream(classNames) .flatMap(className -> Stream.of(className, CommonUtil.baseClassName(className))) - .filter(Predicate.not(String::isEmpty)) - .collect(Collectors.toUnmodifiableSet()); + .filter(not(String::isEmpty)) + .collect(toUnmodifiableSet()); } /** @@ -391,7 +392,7 @@ public final class CheckUtil { return lines.stream() .map(line -> stripIndentAndTrailingWhitespaceFromLine(line, indent)) - .collect(Collectors.joining(System.lineSeparator(), suffix, suffix)); + .collect(joining(System.lineSeparator(), suffix, suffix)); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/CommonUtil.java @@ -30,9 +30,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.BitSet; -import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -235,8 +233,8 @@ public final class CommonUtil { if (baseDirectory == null) { resultPath = path; } else { - final Path pathAbsolute = Paths.get(path); - final Path pathBase = Paths.get(baseDirectory); + final Path pathAbsolute = Path.of(path); + final Path pathBase = Path.of(baseDirectory); resultPath = pathBase.relativize(pathAbsolute).toString(); } return resultPath; @@ -447,7 +445,7 @@ public final class CommonUtil { * extension. */ public static String getFileExtension(String fileNameWithExtension) { - final String fileName = Paths.get(fileNameWithExtension).toString(); + final String fileName = Path.of(fileNameWithExtension).toString(); final int dotIndex = fileName.lastIndexOf('.'); final String extension; if (dotIndex == -1) { @@ -506,7 +504,7 @@ public final class CommonUtil { * @return true if the arg is blank. */ public static boolean isBlank(String value) { - return Objects.isNull(value) || indexOfNonWhitespace(value) >= value.length(); + return value == null || indexOfNonWhitespace(value) >= value.length(); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/JavadocUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/JavadocUtil.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.utils; +import static com.google.common.base.Preconditions.checkArgument; + import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.DetailNode; import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; @@ -262,9 +264,7 @@ public final class JavadocUtil { */ public static String getTokenName(int id) { final String name = TOKEN_VALUE_TO_NAME.get(id); - if (name == null) { - throw new IllegalArgumentException(UNKNOWN_JAVADOC_TOKEN_ID_EXCEPTION_MESSAGE + id); - } + checkArgument(name != null, "%s%s", UNKNOWN_JAVADOC_TOKEN_ID_EXCEPTION_MESSAGE, id); return name; } @@ -277,9 +277,7 @@ public final class JavadocUtil { */ public static int getTokenId(String name) { final Integer id = TOKEN_NAME_TO_VALUE.get(name); - if (id == null) { - throw new IllegalArgumentException("Unknown javadoc token name. Given name " + name); - } + checkArgument(id != null, "Unknown javadoc token name. Given name %s", name); return id; } --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/ModuleReflectionUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/ModuleReflectionUtil.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.utils; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.google.common.reflect.ClassPath; import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean; import com.puppycrawl.tools.checkstyle.TreeWalkerFilter; @@ -33,7 +35,6 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; import java.util.Collection; import java.util.Set; -import java.util.stream.Collectors; /** Contains utility methods for module reflection. */ public final class ModuleReflectionUtil { @@ -57,7 +58,7 @@ public final class ModuleReflectionUtil { .flatMap(pkg -> classPath.getTopLevelClasses(pkg).stream()) .map(ClassPath.ClassInfo::load) .filter(ModuleReflectionUtil::isCheckstyleModule) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/ScopeUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/ScopeUtil.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.utils; +import static java.util.Objects.requireNonNullElseGet; + import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.Scope; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -78,8 +80,7 @@ public final class ScopeUtil { * @see #getDefaultScope(DetailAST) */ public static Scope getScopeFromMods(DetailAST aMods) { - return Optional.ofNullable(getDeclaredScopeFromMods(aMods)) - .orElseGet(() -> getDefaultScope(aMods)); + return requireNonNullElseGet(getDeclaredScopeFromMods(aMods), () -> getDefaultScope(aMods)); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/TokenUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/TokenUtil.java @@ -19,6 +19,10 @@ package com.puppycrawl.tools.checkstyle.utils; +import static com.google.common.base.Preconditions.checkArgument; +import static java.util.function.Predicate.not; +import static java.util.stream.Collectors.toUnmodifiableMap; + import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import java.lang.reflect.Field; @@ -31,7 +35,6 @@ import java.util.Optional; import java.util.ResourceBundle; import java.util.function.Consumer; import java.util.function.Predicate; -import java.util.stream.Collectors; import java.util.stream.IntStream; /** Contains utility methods for tokens. */ @@ -91,7 +94,7 @@ public final class TokenUtil { public static Map nameToValueMapFromPublicIntFields(Class cls) { return Arrays.stream(cls.getDeclaredFields()) .filter(fld -> Modifier.isPublic(fld.getModifiers()) && fld.getType() == Integer.TYPE) - .collect(Collectors.toUnmodifiableMap(Field::getName, fld -> getIntFromField(fld, null))); + .collect(toUnmodifiableMap(Field::getName, fld -> getIntFromField(fld, null))); } /** @@ -102,7 +105,7 @@ public final class TokenUtil { */ public static Map invertMap(Map map) { return map.entrySet().stream() - .collect(Collectors.toUnmodifiableMap(Map.Entry::getValue, Map.Entry::getKey)); + .collect(toUnmodifiableMap(Map.Entry::getValue, Map.Entry::getKey)); } /** @@ -134,9 +137,7 @@ public final class TokenUtil { */ public static String getTokenName(int id) { final String name = TOKEN_VALUE_TO_NAME.get(id); - if (name == null) { - throw new IllegalArgumentException(String.format(Locale.ROOT, TOKEN_ID_EXCEPTION_FORMAT, id)); - } + checkArgument(name != null, String.format(Locale.ROOT, TOKEN_ID_EXCEPTION_FORMAT, id)); return name; } @@ -149,10 +150,7 @@ public final class TokenUtil { */ public static int getTokenId(String name) { final Integer id = TOKEN_NAME_TO_VALUE.get(name); - if (id == null) { - throw new IllegalArgumentException( - String.format(Locale.ROOT, TOKEN_NAME_EXCEPTION_FORMAT, name)); - } + checkArgument(id != null, String.format(Locale.ROOT, TOKEN_NAME_EXCEPTION_FORMAT, name)); return id; } @@ -164,10 +162,9 @@ public final class TokenUtil { * @throws IllegalArgumentException when name is unknown */ public static String getShortDescription(String name) { - if (!TOKEN_NAME_TO_VALUE.containsKey(name)) { - throw new IllegalArgumentException( - String.format(Locale.ROOT, TOKEN_NAME_EXCEPTION_FORMAT, name)); - } + checkArgument( + TOKEN_NAME_TO_VALUE.containsKey(name), + String.format(Locale.ROOT, TOKEN_NAME_EXCEPTION_FORMAT, name)); final String tokenTypes = "com.puppycrawl.tools.checkstyle.api.tokentypes"; final ResourceBundle bundle = ResourceBundle.getBundle(tokenTypes, Locale.ROOT); @@ -332,7 +329,7 @@ public final class TokenUtil { public static BitSet asBitSet(String... tokens) { return Arrays.stream(tokens) .map(String::trim) - .filter(Predicate.not(String::isEmpty)) + .filter(not(String::isEmpty)) .mapToInt(TokenUtil::getTokenId) .collect(BitSet::new, BitSet::set, BitSet::or); } --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/UnmodifiableCollectionUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/UnmodifiableCollectionUtil.java @@ -19,13 +19,15 @@ package com.puppycrawl.tools.checkstyle.utils; +import static java.util.stream.Collectors.toUnmodifiableList; + +import com.google.common.collect.ImmutableSet; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; /** * Note: it simply wraps the existing JDK methods to provide a workaround for Pitest survival on @@ -57,7 +59,7 @@ public final class UnmodifiableCollectionUtil { * @return An unmodifiable List containing elements of the specified type. */ public static List unmodifiableList(Collection items, Class elementType) { - return items.stream().map(elementType::cast).collect(Collectors.toUnmodifiableList()); + return items.stream().map(elementType::cast).collect(toUnmodifiableList()); } /** @@ -92,6 +94,6 @@ public final class UnmodifiableCollectionUtil { * @return immutable set */ public static Set singleton(T obj) { - return Collections.singleton(obj); + return ImmutableSet.of(obj); } } --- a/src/main/java/com/puppycrawl/tools/checkstyle/utils/XpathUtil.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/utils/XpathUtil.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.utils; +import static java.util.stream.Collectors.joining; + import com.puppycrawl.tools.checkstyle.AstTreeStringPrinter; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; @@ -34,7 +36,6 @@ import java.util.BitSet; import java.util.List; import java.util.Locale; import java.util.regex.Pattern; -import java.util.stream.Collectors; import net.sf.saxon.Configuration; import net.sf.saxon.om.Item; import net.sf.saxon.om.NodeInfo; @@ -194,7 +195,7 @@ public final class XpathUtil { return matchingItems.stream() .map(item -> ((ElementNode) item).getUnderlyingNode()) .map(AstTreeStringPrinter::printBranch) - .collect(Collectors.joining(DELIMITER)); + .collect(joining(DELIMITER)); } catch (XPathException ex) { final String errMsg = String.format( --- a/src/main/java/com/puppycrawl/tools/checkstyle/xpath/AbstractElementNode.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/xpath/AbstractElementNode.java @@ -19,11 +19,12 @@ package com.puppycrawl.tools.checkstyle.xpath; +import static java.util.Collections.unmodifiableList; + import com.puppycrawl.tools.checkstyle.xpath.iterators.DescendantIterator; import com.puppycrawl.tools.checkstyle.xpath.iterators.FollowingIterator; import com.puppycrawl.tools.checkstyle.xpath.iterators.PrecedingIterator; import com.puppycrawl.tools.checkstyle.xpath.iterators.ReverseListIterator; -import java.util.Collections; import java.util.List; import java.util.Optional; import net.sf.saxon.om.AxisInfo; @@ -306,7 +307,7 @@ public abstract class AbstractElementNode extends AbstractNode { */ private List getPrecedingSiblings() { final List siblings = parent.getChildren(); - return Collections.unmodifiableList(siblings.subList(0, indexAmongSiblings)); + return unmodifiableList(siblings.subList(0, indexAmongSiblings)); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/xpath/AbstractNode.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/xpath/AbstractNode.java @@ -19,7 +19,8 @@ package com.puppycrawl.tools.checkstyle.xpath; -import java.util.Collections; +import static java.util.Collections.unmodifiableList; + import java.util.List; import net.sf.saxon.Configuration; import net.sf.saxon.event.Receiver; @@ -91,7 +92,7 @@ public abstract class AbstractNode implements NodeInfo { if (children == null) { children = createChildren(); } - return Collections.unmodifiableList(children); + return unmodifiableList(children); } /** --- a/src/main/java/com/puppycrawl/tools/checkstyle/xpath/XpathQueryGenerator.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/xpath/XpathQueryGenerator.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.xpath; +import static java.util.stream.Collectors.toUnmodifiableList; + import com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.FileText; @@ -27,7 +29,6 @@ import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import com.puppycrawl.tools.checkstyle.utils.XpathUtil; import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; /** * Generates xpath queries. Xpath queries are generated based on received {@code DetailAst} element, @@ -145,7 +146,7 @@ public class XpathQueryGenerator { public List generate() { return getMatchingAstElements().stream() .map(XpathQueryGenerator::generateXpathQuery) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); } /** --- a/src/test/java/com/puppycrawl/tools/checkstyle/AbstractAutomaticBeanTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/AbstractAutomaticBeanTest.java @@ -34,9 +34,9 @@ import org.apache.commons.beanutils.ConvertUtilsBean; import org.apache.commons.beanutils.Converter; import org.junit.jupiter.api.Test; -public class AbstractAutomaticBeanTest { +final class AbstractAutomaticBeanTest { @Test - public void testConfigureNoSuchAttribute() { + void configureNoSuchAttribute() { final TestBean testBean = new TestBean(); final DefaultConfiguration conf = new DefaultConfiguration("testConf"); conf.addProperty("NonExistent", "doesn't matter"); @@ -53,7 +53,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testConfigureNoSuchAttribute2() { + void configureNoSuchAttribute2() { final TestBean testBean = new TestBean(); final DefaultConfiguration conf = new DefaultConfiguration("testConf"); conf.addProperty("privateField", "doesn't matter"); @@ -70,7 +70,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testSetupChildFromBaseClass() throws CheckstyleException { + void setupChildFromBaseClass() throws CheckstyleException { final TestBean testBean = new TestBean(); testBean.configure(new DefaultConfiguration("bean config")); testBean.setupChild(null); @@ -90,7 +90,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testSetupInvalidChildFromBaseClass() { + void setupInvalidChildFromBaseClass() { final TestBean testBean = new TestBean(); final DefaultConfiguration parentConf = new DefaultConfiguration("parentConf"); final DefaultConfiguration childConf = new DefaultConfiguration("childConf"); @@ -111,7 +111,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testContextualizeInvocationTargetException() { + void contextualizeInvocationTargetException() { final TestBean testBean = new TestBean(); final DefaultContext context = new DefaultContext(); context.add("exceptionalMethod", 123.0f); @@ -132,7 +132,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testContextualizeConversionException() { + void contextualizeConversionException() { final TestBean testBean = new TestBean(); final DefaultContext context = new DefaultContext(); context.add("val", "some string"); @@ -153,7 +153,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testTestBean() { + void bean() { final TestBean testBean = new TestBean(); testBean.setVal(0); testBean.setWrong("wrongVal"); @@ -170,7 +170,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testRegisterIntegralTypes() throws Exception { + void registerIntegralTypes() throws Exception { final ConvertUtilsBeanStub convertUtilsBean = new ConvertUtilsBeanStub(); TestUtil.invokeStaticMethod( AbstractAutomaticBean.class, "registerIntegralTypes", convertUtilsBean); @@ -180,7 +180,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testBeanConverters() throws Exception { + void beanConverters() throws Exception { final ConverterBean bean = new ConverterBean(); // methods are not seen as used by reflection @@ -214,7 +214,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testBeanConvertersUri2() throws Exception { + void beanConvertersUri2() throws Exception { final ConverterBean bean = new ConverterBean(); final DefaultConfiguration config = new DefaultConfiguration("bean"); config.addProperty("uri", ""); @@ -224,7 +224,7 @@ public class AbstractAutomaticBeanTest { } @Test - public void testBeanConvertersUri3() { + void beanConvertersUri3() { final ConverterBean bean = new ConverterBean(); final DefaultConfiguration config = new DefaultConfiguration("bean"); config.addProperty("uri", "BAD"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/AbstractModuleTestSupport.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/AbstractModuleTestSupport.java @@ -20,7 +20,11 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.stream.Collectors.toCollection; +import static java.util.stream.Collectors.toUnmodifiableList; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.puppycrawl.tools.checkstyle.LocalizedMessage.Utf8Control; @@ -48,7 +52,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.ResourceBundle; -import java.util.stream.Collectors; public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport { @@ -422,8 +425,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport */ protected final void execute(Configuration config, String... filenames) throws Exception { final Checker checker = createChecker(config); - final List files = - Arrays.stream(filenames).map(File::new).collect(Collectors.toUnmodifiableList()); + final List files = Arrays.stream(filenames).map(File::new).collect(toUnmodifiableList()); checker.process(files); checker.destroy(); } @@ -436,8 +438,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport * @throws Exception if there is a problem during checker configuration */ protected static void execute(Checker checker, String... filenames) throws Exception { - final List files = - Arrays.stream(filenames).map(File::new).collect(Collectors.toUnmodifiableList()); + final List files = Arrays.stream(filenames).map(File::new).collect(toUnmodifiableList()); checker.process(files); checker.destroy(); } @@ -458,11 +459,11 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport actualViolations.stream() .map(violation -> violation.substring(0, violation.indexOf(':'))) .map(Integer::valueOf) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); final List expectedViolationLines = testInputViolations.stream() .map(TestInputViolation::getLineNo) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); assertWithMessage("Violation lines for %s differ.", file) .that(actualViolationLines) .isEqualTo(expectedViolationLines); @@ -485,7 +486,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport throws Exception { stream.flush(); stream.reset(); - final List files = Collections.singletonList(new File(file)); + final List files = ImmutableList.of(new File(file)); final Checker checker = createChecker(config); final Map> actualViolations = getActualViolations(checker.process(files)); checker.destroy(); @@ -504,8 +505,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport private Map> getActualViolations(int errorCount) throws IOException { // process each of the lines try (ByteArrayInputStream inputStream = new ByteArrayInputStream(stream.toByteArray()); - LineNumberReader lnr = - new LineNumberReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { + LineNumberReader lnr = new LineNumberReader(new InputStreamReader(inputStream, UTF_8))) { final Map> actualViolations = new HashMap<>(); for (String line = lnr.readLine(); line != null && lnr.getLineNumber() <= errorCount; @@ -608,7 +608,7 @@ public abstract class AbstractModuleTestSupport extends AbstractPathTestSupport protected static String[] removeSuppressed( String[] actualViolations, String... suppressedViolations) { final List actualViolationsList = - Arrays.stream(actualViolations).collect(Collectors.toCollection(ArrayList::new)); + Arrays.stream(actualViolations).collect(toCollection(ArrayList::new)); actualViolationsList.removeAll(Arrays.asList(suppressedViolations)); return actualViolationsList.toArray(CommonUtil.EMPTY_STRING_ARRAY); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/AbstractPathTestSupport.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/AbstractPathTestSupport.java @@ -19,13 +19,14 @@ package com.puppycrawl.tools.checkstyle; +import static java.util.stream.Collectors.joining; + import java.io.File; import java.io.IOException; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; +import java.util.Arrays; import java.util.Locale; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.junit.jupiter.api.BeforeEach; public abstract class AbstractPathTestSupport { @@ -93,7 +94,7 @@ public abstract class AbstractPathTestSupport { * @noinspectionreason RedundantThrows - false positive */ protected static String readFile(String filename) throws IOException { - return toLfLineEnding(Files.readString(Paths.get(filename))); + return toLfLineEnding(Files.readString(Path.of(filename))); } /** @@ -103,7 +104,7 @@ public abstract class AbstractPathTestSupport { * @return joined strings */ public static String addEndOfLine(String... strings) { - return Stream.of(strings).collect(Collectors.joining(EOL, "", EOL)); + return Arrays.stream(strings).collect(joining(EOL, "", EOL)); } /** --- a/src/test/java/com/puppycrawl/tools/checkstyle/AbstractXmlTestSupport.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/AbstractXmlTestSupport.java @@ -21,10 +21,10 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.internal.utils.XmlUtil; import java.io.ByteArrayOutputStream; -import java.nio.charset.StandardCharsets; import java.util.Set; import java.util.function.BiPredicate; import javax.xml.parsers.ParserConfigurationException; @@ -43,7 +43,7 @@ public abstract class AbstractXmlTestSupport extends AbstractModuleTestSupport { */ protected static Document getOutputStreamXml(ByteArrayOutputStream outputStream) throws ParserConfigurationException { - final String xml = outputStream.toString(StandardCharsets.UTF_8); + final String xml = outputStream.toString(UTF_8); return XmlUtil.getRawXml("audit output", xml, xml); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/AstTreeStringPrinterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/AstTreeStringPrinterTest.java @@ -29,10 +29,10 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import java.io.File; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import org.junit.jupiter.api.Test; -public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { +final class AstTreeStringPrinterTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -40,14 +40,14 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(AstTreeStringPrinter.class)) .isTrue(); } @Test - public void testParseFileThrowable() throws Exception { + void parseFileThrowable() throws Exception { final File input = new File(getNonCompilablePath("InputAstTreeStringPrinter.java")); try { AstTreeStringPrinter.printFileAst(input, JavaParser.Options.WITHOUT_COMMENTS); @@ -63,7 +63,7 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testParseFile() throws Exception { + void parseFile() throws Exception { verifyAst( getPath("ExpectedAstTreeStringPrinter.txt"), getPath("InputAstTreeStringPrinterComments.java"), @@ -71,7 +71,7 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testPrintBranch() throws Exception { + void printBranch() throws Exception { final DetailAST ast = JavaParser.parseFile( new File(getPath("InputAstTreeStringPrinterPrintBranch.java")), @@ -89,7 +89,7 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testPrintAst() throws Exception { + void printAst() throws Exception { final FileText text = new FileText( new File(getPath("InputAstTreeStringPrinterComments.java")).getAbsoluteFile(), @@ -97,13 +97,13 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { final String actual = toLfLineEnding(AstTreeStringPrinter.printAst(text, JavaParser.Options.WITHOUT_COMMENTS)); final String expected = - toLfLineEnding(Files.readString(Paths.get(getPath("ExpectedAstTreeStringPrinter.txt")))); + toLfLineEnding(Files.readString(Path.of(getPath("ExpectedAstTreeStringPrinter.txt")))); assertWithMessage("Print AST output is invalid").that(actual).isEqualTo(expected); } @Test - public void testParseFileWithComments() throws Exception { + void parseFileWithComments() throws Exception { verifyAst( getPath("ExpectedAstTreeStringPrinterComments.txt"), getPath("InputAstTreeStringPrinterComments.java"), @@ -111,35 +111,35 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testParseFileWithJavadoc1() throws Exception { + void parseFileWithJavadoc1() throws Exception { verifyJavaAndJavadocAst( getPath("ExpectedAstTreeStringPrinterJavadoc.txt"), getPath("InputAstTreeStringPrinterJavadoc.java")); } @Test - public void testParseFileWithJavadoc2() throws Exception { + void parseFileWithJavadoc2() throws Exception { verifyJavaAndJavadocAst( getPath("ExpectedAstTreeStringPrinterJavaAndJavadoc.txt"), getPath("InputAstTreeStringPrinterJavaAndJavadoc.java")); } @Test - public void testParseFileWithJavadoc3() throws Exception { + void parseFileWithJavadoc3() throws Exception { verifyJavaAndJavadocAst( getPath("ExpectedAstTreeStringPrinterAttributesAndMethodsJavadoc.txt"), getPath("InputAstTreeStringPrinterAttributesAndMethodsJavadoc.java")); } @Test - public void testJavadocPosition() throws Exception { + void javadocPosition() throws Exception { verifyJavaAndJavadocAst( getPath("ExpectedAstTreeStringPrinterJavadocPosition.txt"), getPath("InputAstTreeStringPrinterJavadocPosition.java")); } @Test - public void testAstTreeBlockComments() throws Exception { + void astTreeBlockComments() throws Exception { verifyAst( getPath("ExpectedAstTreeStringPrinterFullOfBlockComments.txt"), getPath("InputAstTreeStringPrinterFullOfBlockComments.java"), @@ -147,7 +147,7 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testAstTreeBlockCommentsCarriageReturn() throws Exception { + void astTreeBlockCommentsCarriageReturn() throws Exception { verifyAst( getPath("ExpectedAstTreeStringPrinterFullOfBlockCommentsCR.txt"), getPath("InputAstTreeStringPrinterFullOfBlockCommentsCR.java"), @@ -155,7 +155,7 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testAstTreeSingleLineComments() throws Exception { + void astTreeSingleLineComments() throws Exception { verifyAst( getPath("ExpectedAstTreeStringPrinterFullOfSinglelineComments.txt"), getPath("InputAstTreeStringPrinterFullOfSinglelineComments.java"), @@ -163,7 +163,7 @@ public class AstTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testTextBlocksEscapesAreOneChar() throws Exception { + void textBlocksEscapesAreOneChar() throws Exception { final String inputFilename = "InputAstTreeStringPrinterTextBlocksEscapesAreOneChar.java"; final DetailAST ast = JavaParser.parseFile( --- a/src/test/java/com/puppycrawl/tools/checkstyle/AuditEventDefaultFormatterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/AuditEventDefaultFormatterTest.java @@ -27,10 +27,10 @@ import com.puppycrawl.tools.checkstyle.api.Violation; import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import org.junit.jupiter.api.Test; -public class AuditEventDefaultFormatterTest { +final class AuditEventDefaultFormatterTest { @Test - public void testFormatFullyQualifiedModuleNameContainsCheckSuffix() { + void formatFullyQualifiedModuleNameContainsCheckSuffix() { final Violation violation = new Violation( 1, @@ -53,7 +53,7 @@ public class AuditEventDefaultFormatterTest { } @Test - public void testFormatFullyQualifiedModuleNameDoesNotContainCheckSuffix() { + void formatFullyQualifiedModuleNameDoesNotContainCheckSuffix() { final Violation violation = new Violation( 1, @@ -76,7 +76,7 @@ public class AuditEventDefaultFormatterTest { } @Test - public void testFormatModuleWithModuleId() { + void formatModuleWithModuleId() { final Violation violation = new Violation( 1, @@ -97,7 +97,7 @@ public class AuditEventDefaultFormatterTest { } @Test - public void testCalculateBufferLength() throws Exception { + void calculateBufferLength() throws Exception { final Violation violation = new Violation( 1, 1, "messages.properties", "key", null, SeverityLevel.ERROR, null, getClass(), null); --- a/src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/CheckerTest.java @@ -25,7 +25,11 @@ import static com.puppycrawl.tools.checkstyle.DefaultLogger.AUDIT_FINISHED_MESSA import static com.puppycrawl.tools.checkstyle.DefaultLogger.AUDIT_STARTED_MESSAGE; import static com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck.MSG_KEY_NO_NEWLINE_EOF; import static com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck.MSG_KEY; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.Collections.unmodifiableList; +import static java.util.stream.Collectors.toUnmodifiableList; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.OutputStreamOptions; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; @@ -72,7 +76,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Locale; @@ -80,7 +83,6 @@ import java.util.Properties; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -117,7 +119,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testDestroy() throws Exception { + void destroy() throws Exception { final Checker checker = new Checker(); final DebugAuditAdapter auditAdapter = new DebugAuditAdapter(); checker.addListener(auditAdapter); @@ -131,8 +133,8 @@ public class CheckerTest extends AbstractModuleTestSupport { // should remove all listeners, file sets, and filters checker.destroy(); - final File tempFile = File.createTempFile("junit", null, temporaryFolder); - checker.process(Collections.singletonList(tempFile)); + final File tempFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); + checker.process(ImmutableList.of(tempFile)); final SortedSet violations = new TreeSet<>(); violations.add( new Violation( @@ -154,7 +156,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testAddListener() throws Exception { + void addListener() throws Exception { final Checker checker = new Checker(); final DebugAuditAdapter auditAdapter = new DebugAuditAdapter(); checker.addListener(auditAdapter); @@ -210,7 +212,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testRemoveListener() throws Exception { + void removeListener() throws Exception { final Checker checker = new Checker(); final DebugAuditAdapter auditAdapter = new DebugAuditAdapter(); final DebugAuditAdapter aa2 = new DebugAuditAdapter(); @@ -267,21 +269,21 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testAddBeforeExecutionFileFilter() throws Exception { + void addBeforeExecutionFileFilter() throws Exception { final Checker checker = new Checker(); final TestBeforeExecutionFileFilter filter = new TestBeforeExecutionFileFilter(); checker.addBeforeExecutionFileFilter(filter); filter.resetFilter(); - checker.process(Collections.singletonList(new File("dummy.java"))); + checker.process(ImmutableList.of(new File("dummy.java"))); assertWithMessage("Checker.acceptFileStarted() doesn't call filter") .that(filter.wasCalled()) .isTrue(); } @Test - public void testRemoveBeforeExecutionFileFilter() throws Exception { + void removeBeforeExecutionFileFilter() throws Exception { final Checker checker = new Checker(); final TestBeforeExecutionFileFilter filter = new TestBeforeExecutionFileFilter(); final TestBeforeExecutionFileFilter f2 = new TestBeforeExecutionFileFilter(); @@ -290,7 +292,7 @@ public class CheckerTest extends AbstractModuleTestSupport { checker.removeBeforeExecutionFileFilter(filter); f2.resetFilter(); - checker.process(Collections.singletonList(new File("dummy.java"))); + checker.process(ImmutableList.of(new File("dummy.java"))); assertWithMessage("Checker.acceptFileStarted() doesn't call filter") .that(f2.wasCalled()) .isTrue(); @@ -300,7 +302,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testAddFilter() { + void addFilter() { final Checker checker = new Checker(); final DebugFilter filter = new DebugFilter(); @@ -316,7 +318,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testRemoveFilter() { + void removeFilter() { final Checker checker = new Checker(); final DebugFilter filter = new DebugFilter(); final DebugFilter f2 = new DebugFilter(); @@ -337,11 +339,12 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testFileExtensions() throws Exception { + void fileExtensions() throws Exception { final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration"); checkerConfig.addProperty("charset", StandardCharsets.UTF_8.name()); checkerConfig.addProperty( - "cacheFile", File.createTempFile("junit", null, temporaryFolder).getPath()); + "cacheFile", + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath()); final Checker checker = new Checker(); checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader()); @@ -357,7 +360,8 @@ public class CheckerTest extends AbstractModuleTestSupport { files.add(otherFile); final String[] fileExtensions = {"java", "xml", "properties"}; checker.setFileExtensions(fileExtensions); - checker.setCacheFile(File.createTempFile("junit", null, temporaryFolder).getPath()); + checker.setCacheFile( + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath()); final int counter = checker.process(files); // comparing to 1 as there is only one legal file in input @@ -378,10 +382,10 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testIgnoredFileExtensions() throws Exception { + void ignoredFileExtensions() throws Exception { final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration"); checkerConfig.addProperty("charset", StandardCharsets.UTF_8.name()); - final File tempFile = File.createTempFile("junit", null, temporaryFolder); + final File tempFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", tempFile.getPath()); final Checker checker = new Checker(); @@ -396,7 +400,8 @@ public class CheckerTest extends AbstractModuleTestSupport { allIgnoredFiles.add(ignoredFile); final String[] fileExtensions = {"java", "xml", "properties"}; checker.setFileExtensions(fileExtensions); - checker.setCacheFile(File.createTempFile("junit", null, temporaryFolder).getPath()); + checker.setCacheFile( + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath()); final int counter = checker.process(allIgnoredFiles); // comparing to 0 as there is no legal file in input @@ -413,7 +418,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testSetters() { + void setters() { // all that is set by reflection, so just make code coverage be happy final Checker checker = new Checker(); checker.setBasedir("some"); @@ -437,7 +442,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testNoClassLoaderNoModuleFactory() { + void noClassLoaderNoModuleFactory() { final Checker checker = new Checker(); try { @@ -451,7 +456,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testNoModuleFactory() throws Exception { + void noModuleFactory() throws Exception { final Checker checker = new Checker(); final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); @@ -465,7 +470,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testFinishLocalSetupFullyInitialized() throws Exception { + void finishLocalSetupFullyInitialized() throws Exception { final Checker checker = new Checker(); final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); checker.setModuleClassLoader(contextClassLoader); @@ -496,7 +501,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testSetupChildExceptions() { + void setupChildExceptions() { final Checker checker = new Checker(); final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), Thread.currentThread().getContextClassLoader()); @@ -514,7 +519,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testSetupChildInvalidProperty() throws Exception { + void setupChildInvalidProperty() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HiddenFieldCheck.class); checkConfig.addProperty("$$No such property", null); try { @@ -533,7 +538,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testSetupChildListener() throws Exception { + void setupChildListener() throws Exception { final Checker checker = new Checker(); final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), Thread.currentThread().getContextClassLoader()); @@ -550,7 +555,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testDestroyCheckerWithWrongCacheFileNameLength() throws Exception { + void destroyCheckerWithWrongCacheFileNameLength() throws Exception { final Checker checker = new Checker(); final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), Thread.currentThread().getContextClassLoader()); @@ -572,8 +577,7 @@ public class CheckerTest extends AbstractModuleTestSupport { /** It is OK to have long test method name here as it describes the test purpose. */ @Test - public void testCacheAndCheckWhichDoesNotImplementExternalResourceHolderInterface() - throws Exception { + void cacheAndCheckWhichDoesNotImplementExternalResourceHolderInterface() throws Exception { assertWithMessage("ExternalResourceHolder has changed his parent") .that(ExternalResourceHolder.class.isAssignableFrom(HiddenFieldCheck.class)) .isFalse(); @@ -585,10 +589,10 @@ public class CheckerTest extends AbstractModuleTestSupport { final DefaultConfiguration checkerConfig = createRootConfig(treeWalkerConfig); checkerConfig.addProperty("charset", StandardCharsets.UTF_8.name()); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); - final File tmpFile = File.createTempFile("file", ".java", temporaryFolder); + final File tmpFile = Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile(); execute(checkerConfig, tmpFile.getPath()); final Properties cacheAfterFirstRun = new Properties(); @@ -609,18 +613,18 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testWithCacheWithNoViolation() throws Exception { + void withCacheWithNoViolation() throws Exception { final Checker checker = new Checker(); final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), Thread.currentThread().getContextClassLoader()); checker.setModuleFactory(factory); checker.configure(createModuleConfig(TranslationCheck.class)); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checker.setCacheFile(cacheFile.getPath()); checker.setupChild(createModuleConfig(TranslationCheck.class)); - final File tmpFile = File.createTempFile("file", ".java", temporaryFolder); + final File tmpFile = Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile(); final List files = new ArrayList<>(1); files.add(tmpFile); checker.process(files); @@ -650,10 +654,10 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testClearExistingCache() throws Exception { + void clearExistingCache() throws Exception { final DefaultConfiguration checkerConfig = createRootConfig(null); checkerConfig.addProperty("charset", StandardCharsets.UTF_8.name()); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); final Checker checker = new Checker(); @@ -675,7 +679,8 @@ public class CheckerTest extends AbstractModuleTestSupport { .that(cacheAfterClear.getProperty(PropertyCacheFile.CONFIG_HASH_KEY)) .isNotNull(); - final String pathToEmptyFile = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String pathToEmptyFile = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); // file that should be audited is not in cache execute(checkerConfig, pathToEmptyFile); @@ -698,12 +703,12 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testClearCache() throws Exception { + void clearCache() throws Exception { final DefaultConfiguration violationCheck = createModuleConfig(DummyFileSetViolationCheck.class); final DefaultConfiguration checkerConfig = new DefaultConfiguration("myConfig"); checkerConfig.addProperty("charset", "UTF-8"); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); checkerConfig.addChild(violationCheck); final Checker checker = new Checker(); @@ -711,7 +716,7 @@ public class CheckerTest extends AbstractModuleTestSupport { checker.configure(checkerConfig); checker.addListener(getBriefUtLogger()); - checker.process(Collections.singletonList(new File("dummy.java"))); + checker.process(ImmutableList.of(new File("dummy.java"))); checker.clearCache(); // invoke destroy to persist cache final PropertyCacheFile cache = TestUtil.getInternalState(checker, "cacheFile"); @@ -726,7 +731,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void setFileExtension() { + void setFileExtension() { final Checker checker = new Checker(); checker.setFileExtensions(".test1", "test2"); final String[] actual = TestUtil.getInternalState(checker, "fileExtensions"); @@ -736,7 +741,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testClearCacheWhenCacheFileIsNotSet() { + void clearCacheWhenCacheFileIsNotSet() { // The idea of the test is to check that when cache file is not set, // the invocation of clearCache method does not throw an exception. final Checker checker = new Checker(); @@ -755,7 +760,7 @@ public class CheckerTest extends AbstractModuleTestSupport { * does not require serialization */ @Test - public void testCatchErrorInProcessFilesMethod() throws Exception { + void catchErrorInProcessFilesMethod() throws Exception { // Assume that I/O error is happened when we try to invoke 'lastModified()' method. final String errorMessage = "Java Virtual Machine is broken" @@ -811,7 +816,7 @@ public class CheckerTest extends AbstractModuleTestSupport { * does not require serialization */ @Test - public void testCatchErrorWithNoFileName() throws Exception { + void catchErrorWithNoFileName() throws Exception { // Assume that I/O error is happened when we try to invoke 'lastModified()' method. final String errorMessage = "Java Virtual Machine is broken" @@ -869,18 +874,18 @@ public class CheckerTest extends AbstractModuleTestSupport { /** It is OK to have long test method name here as it describes the test purpose. */ @Test - public void testCacheAndFilterWhichDoesNotImplementExternalResourceHolderInterface() - throws Exception { + void cacheAndFilterWhichDoesNotImplementExternalResourceHolderInterface() throws Exception { assertWithMessage("ExternalResourceHolder has changed its parent") .that(ExternalResourceHolder.class.isAssignableFrom(DummyFilter.class)) .isFalse(); final DefaultConfiguration filterConfig = createModuleConfig(DummyFilter.class); final DefaultConfiguration checkerConfig = createRootConfig(filterConfig); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); - final String pathToEmptyFile = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String pathToEmptyFile = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); execute(checkerConfig, pathToEmptyFile); final Properties cacheAfterFirstRun = new Properties(); @@ -915,8 +920,7 @@ public class CheckerTest extends AbstractModuleTestSupport { /** It is OK to have long test method name here as it describes the test purpose. */ // -@cs[ExecutableStatementCount] This test needs to verify many things. @Test - public void testCacheAndCheckWhichAddsNewResourceLocationButKeepsSameCheckerInstance() - throws Exception { + void cacheAndCheckWhichAddsNewResourceLocationButKeepsSameCheckerInstance() throws Exception { // Use case (https://github.com/checkstyle/checkstyle/pull/3092#issuecomment-218162436): // Imagine that cache exists in a file. New version of Checkstyle appear. // New release contains update to a some check to have additional external resource. @@ -930,7 +934,7 @@ public class CheckerTest extends AbstractModuleTestSupport { check.setFirstExternalResourceLocation(firstExternalResourceLocation); final DefaultConfiguration checkerConfig = createRootConfig(null); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); final Checker checker = new Checker(); @@ -940,7 +944,8 @@ public class CheckerTest extends AbstractModuleTestSupport { checker.configure(checkerConfig); checker.addListener(getBriefUtLogger()); - final String pathToEmptyFile = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String pathToEmptyFile = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); execute(checker, pathToEmptyFile); final Properties cacheAfterFirstRun = new Properties(); @@ -996,7 +1001,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testClearLazyLoadCacheInDetailAST() throws Exception { + void clearLazyLoadCacheInDetailAST() throws Exception { final DefaultConfiguration checkConfig1 = createModuleConfig(CheckWhichDoesNotRequireCommentNodes.class); final DefaultConfiguration checkConfig2 = @@ -1015,8 +1020,8 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testCacheOnViolationSuppression() throws Exception { - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + void cacheOnViolationSuppression() throws Exception { + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); final DefaultConfiguration violationCheck = createModuleConfig(DummyFileSetViolationCheck.class); @@ -1028,7 +1033,7 @@ public class CheckerTest extends AbstractModuleTestSupport { checkerConfig.addChild(filterConfig); final String fileViolationPath = - File.createTempFile("ViolationFile", ".java", temporaryFolder).getPath(); + Files.createTempFile(temporaryFolder.toPath(), "ViolationFile", ".java").toFile().getPath(); execute(checkerConfig, fileViolationPath); @@ -1043,7 +1048,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testHaltOnException() throws Exception { + void haltOnException() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(CheckWhichThrowsError.class); final String filePath = getPath("InputChecker.java"); try { @@ -1057,8 +1062,8 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testExceptionWithCache() throws Exception { - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + void exceptionWithCache() throws Exception { + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); final DefaultConfiguration checkConfig = createModuleConfig(CheckWhichThrowsError.class); @@ -1074,7 +1079,7 @@ public class CheckerTest extends AbstractModuleTestSupport { final String filePath = getPath("InputChecker.java"); try { - checker.process(Collections.singletonList(new File(filePath))); + checker.process(ImmutableList.of(new File(filePath))); assertWithMessage("Exception is expected").fail(); } catch (CheckstyleException ex) { assertWithMessage("Error message is not expected") @@ -1102,8 +1107,8 @@ public class CheckerTest extends AbstractModuleTestSupport { * does not require serialization */ @Test - public void testCatchErrorWithCache() throws Exception { - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + void catchErrorWithCache() throws Exception { + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration"); checkerConfig.addProperty("charset", StandardCharsets.UTF_8.name()); @@ -1178,8 +1183,8 @@ public class CheckerTest extends AbstractModuleTestSupport { * does not require serialization */ @Test - public void testCatchErrorWithCacheWithNoFileName() throws Exception { - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + void catchErrorWithCacheWithNoFileName() throws Exception { + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration"); checkerConfig.addProperty("charset", StandardCharsets.UTF_8.name()); @@ -1249,7 +1254,7 @@ public class CheckerTest extends AbstractModuleTestSupport { * does not require serialization */ @Test - public void testExceptionWithNoFileName() { + void exceptionWithNoFileName() { final String errorMessage = "Security Exception"; final RuntimeException expectedError = new SecurityException(errorMessage); @@ -1297,8 +1302,8 @@ public class CheckerTest extends AbstractModuleTestSupport { * does not require serialization */ @Test - public void testExceptionWithCacheAndNoFileName() throws Exception { - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + void exceptionWithCacheAndNoFileName() throws Exception { + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); final DefaultConfiguration checkerConfig = new DefaultConfiguration("configuration"); checkerConfig.addProperty("charset", StandardCharsets.UTF_8.name()); @@ -1356,7 +1361,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testHaltOnExceptionOff() throws Exception { + void haltOnExceptionOff() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(CheckWhichThrowsError.class); final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class); @@ -1376,7 +1381,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testTabViolationDefault() throws Exception { + void tabViolationDefault() throws Exception { final String[] expected = { "10:17: violation", "13:33: violation", }; @@ -1384,7 +1389,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testTabViolation() throws Exception { + void tabViolation() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(VerifyPositionAfterTabFileSet.class); final DefaultConfiguration checkerConfig = createRootConfig(checkConfig); @@ -1396,11 +1401,11 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testCheckerProcessCallAllNeededMethodsOfFileSets() throws Exception { + void checkerProcessCallAllNeededMethodsOfFileSets() throws Exception { final DummyFileSet fileSet = new DummyFileSet(); final Checker checker = new Checker(); checker.addFileSetCheck(fileSet); - checker.process(Collections.singletonList(new File("dummy.java"))); + checker.process(ImmutableList.of(new File("dummy.java"))); final List expected = Arrays.asList("beginProcessing", "finishProcessing", "destroy"); assertWithMessage("Method calls were not expected") .that(fileSet.getMethodCalls()) @@ -1408,7 +1413,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testSetFileSetCheckSetsMessageDispatcher() { + void setFileSetCheckSetsMessageDispatcher() { final DummyFileSet fileSet = new DummyFileSet(); final Checker checker = new Checker(); checker.addFileSetCheck(fileSet); @@ -1418,7 +1423,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testAddAuditListenerAsChild() throws Exception { + void addAuditListenerAsChild() throws Exception { final Checker checker = new Checker(); final DebugAuditAdapter auditAdapter = new DebugAuditAdapter(); final PackageObjectFactory factory = @@ -1435,14 +1440,14 @@ public class CheckerTest extends AbstractModuleTestSupport { checker.setModuleFactory(factory); checker.setupChild(createModuleConfig(DebugAuditAdapter.class)); // Let's try fire some events - checker.process(Collections.singletonList(new File("dummy.java"))); + checker.process(ImmutableList.of(new File("dummy.java"))); assertWithMessage("Checker.fireAuditStarted() doesn't call listener") .that(auditAdapter.wasCalled()) .isTrue(); } @Test - public void testAddBeforeExecutionFileFilterAsChild() throws Exception { + void addBeforeExecutionFileFilterAsChild() throws Exception { final Checker checker = new Checker(); final TestBeforeExecutionFileFilter fileFilter = new TestBeforeExecutionFileFilter(); final PackageObjectFactory factory = @@ -1458,14 +1463,14 @@ public class CheckerTest extends AbstractModuleTestSupport { }; checker.setModuleFactory(factory); checker.setupChild(createModuleConfig(TestBeforeExecutionFileFilter.class)); - checker.process(Collections.singletonList(new File("dummy.java"))); + checker.process(ImmutableList.of(new File("dummy.java"))); assertWithMessage("Checker.acceptFileStarted() doesn't call listener") .that(fileFilter.wasCalled()) .isTrue(); } @Test - public void testFileSetCheckInitWhenAddedAsChild() throws Exception { + void fileSetCheckInitWhenAddedAsChild() throws Exception { final Checker checker = new Checker(); final DummyFileSet fileSet = new DummyFileSet(); final PackageObjectFactory factory = @@ -1487,7 +1492,7 @@ public class CheckerTest extends AbstractModuleTestSupport { // -@cs[CheckstyleTestMakeup] must use raw class to directly initialize DefaultLogger @Test - public void testDefaultLoggerClosesItStreams() throws Exception { + void defaultLoggerClosesItStreams() throws Exception { final Checker checker = new Checker(); try (CloseAndFlushTestByteArrayOutputStream testInfoOutputStream = new CloseAndFlushTestByteArrayOutputStream(); @@ -1501,7 +1506,7 @@ public class CheckerTest extends AbstractModuleTestSupport { testErrorOutputStream, OutputStreamOptions.CLOSE)); - final File tmpFile = File.createTempFile("file", ".java", temporaryFolder); + final File tmpFile = Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile(); execute(checker, tmpFile.getPath()); @@ -1522,14 +1527,14 @@ public class CheckerTest extends AbstractModuleTestSupport { // -@cs[CheckstyleTestMakeup] must use raw class to directly initialize DefaultLogger @Test - public void testXmlLoggerClosesItStreams() throws Exception { + void xmlLoggerClosesItStreams() throws Exception { final Checker checker = new Checker(); try (CloseAndFlushTestByteArrayOutputStream testInfoOutputStream = new CloseAndFlushTestByteArrayOutputStream()) { checker.setModuleClassLoader(Thread.currentThread().getContextClassLoader()); checker.addListener(new XMLLogger(testInfoOutputStream, OutputStreamOptions.CLOSE)); - final File tmpFile = File.createTempFile("file", ".java", temporaryFolder); + final File tmpFile = Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile(); execute(checker, tmpFile.getPath(), tmpFile.getPath()); @@ -1543,7 +1548,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testDuplicatedModule() throws Exception { + void duplicatedModule() throws Exception { // we need to test a module with two instances, one with id and the other not final DefaultConfiguration moduleConfig1 = createModuleConfig(NewlineAtEndOfFileCheck.class); final DefaultConfiguration moduleConfig2 = createModuleConfig(NewlineAtEndOfFileCheck.class); @@ -1566,7 +1571,8 @@ public class CheckerTest extends AbstractModuleTestSupport { new AuditEventDefaultFormatter()); checker.addListener(logger); - final String path = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String path = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); final String violationMessage = getCheckMessage(NewlineAtEndOfFileCheck.class, MSG_KEY_NO_NEWLINE_EOF); final String[] expected = { @@ -1575,10 +1581,9 @@ public class CheckerTest extends AbstractModuleTestSupport { // super.verify does not work here, for we change the logger out.flush(); - final int errs = checker.process(Collections.singletonList(new File(path))); + final int errs = checker.process(ImmutableList.of(new File(path))); try (ByteArrayInputStream inputStream = new ByteArrayInputStream(out.toByteArray()); - LineNumberReader lnr = - new LineNumberReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { + LineNumberReader lnr = new LineNumberReader(new InputStreamReader(inputStream, UTF_8))) { // we need to ignore the unrelated lines final List actual = lnr.lines() @@ -1586,7 +1591,7 @@ public class CheckerTest extends AbstractModuleTestSupport { .filter(line -> !getCheckMessage(AUDIT_FINISHED_MESSAGE).equals(line)) .limit(expected.length) .sorted() - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); Arrays.sort(expected); for (int i = 0; i < expected.length; i++) { @@ -1603,7 +1608,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testCachedFile() throws Exception { + void cachedFile() throws Exception { final Checker checker = createChecker(createModuleConfig(TranslationCheck.class)); final OutputStream infoStream = new ByteArrayOutputStream(); final OutputStream errorStream = new ByteArrayOutputStream(); @@ -1612,11 +1617,13 @@ public class CheckerTest extends AbstractModuleTestSupport { infoStream, OutputStreamOptions.CLOSE, errorStream, OutputStreamOptions.CLOSE); checker.addListener(loggerWithCounter); - final File cacheFile = File.createTempFile("cacheFile", ".txt", temporaryFolder); + final File cacheFile = + Files.createTempFile(temporaryFolder.toPath(), "cacheFile", ".txt").toFile(); checker.setCacheFile(cacheFile.getAbsolutePath()); - final File testFile = File.createTempFile("testFile", ".java", temporaryFolder); - final List files = List.of(testFile, testFile); + final File testFile = + Files.createTempFile(temporaryFolder.toPath(), "testFile", ".java").toFile(); + final List files = ImmutableList.of(testFile, testFile); checker.process(files); assertWithMessage("Cached file should not be processed twice") @@ -1628,7 +1635,7 @@ public class CheckerTest extends AbstractModuleTestSupport { @SuppressForbidden @Test - public void testUnmappableCharacters() throws Exception { + void unmappableCharacters() throws Exception { final String[] expected = { "4: " + getCheckMessage(LineLengthCheck.class, MSG_KEY, 75, 238), }; @@ -1643,7 +1650,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } @Test - public void testViolationMessageOnIoException() throws Exception { + void violationMessageOnIoException() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(CheckWhichThrowsError.class); final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class); @@ -1930,7 +1937,7 @@ public class CheckerTest extends AbstractModuleTestSupport { } public List getMethodCalls() { - return Collections.unmodifiableList(methodCalls); + return unmodifiableList(methodCalls); } public boolean isInitCalled() { --- a/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/ConfigurationLoaderTest.java @@ -24,6 +24,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mockConstruction; import static org.mockito.Mockito.when; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.ConfigurationLoader.IgnoredModulesOptions; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.Configuration; @@ -32,9 +33,8 @@ import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Properties; import org.junit.jupiter.api.Test; @@ -75,7 +75,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testResourceLoadConfiguration() throws Exception { + void resourceLoadConfiguration() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -93,7 +93,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testResourceLoadConfigurationWithMultiThreadConfiguration() throws Exception { + void resourceLoadConfigurationWithMultiThreadConfiguration() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -113,7 +113,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testResourceLoadConfigurationWithSingleThreadConfiguration() throws Exception { + void resourceLoadConfigurationWithSingleThreadConfiguration() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -134,14 +134,14 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testEmptyConfiguration() throws Exception { + void emptyConfiguration() throws Exception { final DefaultConfiguration config = (DefaultConfiguration) loadConfiguration("InputConfigurationLoaderEmpty.xml"); verifyConfigNode(config, "Checker", 0, new Properties()); } @Test - public void testEmptyModuleResolver() throws Exception { + void emptyModuleResolver() throws Exception { final DefaultConfiguration config = (DefaultConfiguration) loadConfiguration("InputConfigurationLoaderEmpty.xml", new Properties()); @@ -149,7 +149,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testMissingPropertyName() throws Exception { + void missingPropertyName() throws Exception { try { loadConfiguration("InputConfigurationLoaderMissingPropertyName.xml"); assertWithMessage("missing property name").fail(); @@ -167,7 +167,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testMissingPropertyNameInMethodWithBooleanParameter() throws Exception { + void missingPropertyNameInMethodWithBooleanParameter() throws Exception { try { final String fName = getPath("InputConfigurationLoaderMissingPropertyName.xml"); ConfigurationLoader.loadConfiguration( @@ -188,7 +188,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testMissingPropertyValue() throws Exception { + void missingPropertyValue() throws Exception { try { loadConfiguration("InputConfigurationLoaderMissingPropertyValue.xml"); assertWithMessage("missing property value").fail(); @@ -206,7 +206,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testMissingConfigName() throws Exception { + void missingConfigName() throws Exception { try { loadConfiguration("InputConfigurationLoaderMissingConfigName.xml"); assertWithMessage("missing module name").fail(); @@ -224,7 +224,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testMissingConfigParent() throws Exception { + void missingConfigParent() throws Exception { try { loadConfiguration("InputConfigurationLoaderMissingConfigParent.xml"); assertWithMessage("missing module parent").fail(); @@ -242,7 +242,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testCheckstyleChecks() throws Exception { + void checkstyleChecks() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -280,7 +280,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testCustomMessages() throws Exception { + void customMessages() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -293,8 +293,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { final List messages = new ArrayList<>(grandchildren[0].getMessages().values()); final String expectedKey = "name.invalidPattern"; final List expectedMessages = - Collections.singletonList( - "Member ''{0}'' must start with ''m'' (checked pattern ''{1}'')."); + ImmutableList.of("Member ''{0}'' must start with ''m'' (checked pattern ''{1}'')."); assertWithMessage("Messages should contain key: " + expectedKey) .that(grandchildren[0].getMessages()) .containsKey(expectedKey); @@ -321,7 +320,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testReplacePropertiesNoReplace() throws Exception { + void replacePropertiesNoReplace() throws Exception { final String[] testValues = { "", "a", "$a", "{a", "{a}", "a}", "$a}", "$", "a$b", }; @@ -336,7 +335,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testReplacePropertiesSyntaxError() throws Exception { + void replacePropertiesSyntaxError() throws Exception { final Properties props = initProperties(); try { final String value = @@ -353,7 +352,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testReplacePropertiesMissingProperty() throws Exception { + void replacePropertiesMissingProperty() throws Exception { final Properties props = initProperties(); try { final String value = @@ -371,7 +370,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testReplacePropertiesReplace() throws Exception { + void replacePropertiesReplace() throws Exception { final String[][] testValues = { {"${a}", "A"}, {"x${a}", "xA"}, @@ -404,7 +403,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testSystemEntity() throws Exception { + void systemEntity() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -419,7 +418,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testExternalEntity() throws Exception { + void externalEntity() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -436,7 +435,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testExternalEntitySubdirectory() throws Exception { + void externalEntitySubdirectory() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -453,7 +452,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testExternalEntityFromUri() throws Exception { + void externalEntityFromUri() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); @@ -472,7 +471,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testIncorrectTag() throws Exception { + void incorrectTag() throws Exception { final Class aClassParent = ConfigurationLoader.class; final Constructor ctorParent = aClassParent.getDeclaredConstructor( @@ -501,7 +500,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testNonExistentPropertyName() throws Exception { + void nonExistentPropertyName() throws Exception { try { loadConfiguration("InputConfigurationLoaderNonexistentProperty.xml"); assertWithMessage("exception in expected").fail(); @@ -525,7 +524,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testConfigWithIgnore() throws Exception { + void configWithIgnore() throws Exception { final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( @@ -539,7 +538,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testConfigWithIgnoreUsingInputSource() throws Exception { + void configWithIgnoreUsingInputSource() throws Exception { final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( @@ -556,7 +555,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testConfigCheckerWithIgnore() throws Exception { + void configCheckerWithIgnore() throws Exception { final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( @@ -569,7 +568,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testLoadConfigurationWrongUrl() { + void loadConfigurationWrongUrl() { try { ConfigurationLoader.loadConfiguration( ";InputConfigurationLoaderModuleIgnoreSeverity.xml", @@ -585,13 +584,13 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testLoadConfigurationDeprecated() throws Exception { + void loadConfigurationDeprecated() throws Exception { final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( new InputSource( Files.newInputStream( - Paths.get(getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml")))), + Path.of(getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml")))), new PropertiesExpander(new Properties()), IgnoredModulesOptions.OMIT); @@ -601,7 +600,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testReplacePropertiesDefault() throws Exception { + void replacePropertiesDefault() throws Exception { final Properties props = new Properties(); final String defaultValue = "defaultValue"; @@ -614,7 +613,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testLoadConfigurationFromClassPath() throws Exception { + void loadConfigurationFromClassPath() throws Exception { final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( @@ -628,7 +627,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testParsePropertyString() throws Exception { + void parsePropertyString() throws Exception { final List propertyRefs = new ArrayList<>(); final List fragments = new ArrayList<>(); @@ -638,7 +637,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testConstructors() throws Exception { + void constructors() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.basedir", "basedir"); final String fName = getPath("InputConfigurationLoaderChecks.xml"); @@ -653,7 +652,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { ConfigurationLoader.loadConfiguration( new InputSource( Files.newInputStream( - Paths.get(getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml")))), + Path.of(getPath("InputConfigurationLoaderModuleIgnoreSeverity.xml")))), new PropertiesExpander(new Properties()), ConfigurationLoader.IgnoredModulesOptions.EXECUTE); @@ -663,7 +662,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testConfigWithIgnoreExceptionalAttributes() { + void configWithIgnoreExceptionalAttributes() { try (MockedConstruction mocked = mockConstruction( DefaultConfiguration.class, @@ -691,7 +690,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testLoadConfiguration3() throws Exception { + void loadConfiguration3() throws Exception { final String[] configFiles = { "InputConfigurationLoaderOldConfig0.xml", "InputConfigurationLoaderOldConfig1.xml", @@ -707,7 +706,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { final DefaultConfiguration config = (DefaultConfiguration) ConfigurationLoader.loadConfiguration( - new InputSource(Files.newInputStream(Paths.get(getPath(configFile)))), + new InputSource(Files.newInputStream(Path.of(getPath(configFile)))), new PropertiesExpander(new Properties()), IgnoredModulesOptions.OMIT); @@ -739,7 +738,7 @@ public class ConfigurationLoaderTest extends AbstractPathTestSupport { } @Test - public void testDefaultValuesForNonDefinedProperties() throws Exception { + void defaultValuesForNonDefinedProperties() throws Exception { final Properties props = new Properties(); props.setProperty("checkstyle.charset.base", "UTF"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/DefaultConfigurationTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/DefaultConfigurationTest.java @@ -26,10 +26,10 @@ import java.util.Map; import java.util.TreeMap; import org.junit.jupiter.api.Test; -public class DefaultConfigurationTest { +final class DefaultConfigurationTest { @Test - public void testGetPropertyNames() { + void getPropertyNames() { final DefaultConfiguration config = new DefaultConfiguration("MyConfig"); config.addProperty("property", "value"); final String[] actual = config.getPropertyNames(); @@ -38,7 +38,7 @@ public class DefaultConfigurationTest { } @Test - public void testAddPropertyAndGetProperty() throws CheckstyleException { + void addPropertyAndGetProperty() throws CheckstyleException { final DefaultConfiguration config = new DefaultConfiguration("MyConfig"); config.addProperty("property", "first"); assertWithMessage("Invalid property value") @@ -56,7 +56,7 @@ public class DefaultConfigurationTest { */ @Deprecated(since = "10.2") @Test - public void testDeprecatedAttributeMethods() throws CheckstyleException { + void deprecatedAttributeMethods() throws CheckstyleException { final DefaultConfiguration config = new DefaultConfiguration("MyConfig"); config.addAttribute("attribute", "first"); final String[] actual = config.getAttributeNames(); @@ -72,13 +72,13 @@ public class DefaultConfigurationTest { } @Test - public void testGetName() { + void getName() { final DefaultConfiguration config = new DefaultConfiguration("MyConfig"); assertWithMessage("Invalid configuration name").that(config.getName()).isEqualTo("MyConfig"); } @Test - public void testRemoveChild() { + void removeChild() { final DefaultConfiguration config = new DefaultConfiguration("MyConfig"); final DefaultConfiguration configChild = new DefaultConfiguration("childConfig"); assertWithMessage("Invalid children count").that(config.getChildren().length).isEqualTo(0); @@ -89,7 +89,7 @@ public class DefaultConfigurationTest { } @Test - public void testAddMessageAndGetMessages() { + void addMessageAndGetMessages() { final DefaultConfiguration config = new DefaultConfiguration("MyConfig"); config.addMessage("key", "value"); final Map expected = new TreeMap<>(); @@ -98,7 +98,7 @@ public class DefaultConfigurationTest { } @Test - public void testExceptionForNonExistentProperty() { + void exceptionForNonExistentProperty() { final String name = "MyConfig"; final DefaultConfiguration config = new DefaultConfiguration(name); final String propertyName = "NonExistent#$%"; @@ -113,7 +113,7 @@ public class DefaultConfigurationTest { } @Test - public void testDefaultMultiThreadConfiguration() { + void defaultMultiThreadConfiguration() { final String name = "MyConfig"; final DefaultConfiguration config = new DefaultConfiguration(name); final ThreadModeSettings singleThreadMode = ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE; @@ -123,7 +123,7 @@ public class DefaultConfigurationTest { } @Test - public void testMultiThreadConfiguration() { + void multiThreadConfiguration() { final String name = "MyConfig"; final ThreadModeSettings multiThreadMode = new ThreadModeSettings(4, 2); final DefaultConfiguration config = new DefaultConfiguration(name, multiThreadMode); --- a/src/test/java/com/puppycrawl/tools/checkstyle/DefaultLoggerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/DefaultLoggerTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assumptions.assumeFalse; @@ -32,7 +33,6 @@ import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.nio.charset.StandardCharsets; import java.text.MessageFormat; import java.util.Arrays; import java.util.Locale; @@ -40,17 +40,17 @@ import java.util.ResourceBundle; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -public class DefaultLoggerTest { +final class DefaultLoggerTest { private static final Locale DEFAULT_LOCALE = Locale.ENGLISH; @AfterEach - public void tearDown() { + void tearDown() { ResourceBundle.clearCache(); } @Test - public void testCtor() { + void ctor() { final OutputStream infoStream = new ByteArrayOutputStream(); final ByteArrayOutputStream errorStream = new ByteArrayOutputStream(); final DefaultLogger dl = @@ -58,7 +58,7 @@ public class DefaultLoggerTest { infoStream, OutputStreamOptions.CLOSE, errorStream, OutputStreamOptions.CLOSE); dl.addException(new AuditEvent(5000, "myfile"), new IllegalStateException("upsss")); dl.auditFinished(new AuditEvent(6000, "myfile")); - final String output = errorStream.toString(StandardCharsets.UTF_8); + final String output = errorStream.toString(UTF_8); final LocalizedMessage addExceptionMessage = getAddExceptionMessageClass("myfile"); final String message = addExceptionMessage.getMessage(); assertWithMessage("Invalid exception").that(output).contains(message); @@ -69,7 +69,7 @@ public class DefaultLoggerTest { /** We keep this test for 100% coverage. Until #12873. */ @Test - public void testCtorWithTwoParameters() { + void ctorWithTwoParameters() { final OutputStream infoStream = new ByteArrayOutputStream(); final DefaultLogger dl = new DefaultLogger(infoStream, OutputStreamOptions.CLOSE); dl.addException(new AuditEvent(5000, "myfile"), new IllegalStateException("upsss")); @@ -82,7 +82,7 @@ public class DefaultLoggerTest { /** We keep this test for 100% coverage. Until #12873. */ @Test - public void testCtorWithTwoParametersCloseStreamOptions() { + void ctorWithTwoParametersCloseStreamOptions() { final OutputStream infoStream = new ByteArrayOutputStream(); final DefaultLogger dl = new DefaultLogger(infoStream, AutomaticBean.OutputStreamOptions.CLOSE); final boolean closeInfo = TestUtil.getInternalState(dl, "closeInfo"); @@ -92,7 +92,7 @@ public class DefaultLoggerTest { /** We keep this test for 100% coverage. Until #12873. */ @Test - public void testCtorWithTwoParametersNoneStreamOptions() { + void ctorWithTwoParametersNoneStreamOptions() { final OutputStream infoStream = new ByteArrayOutputStream(); final DefaultLogger dl = new DefaultLogger(infoStream, AutomaticBean.OutputStreamOptions.NONE); final boolean closeInfo = TestUtil.getInternalState(dl, "closeInfo"); @@ -101,7 +101,7 @@ public class DefaultLoggerTest { } @Test - public void testCtorWithNullParameter() { + void ctorWithNullParameter() { final OutputStream infoStream = new ByteArrayOutputStream(); final DefaultLogger dl = new DefaultLogger(infoStream, OutputStreamOptions.CLOSE); dl.addException(new AuditEvent(5000), new IllegalStateException("upsss")); @@ -113,7 +113,7 @@ public class DefaultLoggerTest { } @Test - public void testNewCtorWithTwoParameters() { + void newCtorWithTwoParameters() { final OutputStream infoStream = new ByteArrayOutputStream(); final DefaultLogger dl = new DefaultLogger(infoStream, OutputStreamOptions.NONE); dl.addException(new AuditEvent(5000, "myfile"), new IllegalStateException("upsss")); @@ -124,7 +124,7 @@ public class DefaultLoggerTest { } @Test - public void testNullInfoStreamOptions() { + void nullInfoStreamOptions() { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final IllegalArgumentException ex = assertThrows( @@ -138,7 +138,7 @@ public class DefaultLoggerTest { } @Test - public void testNullErrorStreamOptions() { + void nullErrorStreamOptions() { final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); final IllegalArgumentException ex = assertThrows( @@ -158,7 +158,7 @@ public class DefaultLoggerTest { } @Test - public void testAddError() { + void addError() { final OutputStream infoStream = new ByteArrayOutputStream(); final OutputStream errorStream = new ByteArrayOutputStream(); final String auditStartMessage = getAuditStartMessage(); @@ -188,7 +188,7 @@ public class DefaultLoggerTest { } @Test - public void testAddErrorModuleId() { + void addErrorModuleId() { final OutputStream infoStream = new ByteArrayOutputStream(); final OutputStream errorStream = new ByteArrayOutputStream(); final String auditFinishMessage = getAuditFinishMessage(); @@ -217,7 +217,7 @@ public class DefaultLoggerTest { } @Test - public void testAddErrorIgnoreSeverityLevel() { + void addErrorIgnoreSeverityLevel() { final OutputStream infoStream = new ByteArrayOutputStream(); final OutputStream errorStream = new ByteArrayOutputStream(); final DefaultLogger defaultLogger = @@ -235,7 +235,7 @@ public class DefaultLoggerTest { } @Test - public void testFinishLocalSetup() { + void finishLocalSetup() { final OutputStream infoStream = new ByteArrayOutputStream(); final DefaultLogger dl = new DefaultLogger(infoStream, OutputStreamOptions.CLOSE); dl.finishLocalSetup(); @@ -246,7 +246,7 @@ public class DefaultLoggerTest { /** Verifies that the language specified with the system property {@code user.language} exists. */ @Test - public void testLanguageIsValid() { + void languageIsValid() { final String language = DEFAULT_LOCALE.getLanguage(); assumeFalse(language.isEmpty(), "Locale not set"); assertWithMessage("Invalid language") @@ -256,7 +256,7 @@ public class DefaultLoggerTest { /** Verifies that the country specified with the system property {@code user.country} exists. */ @Test - public void testCountryIsValid() { + void countryIsValid() { final String country = DEFAULT_LOCALE.getCountry(); assumeFalse(country.isEmpty(), "Locale not set"); assertWithMessage("Invalid country") @@ -265,7 +265,7 @@ public class DefaultLoggerTest { } @Test - public void testNewCtor() throws Exception { + void newCtor() throws Exception { final ResourceBundle bundle = ResourceBundle.getBundle(Definitions.CHECKSTYLE_BUNDLE, Locale.ENGLISH); final String auditStartedMessage = bundle.getString(DefaultLogger.AUDIT_STARTED_MESSAGE); @@ -284,8 +284,8 @@ public class DefaultLoggerTest { dl.auditStarted(null); dl.addException(new AuditEvent(5000, "myfile"), new IllegalStateException("upsss")); dl.auditFinished(new AuditEvent(6000, "myfile")); - infoOutput = infoStream.toString(StandardCharsets.UTF_8); - errorOutput = errorStream.toString(StandardCharsets.UTF_8); + infoOutput = infoStream.toString(UTF_8); + errorOutput = errorStream.toString(UTF_8); assertWithMessage("Info stream should be closed") .that(infoStream.closedCount) @@ -310,7 +310,7 @@ public class DefaultLoggerTest { } @Test - public void testStreamsNotClosedByLogger() throws IOException { + void streamsNotClosedByLogger() throws IOException { try (MockByteArrayOutputStream infoStream = new MockByteArrayOutputStream(); MockByteArrayOutputStream errorStream = new MockByteArrayOutputStream()) { final DefaultLogger defaultLogger = --- a/src/test/java/com/puppycrawl/tools/checkstyle/DefinitionsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/DefinitionsTest.java @@ -24,10 +24,10 @@ import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsCla import org.junit.jupiter.api.Test; -public class DefinitionsTest { +final class DefinitionsTest { @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(Definitions.class)) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/DetailAstImplTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -28,7 +29,6 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import java.io.Writer; import java.lang.reflect.Method; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.text.MessageFormat; import java.util.ArrayList; @@ -43,7 +43,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; /** TestCase to check DetailAST. */ -public class DetailAstImplTest extends AbstractModuleTestSupport { +final class DetailAstImplTest extends AbstractModuleTestSupport { // Ignores file which are not meant to have root node intentionally. public static final Set NO_ROOT_FILES = @@ -74,7 +74,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testInitialize() { + void initialize() { final DetailAstImpl ast = new DetailAstImpl(); ast.setText("test"); ast.setType(1); @@ -94,7 +94,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testInitializeToken() { + void initializeToken() { final CommonToken token = new CommonToken(1); token.setText("test"); token.setLine(2); @@ -110,7 +110,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testGetChildCount() throws Exception { + void getChildCount() throws Exception { final DetailAstImpl root = new DetailAstImpl(); final DetailAstImpl firstLevelA = new DetailAstImpl(); final DetailAstImpl firstLevelB = new DetailAstImpl(); @@ -146,7 +146,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testHasChildren() { + void hasChildren() { final DetailAstImpl root = new DetailAstImpl(); final DetailAstImpl child = new DetailAstImpl(); root.setFirstChild(child); @@ -156,7 +156,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testGetChildCountType() throws Exception { + void getChildCountType() throws Exception { final DetailAstImpl root = new DetailAstImpl(); final DetailAstImpl firstLevelA = new DetailAstImpl(); final DetailAstImpl firstLevelB = new DetailAstImpl(); @@ -185,7 +185,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testSetSiblingNull() throws Exception { + void setSiblingNull() throws Exception { final DetailAstImpl root = new DetailAstImpl(); final DetailAstImpl firstLevelA = new DetailAstImpl(); @@ -201,7 +201,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testAddPreviousSibling() { + void addPreviousSibling() { final DetailAST previousSibling = new DetailAstImpl(); final DetailAstImpl instance = new DetailAstImpl(); final DetailAstImpl parent = new DetailAstImpl(); @@ -250,7 +250,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testAddPreviousSiblingNullParent() { + void addPreviousSiblingNullParent() { final DetailAstImpl child = new DetailAstImpl(); final DetailAST newSibling = new DetailAstImpl(); @@ -261,7 +261,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testInsertSiblingBetween() throws Exception { + void insertSiblingBetween() throws Exception { final DetailAstImpl root = new DetailAstImpl(); final DetailAstImpl firstLevelA = new DetailAstImpl(); final DetailAST firstLevelB = new DetailAstImpl(); @@ -291,7 +291,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testBranchContains() { + void branchContains() { final DetailAstImpl root = createToken(null, TokenTypes.CLASS_DEF); final DetailAstImpl modifiers = createToken(root, TokenTypes.MODIFIERS); createToken(modifiers, TokenTypes.LITERAL_PUBLIC); @@ -312,7 +312,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testClearBranchTokenTypes() throws Exception { + void clearBranchTokenTypes() throws Exception { final DetailAstImpl parent = new DetailAstImpl(); final DetailAstImpl child = new DetailAstImpl(); parent.setFirstChild(child); @@ -348,7 +348,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testCacheBranchTokenTypes() { + void cacheBranchTokenTypes() { final DetailAST root = new DetailAstImpl(); final BitSet bitSet = new BitSet(); bitSet.set(999); @@ -358,7 +358,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testClearChildCountCache() { + void clearChildCountCache() { final DetailAstImpl parent = new DetailAstImpl(); final DetailAstImpl child = new DetailAstImpl(); parent.setFirstChild(child); @@ -384,7 +384,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testCacheGetChildCount() { + void cacheGetChildCount() { final DetailAST root = new DetailAstImpl(); TestUtil.setInternalState(root, "childCount", 999); @@ -392,7 +392,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testAddNextSibling() { + void addNextSibling() { final DetailAstImpl parent = new DetailAstImpl(); final DetailAstImpl child = new DetailAstImpl(); final DetailAstImpl sibling = new DetailAstImpl(); @@ -425,7 +425,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testAddNextSibling2() { + void addNextSibling2() { final DetailAstImpl parent = new DetailAstImpl(); final DetailAstImpl child = new DetailAstImpl(); parent.setFirstChild(child); @@ -443,7 +443,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testAddNextSibling3() { + void addNextSibling3() { final DetailAstImpl parent = new DetailAstImpl(); final DetailAstImpl child = new DetailAstImpl(); final DetailAstImpl sibling = new DetailAstImpl(); @@ -456,7 +456,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testAddNextSibling4() { + void addNextSibling4() { final DetailAstImpl parent = new DetailAstImpl(); parent.setText("Parent"); final DetailAstImpl child = new DetailAstImpl(); @@ -470,7 +470,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testAddNextSiblingNullParent() { + void addNextSiblingNullParent() { final DetailAstImpl child = new DetailAstImpl(); final DetailAstImpl newSibling = new DetailAstImpl(); final DetailAstImpl oldParent = new DetailAstImpl(); @@ -483,7 +483,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testGetLineNo() { + void getLineNo() { final DetailAstImpl root1 = new DetailAstImpl(); root1.setLineNo(1); assertWithMessage("Invalid line number").that(root1.getLineNo()).isEqualTo(1); @@ -509,7 +509,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testGetColumnNo() { + void getColumnNo() { final DetailAstImpl root1 = new DetailAstImpl(); root1.setColumnNo(1); assertWithMessage("Invalid column number").that(root1.getColumnNo()).isEqualTo(1); @@ -537,7 +537,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testFindFirstToken() { + void findFirstToken() { final DetailAstImpl root = new DetailAstImpl(); final DetailAstImpl firstChild = new DetailAstImpl(); firstChild.setType(TokenTypes.IDENT); @@ -559,10 +559,10 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testManyComments() throws Exception { + void manyComments() throws Exception { final File file = new File(temporaryFolder, "InputDetailASTManyComments.java"); - try (Writer bw = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) { + try (Writer bw = Files.newBufferedWriter(file.toPath(), UTF_8)) { bw.write("/*\ncom.puppycrawl.tools.checkstyle.checks.TodoCommentCheck\n\n\n\n*/\n"); bw.write("class C {\n"); for (int i = 0; i <= 30000; i++) { @@ -576,7 +576,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testTreeStructure() throws Exception { + void treeStructure() throws Exception { final List files = getAllFiles(new File("src/test/resources/com/puppycrawl/tools/checkstyle")); @@ -592,7 +592,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testToString() { + void testToString() { final DetailAstImpl ast = new DetailAstImpl(); ast.setText("text"); ast.setColumnNo(1); @@ -601,7 +601,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testRemoveChildren() { + void removeChildren() { final DetailAstImpl parent = new DetailAstImpl(); final DetailAstImpl child1 = new DetailAstImpl(); parent.setFirstChild(child1); @@ -614,7 +614,7 @@ public class DetailAstImplTest extends AbstractModuleTestSupport { } @Test - public void testAddChild() { + void addChild() { final DetailAstImpl grandParent = new DetailAstImpl(); grandParent.setText("grandparent"); final DetailAstImpl parent = new DetailAstImpl(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/DetailNodeTreeStringPrinterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/DetailNodeTreeStringPrinterTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import java.io.File; import org.junit.jupiter.api.Test; -public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { +final class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -38,21 +38,21 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(DetailNodeTreeStringPrinter.class)) .isTrue(); } @Test - public void testParseFile() throws Exception { + void parseFile() throws Exception { verifyJavadocTree( getPath("ExpectedDetailNodeTreeStringPrinterJavadocComment.txt"), getPath("InputDetailNodeTreeStringPrinterJavadocComment.javadoc")); } @Test - public void testParseFileWithError() throws Exception { + void parseFileWithError() throws Exception { final File file = new File(getPath("InputDetailNodeTreeStringPrinterJavadocWithError.javadoc")); try { DetailNodeTreeStringPrinter.printFileAst(file); @@ -70,14 +70,14 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testNoUnnecessaryTextInJavadocAst() throws Exception { + void noUnnecessaryTextInJavadocAst() throws Exception { verifyJavadocTree( getPath("ExpectedDetailNodeTreeStringPrinterNoUnnecessaryTextInJavadocAst.txt"), getPath("InputDetailNodeTreeStringPrinterNoUnnecessaryTextInJavadocAst.javadoc")); } @Test - public void testMissedHtmlTagParseErrorMessage() throws Exception { + void missedHtmlTagParseErrorMessage() throws Exception { final String actual = TestUtil.invokeStaticMethod( DetailNodeTreeStringPrinter.class, @@ -98,7 +98,7 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testParseErrorMessage() throws Exception { + void parseErrorMessage() throws Exception { final String actual = TestUtil.invokeStaticMethod( DetailNodeTreeStringPrinter.class, @@ -124,7 +124,7 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testWrongSingletonParseErrorMessage() throws Exception { + void wrongSingletonParseErrorMessage() throws Exception { final String actual = TestUtil.invokeStaticMethod( DetailNodeTreeStringPrinter.class, @@ -146,7 +146,7 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testUnescapedJavaCodeWithGenericsInJavadoc() throws Exception { + void unescapedJavaCodeWithGenericsInJavadoc() throws Exception { final File file = new File( getPath( @@ -168,7 +168,7 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testNoViableAltException() throws Exception { + void noViableAltException() throws Exception { final File file = new File(getPath("InputDetailNodeTreeStringPrinterNoViableAltException.javadoc")); try { @@ -192,7 +192,7 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testHtmlTagCloseBeforeTagOpen() throws Exception { + void htmlTagCloseBeforeTagOpen() throws Exception { final File file = new File(getPath("InputDetailNodeTreeStringPrinterHtmlTagCloseBeforeTagOpen.javadoc")); try { @@ -216,7 +216,7 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testWrongHtmlTagOrder() throws Exception { + void wrongHtmlTagOrder() throws Exception { final File file = new File(getPath("InputDetailNodeTreeStringPrinterWrongHtmlTagOrder.javadoc")); try { @@ -235,7 +235,7 @@ public class DetailNodeTreeStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testOmittedStartTagForHtmlElement() throws Exception { + void omittedStartTagForHtmlElement() throws Exception { final File file = new File(getPath("InputDetailNodeTreeStringPrinterOmittedStartTagForHtmlElement.javadoc")); try { --- a/src/test/java/com/puppycrawl/tools/checkstyle/JavaAstVisitorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/JavaAstVisitorTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.stream.Collectors.toUnmodifiableSet; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.FileContents; @@ -37,13 +38,12 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; import org.junit.jupiter.api.Test; -public class JavaAstVisitorTest extends AbstractModuleTestSupport { +final class JavaAstVisitorTest extends AbstractModuleTestSupport { /** * If a visit method is not overridden, we should explain why we do not 'visit' the parse tree at @@ -97,7 +97,7 @@ public class JavaAstVisitorTest extends AbstractModuleTestSupport { } @Test - public void testAllVisitMethodsAreOverridden() { + void allVisitMethodsAreOverridden() { final Method[] baseVisitMethods = JavaLanguageParserBaseVisitor.class.getDeclaredMethods(); final Method[] visitMethods = JavaAstVisitor.class.getDeclaredMethods(); @@ -107,7 +107,7 @@ public class JavaAstVisitorTest extends AbstractModuleTestSupport { .filter(method -> method.getName().contains("visit")) .filter(method -> method.getModifiers() == Modifier.PUBLIC) .map(Method::getName) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); final Set filteredVisitMethodNames = Arrays.stream(visitMethods) @@ -117,7 +117,7 @@ public class JavaAstVisitorTest extends AbstractModuleTestSupport { .filter(method -> !"visit".equals(method.getName())) .filter(method -> method.getModifiers() == Modifier.PUBLIC) .map(Method::getName) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); final String message = "Visit methods in 'JavaLanguageParserBaseVisitor' generated from " @@ -131,7 +131,7 @@ public class JavaAstVisitorTest extends AbstractModuleTestSupport { } @Test - public void testOrderOfVisitMethodsAndProductionRules() throws Exception { + void orderOfVisitMethodsAndProductionRules() throws Exception { // Order of BaseVisitor's generated 'visit' methods match the order of // production rules in 'JavaLanguageParser.g4'. final String baseVisitorFilename = @@ -200,7 +200,7 @@ public class JavaAstVisitorTest extends AbstractModuleTestSupport { } @Test - public void testNullSelfInAddLastSibling() throws Exception { + void nullSelfInAddLastSibling() throws Exception { final Method addLastSibling = JavaAstVisitor.class.getDeclaredMethod( "addLastSibling", DetailAstImpl.class, DetailAstImpl.class); @@ -227,7 +227,7 @@ public class JavaAstVisitorTest extends AbstractModuleTestSupport { * @throws Exception if input file does not exist */ @Test - public void testNoStackOverflowOnDeepStringConcat() throws Exception { + void noStackOverflowOnDeepStringConcat() throws Exception { final File file = new File(getPath("InputJavaAstVisitorNoStackOverflowOnDeepStringConcat.java")); final FileText fileText = new FileText(file, StandardCharsets.UTF_8.name()); --- a/src/test/java/com/puppycrawl/tools/checkstyle/JavaParserTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/JavaParserTest.java @@ -34,7 +34,7 @@ import java.util.List; import java.util.Optional; import org.junit.jupiter.api.Test; -public class JavaParserTest extends AbstractModuleTestSupport { +final class JavaParserTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,21 +42,21 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(TestUtil.isUtilsClassHasPrivateConstructor(JavaParser.class)) .isTrue(); } @Test - public void testNullRootWithComments() { + void nullRootWithComments() { assertWithMessage("Invalid return root") .that(JavaParser.appendHiddenCommentNodes(null)) .isNull(); } @Test - public void testAppendHiddenBlockCommentNodes() throws Exception { + void appendHiddenBlockCommentNodes() throws Exception { final DetailAST root = JavaParser.parseFile( new File(getPath("InputJavaParserHiddenComments.java")), @@ -68,7 +68,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { assertWithMessage("Block comment should be present").that(blockComment.isPresent()).isTrue(); - final DetailAST comment = blockComment.get(); + final DetailAST comment = blockComment.orElseThrow(); assertWithMessage("Unexpected line number").that(comment.getLineNo()).isEqualTo(3); assertWithMessage("Unexpected column number").that(comment.getColumnNo()).isEqualTo(0); @@ -84,7 +84,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testAppendHiddenSingleLineCommentNodes() throws Exception { + void appendHiddenSingleLineCommentNodes() throws Exception { final DetailAST root = JavaParser.parseFile( new File(getPath("InputJavaParserHiddenComments.java")), @@ -97,7 +97,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { .that(singleLineComment.isPresent()) .isTrue(); - final DetailAST comment = singleLineComment.get(); + final DetailAST comment = singleLineComment.orElseThrow(); assertWithMessage("Unexpected line number").that(comment.getLineNo()).isEqualTo(13); assertWithMessage("Unexpected column number").that(comment.getColumnNo()).isEqualTo(0); @@ -116,7 +116,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testAppendHiddenSingleLineCommentNodes2() throws Exception { + void appendHiddenSingleLineCommentNodes2() throws Exception { final DetailAST root = JavaParser.parseFile( new File(getPath("InputJavaParserHiddenComments2.java")), @@ -129,7 +129,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { .that(singleLineComment.isPresent()) .isTrue(); - final DetailAST comment = singleLineComment.get(); + final DetailAST comment = singleLineComment.orElseThrow(); assertWithMessage("Unexpected line number").that(comment.getLineNo()).isEqualTo(1); assertWithMessage("Unexpected column number").that(comment.getColumnNo()).isEqualTo(4); @@ -148,7 +148,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testDontAppendCommentNodes() throws Exception { + void dontAppendCommentNodes() throws Exception { final DetailAST root = JavaParser.parseFile( new File(getPath("InputJavaParserHiddenComments.java")), @@ -163,7 +163,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testParseException() throws Exception { + void parseException() throws Exception { final File input = new File(getNonCompilablePath("InputJavaParser.java")); try { JavaParser.parseFile(input, JavaParser.Options.WITH_COMMENTS); @@ -188,7 +188,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testComments() throws Exception { + void comments() throws Exception { final DetailAST root = JavaParser.parseFile( new File(getPath("InputJavaParserHiddenComments3.java")), @@ -204,7 +204,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testJava14TextBlocks() throws Exception { + void java14TextBlocks() throws Exception { final DetailAST root = JavaParser.parseFile( new File(getNonCompilablePath("InputJavaParserTextBlocks.java")), @@ -218,7 +218,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { .that(textBlockContent.isPresent()) .isTrue(); - final DetailAST content = textBlockContent.get(); + final DetailAST content = textBlockContent.orElseThrow(); final String expectedContents = "\n string"; assertWithMessage("Unexpected line number").that(content.getLineNo()).isEqualTo(5); @@ -229,7 +229,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testNoFreezeOnDeeplyNestedLambdas() throws Exception { + void noFreezeOnDeeplyNestedLambdas() throws Exception { final File file = new File(getNonCompilablePath("InputJavaParserNoFreezeOnDeeplyNestedLambdas.java")); assertWithMessage("File parsing should complete successfully.") @@ -238,7 +238,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testFullJavaIdentifierSupport() throws Exception { + void fullJavaIdentifierSupport() throws Exception { final File file = new File(getNonCompilablePath("InputJavaParserFullJavaIdentifierSupport.java")); assertWithMessage("File parsing should complete successfully.") @@ -247,7 +247,7 @@ public class JavaParserTest extends AbstractModuleTestSupport { } @Test - public void testReturnValueOfAppendHiddenCommentNodes() throws Exception { + void returnValueOfAppendHiddenCommentNodes() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(JavadocContentLocationCheck.class, MSG_JAVADOC_CONTENT_SECOND_LINE), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/JavadocDetailNodeParserTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/JavadocDetailNodeParserTest.java @@ -24,10 +24,10 @@ import static com.google.common.truth.Truth.assertWithMessage; import com.puppycrawl.tools.checkstyle.api.DetailAST; import java.io.File; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import org.junit.jupiter.api.Test; -public class JavadocDetailNodeParserTest extends AbstractModuleTestSupport { +final class JavadocDetailNodeParserTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class JavadocDetailNodeParserTest extends AbstractModuleTestSupport { } @Test - public void testParseJavadocAsDetailNode() throws Exception { + void parseJavadocAsDetailNode() throws Exception { final DetailAST ast = JavaParser.parseFile( new File(getPath("InputJavadocDetailNodeParser.java")), @@ -49,7 +49,7 @@ public class JavadocDetailNodeParserTest extends AbstractModuleTestSupport { final String actual = toLfLineEnding(DetailNodeTreeStringPrinter.printTree(status.getTree(), "", "")); final String expected = - toLfLineEnding(Files.readString(Paths.get(getPath("ExpectedJavadocDetailNodeParser.txt")))); + toLfLineEnding(Files.readString(Path.of(getPath("ExpectedJavadocDetailNodeParser.txt")))); assertWithMessage("Invalid parse result").that(actual).isEqualTo(expected); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/JavadocPropertiesGeneratorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/JavadocPropertiesGeneratorTest.java @@ -20,13 +20,13 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.util.Locale; import org.apache.commons.io.FileUtils; import org.itsallcode.io.Capturable; @@ -39,7 +39,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @ExtendWith({SystemErrGuard.class, SystemOutGuard.class}) -public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { +final class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { private static final String EOL = System.lineSeparator(); private static final String USAGE = @@ -87,7 +87,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { * @param systemOut wrapper for {@code System.out} */ @BeforeEach - public void setUp(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void setUp(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { systemErr.captureMuted(); systemOut.captureMuted(); @@ -95,14 +95,14 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(TestUtil.isUtilsClassHasPrivateConstructor(JavadocPropertiesGenerator.class)) .isTrue(); } @Test - public void testNonExistentArgument(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void nonExistentArgument(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { JavadocPropertiesGenerator.main("--nonexistent-argument"); @@ -117,7 +117,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testNoDestfileSpecified(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void noDestfileSpecified(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { JavadocPropertiesGenerator.main(getPath("InputMain.java")); @@ -128,7 +128,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testNoInputSpecified(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void noInputSpecified(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { JavadocPropertiesGenerator.main("--destfile", DESTFILE_ABSOLUTE_PATH); @@ -139,8 +139,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testNotClass(@SysErr Capturable systemErr, @SysOut Capturable systemOut) - throws Exception { + void notClass(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { JavadocPropertiesGenerator.main( "--destfile", DESTFILE_ABSOLUTE_PATH, @@ -150,8 +149,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testNotExistentInputSpecified( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void notExistentInputSpecified(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { try { JavadocPropertiesGenerator.main("--destfile", DESTFILE_ABSOLUTE_PATH, "NotExistent.java"); assertWithMessage("Exception was expected").fail(); @@ -177,8 +175,8 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testInvalidDestinationSpecified( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { + void invalidDestinationSpecified(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + throws Exception { try { // Passing a folder name will cause the FileNotFoundException. JavadocPropertiesGenerator.main( @@ -202,8 +200,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testCorrect(@SysErr Capturable systemErr, @SysOut Capturable systemOut) - throws Exception { + void correct(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { final String expectedContent = "EOF1=The end of file token." + EOL @@ -224,13 +221,12 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { DESTFILE_ABSOLUTE_PATH); assertWithMessage("Unexpected error log").that(systemErr.getCapturedData()).isEqualTo(""); assertWithMessage("Unexpected output log").that(systemOut.getCapturedData()).isEqualTo(""); - final String fileContent = FileUtils.readFileToString(DESTFILE, StandardCharsets.UTF_8); + final String fileContent = FileUtils.readFileToString(DESTFILE, UTF_8); assertWithMessage("File content is not expected").that(fileContent).isEqualTo(expectedContent); } @Test - public void testEmptyJavadoc(@SysErr Capturable systemErr, @SysOut Capturable systemOut) - throws Exception { + void emptyJavadoc(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { JavadocPropertiesGenerator.main( getPath("InputJavadocPropertiesGeneratorEmptyJavadoc.java"), "--destfile", @@ -242,8 +238,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testNotConstants(@SysErr Capturable systemErr, @SysOut Capturable systemOut) - throws Exception { + void notConstants(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { JavadocPropertiesGenerator.main( getPath("InputJavadocPropertiesGeneratorNotConstants.java"), "--destfile", @@ -255,15 +250,14 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testHelp(@SysErr Capturable systemErr, @SysOut Capturable systemOut) - throws Exception { + void help(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { JavadocPropertiesGenerator.main("-h"); assertWithMessage("Unexpected error log").that(systemErr.getCapturedData()).isEqualTo(""); assertWithMessage("Unexpected output log").that(systemOut.getCapturedData()).isEqualTo(USAGE); } @Test - public void testJavadocParseError() throws Exception { + void javadocParseError() throws Exception { final String path = getPath("InputJavadocPropertiesGeneratorJavadocParseError.java"); try { JavadocPropertiesGenerator.main(path, "--destfile", DESTFILE_ABSOLUTE_PATH); @@ -278,7 +272,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testNotImplementedTag() throws Exception { + void notImplementedTag() throws Exception { final String path = getPath("InputJavadocPropertiesGeneratorNotImplementedTag.java"); try { JavadocPropertiesGenerator.main(path, "--destfile", DESTFILE_ABSOLUTE_PATH); @@ -293,7 +287,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testParseError() throws Exception { + void parseError() throws Exception { final String path = getNonCompilablePath("InputJavadocPropertiesGeneratorParseError.java"); try { JavadocPropertiesGenerator.main(path, "--destfile", DESTFILE_ABSOLUTE_PATH); @@ -315,8 +309,8 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { } @Test - public void testGetFirstJavadocSentence( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { + void getFirstJavadocSentence(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + throws Exception { final String expectedContent = "EOF1=First Javadoc Sentence."; JavadocPropertiesGenerator.main( @@ -325,7 +319,7 @@ public class JavadocPropertiesGeneratorTest extends AbstractPathTestSupport { DESTFILE_ABSOLUTE_PATH); assertWithMessage("Unexpected error log").that(systemErr.getCapturedData()).isEqualTo(""); assertWithMessage("Unexpected output log").that(systemOut.getCapturedData()).isEqualTo(""); - final String fileContent = FileUtils.readFileToString(DESTFILE, StandardCharsets.UTF_8); + final String fileContent = FileUtils.readFileToString(DESTFILE, UTF_8); assertWithMessage("File content is not expected") .that(fileContent.trim()) .isEqualTo(expectedContent.trim()); --- a/src/test/java/com/puppycrawl/tools/checkstyle/LocalizedMessageTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/LocalizedMessageTest.java @@ -44,13 +44,13 @@ import org.junitpioneer.jupiter.DefaultLocale; * @noinspectionreason ClassLoaderInstantiation - Custom class loader is needed to pass URLs for * testing */ -public class LocalizedMessageTest { +final class LocalizedMessageTest { private static final Locale DEFAULT_LOCALE = Locale.ENGLISH; @DefaultLocale("en") @Test - public void testNullArgs() { + void nullArgs() { final LocalizedMessage messageClass = new LocalizedMessage( Definitions.CHECKSTYLE_BUNDLE, @@ -71,7 +71,7 @@ public class LocalizedMessageTest { } @Test - public void testBundleReloadUrlNull() throws IOException { + void bundleReloadUrlNull() throws IOException { final Utf8Control control = new Utf8Control(); final ResourceBundle bundle = control.newBundle( @@ -93,7 +93,7 @@ public class LocalizedMessageTest { * @noinspectionreason IOResourceOpenedButNotSafelyClosed - no need to close resources in testing */ @Test - public void testBundleReloadUrlNotNull() throws IOException { + void bundleReloadUrlNotNull() throws IOException { final AtomicBoolean closed = new AtomicBoolean(); final InputStream inputStream = @@ -157,7 +157,7 @@ public class LocalizedMessageTest { * @noinspectionreason IOResourceOpenedButNotSafelyClosed - no need to close resources in testing */ @Test - public void testBundleReloadUrlNotNullFalseReload() throws IOException { + void bundleReloadUrlNotNullFalseReload() throws IOException { final AtomicBoolean closed = new AtomicBoolean(); final InputStream inputStream = @@ -214,7 +214,7 @@ public class LocalizedMessageTest { } @Test - public void testBundleReloadUrlNotNullStreamNull() throws IOException { + void bundleReloadUrlNotNullStreamNull() throws IOException { final URL url = new URL( "test", @@ -241,7 +241,7 @@ public class LocalizedMessageTest { /** Verifies that the language specified with the system property {@code user.language} exists. */ @Test - public void testLanguageIsValid() { + void languageIsValid() { final String language = DEFAULT_LOCALE.getLanguage(); assumeFalse(language.isEmpty(), "Locale not set"); assertWithMessage("Invalid language") @@ -252,14 +252,14 @@ public class LocalizedMessageTest { /** Verifies that the country specified with the system property {@code user.country} exists. */ @Test - public void testCountryIsValid() { + void countryIsValid() { final String country = DEFAULT_LOCALE.getCountry(); assumeFalse(country.isEmpty(), "Locale not set"); assertWithMessage("Invalid country").that(Locale.getISOCountries()).asList().contains(country); } @Test - public void testMessageInFrench() { + void messageInFrench() { final LocalizedMessage violation = createSampleViolation(); LocalizedMessage.setLocale(Locale.FRENCH); @@ -270,7 +270,7 @@ public class LocalizedMessageTest { @DefaultLocale("fr") @Test - public void testEnforceEnglishLanguageBySettingUnitedStatesLocale() { + void enforceEnglishLanguageBySettingUnitedStatesLocale() { LocalizedMessage.setLocale(Locale.US); final LocalizedMessage violation = createSampleViolation(); @@ -281,7 +281,7 @@ public class LocalizedMessageTest { @DefaultLocale("fr") @Test - public void testEnforceEnglishLanguageBySettingRootLocale() { + void enforceEnglishLanguageBySettingRootLocale() { LocalizedMessage.setLocale(Locale.ROOT); final LocalizedMessage violation = createSampleViolation(); @@ -298,7 +298,7 @@ public class LocalizedMessageTest { } @AfterEach - public void tearDown() { + void tearDown() { LocalizedMessage.setLocale(DEFAULT_LOCALE); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/MainTest.java @@ -22,6 +22,8 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.AbstractPathTestSupport.addEndOfLine; import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.stream.Collectors.joining; import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mockStatic; @@ -40,10 +42,8 @@ import java.io.File; import java.io.IOException; import java.io.PrintStream; import java.lang.reflect.Method; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -51,7 +51,6 @@ import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.itsallcode.io.Capturable; import org.itsallcode.junit.sysextensions.SystemErrGuard; import org.itsallcode.junit.sysextensions.SystemErrGuard.SysErr; @@ -65,7 +64,7 @@ import org.mockito.MockedStatic; import org.mockito.Mockito; @ExtendWith({SystemErrGuard.class, SystemOutGuard.class}) -public class MainTest { +final class MainTest { private static final String SHORT_USAGE = String.format( @@ -222,7 +221,7 @@ public class MainTest { * @param systemOut wrapper for {@code System.out} */ @BeforeEach - public void setUp(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void setUp(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { systemErr.captureMuted(); systemOut.captureMuted(); @@ -247,14 +246,14 @@ public class MainTest { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(Main.class)) .isTrue(); } @Test - public void testVersionPrint(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void versionPrint(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(0, "-V"); assertWithMessage("Unexpected output log") .that(systemOut.getCapturedData()) @@ -265,7 +264,7 @@ public class MainTest { } @Test - public void testUsageHelpPrint(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void usageHelpPrint(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(0, "-h"); assertWithMessage("Unexpected output log").that(systemOut.getCapturedData()).isEqualTo(USAGE); assertWithMessage("Unexpected system error log") @@ -274,7 +273,7 @@ public class MainTest { } @Test - public void testWrongArgument(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void wrongArgument(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { // need to specify a file: // is defined as a required positional param; // picocli verifies required parameters before checking unknown options @@ -287,8 +286,7 @@ public class MainTest { } @Test - public void testWrongArgumentMissingFiles( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void wrongArgumentMissingFiles(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-q"); // files is defined as a required positional param; // picocli verifies required parameters before checking unknown options @@ -300,7 +298,7 @@ public class MainTest { } @Test - public void testNoConfigSpecified(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void noConfigSpecified(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, getPath("InputMain.java")); assertWithMessage("Unexpected output log") .that(systemOut.getCapturedData()) @@ -311,8 +309,7 @@ public class MainTest { } @Test - public void testNonExistentTargetFile( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void nonExistentTargetFile(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-c", "/google_checks.xml", "NonExistentFile.java"); assertWithMessage("Unexpected output log") .that(systemOut.getCapturedData()) @@ -323,10 +320,12 @@ public class MainTest { } @Test - public void testExistingTargetFileButWithoutReadAccess( + void existingTargetFileButWithoutReadAccess( @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final File file = - File.createTempFile("testExistingTargetFileButWithoutReadAccess", null, temporaryFolder); + Files.createTempFile( + temporaryFolder.toPath(), "testExistingTargetFileButWithoutReadAccess", null) + .toFile(); // skip execution if file is still readable, it is possible on some Windows machines // see https://github.com/checkstyle/checkstyle/issues/7032 for details assumeTrue(file.setReadable(false), "file is still readable"); @@ -342,8 +341,7 @@ public class MainTest { } @Test - public void testNonExistentConfigFile( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void nonExistentConfigFile(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( -1, "-c", "src/main/resources/non_existent_config.xml", getPath("InputMain.java")); assertWithMessage("Unexpected output log") @@ -358,8 +356,7 @@ public class MainTest { } @Test - public void testNonExistentOutputFormat( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void nonExistentOutputFormat(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-c", "/google_checks.xml", "-f", "xmlp", getPath("InputMain.java")); assertWithMessage("Unexpected output log").that(systemOut.getCapturedData()).isEqualTo(""); assertWithMessage("Unexpected system error log") @@ -372,7 +369,7 @@ public class MainTest { } @Test - public void testNonExistentClass(@SysErr Capturable systemErr) { + void nonExistentClass(@SysErr Capturable systemErr) { assertMainReturnCode( -2, "-c", getPath("InputMainConfig-non-existent-classname.xml"), getPath("InputMain.java")); final String cause = @@ -384,7 +381,7 @@ public class MainTest { } @Test - public void testExistingTargetFile(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void existingTargetFile(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( 0, "-c", getPath("InputMainConfig-classname.xml"), getPath("InputMain.java")); assertWithMessage("Unexpected output log") @@ -396,8 +393,8 @@ public class MainTest { } @Test - public void testExistingTargetFileXmlOutput( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { + void existingTargetFileXmlOutput(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + throws IOException { assertMainReturnCode( 0, "-c", getPath("InputMainConfig-classname.xml"), "-f", "xml", getPath("InputMain.java")); final String expectedPath = getFilePath("InputMain.java"); @@ -425,8 +422,7 @@ public class MainTest { * @param systemOut the system output stream */ @Test - public void testNonClosedSystemStreams( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void nonClosedSystemStreams(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { try (ShouldNotBeClosedStream stream = new ShouldNotBeClosedStream()) { System.setOut(stream); System.setErr(stream); @@ -456,7 +452,7 @@ public class MainTest { * @throws Exception if there is an error. */ @Test - public void testGetOutputStreamOptionsMethod() throws Exception { + void getOutputStreamOptionsMethod() throws Exception { final Path path = new File(getPath("InputMain.java")).toPath(); final OutputStreamOptions option = TestUtil.invokeStaticMethod(Main.class, "getOutputStreamOptions", path); @@ -466,8 +462,7 @@ public class MainTest { } @Test - public void testExistingTargetFilePlainOutput( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void existingTargetFilePlainOutput(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( 0, "-c", @@ -484,8 +479,8 @@ public class MainTest { } @Test - public void testExistingTargetFileWithViolations( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { + void existingTargetFileWithViolations(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + throws IOException { assertMainReturnCode( 0, "-c", getPath("InputMainConfig-classname2.xml"), getPath("InputMain.java")); final Violation invalidPatternMessageMain = @@ -529,7 +524,7 @@ public class MainTest { } @Test - public void testViolationsByGoogleAndXpathSuppressions( + void violationsByGoogleAndXpathSuppressions( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { System.setProperty( "org.checkstyle.google.suppressionxpathfilter.config", @@ -545,7 +540,7 @@ public class MainTest { } @Test - public void testViolationsByGoogleAndSuppressions( + void violationsByGoogleAndSuppressions( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { System.setProperty( "org.checkstyle.google.suppressionfilter.config", @@ -561,8 +556,8 @@ public class MainTest { } @Test - public void testExistingTargetFileWithError( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { + void existingTargetFileWithError(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + throws Exception { assertMainReturnCode( 2, "-c", getPath("InputMainConfig-classname2-error.xml"), getPath("InputMain.java")); final Violation errorCounterTwoMessage = @@ -622,8 +617,8 @@ public class MainTest { * @throws Exception should not throw anything */ @Test - public void testExistingTargetFileWithOneError( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { + void existingTargetFileWithOneError(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + throws Exception { assertMainReturnCode( 1, "-c", getPath("InputMainConfig-classname2-error.xml"), getPath("InputMain1.java")); final Violation errorCounterTwoMessage = @@ -662,7 +657,7 @@ public class MainTest { } @Test - public void testExistingTargetFileWithOneErrorAgainstSunCheck( + void existingTargetFileWithOneErrorAgainstSunCheck( @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { assertMainReturnCode(1, "-c", "/sun_checks.xml", getPath("InputMain1.java")); final Violation errorCounterTwoMessage = @@ -697,7 +692,7 @@ public class MainTest { } @Test - public void testExistentTargetFilePlainOutputToNonExistentFile( + void existentTargetFilePlainOutputToNonExistentFile( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( 0, @@ -715,10 +710,12 @@ public class MainTest { } @Test - public void testExistingTargetFilePlainOutputToFile( + void existingTargetFilePlainOutputToFile( @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws Exception { final String outputFile = - File.createTempFile("file", ".output", temporaryFolder).getCanonicalPath(); + Files.createTempFile(temporaryFolder.toPath(), "file", ".output") + .toFile() + .getCanonicalPath(); assertWithMessage("File must exist").that(new File(outputFile).exists()).isTrue(); assertMainReturnCode( 0, @@ -736,7 +733,7 @@ public class MainTest { } @Test - public void testCreateNonExistentOutputFile() throws IOException { + void createNonExistentOutputFile() throws IOException { final String outputFile = new File(temporaryFolder, "nonexistent.out").getCanonicalPath(); assertWithMessage("File must not exist").that(new File(outputFile).exists()).isFalse(); assertMainReturnCode( @@ -752,7 +749,7 @@ public class MainTest { } @Test - public void testExistingTargetFilePlainOutputProperties( + void existingTargetFilePlainOutputProperties( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( 0, @@ -770,7 +767,7 @@ public class MainTest { } @Test - public void testPropertyFileWithPropertyChaining( + void propertyFileWithPropertyChaining( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( 0, @@ -789,7 +786,7 @@ public class MainTest { } @Test - public void testPropertyFileWithPropertyChainingUndefinedProperty( + void propertyFileWithPropertyChainingUndefinedProperty( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( -2, @@ -806,7 +803,7 @@ public class MainTest { } @Test - public void testExistingTargetFilePlainOutputNonexistentProperties( + void existingTargetFilePlainOutputNonexistentProperties( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( -1, @@ -824,7 +821,7 @@ public class MainTest { } @Test - public void testExistingIncorrectConfigFile(@SysErr Capturable systemErr) { + void existingIncorrectConfigFile(@SysErr Capturable systemErr) { assertMainReturnCode( -2, "-c", getPath("InputMainConfig-Incorrect.xml"), getPath("InputMain.java")); final String errorOutput = @@ -836,7 +833,7 @@ public class MainTest { } @Test - public void testExistingIncorrectChildrenInConfigFile(@SysErr Capturable systemErr) { + void existingIncorrectChildrenInConfigFile(@SysErr Capturable systemErr) { assertMainReturnCode( -2, "-c", getPath("InputMainConfig-incorrectChildren.xml"), getPath("InputMain.java")); final String errorOutput = @@ -849,7 +846,7 @@ public class MainTest { } @Test - public void testExistingIncorrectChildrenInConfigFile2(@SysErr Capturable systemErr) { + void existingIncorrectChildrenInConfigFile2(@SysErr Capturable systemErr) { assertMainReturnCode( -2, "-c", getPath("InputMainConfig-incorrectChildren2.xml"), getPath("InputMain.java")); final String errorOutput = @@ -863,7 +860,7 @@ public class MainTest { } @Test - public void testLoadPropertiesIoException() throws Exception { + void loadPropertiesIoException() throws Exception { final Class[] param = new Class[1]; param[0] = File.class; final Class cliOptionsClass = Class.forName(Main.class.getName()); @@ -905,8 +902,8 @@ public class MainTest { } @Test - public void testExistingDirectoryWithViolations( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { + void existingDirectoryWithViolations(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + throws IOException { // we just reference there all violations final String[][] outputValues = { {"InputMainComplexityOverflow", "1", "172"}, @@ -953,7 +950,7 @@ public class MainTest { * does not require serialization */ @Test - public void testListFilesNotFile() throws Exception { + void listFilesNotFile() throws Exception { final File fileMock = new File("") { private static final long serialVersionUID = 1L; @@ -987,7 +984,7 @@ public class MainTest { * does not require serialization */ @Test - public void testListFilesDirectoryWithNull() throws Exception { + void listFilesDirectoryWithNull() throws Exception { final File[] nullResult = null; final File fileMock = new File("") { @@ -1015,7 +1012,7 @@ public class MainTest { } @Test - public void testFileReferenceDuringException(@SysErr Capturable systemErr) { + void fileReferenceDuringException(@SysErr Capturable systemErr) { // We put xml as source to cause parse exception assertMainReturnCode( -2, @@ -1033,7 +1030,7 @@ public class MainTest { } @Test - public void testRemoveLexerDefaultErrorListener(@SysErr Capturable systemErr) { + void removeLexerDefaultErrorListener(@SysErr Capturable systemErr) { assertMainReturnCode(-2, "-t", getNonCompilablePath("InputMainIncorrectClass.java")); assertWithMessage("First line of exception message should not contain lexer error.") @@ -1042,7 +1039,7 @@ public class MainTest { } @Test - public void testRemoveParserDefaultErrorListener(@SysErr Capturable systemErr) { + void removeParserDefaultErrorListener(@SysErr Capturable systemErr) { assertMainReturnCode(-2, "-t", getNonCompilablePath("InputMainIncorrectClass.java")); final String capturedData = systemErr.getCapturedData(); @@ -1057,8 +1054,7 @@ public class MainTest { } @Test - public void testPrintTreeOnMoreThanOneFile( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printTreeOnMoreThanOneFile(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-t", getPath("")); assertWithMessage("Unexpected output log") .that(systemOut.getCapturedData()) @@ -1069,7 +1065,7 @@ public class MainTest { } @Test - public void testPrintTreeOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printTreeOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -1111,7 +1107,7 @@ public class MainTest { } @Test - public void testPrintXpathOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printXpathOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -1136,8 +1132,7 @@ public class MainTest { } @Test - public void testPrintXpathCommentNode( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printXpathCommentNode(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -1159,8 +1154,7 @@ public class MainTest { } @Test - public void testPrintXpathNodeParentNull( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printXpathNodeParentNull(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine("COMPILATION_UNIT -> COMPILATION_UNIT [1:0]"); assertMainReturnCode(0, "-b", "/COMPILATION_UNIT", getPath("InputMainXPath.java")); assertWithMessage("Unexpected output log") @@ -1172,7 +1166,7 @@ public class MainTest { } @Test - public void testPrintXpathFullOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printXpathFullOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -1194,7 +1188,7 @@ public class MainTest { } @Test - public void testPrintXpathTwoResults(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printXpathTwoResults(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -1220,7 +1214,7 @@ public class MainTest { } @Test - public void testPrintXpathInvalidXpath(@SysErr Capturable systemErr) throws Exception { + void printXpathInvalidXpath(@SysErr Capturable systemErr) throws Exception { final String invalidXpath = "\\/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='Two']]" + "//METHOD_DEF"; final String filePath = getFilePath("InputMainXPath.java"); @@ -1238,8 +1232,7 @@ public class MainTest { } @Test - public void testPrintTreeCommentsOption( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printTreeCommentsOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -1293,10 +1286,10 @@ public class MainTest { * @noinspectionreason RedundantThrows - false positive */ @Test - public void testPrintTreeJavadocOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void printTreeJavadocOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final String expected = - Files.readString(Paths.get(getPath("InputMainExpectedInputJavadocComment.txt"))) + Files.readString(Path.of(getPath("InputMainExpectedInputJavadocComment.txt"))) .replaceAll("\\\\r\\\\n", "\\\\n") .replaceAll("\r\n", "\n"); @@ -1311,8 +1304,7 @@ public class MainTest { } @Test - public void testPrintSuppressionOption( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void printSuppressionOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputMainSuppressionsStringPrinter']]", @@ -1331,7 +1323,7 @@ public class MainTest { } @Test - public void testPrintSuppressionAndTabWidthOption( + void printSuppressionAndTabWidthOption( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( @@ -1363,7 +1355,7 @@ public class MainTest { } @Test - public void testPrintSuppressionConflictingOptionsTvsC( + void printSuppressionConflictingOptionsTvsC( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-c", "/google_checks.xml", getPath(""), "-s", "2:4"); assertWithMessage("Unexpected output log") @@ -1375,7 +1367,7 @@ public class MainTest { } @Test - public void testPrintSuppressionConflictingOptionsTvsP( + void printSuppressionConflictingOptionsTvsP( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode( -1, "-p", getPath("InputMainMycheckstyle.properties"), "-s", "2:4", getPath("")); @@ -1388,7 +1380,7 @@ public class MainTest { } @Test - public void testPrintSuppressionConflictingOptionsTvsF( + void printSuppressionConflictingOptionsTvsF( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-f", "plain", "-s", "2:4", getPath("")); assertWithMessage("Unexpected output log") @@ -1400,7 +1392,7 @@ public class MainTest { } @Test - public void testPrintSuppressionConflictingOptionsTvsO( + void printSuppressionConflictingOptionsTvsO( @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final String outputPath = new File(temporaryFolder, "file.output").getCanonicalPath(); @@ -1414,7 +1406,7 @@ public class MainTest { } @Test - public void testPrintSuppressionOnMoreThanOneFile( + void printSuppressionOnMoreThanOneFile( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-s", "2:4", getPath(""), getPath("")); assertWithMessage("Unexpected output log") @@ -1427,7 +1419,7 @@ public class MainTest { } @Test - public void testGenerateXpathSuppressionOptionOne( + void generateXpathSuppressionOptionOne( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( @@ -1546,7 +1538,7 @@ public class MainTest { } @Test - public void testGenerateXpathSuppressionOptionTwo( + void generateXpathSuppressionOptionTwo( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( @@ -1593,7 +1585,7 @@ public class MainTest { } @Test - public void testGenerateXpathSuppressionOptionEmptyConfig( + void generateXpathSuppressionOptionEmptyConfig( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = ""; @@ -1612,8 +1604,7 @@ public class MainTest { } @Test - public void testGenerateXpathSuppressionOptionCustomOutput(@SysErr Capturable systemErr) - throws IOException { + void generateXpathSuppressionOptionCustomOutput(@SysErr Capturable systemErr) throws IOException { final String expected = addEndOfLine( "", @@ -1639,7 +1630,7 @@ public class MainTest { "--generate-xpath-suppression", getPath("InputMainGenerateXpathSuppressionsTabWidth.java")); try (BufferedReader br = Files.newBufferedReader(file.toPath())) { - final String fileContent = br.lines().collect(Collectors.joining(EOL, "", EOL)); + final String fileContent = br.lines().collect(joining(EOL, "", EOL)); assertWithMessage("Unexpected output log").that(fileContent).isEqualTo(expected); assertWithMessage("Unexpected system error log") .that(systemErr.getCapturedData()) @@ -1648,7 +1639,7 @@ public class MainTest { } @Test - public void testGenerateXpathSuppressionOptionDefaultTabWidth( + void generateXpathSuppressionOptionDefaultTabWidth( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = addEndOfLine( @@ -1681,7 +1672,7 @@ public class MainTest { } @Test - public void testGenerateXpathSuppressionOptionCustomTabWidth( + void generateXpathSuppressionOptionCustomTabWidth( @SysErr Capturable systemErr, @SysOut Capturable systemOut) { final String expected = ""; @@ -1711,11 +1702,10 @@ public class MainTest { * @noinspectionreason RedundantThrows - false positive */ @Test - public void testPrintFullTreeOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void printFullTreeOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final String expected = - Files.readString( - Paths.get(getPath("InputMainExpectedInputAstTreeStringPrinterJavadoc.txt"))) + Files.readString(Path.of(getPath("InputMainExpectedInputAstTreeStringPrinterJavadoc.txt"))) .replaceAll("\\\\r\\\\n", "\\\\n") .replaceAll("\r\n", "\n"); @@ -1730,8 +1720,7 @@ public class MainTest { } @Test - public void testConflictingOptionsTvsC( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void conflictingOptionsTvsC(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-c", "/google_checks.xml", "-t", getPath("")); assertWithMessage("Unexpected output log") .that(systemOut.getCapturedData()) @@ -1742,8 +1731,7 @@ public class MainTest { } @Test - public void testConflictingOptionsTvsP( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void conflictingOptionsTvsP(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-p", getPath("InputMainMycheckstyle.properties"), "-t", getPath("")); assertWithMessage("Unexpected output log") .that(systemOut.getCapturedData()) @@ -1754,8 +1742,7 @@ public class MainTest { } @Test - public void testConflictingOptionsTvsF( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void conflictingOptionsTvsF(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1, "-f", "plain", "-t", getPath("")); assertWithMessage("Unexpected output log") .that(systemOut.getCapturedData()) @@ -1766,7 +1753,7 @@ public class MainTest { } @Test - public void testConflictingOptionsTvsS(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void conflictingOptionsTvsS(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final String outputPath = new File(temporaryFolder, "file.output").getCanonicalPath(); @@ -1780,7 +1767,7 @@ public class MainTest { } @Test - public void testConflictingOptionsTvsO(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void conflictingOptionsTvsO(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final String outputPath = new File(temporaryFolder, "file.output").getCanonicalPath(); @@ -1794,7 +1781,7 @@ public class MainTest { } @Test - public void testDebugOption(@SysErr Capturable systemErr) { + void debugOption(@SysErr Capturable systemErr) { assertMainReturnCode(0, "-c", "/google_checks.xml", getPath("InputMain.java"), "-d"); assertWithMessage("Unexpected system error log") .that(systemErr.getCapturedData()) @@ -1802,7 +1789,7 @@ public class MainTest { } @Test - public void testExcludeOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void excludeOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final String filePath = getFilePath(""); assertMainReturnCode(-1, "-c", "/google_checks.xml", filePath, "-e", filePath); @@ -1815,7 +1802,7 @@ public class MainTest { } @Test - public void testExcludeOptionFile(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void excludeOptionFile(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final String filePath = getFilePath("InputMain.java"); assertMainReturnCode(-1, "-c", "/google_checks.xml", filePath, "-e", filePath); @@ -1828,7 +1815,7 @@ public class MainTest { } @Test - public void testExcludeRegexpOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + void excludeRegexpOption(@SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { final String filePath = getFilePath(""); assertMainReturnCode(-1, "-c", "/google_checks.xml", filePath, "-x", "."); @@ -1839,8 +1826,8 @@ public class MainTest { } @Test - public void testExcludeRegexpOptionFile( - @SysErr Capturable systemErr, @SysOut Capturable systemOut) throws IOException { + void excludeRegexpOptionFile(@SysErr Capturable systemErr, @SysOut Capturable systemOut) + throws IOException { final String filePath = getFilePath("InputMain.java"); assertMainReturnCode(-1, "-c", "/google_checks.xml", filePath, "-x", "."); assertWithMessage("Unexpected output log") @@ -1849,9 +1836,9 @@ public class MainTest { assertWithMessage("Unexpected output log").that(systemErr.getCapturedData()).isEqualTo(""); } - @Test @SuppressWarnings("unchecked") - public void testExcludeDirectoryNotMatch() throws Exception { + @Test + void excludeDirectoryNotMatch() throws Exception { final Class optionsClass = Class.forName(Main.class.getName()); final Method method = optionsClass.getDeclaredMethod("listFiles", File.class, List.class); method.setAccessible(true); @@ -1863,7 +1850,7 @@ public class MainTest { } @Test - public void testCustomRootModule(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void customRootModule(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { TestRootModuleChecker.reset(); assertMainReturnCode( @@ -1879,7 +1866,7 @@ public class MainTest { } @Test - public void testCustomSimpleRootModule(@SysErr Capturable systemErr) { + void customSimpleRootModule(@SysErr Capturable systemErr) { TestRootModuleChecker.reset(); assertMainReturnCode( -2, @@ -1908,8 +1895,7 @@ public class MainTest { } @Test - public void testExceptionOnExecuteIgnoredModuleWithUnknownModuleName( - @SysErr Capturable systemErr) { + void exceptionOnExecuteIgnoredModuleWithUnknownModuleName(@SysErr Capturable systemErr) { assertMainReturnCode( -2, "-c", @@ -1925,8 +1911,7 @@ public class MainTest { } @Test - public void testExceptionOnExecuteIgnoredModuleWithBadPropertyValue( - @SysErr Capturable systemErr) { + void exceptionOnExecuteIgnoredModuleWithBadPropertyValue(@SysErr Capturable systemErr) { assertMainReturnCode( -2, "-c", @@ -1946,15 +1931,14 @@ public class MainTest { } @Test - public void testNoProblemOnExecuteIgnoredModuleWithBadPropertyValue( - @SysErr Capturable systemErr) { + void noProblemOnExecuteIgnoredModuleWithBadPropertyValue(@SysErr Capturable systemErr) { assertMainReturnCode( 0, "-c", getPath("InputMainConfig-TypeName-bad-value.xml"), "", getPath("InputMain.java")); assertWithMessage("Unexpected system error log").that(systemErr.getCapturedData()).isEmpty(); } @Test - public void testMissingFiles(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { + void missingFiles(@SysErr Capturable systemErr, @SysOut Capturable systemOut) { assertMainReturnCode(-1); final String usage = "Missing required parameter: ''" + EOL + SHORT_USAGE; assertWithMessage("Unexpected output log").that(systemOut.getCapturedData()).isEqualTo(""); @@ -1964,13 +1948,13 @@ public class MainTest { } @Test - public void testOutputFormatToStringLowercase() { + void outputFormatToStringLowercase() { assertWithMessage("expected xml").that(Main.OutputFormat.XML.toString()).isEqualTo("xml"); assertWithMessage("expected plain").that(Main.OutputFormat.PLAIN.toString()).isEqualTo("plain"); } @Test - public void testXmlOutputFormatCreateListener() throws IOException { + void xmlOutputFormatCreateListener() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final AuditListener listener = Main.OutputFormat.XML.createListener(out, OutputStreamOptions.CLOSE); @@ -1978,7 +1962,7 @@ public class MainTest { } @Test - public void testSarifOutputFormatCreateListener() throws IOException { + void sarifOutputFormatCreateListener() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final AuditListener listener = Main.OutputFormat.SARIF.createListener(out, OutputStreamOptions.CLOSE); @@ -1986,7 +1970,7 @@ public class MainTest { } @Test - public void testPlainOutputFormatCreateListener() throws IOException { + void plainOutputFormatCreateListener() throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final AuditListener listener = Main.OutputFormat.PLAIN.createListener(out, OutputStreamOptions.CLOSE); @@ -2025,7 +2009,7 @@ public class MainTest { private boolean isClosed; private ShouldNotBeClosedStream() { - super(new ByteArrayOutputStream(), false, StandardCharsets.UTF_8); + super(new ByteArrayOutputStream(), false, UTF_8); } @Override --- a/src/test/java/com/puppycrawl/tools/checkstyle/MetadataGeneratorLoggerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/MetadataGeneratorLoggerTest.java @@ -31,10 +31,10 @@ import java.io.IOException; import java.io.OutputStream; import org.junit.jupiter.api.Test; -public class MetadataGeneratorLoggerTest { +final class MetadataGeneratorLoggerTest { @Test - public void testIgnoreSeverityLevel() { + void ignoreSeverityLevel() { final OutputStream outputStream = new ByteArrayOutputStream(); final MetadataGeneratorLogger logger = new MetadataGeneratorLogger(outputStream, OutputStreamOptions.CLOSE); @@ -59,7 +59,7 @@ public class MetadataGeneratorLoggerTest { } @Test - public void testAddException() { + void addException() { final OutputStream outputStream = new ByteArrayOutputStream(); final MetadataGeneratorLogger logger = new MetadataGeneratorLogger(outputStream, OutputStreamOptions.CLOSE); @@ -72,7 +72,7 @@ public class MetadataGeneratorLoggerTest { } @Test - public void testClose() throws IOException { + void close() throws IOException { try (CloseAndFlushTestByteArrayOutputStream outputStream = new CloseAndFlushTestByteArrayOutputStream()) { final MetadataGeneratorLogger logger = @@ -83,7 +83,7 @@ public class MetadataGeneratorLoggerTest { } @Test - public void testCloseOutputStreamOptionNone() throws IOException { + void closeOutputStreamOptionNone() throws IOException { try (CloseAndFlushTestByteArrayOutputStream outputStream = new CloseAndFlushTestByteArrayOutputStream()) { final MetadataGeneratorLogger logger = @@ -95,7 +95,7 @@ public class MetadataGeneratorLoggerTest { } @Test - public void testFlushStreams() throws Exception { + void flushStreams() throws Exception { try (CloseAndFlushTestByteArrayOutputStream outputStream = new CloseAndFlushTestByteArrayOutputStream()) { final MetadataGeneratorLogger logger = --- a/src/test/java/com/puppycrawl/tools/checkstyle/PackageNamesLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/PackageNamesLoaderTest.java @@ -20,8 +20,10 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static java.util.Collections.emptyEnumeration; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import java.io.File; import java.io.IOException; @@ -45,7 +47,7 @@ import org.xml.sax.SAXException; * pretend these are loaded from the classpath though we can't add/change the files for testing. * The class loader is nested in this class, so the custom class loader we are using is safe. */ -public class PackageNamesLoaderTest extends AbstractPathTestSupport { +final class PackageNamesLoaderTest extends AbstractPathTestSupport { @Override protected String getPackageLocation() { @@ -53,26 +55,25 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } @Test - public void testDefault() throws CheckstyleException { + void testDefault() throws CheckstyleException { final Set packageNames = PackageNamesLoader.getPackageNames(Thread.currentThread().getContextClassLoader()); assertWithMessage("pkgNames.length.").that(packageNames).isEmpty(); } @Test - public void testNoPackages() throws Exception { + void noPackages() throws Exception { final Set actualPackageNames = - PackageNamesLoader.getPackageNames(new TestUrlsClassLoader(Collections.emptyEnumeration())); + PackageNamesLoader.getPackageNames(new TestUrlsClassLoader(emptyEnumeration())); assertWithMessage("Invalid package names length.").that(actualPackageNames).isEmpty(); } @Test - public void testPackagesFile() throws Exception { + void packagesFile() throws Exception { final Enumeration enumeration = Collections.enumeration( - Collections.singleton( - new File(getPath("InputPackageNamesLoaderFile.xml")).toURI().toURL())); + ImmutableSet.of(new File(getPath("InputPackageNamesLoaderFile.xml")).toURI().toURL())); final Set actualPackageNames = PackageNamesLoader.getPackageNames(new TestUrlsClassLoader(enumeration)); @@ -107,10 +108,10 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } @Test - public void testPackagesWithDots() throws Exception { + void packagesWithDots() throws Exception { final Enumeration enumeration = Collections.enumeration( - Collections.singleton( + ImmutableSet.of( new File(getPath("InputPackageNamesLoaderWithDots.xml")).toURI().toURL())); final Set actualPackageNames = @@ -129,10 +130,10 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } @Test - public void testPackagesWithDotsEx() throws Exception { + void packagesWithDotsEx() throws Exception { final Enumeration enumeration = Collections.enumeration( - Collections.singleton( + ImmutableSet.of( new File(getPath("InputPackageNamesLoaderWithDotsEx.xml")).toURI().toURL())); final Set actualPackageNames = @@ -151,10 +152,10 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } @Test - public void testPackagesWithSaxException() throws Exception { + void packagesWithSaxException() throws Exception { final Enumeration enumeration = Collections.enumeration( - Collections.singleton( + ImmutableSet.of( new File(getPath("InputPackageNamesLoaderNotXml.java")).toURI().toURL())); try { @@ -169,7 +170,7 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } @Test - public void testPackagesWithIoException() throws Exception { + void packagesWithIoException() throws Exception { final URLConnection urlConnection = new URLConnection(null) { @Override @@ -195,7 +196,7 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } }); - final Enumeration enumeration = Collections.enumeration(Collections.singleton(url)); + final Enumeration enumeration = Collections.enumeration(ImmutableSet.of(url)); try { PackageNamesLoader.getPackageNames(new TestUrlsClassLoader(enumeration)); @@ -213,7 +214,7 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } @Test - public void testPackagesWithIoExceptionGetResources() { + void packagesWithIoExceptionGetResources() { try { PackageNamesLoader.getPackageNames(new TestIoExceptionClassLoader()); assertWithMessage("CheckstyleException is expected").fail(); @@ -229,21 +230,20 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } @Test - public void testUnmodifiableCollection() throws Exception { + void unmodifiableCollection() throws Exception { final Set actualPackageNames = - PackageNamesLoader.getPackageNames(new TestUrlsClassLoader(Collections.emptyEnumeration())); + PackageNamesLoader.getPackageNames(new TestUrlsClassLoader(emptyEnumeration())); - assertThrows( - UnsupportedOperationException.class, - () -> actualPackageNames.add("com.puppycrawl.tools.checkstyle.checks.modifier")); + assertThatThrownBy( + () -> actualPackageNames.add("com.puppycrawl.tools.checkstyle.checks.modifier")) + .isInstanceOf(UnsupportedOperationException.class); } @Test - public void testMapping() throws Exception { + void mapping() throws Exception { final Enumeration enumeration = Collections.enumeration( - Collections.singleton( - new File(getPath("InputPackageNamesLoader1.xml")).toURI().toURL())); + ImmutableSet.of(new File(getPath("InputPackageNamesLoader1.xml")).toURI().toURL())); final Set actualPackageNames = PackageNamesLoader.getPackageNames(new TestUrlsClassLoader(enumeration)); @@ -252,11 +252,10 @@ public class PackageNamesLoaderTest extends AbstractPathTestSupport { } @Test - public void testMapping2() throws Exception { + void mapping2() throws Exception { final Enumeration enumeration = Collections.enumeration( - Collections.singleton( - new File(getPath("InputPackageNamesLoader2.xml")).toURI().toURL())); + ImmutableSet.of(new File(getPath("InputPackageNamesLoader2.xml")).toURI().toURL())); final Set actualPackageNames = PackageNamesLoader.getPackageNames(new TestUrlsClassLoader(enumeration)); --- a/src/test/java/com/puppycrawl/tools/checkstyle/PackageObjectFactoryTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/PackageObjectFactoryTest.java @@ -30,9 +30,12 @@ import static com.puppycrawl.tools.checkstyle.PackageObjectFactory.NULL_PACKAGE_ import static com.puppycrawl.tools.checkstyle.PackageObjectFactory.PACKAGE_SEPARATOR; import static com.puppycrawl.tools.checkstyle.PackageObjectFactory.STRING_SEPARATOR; import static com.puppycrawl.tools.checkstyle.PackageObjectFactory.UNABLE_TO_INSTANTIATE_EXCEPTION_MESSAGE; +import static java.util.Collections.singleton; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mockStatic; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.FileText; @@ -47,7 +50,6 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Map; @@ -58,13 +60,13 @@ import org.mockito.MockedStatic; import org.mockito.Mockito; /** Enter a description of class PackageObjectFactoryTest.java. */ -public class PackageObjectFactoryTest { +final class PackageObjectFactoryTest { private final PackageObjectFactory factory = new PackageObjectFactory(BASE_PACKAGE, Thread.currentThread().getContextClassLoader()); @Test - public void testCtorNullLoaderException1() { + void ctorNullLoaderException1() { try { final Object test = new PackageObjectFactory(new HashSet<>(), null); assertWithMessage("Exception is expected but got " + test).fail(); @@ -76,7 +78,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCtorNullLoaderException2() { + void ctorNullLoaderException2() { try { final Object test = new PackageObjectFactory("test", null); assertWithMessage("Exception is expected but got " + test).fail(); @@ -88,12 +90,12 @@ public class PackageObjectFactoryTest { } @Test - public void testCtorNullPackageException1() { + void ctorNullPackageException1() { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { // XXX: Don't suggest `ImmutableSet.of(elem)` for nullable `elem`. @SuppressWarnings("ImmutableSetOf1") - final Object test = new PackageObjectFactory(Collections.singleton(null), classLoader); + final Object test = new PackageObjectFactory(singleton(null), classLoader); assertWithMessage("Exception is expected but got " + test).fail(); } catch (IllegalArgumentException ex) { assertWithMessage("Invalid exception message") @@ -103,7 +105,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCtorNullPackageException2() { + void ctorNullPackageException2() { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { final Object test = new PackageObjectFactory((String) null, classLoader); @@ -116,14 +118,13 @@ public class PackageObjectFactoryTest { } @Test - public void testCtorNullPackageException3() { + void ctorNullPackageException3() { final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { // XXX: Don't suggest `ImmutableSet.of(elem)` for nullable `elem`. @SuppressWarnings("ImmutableSetOf1") final Object test = - new PackageObjectFactory( - Collections.singleton(null), classLoader, TRY_IN_ALL_REGISTERED_PACKAGES); + new PackageObjectFactory(singleton(null), classLoader, TRY_IN_ALL_REGISTERED_PACKAGES); assertWithMessage("Exception is expected but got " + test).fail(); } catch (IllegalArgumentException ex) { assertWithMessage("Invalid exception message") @@ -133,7 +134,7 @@ public class PackageObjectFactoryTest { } @Test - public void testMakeObjectFromName() throws CheckstyleException { + void makeObjectFromName() throws CheckstyleException { final Checker checker = (Checker) factory.createModule("com.puppycrawl.tools.checkstyle.Checker"); assertWithMessage("Checker should not be null when creating module from name") @@ -142,7 +143,7 @@ public class PackageObjectFactoryTest { } @Test - public void testMakeCheckFromName() { + void makeCheckFromName() { final String name = "com.puppycrawl.tools.checkstyle.checks.naming.ConstantName"; try { factory.createModule(name); @@ -162,7 +163,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateModuleWithNonExistName() { + void createModuleWithNonExistName() { final String[] names = { "NonExistClassOne", "NonExistClassTwo", }; @@ -198,7 +199,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateObjectFromMap() throws Exception { + void createObjectFromMap() throws Exception { final String moduleName = "Foo"; final String name = moduleName + CHECK_SUFFIX; final String packageName = BASE_PACKAGE + ".packageobjectfactory.bar"; @@ -216,7 +217,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateStandardModuleObjectFromMap() throws Exception { + void createStandardModuleObjectFromMap() throws Exception { final String moduleName = "TreeWalker"; final String packageName = BASE_PACKAGE + ".packageobjectfactory.bar"; final String fullName = BASE_PACKAGE + PACKAGE_SEPARATOR + moduleName; @@ -229,7 +230,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateStandardCheckModuleObjectFromMap() throws Exception { + void createStandardCheckModuleObjectFromMap() throws Exception { final String moduleName = "TypeName"; final String packageName = BASE_PACKAGE + ".packageobjectfactory.bar"; final String fullName = @@ -250,7 +251,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateObjectFromFullModuleNamesWithAmbiguousException() { + void createObjectFromFullModuleNamesWithAmbiguousException() { final String barPackage = BASE_PACKAGE + ".packageobjectfactory.bar"; final String fooPackage = BASE_PACKAGE + ".packageobjectfactory.foo"; final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); @@ -284,7 +285,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateObjectFromFullModuleNamesWithCantInstantiateException() { + void createObjectFromFullModuleNamesWithCantInstantiateException() { final String package1 = BASE_PACKAGE + ".wrong1"; final String package2 = BASE_PACKAGE + ".wrong2"; final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); @@ -329,7 +330,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateObjectFromFullModuleNamesWithExceptionByBruteForce() { + void createObjectFromFullModuleNamesWithExceptionByBruteForce() { final String package1 = BASE_PACKAGE + ".wrong1"; final String package2 = BASE_PACKAGE + ".wrong2"; final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); @@ -378,7 +379,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateObjectByBruteForce() throws Exception { + void createObjectByBruteForce() throws Exception { final String className = "Checker"; final Method createModuleByBruteForce = PackageObjectFactory.class.getDeclaredMethod( @@ -391,7 +392,7 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateCheckByBruteForce() throws Exception { + void createCheckByBruteForce() throws Exception { final String checkName = "AnnotationLocation"; final Method createModuleByBruteForce = PackageObjectFactory.class.getDeclaredMethod( @@ -410,11 +411,11 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateCheckWithPartialPackageNameByBruteForce() throws Exception { + void createCheckWithPartialPackageNameByBruteForce() throws Exception { final String checkName = "checks.annotation.AnnotationLocation"; final PackageObjectFactory packageObjectFactory = new PackageObjectFactory( - new HashSet<>(Collections.singletonList(BASE_PACKAGE)), + new HashSet<>(ImmutableList.of(BASE_PACKAGE)), Thread.currentThread().getContextClassLoader(), TRY_IN_ALL_REGISTERED_PACKAGES); final AnnotationLocationCheck check = @@ -425,21 +426,21 @@ public class PackageObjectFactoryTest { } @Test - public void testJoinPackageNamesWithClassName() throws Exception { + void joinPackageNamesWithClassName() throws Exception { final Class clazz = PackageObjectFactory.class; final Method method = clazz.getDeclaredMethod("joinPackageNamesWithClassName", String.class, Set.class); method.setAccessible(true); - final Set packages = Collections.singleton("test"); + final Set packages = ImmutableSet.of("test"); final String className = "SomeClass"; final String actual = String.valueOf(method.invoke(PackageObjectFactory.class, className, packages)); assertWithMessage("Invalid class name").that(actual).isEqualTo("test." + className); } - @Test @SuppressWarnings("unchecked") - public void testNameToFullModuleNameMap() throws Exception { + @Test + void nameToFullModuleNameMap() throws Exception { final Set> classes = CheckUtil.getCheckstyleModules(); final Class packageObjectFactoryClass = PackageObjectFactory.class; final Field field = packageObjectFactoryClass.getDeclaredField("NAME_TO_FULL_MODULE_NAME"); @@ -470,7 +471,7 @@ public class PackageObjectFactoryTest { } @Test - public void testConstructorFailure() { + void constructorFailure() { try { factory.createModule(FailConstructorFileSet.class.getName()); assertWithMessage("Exception is expected").fail(); @@ -487,7 +488,7 @@ public class PackageObjectFactoryTest { } @Test - public void testGetShortFromFullModuleNames() { + void getShortFromFullModuleNames() { final String fullName = "com.puppycrawl.tools.checkstyle.checks.coding.DefaultComesLastCheck"; assertWithMessage("Invalid simple check name") @@ -496,7 +497,7 @@ public class PackageObjectFactoryTest { } @Test - public void testGetShortFromFullModuleNamesThirdParty() { + void getShortFromFullModuleNamesThirdParty() { final String fullName = "java.util.stream.Collectors"; assertWithMessage("Invalid simple check name") @@ -516,11 +517,11 @@ public class PackageObjectFactoryTest { * @throws Exception when the code tested throws an exception */ @Test - public void testGenerateThirdPartyNameToFullModuleNameWithException() throws Exception { + void generateThirdPartyNameToFullModuleNameWithException() throws Exception { final String name = "String"; final String packageName = "java.lang"; final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - final Set packages = Collections.singleton(packageName); + final Set packages = ImmutableSet.of(packageName); final PackageObjectFactory objectFactory = new PackageObjectFactory(packages, classLoader, TRY_IN_ALL_REGISTERED_PACKAGES); @@ -544,9 +545,9 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateObjectWithNameContainingPackageSeparator() throws Exception { + void createObjectWithNameContainingPackageSeparator() throws Exception { final ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - final Set packages = Collections.singleton(BASE_PACKAGE); + final Set packages = ImmutableSet.of(BASE_PACKAGE); final PackageObjectFactory objectFactory = new PackageObjectFactory(packages, classLoader, TRY_IN_ALL_REGISTERED_PACKAGES); @@ -562,9 +563,9 @@ public class PackageObjectFactoryTest { * It ensures that ModuleReflectionUtil.getCheckstyleModules is not executed in this case. */ @Test - public void testCreateObjectWithNameContainingPackageSeparatorWithoutSearch() throws Exception { + void createObjectWithNameContainingPackageSeparatorWithoutSearch() throws Exception { final ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - final Set packages = Collections.singleton(BASE_PACKAGE); + final Set packages = ImmutableSet.of(BASE_PACKAGE); final PackageObjectFactory objectFactory = new PackageObjectFactory(packages, classLoader, TRY_IN_ALL_REGISTERED_PACKAGES); @@ -588,9 +589,9 @@ public class PackageObjectFactoryTest { } @Test - public void testCreateModuleWithTryInAllRegisteredPackages() { + void createModuleWithTryInAllRegisteredPackages() { final ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - final Set packages = Collections.singleton(BASE_PACKAGE); + final Set packages = ImmutableSet.of(BASE_PACKAGE); final PackageObjectFactory objectFactory = new PackageObjectFactory(packages, classLoader, SEARCH_REGISTERED_PACKAGES); final CheckstyleException ex = @@ -611,7 +612,7 @@ public class PackageObjectFactoryTest { } @Test - public void testExceptionMessage() { + void exceptionMessage() { final String barPackage = BASE_PACKAGE + ".packageobjectfactory.bar"; final String fooPackage = BASE_PACKAGE + ".packageobjectfactory.foo"; final String zooPackage = BASE_PACKAGE + ".packageobjectfactory.zoo"; --- a/src/test/java/com/puppycrawl/tools/checkstyle/PropertiesExpanderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/PropertiesExpanderTest.java @@ -24,10 +24,10 @@ import static com.google.common.truth.Truth.assertWithMessage; import java.util.Properties; import org.junit.jupiter.api.Test; -public class PropertiesExpanderTest { +final class PropertiesExpanderTest { @Test - public void testCtorException() { + void ctorException() { try { final Object test = new PropertiesExpander(null); assertWithMessage("exception expected but got " + test).fail(); @@ -39,7 +39,7 @@ public class PropertiesExpanderTest { } @Test - public void testDefaultProperties() { + void defaultProperties() { final Properties properties = new Properties(System.getProperties()); properties.setProperty("test", "checkstyle"); final String propertiesUserHome = properties.getProperty("user.home"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/PropertyCacheFileTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/PropertyCacheFileTest.java @@ -25,7 +25,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mockStatic; import com.google.common.io.BaseEncoding; -import com.google.common.io.ByteStreams; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; @@ -39,7 +38,6 @@ import java.io.ObjectOutputStream; import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.HashSet; @@ -54,7 +52,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.mockito.MockedStatic; -public class PropertyCacheFileTest extends AbstractPathTestSupport { +final class PropertyCacheFileTest extends AbstractPathTestSupport { @TempDir public File temporaryFolder; @@ -64,7 +62,7 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testCtor() { + void ctor() { try { final Object test = new PropertyCacheFile(null, ""); assertWithMessage("exception expected but got " + test).fail(); @@ -85,9 +83,10 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testInCache() throws IOException { + void inCache() throws IOException { final Configuration config = new DefaultConfiguration("myName"); - final String filePath = File.createTempFile("junit", null, temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath(); final PropertyCacheFile cache = new PropertyCacheFile(config, filePath); cache.put("myFile", 1); assertWithMessage("Should return true when file is in cache") @@ -102,7 +101,7 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testResetIfFileDoesNotExist() throws IOException { + void resetIfFileDoesNotExist() throws IOException { final Configuration config = new DefaultConfiguration("myName"); final PropertyCacheFile cache = new PropertyCacheFile(config, "fileDoesNotExist.txt"); @@ -114,7 +113,7 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testPopulateDetails() throws IOException { + void populateDetails() throws IOException { final Configuration config = new DefaultConfiguration("myName"); final PropertyCacheFile cache = new PropertyCacheFile(config, getPath("InputPropertyCacheFile")); @@ -136,9 +135,10 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testConfigHashOnReset() throws IOException { + void configHashOnReset() throws IOException { final Configuration config = new DefaultConfiguration("myName"); - final String filePath = File.createTempFile("junit", null, temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath(); final PropertyCacheFile cache = new PropertyCacheFile(config, filePath); cache.load(); @@ -154,9 +154,10 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testConfigHashRemainsOnResetExternalResources() throws IOException { + void configHashRemainsOnResetExternalResources() throws IOException { final Configuration config = new DefaultConfiguration("myName"); - final String filePath = File.createTempFile("junit", null, temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath(); final PropertyCacheFile cache = new PropertyCacheFile(config, filePath); // create cache with one file @@ -180,11 +181,12 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testCacheRemainsWhenExternalResourceTheSame() throws IOException { + void cacheRemainsWhenExternalResourceTheSame() throws IOException { final Configuration config = new DefaultConfiguration("myName"); final String externalResourcePath = - File.createTempFile("junit", null, temporaryFolder).getPath(); - final String filePath = File.createTempFile("junit", null, temporaryFolder).getPath(); + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath(); final PropertyCacheFile cache = new PropertyCacheFile(config, filePath); // pre-populate with cache with resources @@ -209,9 +211,10 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testExternalResourceIsSavedInCache() throws Exception { + void externalResourceIsSavedInCache() throws Exception { final Configuration config = new DefaultConfiguration("myName"); - final String filePath = File.createTempFile("junit", null, temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath(); final PropertyCacheFile cache = new PropertyCacheFile(config, filePath); cache.load(); @@ -223,7 +226,7 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { final MessageDigest digest = MessageDigest.getInstance("SHA-1"); final URI uri = CommonUtil.getUriByFilename(pathToResource); - final byte[] input = ByteStreams.toByteArray(new BufferedInputStream(uri.toURL().openStream())); + final byte[] input = new BufferedInputStream(uri.toURL().openStream()).readAllBytes(); final ByteArrayOutputStream out = new ByteArrayOutputStream(); try (ObjectOutputStream oos = new ObjectOutputStream(out)) { oos.writeObject(input); @@ -237,7 +240,7 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testCacheDirectoryDoesNotExistAndShouldBeCreated() throws IOException { + void cacheDirectoryDoesNotExistAndShouldBeCreated() throws IOException { final Configuration config = new DefaultConfiguration("myName"); final String filePath = String.format(Locale.ENGLISH, "%s%2$stemp%2$scache.temp", temporaryFolder, File.separator); @@ -250,10 +253,10 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testPathToCacheContainsOnlyFileName() throws IOException { + void pathToCacheContainsOnlyFileName() throws IOException { final Configuration config = new DefaultConfiguration("myName"); final String fileName = "temp.cache"; - final Path filePath = Paths.get(fileName); + final Path filePath = Path.of(fileName); final PropertyCacheFile cache = new PropertyCacheFile(config, fileName); // no exception expected @@ -263,9 +266,9 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { Files.delete(filePath); } - @Test @DisabledOnOs(OS.WINDOWS) - public void testPersistWithSymbolicLinkToDirectory() throws IOException { + @Test + void persistWithSymbolicLinkToDirectory() throws IOException { final Path tempDirectory = temporaryFolder.toPath(); final Path symbolicLinkDirectory = temporaryFolder.toPath().resolve("symbolicLink"); Files.createSymbolicLink(symbolicLinkDirectory, tempDirectory); @@ -282,9 +285,9 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { .isTrue(); } - @Test @DisabledOnOs(OS.WINDOWS) - public void testSymbolicLinkResolution() throws IOException { + @Test + void symbolicLinkResolution() throws IOException { final Path tempDirectory = temporaryFolder.toPath(); final Path symbolicLinkDirectory = temporaryFolder.toPath().resolve("symbolicLink"); Files.createSymbolicLink(symbolicLinkDirectory, tempDirectory); @@ -301,9 +304,9 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { .isTrue(); } - @Test @DisabledOnOs(OS.WINDOWS) - public void testSymbolicLinkToNonDirectory() throws IOException { + @Test + void symbolicLinkToNonDirectory() throws IOException { final Path tempFile = Files.createTempFile("tempFile", null); final Path symbolicLinkDirectory = temporaryFolder.toPath(); final Path symbolicLink = symbolicLinkDirectory.resolve("symbolicLink"); @@ -323,9 +326,9 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { .contains(expectedMessage); } - @Test @DisabledOnOs(OS.WINDOWS) - public void testMultipleSymbolicLinkResolution() throws IOException { + @Test + void multipleSymbolicLinkResolution() throws IOException { final Path actualDirectory = temporaryFolder.toPath(); final Path firstSymbolicLink = temporaryFolder.toPath().resolve("firstLink"); Files.createSymbolicLink(firstSymbolicLink, actualDirectory); @@ -346,11 +349,11 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testChangeInConfig() throws Exception { + void changeInConfig() throws Exception { final DefaultConfiguration config = new DefaultConfiguration("myConfig"); config.addProperty("attr", "value"); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); final PropertyCacheFile cache = new PropertyCacheFile(config, cacheFile.getPath()); cache.load(); @@ -392,9 +395,10 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testNonExistentResource() throws IOException { + void nonExistentResource() throws IOException { final Configuration config = new DefaultConfiguration("myName"); - final String filePath = File.createTempFile("junit", null, temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath(); final PropertyCacheFile cache = new PropertyCacheFile(config, filePath); // create cache with one file @@ -421,9 +425,10 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { } @Test - public void testExceptionNoSuchAlgorithmException() throws Exception { + void exceptionNoSuchAlgorithmException() throws Exception { final Configuration config = new DefaultConfiguration("myName"); - final String filePath = File.createTempFile("junit", null, temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath(); final PropertyCacheFile cache = new PropertyCacheFile(config, filePath); cache.put("myFile", 1); @@ -460,9 +465,9 @@ public class PropertyCacheFileTest extends AbstractPathTestSupport { * @param rawMessages exception messages separated by ';' */ @ParameterizedTest - @ValueSource(strings = {"Same;Same", "First;Second"}) - public void testPutNonExistentExternalResource(String rawMessages) throws Exception { - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + @ValueSource(strings = {"First;Second", "Same;Same"}) + void putNonExistentExternalResource(String rawMessages) throws Exception { + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); final String[] messages = rawMessages.split(";"); // We mock getUriByFilename method of CommonUtil to guarantee that it will // throw CheckstyleException with the specific content. --- a/src/test/java/com/puppycrawl/tools/checkstyle/SarifLoggerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/SarifLoggerTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.OutputStreamOptions; import com.puppycrawl.tools.checkstyle.api.AuditEvent; @@ -29,10 +30,9 @@ import com.puppycrawl.tools.checkstyle.internal.utils.CloseAndFlushTestByteArray import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintWriter; -import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; -public class SarifLoggerTest extends AbstractModuleTestSupport { +final class SarifLoggerTest extends AbstractModuleTestSupport { /** * Output stream to hold the test results. The IntelliJ IDEA issues the AutoCloseableResource @@ -48,7 +48,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testEscape() { + void escape() { final String[][] encodings = { {"\"", "\\\""}, {"\\", "\\\\"}, @@ -71,7 +71,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testAddError() throws IOException { + void addError() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -94,7 +94,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testAddErrorWithWarningLevel() throws IOException { + void addErrorWithWarningLevel() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -117,7 +117,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testAddErrors() throws IOException { + void addErrors() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -155,7 +155,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testAddException() throws IOException { + void addException() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation message = @@ -170,7 +170,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testAddExceptions() throws IOException { + void addExceptions() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -192,7 +192,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testLineOnly() throws IOException { + void lineOnly() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -207,7 +207,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testEmpty() throws IOException { + void empty() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -221,7 +221,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testNullOutputStreamOptions() { + void nullOutputStreamOptions() { try { final SarifLogger logger = new SarifLogger(outStream, null); // assert required to calm down eclipse's 'The allocated object is never used' violation @@ -235,7 +235,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testCloseStream() throws IOException { + void closeStream() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); logger.auditFinished(null); @@ -246,7 +246,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testNoCloseStream() throws IOException { + void noCloseStream() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.NONE); logger.auditStarted(null); logger.auditFinished(null); @@ -259,7 +259,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testFinishLocalSetup() throws IOException { + void finishLocalSetup() throws IOException { final SarifLogger logger = new SarifLogger(outStream, OutputStreamOptions.CLOSE); logger.finishLocalSetup(); logger.auditStarted(null); @@ -268,7 +268,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { } @Test - public void testReadResourceWithInvalidName() { + void readResourceWithInvalidName() { try { SarifLogger.readResource("random"); assertWithMessage("Exception expected").fail(); @@ -282,8 +282,7 @@ public class SarifLoggerTest extends AbstractModuleTestSupport { private static void verifyContent( String expectedOutputFile, ByteArrayOutputStream actualOutputStream) throws IOException { final String expectedContent = readFile(expectedOutputFile); - final String actualContent = - toLfLineEnding(actualOutputStream.toString(StandardCharsets.UTF_8)); + final String actualContent = toLfLineEnding(actualOutputStream.toString(UTF_8)); assertWithMessage("sarif content should match").that(actualContent).isEqualTo(expectedContent); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/SuppressionsStringPrinterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/SuppressionsStringPrinterTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import java.io.File; import org.junit.jupiter.api.Test; -public class SuppressionsStringPrinterTest extends AbstractTreeTestSupport { +final class SuppressionsStringPrinterTest extends AbstractTreeTestSupport { private static final String EOL = System.getProperty("line.separator"); @@ -36,14 +36,14 @@ public class SuppressionsStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(SuppressionsStringPrinter.class)) .isTrue(); } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final String expected = "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='InputSuppressionsStringPrinter']]" @@ -65,7 +65,7 @@ public class SuppressionsStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testCustomTabWidth() throws Exception { + void customTabWidth() throws Exception { final String expected = "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='InputSuppressionsStringPrinter']]" @@ -90,7 +90,7 @@ public class SuppressionsStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testCustomTabWidthEmptyResult() throws Exception { + void customTabWidthEmptyResult() throws Exception { final File input = new File(getPath("InputSuppressionsStringPrinter.java")); final String lineAndColumnNumber = "5:13"; final int tabWidth = 6; @@ -100,7 +100,7 @@ public class SuppressionsStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testInvalidLineAndColumnNumberParameter() throws Exception { + void invalidLineAndColumnNumberParameter() throws Exception { final File input = new File(getPath("InputSuppressionsStringPrinter.java")); final String invalidLineAndColumnNumber = "abc-432"; final int tabWidth = 2; @@ -115,7 +115,7 @@ public class SuppressionsStringPrinterTest extends AbstractTreeTestSupport { } @Test - public void testParseFileTextThrowable() throws Exception { + void parseFileTextThrowable() throws Exception { final File input = new File(getNonCompilablePath("InputSuppressionsStringPrinter.java")); final String lineAndColumnNumber = "2:3"; final int tabWidth = 2; --- a/src/test/java/com/puppycrawl/tools/checkstyle/ThreadModeSettingsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/ThreadModeSettingsTest.java @@ -25,10 +25,10 @@ import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil; import java.util.Set; import org.junit.jupiter.api.Test; -public class ThreadModeSettingsTest { +final class ThreadModeSettingsTest { @Test - public void testProperties() { + void properties() { final ThreadModeSettings config = new ThreadModeSettings(1, 2); assertWithMessage("Invalid checker threads number") .that(config.getCheckerThreadsNumber()) @@ -39,7 +39,7 @@ public class ThreadModeSettingsTest { } @Test - public void testResolveCheckerInMultiThreadMode() { + void resolveCheckerInMultiThreadMode() { final ThreadModeSettings configuration = new ThreadModeSettings(2, 2); try { @@ -53,7 +53,7 @@ public class ThreadModeSettingsTest { } @Test - public void testResolveCheckerInSingleThreadMode() { + void resolveCheckerInSingleThreadMode() { final ThreadModeSettings singleThreadMode = ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE; final String name = singleThreadMode.resolveName(ThreadModeSettings.CHECKER_MODULE_NAME); @@ -63,7 +63,7 @@ public class ThreadModeSettingsTest { } @Test - public void testResolveTreeWalker() { + void resolveTreeWalker() { final ThreadModeSettings configuration = new ThreadModeSettings(2, 2); try { @@ -77,7 +77,7 @@ public class ThreadModeSettingsTest { } @Test - public void testResolveTreeWalkerInSingleThreadMode() { + void resolveTreeWalkerInSingleThreadMode() { final ThreadModeSettings singleThreadMode = ThreadModeSettings.SINGLE_THREAD_MODE_INSTANCE; final String actual = singleThreadMode.resolveName(ThreadModeSettings.TREE_WALKER_MODULE_NAME); assertWithMessage("Invalid name resolved: " + actual) @@ -86,7 +86,7 @@ public class ThreadModeSettingsTest { } @Test - public void testResolveAnyOtherModule() throws Exception { + void resolveAnyOtherModule() throws Exception { final Set> allModules = CheckUtil.getCheckstyleModules(); final ThreadModeSettings multiThreadModeSettings = new ThreadModeSettings(2, 2); final ThreadModeSettings singleThreadModeSettings = --- a/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/TreeWalkerTest.java @@ -21,11 +21,15 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.CALLS_REAL_METHODS; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockConstruction; +import static org.mockito.Mockito.mockStatic; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.Configuration; @@ -58,7 +62,6 @@ import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -90,7 +93,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testProperFileExtension() throws Exception { + void properFileExtension() throws Exception { final String path = getPath("InputTreeWalkerProperFileExtension.java"); final String[] expected = { "10:27: " @@ -126,14 +129,14 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { * @throws Exception if an error occurs */ @Test - public void testNoAuditEventsWithoutFilters() throws Exception { + void noAuditEventsWithoutFilters() throws Exception { final String[] expected = { "10:1: " + getCheckMessage( OneTopLevelClassCheck.class, OneTopLevelClassCheck.MSG_KEY, "InputTreeWalkerInner"), }; try (MockedConstruction mocked = - Mockito.mockConstruction( + mockConstruction( TreeWalkerAuditEvent.class, (mock, context) -> { throw new CheckstyleException("No audit events expected"); @@ -147,7 +150,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { * that the {@code if (!ordinaryChecks.isEmpty())} condition cannot be removed. */ @Test - public void testConditionRequiredWithoutOrdinaryChecks() throws Exception { + void conditionRequiredWithoutOrdinaryChecks() throws Exception { final String[] expected = { "7: " + getCheckMessage( @@ -159,7 +162,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { JavaParser.parseFile(new File(path), JavaParser.Options.WITH_COMMENTS); // Ensure that there is no calls to walk(..., AstState.ORDINARY) doThrow(IllegalStateException.class).when(mockAst).getFirstChild(); - try (MockedStatic parser = Mockito.mockStatic(JavaParser.class)) { + try (MockedStatic parser = mockStatic(JavaParser.class)) { parser.when(() -> JavaParser.parse(any(FileContents.class))).thenReturn(mockAst); // This will re-enable walk(..., AstState.WITH_COMMENTS) parser.when(() -> JavaParser.appendHiddenCommentNodes(mockAst)).thenReturn(realAst); @@ -173,14 +176,13 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { * that the {@code if (!commentChecks.isEmpty())} condition cannot be removed. */ @Test - public void testConditionRequiredWithoutCommentChecks() throws Exception { + void conditionRequiredWithoutCommentChecks() throws Exception { final String[] expected = { "10:1: " + getCheckMessage( OneTopLevelClassCheck.class, OneTopLevelClassCheck.MSG_KEY, "InputTreeWalkerInner"), }; - try (MockedStatic parser = - Mockito.mockStatic(JavaParser.class, CALLS_REAL_METHODS)) { + try (MockedStatic parser = mockStatic(JavaParser.class, CALLS_REAL_METHODS)) { // Ensure that there is no calls to walk(..., AstState.WITH_COMMENTS) parser .when(() -> JavaParser.appendHiddenCommentNodes(any(DetailAST.class))) @@ -191,7 +193,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testImproperFileExtension() throws Exception { + void improperFileExtension() throws Exception { final String regularFilePath = getPath("InputTreeWalkerImproperFileExtension.java"); final File originalFile = new File(regularFilePath); final File tempFile = new File(temporaryFolder, "file.pdf"); @@ -201,7 +203,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testAcceptableTokens() throws Exception { + void acceptableTokens() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HiddenFieldCheck.class); checkConfig.addProperty("tokens", "VARIABLE_DEF, ENUM_DEF, CLASS_DEF, METHOD_DEF," + "IMPORT"); try { @@ -225,22 +227,22 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testOnEmptyFile() throws Exception { + void onEmptyFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HiddenFieldCheck.class); - final File emptyFile = File.createTempFile("file", ".java", temporaryFolder); + final File emptyFile = Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile(); execute(checkConfig, emptyFile.getPath()); final long fileSize = Files.size(emptyFile.toPath()); assertWithMessage("File should be empty").that(fileSize).isEqualTo(0); } @Test - public void testWithCheckNotHavingTreeWalkerAsParent() throws Exception { + void withCheckNotHavingTreeWalkerAsParent() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(JavadocPackageCheck.class); try { execute( createTreeWalkerConfig(checkConfig), - File.createTempFile("junit", null, temporaryFolder).getPath()); + Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile().getPath()); assertWithMessage("CheckstyleException is expected").fail(); } catch (CheckstyleException exception) { assertWithMessage("Error message is unexpected") @@ -250,7 +252,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testSetupChildExceptions() { + void setupChildExceptions() { final TreeWalker treeWalker = new TreeWalker(); final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), Thread.currentThread().getContextClassLoader()); @@ -271,7 +273,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testSettersForParameters() throws Exception { + void settersForParameters() throws Exception { final TreeWalker treeWalker = new TreeWalker(); final DefaultConfiguration config = new DefaultConfiguration("default config"); treeWalker.setTabWidth(1); @@ -284,9 +286,10 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testForInvalidCheckImplementation() throws Exception { + void forInvalidCheckImplementation() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(BadJavaDocCheck.class); - final String pathToEmptyFile = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String pathToEmptyFile = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); try { execute(checkConfig, pathToEmptyFile); @@ -307,7 +310,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testProcessNonJavaFiles() throws Exception { + void processNonJavaFiles() throws Exception { final TreeWalker treeWalker = new TreeWalker(); final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), Thread.currentThread().getContextClassLoader()); @@ -335,7 +338,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testProcessNonJavaFilesWithoutException() throws Exception { + void processNonJavaFilesWithoutException() throws Exception { final TreeWalker treeWalker = new TreeWalker(); treeWalker.setTabWidth(1); treeWalker.configure(new DefaultConfiguration("default config")); @@ -347,14 +350,14 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testWithCacheWithNoViolation() throws Exception { + void withCacheWithNoViolation() throws Exception { final String path = getPath("InputTreeWalkerWithCacheWithNoViolation.java"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(path, expected); } @Test - public void testProcessWithParserThrowable() throws Exception { + void processWithParserThrowable() throws Exception { final TreeWalker treeWalker = new TreeWalker(); treeWalker.configure(createModuleConfig(TypeNameCheck.class)); final PackageObjectFactory factory = @@ -377,7 +380,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testProcessWithRecognitionException() throws Exception { + void processWithRecognitionException() throws Exception { final TreeWalker treeWalker = new TreeWalker(); treeWalker.configure(createModuleConfig(TypeNameCheck.class)); final PackageObjectFactory factory = @@ -400,9 +403,9 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testRequiredTokenIsEmptyIntArray() throws Exception { + void requiredTokenIsEmptyIntArray() throws Exception { final File file = new File(temporaryFolder, "file.java"); - try (Writer writer = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) { + try (Writer writer = Files.newBufferedWriter(file.toPath(), UTF_8)) { final String configComment = "/*\n" + "com.puppycrawl.tools.checkstyle.TreeWalkerTest" @@ -415,7 +418,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testBehaviourWithZeroChecks() throws Exception { + void behaviourWithZeroChecks() throws Exception { final TreeWalker treeWalker = new TreeWalker(); final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), Thread.currentThread().getContextClassLoader()); @@ -430,7 +433,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testBehaviourWithOrdinaryAndCommentChecks() throws Exception { + void behaviourWithOrdinaryAndCommentChecks() throws Exception { final TreeWalker treeWalker = new TreeWalker(); treeWalker.configure(createModuleConfig(TypeNameCheck.class)); treeWalker.configure(createModuleConfig(CommentsIndentationCheck.class)); @@ -457,7 +460,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testSetupChild() throws Exception { + void setupChild() throws Exception { final TreeWalker treeWalker = new TreeWalker(); final PackageObjectFactory factory = new PackageObjectFactory(new HashSet<>(), Thread.currentThread().getContextClassLoader()); @@ -477,7 +480,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testBehaviourWithChecksAndFilters() throws Exception { + void behaviourWithChecksAndFilters() throws Exception { final String[] expected = { "17:17: " @@ -492,7 +495,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testMultiCheckOrder() throws Exception { + void multiCheckOrder() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(WhitespaceAfterCheck.class, "ws.notFollowed", "if"), @@ -503,7 +506,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testMultiCheckOfSameTypeNoIdResultsInOrderingByHash() throws Exception { + void multiCheckOfSameTypeNoIdResultsInOrderingByHash() throws Exception { final String[] expected = { "15:28: " @@ -521,7 +524,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testFinishLocalSetupFullyInitialized() { + void finishLocalSetupFullyInitialized() { final TreeWalker treeWalker = new TreeWalker(); treeWalker.setSeverity("error"); treeWalker.setTabWidth(100); @@ -537,18 +540,18 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testCheckInitIsCalledInTreeWalker() throws Exception { + void checkInitIsCalledInTreeWalker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(VerifyInitCheck.class); - final File file = File.createTempFile("file", ".pdf", temporaryFolder); + final File file = Files.createTempFile(temporaryFolder.toPath(), "file", ".pdf").toFile(); execute(checkConfig, file.getPath()); assertWithMessage("Init was not called").that(VerifyInitCheck.isInitWasCalled()).isTrue(); } @Test - public void testCheckDestroyIsCalledInTreeWalker() throws Exception { + void checkDestroyIsCalledInTreeWalker() throws Exception { VerifyDestroyCheck.resetDestroyWasCalled(); final DefaultConfiguration checkConfig = createModuleConfig(VerifyDestroyCheck.class); - final File file = File.createTempFile("file", ".pdf", temporaryFolder); + final File file = Files.createTempFile(temporaryFolder.toPath(), "file", ".pdf").toFile(); execute(checkConfig, file.getPath()); assertWithMessage("Destroy was not called") .that(VerifyDestroyCheck.isDestroyWasCalled()) @@ -556,10 +559,10 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testCommentCheckDestroyIsCalledInTreeWalker() throws Exception { + void commentCheckDestroyIsCalledInTreeWalker() throws Exception { VerifyDestroyCheck.resetDestroyWasCalled(); final DefaultConfiguration checkConfig = createModuleConfig(VerifyDestroyCommentCheck.class); - final File file = File.createTempFile("file", ".pdf", temporaryFolder); + final File file = Files.createTempFile(temporaryFolder.toPath(), "file", ".pdf").toFile(); execute(checkConfig, file.getPath()); assertWithMessage("Destroy was not called") .that(VerifyDestroyCheck.isDestroyWasCalled()) @@ -567,17 +570,18 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testCacheWhenFileExternalResourceContentDoesNotChange() throws Exception { + void cacheWhenFileExternalResourceContentDoesNotChange() throws Exception { final DefaultConfiguration filterConfig = createModuleConfig(SuppressionXpathFilter.class); filterConfig.addProperty("file", getPath("InputTreeWalkerSuppressionXpathFilter.xml")); final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class); treeWalkerConfig.addChild(filterConfig); final DefaultConfiguration checkerConfig = createRootConfig(treeWalkerConfig); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); - final String filePath = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); execute(checkerConfig, filePath); // One more time to use cache. @@ -589,7 +593,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testTreeWalkerFilterAbsolutePath() throws Exception { + void treeWalkerFilterAbsolutePath() throws Exception { // test is only valid when relative paths are given final String filePath = "src/test/resources/" @@ -601,7 +605,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { } @Test - public void testExternalResourceFiltersWithNoExternalResource() throws Exception { + void externalResourceFiltersWithNoExternalResource() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(EmptyStatementCheck.class); final DefaultConfiguration filterConfig = createModuleConfig(SuppressWithNearbyCommentFilter.class); @@ -610,9 +614,10 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { treeWalkerConfig.addChild(filterConfig); final DefaultConfiguration checkerConfig = createRootConfig(treeWalkerConfig); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); - final String filePath = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); execute(checkerConfig, filePath); @@ -626,7 +631,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { * @throws Exception if file is not found */ @Test - public void testOrderOfCheckExecution() throws Exception { + void orderOfCheckExecution() throws Exception { final DefaultConfiguration configuration1 = createModuleConfig(AaCheck.class); configuration1.addProperty("id", "2"); @@ -637,7 +642,7 @@ public class TreeWalkerTest extends AbstractModuleTestSupport { treeWalkerConfig.addChild(configuration2); treeWalkerConfig.addChild(configuration1); - final List files = Collections.singletonList(new File(getPath("InputTreeWalker2.java"))); + final List files = ImmutableList.of(new File(getPath("InputTreeWalker2.java"))); final Checker checker = createChecker(treeWalkerConfig); try { --- a/src/test/java/com/puppycrawl/tools/checkstyle/XMLLoggerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/XMLLoggerTest.java @@ -34,7 +34,7 @@ import org.junit.jupiter.api.Test; /** Enter a description of class XMLLoggerTest.java. */ // -@cs[AbbreviationAsWordInName] Test should be named as its main class. -public class XMLLoggerTest extends AbstractXmlTestSupport { +final class XMLLoggerTest extends AbstractXmlTestSupport { /** * Output stream to hold the test results. The IntelliJ IDEA issues the AutoCloseableResource @@ -50,7 +50,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testEncode() throws IOException { + void encode() throws IOException { final XMLLogger test = new XMLLogger(outStream, OutputStreamOptions.NONE); assertWithMessage("should be able to create XMLLogger without issue").that(test).isNotNull(); final String[][] encodings = { @@ -75,7 +75,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testIsReference() throws IOException { + void isReference() throws IOException { final XMLLogger test = new XMLLogger(outStream, OutputStreamOptions.NONE); assertWithMessage("should be able to create XMLLogger without issue").that(test).isNotNull(); final String[] references = { @@ -97,7 +97,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testCloseStream() throws Exception { + void closeStream() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); logger.auditFinished(null); @@ -108,7 +108,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testNoCloseStream() throws Exception { + void noCloseStream() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.NONE); logger.auditStarted(null); logger.auditFinished(null); @@ -120,7 +120,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testFileStarted() throws Exception { + void fileStarted() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final AuditEvent ev = new AuditEvent(this, "Test.java"); @@ -131,7 +131,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testFileFinished() throws Exception { + void fileFinished() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final AuditEvent ev = new AuditEvent(this, "Test.java"); @@ -141,7 +141,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddError() throws Exception { + void addError() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -156,7 +156,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddErrorWithNullFileName() throws Exception { + void addErrorWithNullFileName() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -170,7 +170,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddErrorModuleId() throws Exception { + void addErrorModuleId() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -191,7 +191,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddErrorOnZeroColumns() throws Exception { + void addErrorOnZeroColumns() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -206,7 +206,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddIgnored() throws Exception { + void addIgnored() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -219,7 +219,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddException() throws Exception { + void addException() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -232,7 +232,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddExceptionWithNullFileName() throws Exception { + void addExceptionWithNullFileName() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -245,7 +245,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddExceptionAfterFileStarted() throws Exception { + void addExceptionAfterFileStarted() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); @@ -264,7 +264,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddExceptionBeforeFileFinished() throws Exception { + void addExceptionBeforeFileFinished() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -279,7 +279,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAddExceptionBetweenFileStartedAndFinished() throws Exception { + void addExceptionBetweenFileStartedAndFinished() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final Violation violation = @@ -296,7 +296,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testAuditFinishedWithoutFileFinished() throws Exception { + void auditFinishedWithoutFileFinished() throws Exception { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.auditStarted(null); final AuditEvent fileStartedEvent = new AuditEvent(this, "Test.java"); @@ -314,7 +314,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testNullOutputStreamOptions() { + void nullOutputStreamOptions() { try { final XMLLogger logger = new XMLLogger(outStream, (OutputStreamOptions) null); // assert required to calm down eclipse's 'The allocated object is never used' violation @@ -328,7 +328,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { } @Test - public void testFinishLocalSetup() { + void finishLocalSetup() { final XMLLogger logger = new XMLLogger(outStream, OutputStreamOptions.CLOSE); logger.finishLocalSetup(); logger.auditStarted(null); @@ -338,7 +338,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { /** We keep this test for 100% coverage. Until #12873. */ @Test - public void testCtorWithTwoParametersCloseStreamOptions() { + void ctorWithTwoParametersCloseStreamOptions() { final XMLLogger logger = new XMLLogger(outStream, AutomaticBean.OutputStreamOptions.CLOSE); final boolean closeStream = TestUtil.getInternalState(logger, "closeStream"); @@ -347,7 +347,7 @@ public class XMLLoggerTest extends AbstractXmlTestSupport { /** We keep this test for 100% coverage. Until #12873. */ @Test - public void testCtorWithTwoParametersNoneStreamOptions() { + void ctorWithTwoParametersNoneStreamOptions() { final XMLLogger logger = new XMLLogger(outStream, AutomaticBean.OutputStreamOptions.NONE); final boolean closeStream = TestUtil.getInternalState(logger, "closeStream"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/XdocsPropertyTypeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/XdocsPropertyTypeTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle; import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.stream.Collectors.toUnmodifiableSet; import com.puppycrawl.tools.checkstyle.checks.header.AbstractHeaderCheck; import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil; @@ -28,14 +29,13 @@ import java.io.IOException; import java.util.Arrays; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.jupiter.api.Test; -public class XdocsPropertyTypeTest { +final class XdocsPropertyTypeTest { @Test - public void testAllPropertyTypesAreUsed() throws IOException { + void allPropertyTypesAreUsed() throws IOException { final Set propertyTypes = Stream.concat( Stream.of(AbstractHeaderCheck.class, Checker.class), @@ -45,7 +45,7 @@ public class XdocsPropertyTypeTest { .map(field -> field.getAnnotation(XdocsPropertyType.class)) .filter(Objects::nonNull) .map(XdocsPropertyType::value) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); assertWithMessage("All property types should be used") .that(propertyTypes) @@ -53,7 +53,7 @@ public class XdocsPropertyTypeTest { } @Test - public void testAllPropertyTypesHaveDescription() { + void allPropertyTypesHaveDescription() { for (PropertyType value : PropertyType.values()) { assertWithMessage("Property type '%s' has no description", value) .that(CommonUtil.isBlank(value.getDescription())) --- a/src/test/java/com/puppycrawl/tools/checkstyle/XmlLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/XmlLoaderTest.java @@ -30,10 +30,10 @@ import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; -public class XmlLoaderTest { +final class XmlLoaderTest { @Test - public void testParserConfiguredSuccessfully() throws Exception { + void parserConfiguredSuccessfully() throws Exception { final DummyLoader dummyLoader = new DummyLoader(new HashMap<>(1)); final XMLReader parser = TestUtil.getInternalState(dummyLoader, "parser"); assertWithMessage("Invalid entity resolver") @@ -42,14 +42,14 @@ public class XmlLoaderTest { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(XmlLoader.LoadExternalDtdFeatureProvider.class)) .isTrue(); } @Test - public void testResolveEntityDefault() throws Exception { + void resolveEntityDefault() throws Exception { final Map map = new HashMap<>(); map.put("predefined", "/google.xml"); final DummyLoader dummyLoader = new DummyLoader(map); @@ -59,7 +59,7 @@ public class XmlLoaderTest { } @Test - public void testResolveEntityMap() throws Exception { + void resolveEntityMap() throws Exception { final Map map = new HashMap<>(); map.put("predefined", "/google.xml"); final DummyLoader dummyLoader = new DummyLoader(map); --- a/src/test/java/com/puppycrawl/tools/checkstyle/XpathFileGeneratorAstFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/XpathFileGeneratorAstFilterTest.java @@ -35,10 +35,10 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import org.junit.jupiter.api.Test; -public class XpathFileGeneratorAstFilterTest { +final class XpathFileGeneratorAstFilterTest { @Test - public void testAcceptNoToken() { + void acceptNoToken() { final Violation violation = new Violation( 0, 0, 0, null, null, null, null, null, XpathFileGeneratorAstFilterTest.class, null); @@ -56,7 +56,7 @@ public class XpathFileGeneratorAstFilterTest { } @Test - public void test() throws Exception { + void test() throws Exception { final Violation violation = new Violation( 3, @@ -87,7 +87,7 @@ public class XpathFileGeneratorAstFilterTest { } @Test - public void testNoXpathQuery() throws Exception { + void noXpathQuery() throws Exception { final Violation violation = new Violation( 10, @@ -116,7 +116,7 @@ public class XpathFileGeneratorAstFilterTest { } @Test - public void testTabWidth() throws Exception { + void tabWidth() throws Exception { final Violation violation = new Violation( 6, @@ -154,9 +154,9 @@ public class XpathFileGeneratorAstFilterTest { * * @throws Exception when code tested throws exception */ - @Test @SuppressWarnings("unchecked") - public void testClearState() throws Exception { + @Test + void clearState() throws Exception { final Violation violation = new Violation( 3, --- a/src/test/java/com/puppycrawl/tools/checkstyle/XpathFileGeneratorAuditListenerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/XpathFileGeneratorAuditListenerTest.java @@ -41,7 +41,7 @@ import java.io.OutputStream; import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; -public class XpathFileGeneratorAuditListenerTest { +final class XpathFileGeneratorAuditListenerTest { /** OS specific line separator. */ private static final String EOL = System.getProperty("line.separator"); @@ -90,7 +90,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testFinishLocalSetup() { + void finishLocalSetup() { final OutputStream out = new ByteArrayOutputStream(); final XpathFileGeneratorAuditListener listener = new XpathFileGeneratorAuditListener(out, OutputStreamOptions.CLOSE); @@ -103,7 +103,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testFileStarted() { + void fileStarted() { final OutputStream out = new ByteArrayOutputStream(); final XpathFileGeneratorAuditListener listener = new XpathFileGeneratorAuditListener(out, OutputStreamOptions.CLOSE); @@ -115,7 +115,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testFileFinished() { + void fileFinished() { final OutputStream out = new ByteArrayOutputStream(); final XpathFileGeneratorAuditListener listener = new XpathFileGeneratorAuditListener(out, OutputStreamOptions.CLOSE); @@ -127,7 +127,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testAddException() { + void addException() { final OutputStream out = new ByteArrayOutputStream(); final XpathFileGeneratorAuditListener logger = new XpathFileGeneratorAuditListener(out, OutputStreamOptions.CLOSE); @@ -147,7 +147,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testCorrectOne() { + void correctOne() { final AuditEvent event = createAuditEvent("InputXpathFileGeneratorAuditListener.java", FIRST_MESSAGE); @@ -180,7 +180,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testCorrectTwo() { + void correctTwo() { final AuditEvent event1 = createAuditEvent("InputXpathFileGeneratorAuditListener.java", SECOND_MESSAGE); @@ -227,7 +227,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testOnlyOneMatching() { + void onlyOneMatching() { final AuditEvent event1 = createAuditEvent( "InputXpathFileGeneratorAuditListener.java", 10, 5, MethodParamPadCheck.class); @@ -268,7 +268,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testCloseStream() { + void closeStream() { final XpathFileGeneratorAuditListener listener = new XpathFileGeneratorAuditListener(outStream, OutputStreamOptions.CLOSE); listener.finishLocalSetup(); @@ -279,7 +279,7 @@ public class XpathFileGeneratorAuditListenerTest { } @Test - public void testNoCloseStream() { + void noCloseStream() { final XpathFileGeneratorAuditListener listener = new XpathFileGeneratorAuditListener(outStream, OutputStreamOptions.NONE); listener.finishLocalSetup(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTaskTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle.ant; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.truth.StandardSubjectBuilder; @@ -35,7 +36,6 @@ import com.puppycrawl.tools.checkstyle.internal.testmodules.TestRootModuleChecke import java.io.File; import java.io.IOException; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; import java.util.List; @@ -52,7 +52,7 @@ import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.resources.FileResource; import org.junit.jupiter.api.Test; -public class CheckstyleAntTaskTest extends AbstractPathTestSupport { +final class CheckstyleAntTaskTest extends AbstractPathTestSupport { private static final String FLAWLESS_INPUT = "InputCheckstyleAntTaskFlawless.java"; private static final String VIOLATED_INPUT = "InputCheckstyleAntTaskError.java"; @@ -80,7 +80,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testDefaultFlawless() throws IOException { + final void defaultFlawless() throws IOException { TestRootModuleChecker.reset(); final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE); antTask.setFile(new File(getPath(FLAWLESS_INPUT))); @@ -92,7 +92,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testPathsOneFile() throws IOException { + final void pathsOneFile() throws IOException { // given TestRootModuleChecker.reset(); @@ -118,7 +118,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testPathsFileWithLogVerification() throws IOException { + final void pathsFileWithLogVerification() throws IOException { // given TestRootModuleChecker.reset(); final CheckstyleAntTaskLogStub antTask = new CheckstyleAntTaskLogStub(); @@ -169,7 +169,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testPathsDirectoryWithNestedFile() throws IOException { + final void pathsDirectoryWithNestedFile() throws IOException { // given TestRootModuleChecker.reset(); @@ -200,7 +200,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testCustomRootModule() throws IOException { + final void customRootModule() throws IOException { TestRootModuleChecker.reset(); final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE); @@ -213,7 +213,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testFileSet() throws IOException { + final void fileSet() throws IOException { TestRootModuleChecker.reset(); final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE); final FileSet examinationFileSet = new FileSet(); @@ -232,7 +232,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testNoConfigFile() throws IOException { + final void noConfigFile() throws IOException { final CheckstyleAntTask antTask = new CheckstyleAntTask(); antTask.setProject(new Project()); antTask.setFile(new File(getPath(FLAWLESS_INPUT))); @@ -244,7 +244,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testNonExistentConfig() throws IOException { + final void nonExistentConfig() throws IOException { final CheckstyleAntTask antTask = new CheckstyleAntTask(); antTask.setConfig(getPath(NOT_EXISTING_FILE)); antTask.setProject(new Project()); @@ -257,7 +257,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testEmptyConfigFile() throws IOException { + final void emptyConfigFile() throws IOException { final CheckstyleAntTask antTask = new CheckstyleAntTask(); antTask.setConfig(getPath("InputCheckstyleAntTaskEmptyConfig.xml")); antTask.setProject(new Project()); @@ -270,7 +270,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testNoFile() throws IOException { + final void noFile() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); final BuildException ex = assertThrows(BuildException.class, antTask::execute, "BuildException is expected"); @@ -280,7 +280,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testMaxWarningExceeded() throws IOException { + final void maxWarningExceeded() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(WARNING_INPUT))); antTask.setMaxWarnings(0); @@ -292,7 +292,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testMaxErrors() throws IOException { + final void maxErrors() throws IOException { TestRootModuleChecker.reset(); final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE); @@ -306,7 +306,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testFailureProperty() throws IOException { + final void failureProperty() throws IOException { final CheckstyleAntTask antTask = new CheckstyleAntTask(); antTask.setConfig(getPath(CONFIG_FILE)); antTask.setFile(new File(getPath(VIOLATED_INPUT))); @@ -330,7 +330,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testOverrideProperty() throws IOException { + final void overrideProperty() throws IOException { TestRootModuleChecker.reset(); final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE); @@ -347,7 +347,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testExecuteIgnoredModules() throws IOException { + final void executeIgnoredModules() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(VIOLATED_INPUT))); antTask.setFailOnViolation(false); @@ -390,7 +390,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testConfigurationByUrl() throws IOException { + final void configurationByUrl() throws IOException { final CheckstyleAntTask antTask = new CheckstyleAntTask(); antTask.setProject(new Project()); final URL url = new File(getPath(CONFIG_FILE)).toURI().toURL(); @@ -414,7 +414,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testConfigurationByResource() throws IOException { + final void configurationByResource() throws IOException { final CheckstyleAntTask antTask = new CheckstyleAntTask(); antTask.setProject(new Project()); antTask.setConfig(getPath(CONFIG_FILE)); @@ -437,7 +437,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testSimultaneousConfiguration() throws IOException { + final void simultaneousConfiguration() throws IOException { final File file = new File(getPath(CONFIG_FILE)); final URL url = file.toURI().toURL(); @@ -453,7 +453,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testSetPropertiesFile() throws IOException { + final void setPropertiesFile() throws IOException { TestRootModuleChecker.reset(); final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE); @@ -467,7 +467,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testSetPropertiesNonExistentFile() throws IOException { + final void setPropertiesNonExistentFile() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(FLAWLESS_INPUT))); antTask.setProperties(new File(getPath(NOT_EXISTING_FILE))); @@ -479,7 +479,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testXmlOutput() throws IOException { + final void xmlOutput() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(VIOLATED_INPUT))); antTask.setFailOnViolation(false); @@ -506,7 +506,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testSarifOutput() throws IOException { + final void sarifOutput() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(VIOLATED_INPUT))); antTask.setFailOnViolation(false); @@ -538,7 +538,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testCreateListenerException() throws IOException { + final void createListenerException() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(FLAWLESS_INPUT))); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -553,7 +553,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testCreateListenerExceptionWithXmlLogger() throws IOException { + final void createListenerExceptionWithXmlLogger() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(FLAWLESS_INPUT))); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -571,7 +571,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testCreateListenerExceptionWithSarifLogger() throws IOException { + final void createListenerExceptionWithSarifLogger() throws IOException { final CheckstyleAntTask antTask = getCheckstyleAntTask(); antTask.setFile(new File(getPath(FLAWLESS_INPUT))); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -589,7 +589,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testSetInvalidType() { + void setInvalidType() { final CheckstyleAntTask.FormatterType formatterType = new CheckstyleAntTask.FormatterType(); final BuildException ex = assertThrows( @@ -602,7 +602,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testSetFileValueByFile() throws IOException { + void setFileValueByFile() throws IOException { final String filename = getPath("InputCheckstyleAntTaskCheckstyleAntTest.properties"); final CheckstyleAntTask.Property property = new CheckstyleAntTask.Property(); property.setFile(new File(filename)); @@ -612,7 +612,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testDefaultLoggerListener() throws IOException { + void defaultLoggerListener() throws IOException { final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); formatter.setUseFile(false); assertWithMessage("Listener instance has unexpected type") @@ -621,7 +621,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testDefaultLoggerListenerWithToFile() throws IOException { + void defaultLoggerListenerWithToFile() throws IOException { final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); formatter.setUseFile(false); formatter.setTofile(new File("target/")); @@ -631,7 +631,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testXmlLoggerListener() throws IOException { + void xmlLoggerListener() throws IOException { final CheckstyleAntTask.FormatterType formatterType = new CheckstyleAntTask.FormatterType(); formatterType.setValue("xml"); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -643,7 +643,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testXmlLoggerListenerWithToFile() throws IOException { + void xmlLoggerListenerWithToFile() throws IOException { final CheckstyleAntTask.FormatterType formatterType = new CheckstyleAntTask.FormatterType(); formatterType.setValue("xml"); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -656,7 +656,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testDefaultLoggerWithNullToFile() throws IOException { + void defaultLoggerWithNullToFile() throws IOException { final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); formatter.setTofile(null); assertWithMessage("Listener instance has unexpected type") @@ -665,7 +665,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testXmlLoggerWithNullToFile() throws IOException { + void xmlLoggerWithNullToFile() throws IOException { final CheckstyleAntTask.FormatterType formatterType = new CheckstyleAntTask.FormatterType(); formatterType.setValue("xml"); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -677,7 +677,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testSarifLoggerListener() throws IOException { + void sarifLoggerListener() throws IOException { final CheckstyleAntTask.FormatterType formatterType = new CheckstyleAntTask.FormatterType(); formatterType.setValue("sarif"); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -689,7 +689,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testSarifLoggerListenerWithToFile() throws IOException { + void sarifLoggerListenerWithToFile() throws IOException { final CheckstyleAntTask.FormatterType formatterType = new CheckstyleAntTask.FormatterType(); formatterType.setValue("sarif"); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -702,7 +702,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testSarifLoggerWithNullToFile() throws IOException { + void sarifLoggerWithNullToFile() throws IOException { final CheckstyleAntTask.FormatterType formatterType = new CheckstyleAntTask.FormatterType(); formatterType.setValue("sarif"); final CheckstyleAntTask.Formatter formatter = new CheckstyleAntTask.Formatter(); @@ -715,14 +715,14 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { /** Testing deprecated method. */ @Test - public void testCreateClasspath() { + void createClasspath() { final CheckstyleAntTask antTask = new CheckstyleAntTask(); assertWithMessage("Invalid classpath").that(antTask.createClasspath().toString()).isEmpty(); } @Test - public void testDestroyed() throws IOException { + void destroyed() throws IOException { TestRootModuleChecker.reset(); final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE); @@ -736,7 +736,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testMaxWarnings() throws IOException { + void maxWarnings() throws IOException { TestRootModuleChecker.reset(); final CheckstyleAntTask antTask = getCheckstyleAntTask(CUSTOM_ROOT_CONFIG_FILE); @@ -750,7 +750,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public final void testExecuteLogOutput() throws Exception { + final void executeLogOutput() throws Exception { final URL url = new File(getPath(CONFIG_FILE)).toURI().toURL(); final ResourceBundle bundle = ResourceBundle.getBundle(Definitions.CHECKSTYLE_BUNDLE, Locale.ROOT); @@ -795,7 +795,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testCheckerException() throws IOException { + void checkerException() throws IOException { final CheckstyleAntTask antTask = new CheckstyleAntTaskStub(); antTask.setConfig(getPath(CONFIG_FILE)); antTask.setProject(new Project()); @@ -809,7 +809,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } @Test - public void testLoggedTime() throws IOException { + void loggedTime() throws IOException { final CheckstyleAntTaskLogStub antTask = new CheckstyleAntTaskLogStub(); antTask.setConfig(getPath(CONFIG_FILE)); antTask.setProject(new Project()); @@ -835,7 +835,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { .that(optionalMessageLevelPair.isPresent()) .isTrue(); - final long actualTime = getNumberFromLine(optionalMessageLevelPair.get().getMsg()); + final long actualTime = getNumberFromLine(optionalMessageLevelPair.orElseThrow().getMsg()); assertWithMessage( "Logged time in '" + expectedMsg + "' " + "must be less than the testing time") @@ -844,7 +844,7 @@ public class CheckstyleAntTaskTest extends AbstractPathTestSupport { } private static List readWholeFile(File outputFile) throws IOException { - return Files.readAllLines(outputFile.toPath(), StandardCharsets.UTF_8); + return Files.readAllLines(outputFile.toPath(), UTF_8); } private static long getNumberFromLine(String line) { --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/AbstractCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/AbstractCheckTest.java @@ -20,8 +20,9 @@ package com.puppycrawl.tools.checkstyle.api; import static com.google.common.truth.Truth.assertWithMessage; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.DetailAstImpl; @@ -29,7 +30,6 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import java.nio.charset.Charset; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -37,7 +37,7 @@ import java.util.Set; import java.util.SortedSet; import org.junit.jupiter.api.Test; -public class AbstractCheckTest extends AbstractModuleTestSupport { +final class AbstractCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -45,7 +45,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AbstractCheck check = new AbstractCheck() { @Override @@ -70,7 +70,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptable() { + void getAcceptable() { final AbstractCheck check = new AbstractCheck() { @Override @@ -95,7 +95,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentNodes() { + void commentNodes() { final AbstractCheck check = new AbstractCheck() { @Override @@ -118,7 +118,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokenNames() { + void tokenNames() { final AbstractCheck check = new AbstractCheck() { @Override @@ -144,7 +144,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitToken() { + void visitToken() { final VisitCounterCheck check = new VisitCounterCheck(); // Eventually it will become clear abstract method check.visitToken(null); @@ -153,7 +153,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetLine() throws Exception { + void getLine() throws Exception { final AbstractCheck check = new AbstractCheck() { @Override @@ -181,7 +181,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetLineCodePoints() throws Exception { + void getLineCodePoints() throws Exception { final AbstractCheck check = new AbstractCheck() { @Override @@ -213,7 +213,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetTabWidth() { + void getTabWidth() { final AbstractCheck check = new AbstractCheck() { @Override @@ -238,7 +238,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileContents() { + void fileContents() { final AbstractCheck check = new AbstractCheck() { @Override @@ -268,7 +268,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final int[] defaultTokens = {TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF}; final int[] acceptableTokens = {TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF}; final int[] requiredTokens = {TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF}; @@ -302,7 +302,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testClearViolations() { + void clearViolations() { final AbstractCheck check = new DummyAbstractCheck(); check.log(1, "key", "args"); @@ -312,11 +312,11 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testLineColumnLog() throws Exception { + void lineColumnLog() throws Exception { final ViolationCheck check = new ViolationCheck(); check.configure(new DefaultConfiguration("check")); final File file = new File("fileName"); - final FileText theText = new FileText(file, Collections.singletonList("test123")); + final FileText theText = new FileText(file, ImmutableList.of("test123")); check.setFileContents(new FileContents(theText)); check.clearViolations(); @@ -338,11 +338,11 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testAstLog() throws Exception { + void astLog() throws Exception { final ViolationAstCheck check = new ViolationAstCheck(); check.configure(new DefaultConfiguration("check")); final File file = new File("fileName"); - final FileText theText = new FileText(file, Collections.singletonList("test123")); + final FileText theText = new FileText(file, ImmutableList.of("test123")); check.setFileContents(new FileContents(theText)); check.clearViolations(); @@ -362,7 +362,7 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheck() throws Exception { + void check() throws Exception { final String[] expected = { "6:1: Violation.", }; @@ -375,10 +375,11 @@ public class AbstractCheckTest extends AbstractModuleTestSupport { * file as none of the checks try to modify the tokens. */ @Test - public void testTokensAreUnmodifiable() { + void tokensAreUnmodifiable() { final DummyAbstractCheck check = new DummyAbstractCheck(); final Set tokenNameSet = check.getTokenNames(); - assertThrows(UnsupportedOperationException.class, () -> tokenNameSet.add("")); + assertThatThrownBy(() -> tokenNameSet.add("")) + .isInstanceOf(UnsupportedOperationException.class); } public static final class DummyAbstractCheck extends AbstractCheck { --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/AbstractFileSetCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/AbstractFileSetCheckTest.java @@ -21,19 +21,19 @@ package com.puppycrawl.tools.checkstyle.api; import static com.google.common.truth.Truth.assertWithMessage; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import java.io.File; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; import org.junit.jupiter.api.Test; -public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { +final class AbstractFileSetCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,17 +41,17 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testTabWidth() { + void tabWidth() { final DummyFileSetCheck check = new DummyFileSetCheck(); check.setTabWidth(12345); assertWithMessage("expected tab width").that(check.getTabWidth()).isEqualTo(12345); } @Test - public void testFileContents() { + void fileContents() { final FileContents contents = new FileContents( - new FileText(new File("inputAbstractFileSetCheck.tmp"), Collections.emptyList())); + new FileText(new File("inputAbstractFileSetCheck.tmp"), ImmutableList.of())); final DummyFileSetCheck check = new DummyFileSetCheck(); check.setFileContents(contents); assertWithMessage("expected file contents") @@ -60,13 +60,13 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testProcessSequential() throws Exception { + void processSequential() throws Exception { final DummyFileSetCheck check = new DummyFileSetCheck(); check.configure(new DefaultConfiguration("filesetcheck")); check.setFileExtensions("tmp"); final File firstFile = new File("inputAbstractFileSetCheck.tmp"); final SortedSet firstFileMessages = - check.process(firstFile, new FileText(firstFile, Collections.emptyList())); + check.process(firstFile, new FileText(firstFile, ImmutableList.of())); assertWithMessage("Invalid message") .that(firstFileMessages.first().getViolation()) @@ -86,25 +86,25 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotProcessed() throws Exception { + void notProcessed() throws Exception { final ExceptionFileSetCheck check = new ExceptionFileSetCheck(); check.setFileExtensions("java"); final File firstFile = new File("inputAbstractFileSetCheck.tmp"); - check.process(firstFile, new FileText(firstFile, Collections.emptyList())); + check.process(firstFile, new FileText(firstFile, ImmutableList.of())); final SortedSet internalMessages = check.getViolations(); assertWithMessage("Internal message should be empty").that(internalMessages).isEmpty(); } @Test - public void testProcessException() throws Exception { + void processException() throws Exception { final ExceptionFileSetCheck check = new ExceptionFileSetCheck(); check.configure(new DefaultConfiguration("filesetcheck")); check.setFileExtensions("tmp"); final File firstFile = new File("inputAbstractFileSetCheck.tmp"); - final FileText fileText = new FileText(firstFile, Collections.emptyList()); + final FileText fileText = new FileText(firstFile, ImmutableList.of()); try { check.process(firstFile, fileText); assertWithMessage("Exception is expected").fail(); @@ -118,7 +118,7 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { // again to prove only 1 violation exists final File secondFile = new File("inputAbstractFileSetCheck.tmp"); - final FileText fileText2 = new FileText(secondFile, Collections.emptyList()); + final FileText fileText2 = new FileText(secondFile, ImmutableList.of()); try { check.process(secondFile, fileText2); assertWithMessage("Exception is expected").fail(); @@ -134,7 +134,7 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetFileExtension() { + void getFileExtension() { final DummyFileSetCheck check = new DummyFileSetCheck(); check.setFileExtensions("tmp", ".java"); final String[] expectedExtensions = {".tmp", ".java"}; @@ -146,7 +146,7 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { /** This javadoc exists only to suppress IntelliJ IDEA inspection. */ @Test - public void testSetExtensionThrowsExceptionWhenTheyAreNull() { + void setExtensionThrowsExceptionWhenTheyAreNull() { final DummyFileSetCheck check = new DummyFileSetCheck(); try { check.setFileExtensions((String[]) null); @@ -159,7 +159,7 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testLineColumnLog() throws Exception { + void lineColumnLog() throws Exception { final ViolationFileSetCheck check = new ViolationFileSetCheck(); check.configure(new DefaultConfiguration("filesetcheck")); final File file = new File(getPath("InputAbstractFileSetLineColumn.java")); @@ -174,7 +174,7 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetMessageDispatcher() { + void getMessageDispatcher() { final DummyFileSetCheck check = new DummyFileSetCheck(); final Checker checker = new Checker(); check.setMessageDispatcher(checker); @@ -185,7 +185,7 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheck() throws Exception { + void check() throws Exception { final String[] expected = { "1:1: Violation.", }; @@ -193,7 +193,7 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiFileFireErrors() throws Exception { + void multiFileFireErrors() throws Exception { final MultiFileViolationFileSetCheck check = new MultiFileViolationFileSetCheck(); check.configure(new DefaultConfiguration("filesetcheck")); final ViolationDispatcher dispatcher = new ViolationDispatcher(); @@ -227,7 +227,7 @@ public class AbstractFileSetCheckTest extends AbstractModuleTestSupport { * as none of the checks try to modify the fileExtensions. */ @Test - public void testCopiedArrayIsReturned() { + void copiedArrayIsReturned() { final DummyFileSetCheck check = new DummyFileSetCheck(); check.setFileExtensions(".tmp"); assertWithMessage("Extensions should be copied") --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/AbstractViolationReporterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/AbstractViolationReporterTest.java @@ -28,7 +28,7 @@ import java.util.SortedSet; import org.junit.jupiter.api.Test; /** Tests to ensure that default message bundle is determined correctly. */ -public class AbstractViolationReporterTest { +final class AbstractViolationReporterTest { private final AbstractCheck emptyCheck = new EmptyCheck(); @@ -37,7 +37,7 @@ public class AbstractViolationReporterTest { } @Test - public void testGetMessageBundleWithPackage() throws Exception { + void getMessageBundleWithPackage() throws Exception { assertWithMessage("violation bundle differs from expected") .that( TestUtil.invokeStaticMethod( @@ -48,7 +48,7 @@ public class AbstractViolationReporterTest { } @Test - public void testGetMessageBundleWithoutPackage() throws Exception { + void getMessageBundleWithoutPackage() throws Exception { assertWithMessage("violation bundle differs from expected") .that( TestUtil.invokeStaticMethod( @@ -57,13 +57,13 @@ public class AbstractViolationReporterTest { } @Test - public void testCustomId() { + void customId() { emptyCheck.setId("MyId"); assertWithMessage("Id differs from expected").that(emptyCheck.getId()).isEqualTo("MyId"); } @Test - public void testSeverity() throws Exception { + void severity() throws Exception { final DefaultConfiguration config = createModuleConfig(emptyCheck.getClass()); config.addMessage("severity", "error"); emptyCheck.configure(config); @@ -75,7 +75,7 @@ public class AbstractViolationReporterTest { } @Test - public void testCustomMessage() throws Exception { + void customMessage() throws Exception { final DefaultConfiguration config = createModuleConfig(emptyCheck.getClass()); config.addMessage("msgKey", "This is a custom violation."); emptyCheck.configure(config); @@ -91,7 +91,7 @@ public class AbstractViolationReporterTest { } @Test - public void testCustomMessageWithParameters() throws Exception { + void customMessageWithParameters() throws Exception { final DefaultConfiguration config = createModuleConfig(emptyCheck.getClass()); config.addMessage("msgKey", "This is a custom violation with {0}."); emptyCheck.configure(config); @@ -107,7 +107,7 @@ public class AbstractViolationReporterTest { } @Test - public void testCustomMessageWithParametersNegative() throws Exception { + void customMessageWithParametersNegative() throws Exception { final DefaultConfiguration config = createModuleConfig(emptyCheck.getClass()); config.addMessage("msgKey", "This is a custom violation {0."); emptyCheck.configure(config); --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/AuditEventTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/AuditEventTest.java @@ -24,10 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -public class AuditEventTest { +final class AuditEventTest { @Test - public void test() { + void test() { final AuditEvent event = new AuditEvent(getClass()); assertWithMessage("invalid file name").that(event.getFileName()).isNull(); @@ -39,7 +39,7 @@ public class AuditEventTest { } @Test - public void testNoSource() { + void noSource() { final IllegalArgumentException ex = assertThrows( IllegalArgumentException.class, @@ -49,7 +49,7 @@ public class AuditEventTest { } @Test - public void testFullConstructor() { + void fullConstructor() { final Violation message = new Violation( 1, --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/BeforeExecutionFileFilterSetTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/BeforeExecutionFileFilterSetTest.java @@ -20,17 +20,17 @@ package com.puppycrawl.tools.checkstyle.api; import static com.google.common.truth.Truth.assertWithMessage; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.puppycrawl.tools.checkstyle.filefilters.BeforeExecutionExclusionFileFilter; import java.util.Set; import java.util.regex.Pattern; import org.junit.jupiter.api.Test; -public class BeforeExecutionFileFilterSetTest { +final class BeforeExecutionFileFilterSetTest { @Test - public void testRemoveFilters() { + void removeFilters() { final BeforeExecutionFileFilterSet filterSet = new BeforeExecutionFileFilterSet(); final BeforeExecutionFileFilter filter = new BeforeExecutionExclusionFileFilter(); filterSet.addBeforeExecutionFileFilter(filter); @@ -39,7 +39,7 @@ public class BeforeExecutionFileFilterSetTest { } @Test - public void testAccept() { + void accept() { final String fileName = "BAD"; final BeforeExecutionExclusionFileFilter filter = new BeforeExecutionExclusionFileFilter(); filter.setFileNamePattern(Pattern.compile(fileName)); @@ -52,7 +52,7 @@ public class BeforeExecutionFileFilterSetTest { } @Test - public void testReject() { + void reject() { final String fileName = "Test"; final BeforeExecutionExclusionFileFilter filter = new BeforeExecutionExclusionFileFilter(); filter.setFileNamePattern(Pattern.compile(fileName)); @@ -65,7 +65,7 @@ public class BeforeExecutionFileFilterSetTest { } @Test - public void testGetFilters2() { + void getFilters2() { final BeforeExecutionFileFilterSet filterSet = new BeforeExecutionFileFilterSet(); filterSet.addBeforeExecutionFileFilter(new BeforeExecutionExclusionFileFilter()); assertWithMessage("size is the same") @@ -74,14 +74,14 @@ public class BeforeExecutionFileFilterSetTest { } @Test - public void testToString2() { + void toString2() { final BeforeExecutionFileFilterSet filterSet = new BeforeExecutionFileFilterSet(); filterSet.addBeforeExecutionFileFilter(new BeforeExecutionExclusionFileFilter()); assertWithMessage("size is the same").that(filterSet.toString()).isNotNull(); } @Test - public void testClear() { + void clear() { final BeforeExecutionFileFilterSet filterSet = new BeforeExecutionFileFilterSet(); filterSet.addBeforeExecutionFileFilter(new BeforeExecutionExclusionFileFilter()); @@ -102,12 +102,13 @@ public class BeforeExecutionFileFilterSetTest { done for the time being */ @Test - public void testUnmodifiableSet() { + void unmodifiableSet() { final BeforeExecutionFileFilterSet filterSet = new BeforeExecutionFileFilterSet(); final BeforeExecutionFileFilter filter = new BeforeExecutionExclusionFileFilter(); filterSet.addBeforeExecutionFileFilter(filter); final Set excFilterSet = filterSet.getBeforeExecutionFileFilters(); - assertThrows(UnsupportedOperationException.class, () -> excFilterSet.add(filter)); + assertThatThrownBy(() -> excFilterSet.add(filter)) + .isInstanceOf(UnsupportedOperationException.class); } /* @@ -115,7 +116,7 @@ public class BeforeExecutionFileFilterSetTest { useful for third party integrations. */ @Test - public void testEmptyToString() { + void emptyToString() { final BeforeExecutionFileFilterSet filterSet = new BeforeExecutionFileFilterSet(); assertWithMessage("toString() result shouldn't be an empty string") .that(filterSet.toString()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/CommentTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/CommentTest.java @@ -23,10 +23,10 @@ import static com.google.common.truth.Truth.assertWithMessage; import org.junit.jupiter.api.Test; -public class CommentTest { +final class CommentTest { @Test - public void test() { + void test() { final String[] text = {"test"}; final Comment comment = new Comment(text, 1, 2, 3); @@ -42,7 +42,7 @@ public class CommentTest { } @Test - public void testIntersects() { + void intersects() { final String[] text = {"test", "test"}; final Comment comment = new Comment(text, 2, 4, 4); @@ -55,7 +55,7 @@ public class CommentTest { } @Test - public void testIntersects2() { + void intersects2() { final String[] text = {"a"}; final Comment comment = new Comment(text, 2, 2, 2); @@ -63,7 +63,7 @@ public class CommentTest { } @Test - public void testIntersects3() { + void intersects3() { final String[] text = {"test"}; final Comment comment = new Comment(text, 1, 1, 2); --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/FileContentsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/FileContentsTest.java @@ -20,21 +20,21 @@ package com.puppycrawl.tools.checkstyle.api; import static com.google.common.truth.Truth.assertWithMessage; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.jupiter.api.Test; -public class FileContentsTest { +final class FileContentsTest { @Test - public void testTextFileName() { + void textFileName() { final FileContents fileContents = new FileContents(new FileText(new File("filename"), Arrays.asList("123", "456"))); @@ -48,36 +48,35 @@ public class FileContentsTest { } @Test - public void testIsLineBlank() { + void isLineBlank() { assertWithMessage("Invalid result") .that( - new FileContents(new FileText(new File("filename"), Collections.singletonList("123"))) + new FileContents(new FileText(new File("filename"), ImmutableList.of("123"))) .lineIsBlank(0)) .isFalse(); assertWithMessage("Invalid result") .that( - new FileContents(new FileText(new File("filename"), Collections.singletonList(""))) + new FileContents(new FileText(new File("filename"), ImmutableList.of(""))) .lineIsBlank(0)) .isTrue(); } @Test - public void testLineIsComment() { + void lineIsComment() { assertWithMessage("Invalid result") .that( - new FileContents(new FileText(new File("filename"), Collections.singletonList("123"))) + new FileContents(new FileText(new File("filename"), ImmutableList.of("123"))) .lineIsComment(0)) .isFalse(); assertWithMessage("Invalid result") .that( - new FileContents( - new FileText(new File("filename"), Collections.singletonList(" // abc"))) + new FileContents(new FileText(new File("filename"), ImmutableList.of(" // abc"))) .lineIsComment(0)) .isTrue(); } @Test - public void testDeprecatedAbbreviatedMethod() { + void deprecatedAbbreviatedMethod() { // just to make UT coverage 100% final FileContents fileContents = new FileContents(new FileText(new File("filename"), Arrays.asList("123", "456"))); @@ -93,10 +92,10 @@ public class FileContentsTest { } @Test - public void testSinglelineCommentNotIntersect() { + void singlelineCommentNotIntersect() { // just to make UT coverage 100% final FileContents fileContents = - new FileContents(new FileText(new File("filename"), Collections.singletonList(" // "))); + new FileContents(new FileText(new File("filename"), ImmutableList.of(" // "))); fileContents.reportSingleLineComment(1, 2); assertWithMessage("Should return false when there is no intersection") .that(fileContents.hasIntersectionWithComment(1, 0, 1, 1)) @@ -104,10 +103,10 @@ public class FileContentsTest { } @Test - public void testSinglelineCommentIntersect() { + void singlelineCommentIntersect() { // just to make UT coverage 100% final FileContents fileContents = - new FileContents(new FileText(new File("filename"), Collections.singletonList(" // "))); + new FileContents(new FileText(new File("filename"), ImmutableList.of(" // "))); fileContents.reportSingleLineComment("type", 1, 2); assertWithMessage("Should return true when comments intersect") .that(fileContents.hasIntersectionWithComment(1, 5, 1, 6)) @@ -115,9 +114,9 @@ public class FileContentsTest { } @Test - public void testReportCppComment() { + void reportCppComment() { final FileContents fileContents = - new FileContents(new FileText(new File("filename"), Collections.singletonList(" // "))); + new FileContents(new FileText(new File("filename"), ImmutableList.of(" // "))); fileContents.reportSingleLineComment(1, 2); final Map cppComments = fileContents.getSingleLineComments(); @@ -127,7 +126,7 @@ public class FileContentsTest { } @Test - public void testHasIntersectionWithSingleLineComment() { + void hasIntersectionWithSingleLineComment() { final FileContents fileContents = new FileContents( new FileText( @@ -141,9 +140,9 @@ public class FileContentsTest { } @Test - public void testReportComment() { + void reportComment() { final FileContents fileContents = - new FileContents(new FileText(new File("filename"), Collections.singletonList(" // "))); + new FileContents(new FileText(new File("filename"), ImmutableList.of(" // "))); fileContents.reportBlockComment("type", 1, 2, 1, 2); final Map> comments = fileContents.getBlockComments(); @@ -153,10 +152,9 @@ public class FileContentsTest { } @Test - public void testReportBlockCommentSameLine() { + void reportBlockCommentSameLine() { final FileContents fileContents = - new FileContents( - new FileText(new File("filename"), Collections.singletonList("/* a */ /* b */ "))); + new FileContents(new FileText(new File("filename"), ImmutableList.of("/* a */ /* b */ "))); fileContents.reportBlockComment("type", 1, 0, 1, 6); fileContents.reportBlockComment("type", 1, 8, 1, 14); final Map> comments = fileContents.getBlockComments(); @@ -171,7 +169,7 @@ public class FileContentsTest { } @Test - public void testReportBlockCommentMultiLine() { + void reportBlockCommentMultiLine() { final FileContents fileContents = new FileContents(new FileText(new File("filename"), Arrays.asList("/*", "c", "*/"))); fileContents.reportBlockComment("type", 1, 0, 3, 1); @@ -180,12 +178,11 @@ public class FileContentsTest { assertWithMessage("Invalid comment") .that(comments.get(1).toString()) .isEqualTo( - Collections.singletonList(new Comment(new String[] {"/*", "c", "*/"}, 0, 3, 1)) - .toString()); + ImmutableList.of(new Comment(new String[] {"/*", "c", "*/"}, 0, 3, 1)).toString()); } @Test - public void testReportBlockCommentJavadoc() { + void reportBlockCommentJavadoc() { final FileContents fileContents = new FileContents( new FileText( @@ -203,7 +200,7 @@ public class FileContentsTest { } @Test - public void testHasIntersectionWithBlockComment() { + void hasIntersectionWithBlockComment() { final FileContents fileContents = new FileContents( new FileText( @@ -218,7 +215,7 @@ public class FileContentsTest { } @Test - public void testHasIntersectionWithBlockComment2() { + void hasIntersectionWithBlockComment2() { final FileContents fileContents = new FileContents( new FileText(new File("filename"), Arrays.asList(" /* */ ", " ", " "))); @@ -230,10 +227,9 @@ public class FileContentsTest { } @Test - public void testReportJavadocComment() { + void reportJavadocComment() { final FileContents fileContents = - new FileContents( - new FileText(new File("filename"), Collections.singletonList(" /** */ "))); + new FileContents(new FileText(new File("filename"), ImmutableList.of(" /** */ "))); fileContents.reportBlockComment(1, 2, 1, 6); final TextBlock comment = fileContents.getJavadocBefore(2); @@ -243,10 +239,9 @@ public class FileContentsTest { } @Test - public void testReportJavadocComment2() { + void reportJavadocComment2() { final FileContents fileContents = - new FileContents( - new FileText(new File("filename"), Collections.singletonList(" /** */ "))); + new FileContents(new FileText(new File("filename"), ImmutableList.of(" /** */ "))); fileContents.reportBlockComment(1, 2, 1, 6); final TextBlock comment = fileContents.getJavadocBefore(2); @@ -261,10 +256,9 @@ public class FileContentsTest { */ @Deprecated(since = "10.2") @Test - public void testInPackageInfo() { + void inPackageInfo() { final FileContents fileContents = - new FileContents( - new FileText(new File("package-info.java"), Collections.singletonList(" // "))); + new FileContents(new FileText(new File("package-info.java"), ImmutableList.of(" // "))); assertWithMessage("Should return true when in package info") .that(fileContents.inPackageInfo()) @@ -277,10 +271,10 @@ public class FileContentsTest { */ @Deprecated(since = "10.2") @Test - public void testNotInPackageInfo() { + void notInPackageInfo() { final FileContents fileContents = new FileContents( - new FileText(new File("some-package-info.java"), Collections.singletonList(" // "))); + new FileText(new File("some-package-info.java"), ImmutableList.of(" // "))); assertWithMessage("Should return false when not in package info") .that(fileContents.inPackageInfo()) @@ -288,9 +282,9 @@ public class FileContentsTest { } @Test - public void testGetJavadocBefore() { + void getJavadocBefore() { final FileContents fileContents = - new FileContents(new FileText(new File("filename"), Collections.singletonList(" "))); + new FileContents(new FileText(new File("filename"), ImmutableList.of(" "))); final Map javadoc = new HashMap<>(); javadoc.put(0, new Comment(new String[] {"// "}, 2, 1, 2)); TestUtil.setInternalState(fileContents, "javadocComments", javadoc); @@ -302,7 +296,7 @@ public class FileContentsTest { } @Test - public void testExtractBlockComment() { + void extractBlockComment() { final FileContents fileContents = new FileContents( new FileText( @@ -318,14 +312,14 @@ public class FileContentsTest { } @Test - public void testHasIntersectionEarlyOut() throws Exception { + void hasIntersectionEarlyOut() throws Exception { final FileContents fileContents = - new FileContents(new FileText(new File("filename"), Collections.emptyList())); + new FileContents(new FileText(new File("filename"), ImmutableList.of())); final Map> clangComments = TestUtil.getInternalState(fileContents, "clangComments"); final TextBlock textBlock = new Comment(new String[] {""}, 1, 1, 1); - clangComments.put(1, Collections.singletonList(textBlock)); - clangComments.put(2, Collections.emptyList()); + clangComments.put(1, ImmutableList.of(textBlock)); + clangComments.put(2, ImmutableList.of()); assertWithMessage("Invalid results") .that( @@ -335,22 +329,22 @@ public class FileContentsTest { } @Test - public void testUnmodifiableGetSingleLineComment() { + void unmodifiableGetSingleLineComment() { final FileContents cppComments = new FileContents( new FileText(new File("filename"), Arrays.asList("// comment ", " A + B ", " "))); cppComments.reportSingleLineComment(1, 0); final Map comments = cppComments.getSingleLineComments(); - assertThrows(UnsupportedOperationException.class, () -> comments.remove(0)); + assertThatThrownBy(() -> comments.remove(0)).isInstanceOf(UnsupportedOperationException.class); } @Test - public void testUnmodifiableGetBlockComments() { + void unmodifiableGetBlockComments() { final FileContents clangComments = new FileContents( new FileText(new File("filename"), Arrays.asList("/* comment ", " ", " comment */"))); clangComments.reportBlockComment(1, 0, 3, 9); final Map> comments = clangComments.getBlockComments(); - assertThrows(UnsupportedOperationException.class, () -> comments.remove(0)); + assertThatThrownBy(() -> comments.remove(0)).isInstanceOf(UnsupportedOperationException.class); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/FileSetCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/FileSetCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import org.junit.jupiter.api.Test; -public class FileSetCheckTest extends AbstractModuleTestSupport { +final class FileSetCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class FileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testTranslation() throws Exception { + void translation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFileSetIllegalTokens.java"), expected); @@ -44,7 +44,7 @@ public class FileSetCheckTest extends AbstractModuleTestSupport { } @Test - public void testProcessCallsFinishBeforeCallingDestroy() throws Exception { + void processCallsFinishBeforeCallingDestroy() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFileSetIllegalTokens.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/FileTextTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/FileTextTest.java @@ -20,7 +20,9 @@ package com.puppycrawl.tools.checkstyle.api; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.ISO_8859_1; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractPathTestSupport; import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil; import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; @@ -30,11 +32,10 @@ import java.io.IOException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class FileTextTest extends AbstractPathTestSupport { +final class FileTextTest extends AbstractPathTestSupport { @Override protected String getPackageLocation() { @@ -42,7 +43,7 @@ public class FileTextTest extends AbstractPathTestSupport { } @Test - public void testUnsupportedCharset() throws IOException { + void unsupportedCharset() throws IOException { // just to make UT coverage 100% final String charsetName = "STRANGE_CHARSET"; final File file = new File("any name"); @@ -58,7 +59,7 @@ public class FileTextTest extends AbstractPathTestSupport { } @Test - public void testFileNotFound() throws IOException { + void fileNotFound() throws IOException { final String charsetName = StandardCharsets.ISO_8859_1.name(); final File file = new File("any name"); try { @@ -73,7 +74,7 @@ public class FileTextTest extends AbstractPathTestSupport { } @Test - public void testSupportedCharset() throws IOException { + void supportedCharset() throws IOException { final String charsetName = StandardCharsets.ISO_8859_1.name(); final FileText fileText = new FileText(new File(getPath("InputFileTextImportControl.xml")), charsetName); @@ -83,7 +84,7 @@ public class FileTextTest extends AbstractPathTestSupport { } @Test - public void testLineColumnBeforeCopyConstructor() throws IOException { + void lineColumnBeforeCopyConstructor() throws IOException { final String charsetName = StandardCharsets.ISO_8859_1.name(); final FileText fileText = new FileText(new File(getPath("InputFileTextImportControl.xml")), charsetName); @@ -97,8 +98,8 @@ public class FileTextTest extends AbstractPathTestSupport { } @Test - public void testLineColumnAfterCopyConstructor() throws IOException { - final Charset charset = StandardCharsets.ISO_8859_1; + void lineColumnAfterCopyConstructor() throws IOException { + final Charset charset = ISO_8859_1; final String filepath = getPath("InputFileTextImportControl.xml"); final FileText fileText = new FileText(new File(filepath), charset.name()); final FileText copy = new FileText(fileText); @@ -115,7 +116,7 @@ public class FileTextTest extends AbstractPathTestSupport { } @Test - public void testLineColumnAtTheStartOfFile() throws IOException { + void lineColumnAtTheStartOfFile() throws IOException { final String charsetName = StandardCharsets.ISO_8859_1.name(); final FileText fileText = new FileText(new File(getPath("InputFileTextImportControl.xml")), charsetName); @@ -126,15 +127,15 @@ public class FileTextTest extends AbstractPathTestSupport { } @Test - public void testLines() throws IOException { - final List lines = Collections.singletonList("abc"); + void lines() throws IOException { + final List lines = ImmutableList.of("abc"); final FileText fileText = new FileText(new File(getPath("InputFileTextImportControl.xml")), lines); assertWithMessage("Invalid line").that(fileText.toLinesArray()).isEqualTo(new String[] {"abc"}); } @Test - public void testFindLineBreaks() throws Exception { + void findLineBreaks() throws Exception { final FileText fileText = new FileText(new File("fileName"), Arrays.asList("1", "2")); assertWithMessage("Invalid line breaks") @@ -156,8 +157,8 @@ public class FileTextTest extends AbstractPathTestSupport { * @throws Exception if there is an error. */ @Test - public void testFindLineBreaksCache() throws Exception { - final FileText fileText = new FileText(new File("fileName"), Collections.emptyList()); + void findLineBreaksCache() throws Exception { + final FileText fileText = new FileText(new File("fileName"), ImmutableList.of()); final int[] lineBreaks = {5}; TestUtil.setInternalState(fileText, "lineBreaks", lineBreaks); // produces NPE if used @@ -169,8 +170,8 @@ public class FileTextTest extends AbstractPathTestSupport { } @Test - public void testCharsetAfterCopyConstructor() throws IOException { - final Charset charset = StandardCharsets.ISO_8859_1; + void charsetAfterCopyConstructor() throws IOException { + final Charset charset = ISO_8859_1; final String filepath = getPath("InputFileTextImportControl.xml"); final FileText fileText = new FileText(new File(filepath), charset.name()); final FileText copy = new FileText(fileText); --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/FilterSetTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/FilterSetTest.java @@ -20,24 +20,24 @@ package com.puppycrawl.tools.checkstyle.api; import static com.google.common.truth.Truth.assertWithMessage; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.puppycrawl.tools.checkstyle.filters.SeverityMatchFilter; import java.util.Objects; import java.util.Set; import org.junit.jupiter.api.Test; -public class FilterSetTest { +final class FilterSetTest { @Test - public void testGetFilters() { + void getFilters() { final FilterSet filterSet = new FilterSet(); filterSet.addFilter(new SeverityMatchFilter()); assertWithMessage("Invalid filter set size").that(filterSet.getFilters()).hasSize(1); } @Test - public void testRemoveFilters() { + void removeFilters() { final FilterSet filterSet = new FilterSet(); final Filter filter = new SeverityMatchFilter(); filterSet.addFilter(filter); @@ -46,14 +46,14 @@ public class FilterSetTest { } @Test - public void testToString() { + void testToString() { final FilterSet filterSet = new FilterSet(); filterSet.addFilter(new SeverityMatchFilter()); assertWithMessage("Invalid filter set size").that(filterSet.toString()).isNotNull(); } @Test - public void testClear() { + void clear() { final FilterSet filterSet = new FilterSet(); filterSet.addFilter(new SeverityMatchFilter()); @@ -65,21 +65,21 @@ public class FilterSetTest { } @Test - public void testAccept() { + void accept() { final FilterSet filterSet = new FilterSet(); filterSet.addFilter(new DummyFilter(true)); assertWithMessage("invalid accept response").that(filterSet.accept(null)).isTrue(); } @Test - public void testNotAccept() { + void notAccept() { final FilterSet filterSet = new FilterSet(); filterSet.addFilter(new DummyFilter(false)); assertWithMessage("invalid accept response").that(filterSet.accept(null)).isFalse(); } @Test - public void testNotAcceptEvenIfOneAccepts() { + void notAcceptEvenIfOneAccepts() { final FilterSet filterSet = new FilterSet(); filterSet.addFilter(new DummyFilter(true)); filterSet.addFilter(new DummyFilter(false)); @@ -92,12 +92,13 @@ public class FilterSetTest { done for the time being */ @Test - public void testUnmodifiableSet() { + void unmodifiableSet() { final FilterSet filterSet = new FilterSet(); final Filter filter = new FilterSet(); filterSet.addFilter(filter); final Set subFilterSet = filterSet.getFilters(); - assertThrows(UnsupportedOperationException.class, () -> subFilterSet.add(filter)); + assertThatThrownBy(() -> subFilterSet.add(filter)) + .isInstanceOf(UnsupportedOperationException.class); } /* @@ -105,7 +106,7 @@ public class FilterSetTest { be useful for third party integrations */ @Test - public void testEmptyToString() { + void emptyToString() { final FilterSet filterSet = new FilterSet(); assertWithMessage("toString() result shouldn't be an empty string") .that(filterSet.toString()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/FullIdentTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/FullIdentTest.java @@ -30,7 +30,7 @@ import java.io.File; import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; -public class FullIdentTest extends AbstractModuleTestSupport { +final class FullIdentTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,7 +38,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testToString() { + void testToString() { final DetailAstImpl ast = new DetailAstImpl(); ast.setType(TokenTypes.LITERAL_NEW); ast.setColumnNo(14); @@ -60,7 +60,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testCreateFullIdentBelow() { + void createFullIdentBelow() { final DetailAST ast = new DetailAstImpl(); final FullIdent indent = FullIdent.createFullIdentBelow(ast); @@ -68,7 +68,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testGetDetailAst() throws Exception { + void getDetailAst() throws Exception { final FileText testFileText = new FileText( new File(getPath("InputFullIdentTestArrayType.java")).getAbsoluteFile(), @@ -83,7 +83,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testNonValidCoordinatesWithNegative() { + void nonValidCoordinatesWithNegative() { final FullIdent fullIdent = prepareFullIdentWithCoordinates(14, 15); assertWithMessage("Invalid full indent") .that(fullIdent.toString()) @@ -91,7 +91,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testNonValidCoordinatesWithZero() { + void nonValidCoordinatesWithZero() { final FullIdent fullIdent = prepareFullIdentWithCoordinates(0, 0); assertWithMessage("Invalid full indent") .that(fullIdent.toString()) @@ -99,7 +99,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testWithArrayCreateFullIdentWithArrayDeclare() throws Exception { + void withArrayCreateFullIdentWithArrayDeclare() throws Exception { final FileText testFileText = new FileText( new File(getPath("InputFullIdentTestArrayType.java")).getAbsoluteFile(), @@ -118,7 +118,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testFullIdentAnnotation() throws Exception { + void fullIdentAnnotation() throws Exception { final FileText testFileText = new FileText( new File(getPath("InputFullIdentAnnotation.java")).getAbsoluteFile(), @@ -146,7 +146,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testFullIdentArrayInit() throws Exception { + void fullIdentArrayInit() throws Exception { final FileText testFileText = new FileText( new File(getPath("InputFullIdentArrayInit.java")).getAbsoluteFile(), @@ -203,7 +203,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testReturnNoAnnotation() throws Exception { + void returnNoAnnotation() throws Exception { final FileText testFileText = new FileText( new File(getPath("InputFullIdentReturnNoAnnotation.java")).getAbsoluteFile(), @@ -216,7 +216,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testFullyQualifiedStringArray() throws Exception { + void fullyQualifiedStringArray() throws Exception { final FileText testFileText = new FileText( new File(getPath("InputFullIdentFullyQualifiedStringArray.java")).getAbsoluteFile(), @@ -236,7 +236,7 @@ public class FullIdentTest extends AbstractModuleTestSupport { } @Test - public void testCreateFullIdentBelow2() throws Exception { + void createFullIdentBelow2() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(ImportOrderCheck.class, MSG_ORDERING, "java.util.HashMap"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/JavadocTokenTypesTest.java @@ -25,17 +25,17 @@ import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsCla import java.lang.reflect.Field; import org.junit.jupiter.api.Test; -public class JavadocTokenTypesTest { +final class JavadocTokenTypesTest { @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(JavadocTokenTypes.class)) .isTrue(); } @Test - public void testTokenValues() { + void tokenValues() { final String msg = "Please ensure that token values in `JavadocTokenTypes.java` have not" + " changed."; assertWithMessage(msg).that(JavadocTokenTypes.RETURN_LITERAL).isEqualTo(11); @@ -222,7 +222,7 @@ public class JavadocTokenTypesTest { } @Test - public void testRuleOffsetValue() throws Exception { + void ruleOffsetValue() throws Exception { final Field ruleTypesOffset = JavadocTokenTypes.class.getDeclaredField("RULE_TYPES_OFFSET"); ruleTypesOffset.setAccessible(true); assertWithMessage( --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/LineColumnTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/LineColumnTest.java @@ -25,16 +25,16 @@ import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.Test; -public class LineColumnTest { +final class LineColumnTest { @Test - public void testCompareToBothEqual() { + void compareToBothEqual() { final int actual = new LineColumn(0, 0).compareTo(new LineColumn(0, 0)); assertWithMessage("Invalid LineColumn comparing result").that(actual).isEqualTo(0); } @Test - public void testCompareToFirstLarger() { + void compareToFirstLarger() { final LineColumn lineColumn = new LineColumn(0, 0); final int line1column0 = new LineColumn(1, 0).compareTo(lineColumn); @@ -44,7 +44,7 @@ public class LineColumnTest { } @Test - public void testCompareToFirstSmaller() { + void compareToFirstSmaller() { final Comparable lineColumn = new LineColumn(0, 0); final int line1Column0 = lineColumn.compareTo(new LineColumn(1, 0)); @@ -54,14 +54,14 @@ public class LineColumnTest { } @Test - public void testEqualsAndHashCode() { + void equalsAndHashCode() { final EqualsVerifierReport ev = EqualsVerifier.forClass(LineColumn.class).usingGetClass().report(); assertWithMessage("Error: " + ev.getMessage()).that(ev.isSuccessful()).isTrue(); } @Test - public void testGetters() { + void getters() { final LineColumn lineColumn = new LineColumn(2, 3); assertWithMessage("Invalid LineColumn comparison result") --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/ScopeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/ScopeTest.java @@ -25,20 +25,20 @@ import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.DefaultLocale; /** Test cases for {@link Scope} enumeration. */ -public class ScopeTest { +final class ScopeTest { /* Additional test for jacoco, since valueOf() * is generated by javac and jacoco reports that * valueOf() is uncovered. */ @Test - public void testScopeValueOf() { + void scopeValueOf() { final Scope scope = Scope.valueOf("PRIVATE"); assertWithMessage("Invalid scope").that(scope).isEqualTo(Scope.PRIVATE); } @Test - public void testMisc() { + void misc() { final Scope scope = Scope.getInstance("public"); assertWithMessage("Scope must not be null").that(scope).isNotNull(); assertWithMessage("Invalid scope toString").that(scope.toString()).isEqualTo("public"); @@ -55,7 +55,7 @@ public class ScopeTest { } @Test - public void testMixedCaseSpaces() { + void mixedCaseSpaces() { assertWithMessage("Invalid scope").that(Scope.getInstance("NothinG ")).isEqualTo(Scope.NOTHING); assertWithMessage("Invalid scope").that(Scope.getInstance(" PuBlic")).isEqualTo(Scope.PUBLIC); assertWithMessage("Invalid scope") @@ -74,7 +74,7 @@ public class ScopeTest { @DefaultLocale(language = "tr", country = "TR") @Test - public void testMixedCaseSpacesWithDifferentLocale() { + void mixedCaseSpacesWithDifferentLocale() { assertWithMessage("Invalid scope").that(Scope.getInstance("NothinG ")).isEqualTo(Scope.NOTHING); assertWithMessage("Invalid scope").that(Scope.getInstance(" PuBlic")).isEqualTo(Scope.PUBLIC); assertWithMessage("Invalid scope") @@ -92,7 +92,7 @@ public class ScopeTest { } @Test - public void testIsInAnonInner() { + void isInAnonInner() { assertWithMessage("Invalid subscope").that(Scope.NOTHING.isIn(Scope.ANONINNER)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PUBLIC.isIn(Scope.ANONINNER)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PROTECTED.isIn(Scope.ANONINNER)).isTrue(); @@ -102,7 +102,7 @@ public class ScopeTest { } @Test - public void testIsInPrivate() { + void isInPrivate() { assertWithMessage("Invalid subscope").that(Scope.NOTHING.isIn(Scope.PRIVATE)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PUBLIC.isIn(Scope.PRIVATE)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PROTECTED.isIn(Scope.PRIVATE)).isTrue(); @@ -112,7 +112,7 @@ public class ScopeTest { } @Test - public void testIsInPackage() { + void isInPackage() { assertWithMessage("Invalid subscope").that(Scope.NOTHING.isIn(Scope.PACKAGE)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PUBLIC.isIn(Scope.PACKAGE)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PROTECTED.isIn(Scope.PACKAGE)).isTrue(); @@ -122,7 +122,7 @@ public class ScopeTest { } @Test - public void testIsInProtected() { + void isInProtected() { assertWithMessage("Invalid subscope").that(Scope.NOTHING.isIn(Scope.PROTECTED)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PUBLIC.isIn(Scope.PROTECTED)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PROTECTED.isIn(Scope.PROTECTED)).isTrue(); @@ -132,7 +132,7 @@ public class ScopeTest { } @Test - public void testIsInPublic() { + void isInPublic() { assertWithMessage("Invalid subscope").that(Scope.NOTHING.isIn(Scope.PUBLIC)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PUBLIC.isIn(Scope.PUBLIC)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PROTECTED.isIn(Scope.PUBLIC)).isFalse(); @@ -142,7 +142,7 @@ public class ScopeTest { } @Test - public void testIsInNothing() { + void isInNothing() { assertWithMessage("Invalid subscope").that(Scope.NOTHING.isIn(Scope.NOTHING)).isTrue(); assertWithMessage("Invalid subscope").that(Scope.PUBLIC.isIn(Scope.NOTHING)).isFalse(); assertWithMessage("Invalid subscope").that(Scope.PROTECTED.isIn(Scope.NOTHING)).isFalse(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/SeverityLevelCounterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/SeverityLevelCounterTest.java @@ -23,10 +23,10 @@ import static com.google.common.truth.Truth.assertWithMessage; import org.junit.jupiter.api.Test; -public class SeverityLevelCounterTest { +final class SeverityLevelCounterTest { @Test - public void testCtorException() { + void ctorException() { try { final Object test = new SeverityLevelCounter(null); assertWithMessage("exception expected but got %s", test).fail(); @@ -39,7 +39,7 @@ public class SeverityLevelCounterTest { } @Test - public void testAddError() { + void addError() { final SeverityLevelCounter counter = new SeverityLevelCounter(SeverityLevel.ERROR); assertWithMessage("Invalid severity level count").that(counter.getCount()).isEqualTo(0); // not counted @@ -59,7 +59,7 @@ public class SeverityLevelCounterTest { } @Test - public void testAddException() { + void addException() { final SeverityLevelCounter counter = new SeverityLevelCounter(SeverityLevel.ERROR); final AuditEvent event = new AuditEvent(this, "ATest.java", null); assertWithMessage("Invalid severity level count").that(counter.getCount()).isEqualTo(0); @@ -68,7 +68,7 @@ public class SeverityLevelCounterTest { } @Test - public void testAddExceptionWarning() { + void addExceptionWarning() { final SeverityLevelCounter counter = new SeverityLevelCounter(SeverityLevel.WARNING); final AuditEvent event = new AuditEvent(this, "ATest.java", null); assertWithMessage("Invalid severity level count").that(counter.getCount()).isEqualTo(0); @@ -77,7 +77,7 @@ public class SeverityLevelCounterTest { } @Test - public void testAuditStartedClearsState() { + void auditStartedClearsState() { final SeverityLevelCounter counter = new SeverityLevelCounter(SeverityLevel.ERROR); final AuditEvent event = new AuditEvent(this, "ATest.java", null); final AuditEvent secondEvent = new AuditEvent(this, "BTest.java", null); --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/SeverityLevelTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/SeverityLevelTest.java @@ -25,20 +25,20 @@ import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.DefaultLocale; /** Test cases for {@link SeverityLevel} enumeration. */ -public class SeverityLevelTest { +final class SeverityLevelTest { /* Additional test for jacoco, since valueOf() * is generated by javac and jacoco reports that * valueOf() is uncovered. */ @Test - public void testSeverityLevelValueOf() { + void severityLevelValueOf() { final SeverityLevel level = SeverityLevel.valueOf("INFO"); assertWithMessage("Invalid severity level").that(level).isEqualTo(SeverityLevel.INFO); } @Test - public void testMisc() { + void misc() { final SeverityLevel severityLevel = SeverityLevel.getInstance("info"); assertWithMessage("Invalid getInstance result, should not be null") .that(severityLevel) @@ -60,7 +60,7 @@ public class SeverityLevelTest { } @Test - public void testMixedCaseSpaces() { + void mixedCaseSpaces() { assertWithMessage("Invalid getInstance result") .that(SeverityLevel.getInstance("IgnoRe ")) .isEqualTo(SeverityLevel.IGNORE); @@ -77,7 +77,7 @@ public class SeverityLevelTest { @DefaultLocale(language = "tr", country = "TR") @Test - public void testMixedCaseSpacesWithDifferentLocales() { + void mixedCaseSpacesWithDifferentLocales() { assertWithMessage("Invalid getInstance result") .that(SeverityLevel.getInstance("IgnoRe ")) .isEqualTo(SeverityLevel.IGNORE); --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/TokenTypesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/TokenTypesTest.java @@ -21,20 +21,20 @@ package com.puppycrawl.tools.checkstyle.api; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor; +import static java.util.stream.Collectors.toUnmodifiableSet; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import java.util.Arrays; -import java.util.Collections; import java.util.Locale; import java.util.ResourceBundle; import java.util.Set; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -public class TokenTypesTest { +final class TokenTypesTest { @Test - public void testAllTokenTypesHasDescription() { + void allTokenTypesHasDescription() { final String tokenTypes = "com.puppycrawl.tools.checkstyle.api.tokentypes"; final ResourceBundle bundle = ResourceBundle.getBundle(tokenTypes, Locale.ROOT); @@ -42,27 +42,27 @@ public class TokenTypesTest { Arrays.stream(TokenUtil.getAllTokenIds()) .mapToObj(TokenUtil::getTokenName) .filter(name -> name.charAt(0) != '$') - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); final Set actual = bundle.keySet(); assertWithMessage("TokenTypes without description").that(actual).isEqualTo(expected); } @Test - public void testAllDescriptionsEndsWithPeriod() { + void allDescriptionsEndsWithPeriod() { final Set badDescriptions = Arrays.stream(TokenUtil.getAllTokenIds()) .mapToObj(TokenUtil::getTokenName) .filter(name -> name.charAt(0) != '$') .map(TokenUtil::getShortDescription) .filter(desc -> desc.charAt(desc.length() - 1) != '.') - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); assertWithMessage("Malformed TokenType descriptions") .that(badDescriptions) - .isEqualTo(Collections.emptySet()); + .isEqualTo(ImmutableSet.of()); } @Test - public void testGetShortDescription() { + void getShortDescription() { assertWithMessage("short description for EQUAL") .that(TokenUtil.getShortDescription("EQUAL")) .isEqualTo("The == (equal) operator."); @@ -89,7 +89,7 @@ public class TokenTypesTest { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(TokenTypes.class)) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/api/ViolationTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/api/ViolationTest.java @@ -29,17 +29,17 @@ import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.Test; import org.junitpioneer.jupiter.DefaultLocale; -public class ViolationTest { +final class ViolationTest { @Test - public void testEqualsAndHashCode() { + void equalsAndHashCode() { final EqualsVerifierReport ev = EqualsVerifier.forClass(Violation.class).usingGetClass().report(); assertWithMessage("Error: " + ev.getMessage()).that(ev.isSuccessful()).isTrue(); } @Test - public void testGetSeverityLevel() { + void getSeverityLevel() { final Violation violation = createSampleViolation(); assertWithMessage("Invalid severity level") @@ -48,14 +48,14 @@ public class ViolationTest { } @Test - public void testGetModuleId() { + void getModuleId() { final Violation violation = createSampleViolation(); assertWithMessage("Invalid module id").that(violation.getModuleId()).isEqualTo("module"); } @Test - public void testGetSourceName() { + void getSourceName() { final Violation violation = createSampleViolation(); assertWithMessage("Invalid source name") @@ -65,7 +65,7 @@ public class ViolationTest { @DefaultLocale("en") @Test - public void testMessageInEnglish() { + void messageInEnglish() { final Violation violation = createSampleViolation(); assertWithMessage("Invalid violation") @@ -75,7 +75,7 @@ public class ViolationTest { @DefaultLocale("fr") @Test - public void testGetKey() { + void getKey() { final Violation violation = createSampleViolation(); assertWithMessage("Invalid violation key") @@ -84,7 +84,7 @@ public class ViolationTest { } @Test - public void testTokenType() { + void tokenType() { final Violation violation1 = new Violation( 1, @@ -119,7 +119,7 @@ public class ViolationTest { } @Test - public void testGetColumnCharIndex() { + void getColumnCharIndex() { final Violation violation1 = new Violation( 1, @@ -140,7 +140,7 @@ public class ViolationTest { } @Test - public void testCompareToWithDifferentModuleId() { + void compareToWithDifferentModuleId() { final Violation message1 = createSampleViolationWithId("module1"); final Violation message2 = createSampleViolationWithId("module2"); final Violation messageNull = createSampleViolationWithId(null); @@ -155,7 +155,7 @@ public class ViolationTest { } @Test - public void testCompareToWithDifferentClass() { + void compareToWithDifferentClass() { final Violation message1 = createSampleViolationWithClass(AnnotationLocationCheck.class); final Violation message2 = createSampleViolationWithClass(AnnotationOnSameLineCheck.class); final Violation messageNull = createSampleViolationWithClass(null); @@ -170,7 +170,7 @@ public class ViolationTest { } @Test - public void testCompareToWithDifferentLines() { + void compareToWithDifferentLines() { final Violation message1 = createSampleViolationWithLine(1); final Violation message1a = createSampleViolationWithLine(1); final Violation message2 = createSampleViolationWithLine(2); @@ -182,7 +182,7 @@ public class ViolationTest { } @Test - public void testCompareToWithDifferentColumns() { + void compareToWithDifferentColumns() { final Violation message1 = createSampleViolationWithColumn(1); final Violation message1a = createSampleViolationWithColumn(1); final Violation message2 = createSampleViolationWithColumn(2); --- a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/InlineConfigParser.java @@ -19,6 +19,8 @@ package com.puppycrawl.tools.checkstyle.bdd; +import static java.util.stream.Collectors.toUnmodifiableList; + import com.puppycrawl.tools.checkstyle.ConfigurationLoader; import com.puppycrawl.tools.checkstyle.PropertiesExpander; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; @@ -29,7 +31,6 @@ import java.io.StringReader; import java.lang.reflect.Modifier; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -41,7 +42,6 @@ import java.util.Properties; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.xml.sax.InputSource; public final class InlineConfigParser { @@ -184,7 +184,7 @@ public final class InlineConfigParser { throws Exception { final TestInputConfiguration.Builder testInputConfigBuilder = new TestInputConfiguration.Builder(); - final Path filePath = Paths.get(inputFilePath); + final Path filePath = Path.of(inputFilePath); final List lines = readFile(filePath); try { setModules(testInputConfigBuilder, inputFilePath, lines); @@ -241,7 +241,7 @@ public final class InlineConfigParser { return lines.stream() .skip(1) .takeWhile(line -> !line.startsWith("*/")) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); } private static void handleXmlConfig( --- a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/ModuleInputConfiguration.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/ModuleInputConfiguration.java @@ -19,8 +19,9 @@ package com.puppycrawl.tools.checkstyle.bdd; +import static java.util.Collections.unmodifiableMap; + import com.puppycrawl.tools.checkstyle.DefaultConfiguration; -import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -57,19 +58,19 @@ public final class ModuleInputConfiguration { final Map properties = new HashMap<>(); properties.putAll(defaultProperties); properties.putAll(nonDefaultProperties); - return Collections.unmodifiableMap(properties); + return unmodifiableMap(properties); } public Map getDefaultProperties() { - return Collections.unmodifiableMap(defaultProperties); + return unmodifiableMap(defaultProperties); } public Map getNonDefaultProperties() { - return Collections.unmodifiableMap(nonDefaultProperties); + return unmodifiableMap(nonDefaultProperties); } public Map getModuleMessages() { - return Collections.unmodifiableMap(moduleMessages); + return unmodifiableMap(moduleMessages); } public DefaultConfiguration createConfiguration() { --- a/src/test/java/com/puppycrawl/tools/checkstyle/bdd/TestInputConfiguration.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/bdd/TestInputConfiguration.java @@ -19,13 +19,14 @@ package com.puppycrawl.tools.checkstyle.bdd; +import static java.util.Collections.unmodifiableList; + import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.TreeWalker; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -76,15 +77,15 @@ public final class TestInputConfiguration { } public List getChildrenModules() { - return Collections.unmodifiableList(childrenModules); + return unmodifiableList(childrenModules); } public List getViolations() { - return Collections.unmodifiableList(violations); + return unmodifiableList(violations); } public List getFilteredViolations() { - return Collections.unmodifiableList(filteredViolations); + return unmodifiableList(filteredViolations); } public DefaultConfiguration createConfiguration() { @@ -163,7 +164,7 @@ public final class TestInputConfiguration { } public List getChildrenModules() { - return Collections.unmodifiableList(childrenModules); + return unmodifiableList(childrenModules); } } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class ArrayTypeStyleCheckTest extends AbstractModuleTestSupport { +final class ArrayTypeStyleCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class ArrayTypeStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final ArrayTypeStyleCheck checkObj = new ArrayTypeStyleCheck(); final int[] expected = {TokenTypes.ARRAY_DECLARATOR}; assertWithMessage("Required tokens differs from expected") @@ -43,7 +43,7 @@ public class ArrayTypeStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavaStyleOn() throws Exception { + void javaStyleOn() throws Exception { final String[] expected = { "13:23: " + getCheckMessage(MSG_KEY), "14:18: " + getCheckMessage(MSG_KEY), @@ -58,7 +58,7 @@ public class ArrayTypeStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavaStyleOff() throws Exception { + void javaStyleOff() throws Exception { final String[] expected = { "12:16: " + getCheckMessage(MSG_KEY), "16:39: " + getCheckMessage(MSG_KEY), @@ -74,7 +74,7 @@ public class ArrayTypeStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testNestedGenerics() throws Exception { + void nestedGenerics() throws Exception { final String[] expected = { "22:45: " + getCheckMessage(MSG_KEY), "23:61: " + getCheckMessage(MSG_KEY), @@ -85,7 +85,7 @@ public class ArrayTypeStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final int[] expected = {TokenTypes.ARRAY_DECLARATOR}; final ArrayTypeStyleCheck check = new ArrayTypeStyleCheck(); final int[] actual = check.getAcceptableTokens(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheckTest.java @@ -31,7 +31,7 @@ import java.util.regex.Pattern; import java.util.stream.IntStream; import org.junit.jupiter.api.Test; -public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSupport { +final class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSupport { // C0 (ASCII and derivatives) // https://en.wiktionary.org/wiki/Appendix:Control_characters#C0_.28ASCII_and_derivatives.29 @@ -63,7 +63,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AvoidEscapedUnicodeCharactersCheck checkObj = new AvoidEscapedUnicodeCharactersCheck(); final int[] expected = { TokenTypes.STRING_LITERAL, TokenTypes.CHAR_LITERAL, TokenTypes.TEXT_BLOCK_CONTENT, @@ -74,7 +74,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "17:38: " + getCheckMessage(MSG_KEY), "19:38: " + getCheckMessage(MSG_KEY), @@ -130,7 +130,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testAllowEscapesForControlCharacterSet() throws Exception { + void allowEscapesForControlCharacterSet() throws Exception { final String[] expected = { "17:38: " + getCheckMessage(MSG_KEY), "19:38: " + getCheckMessage(MSG_KEY), @@ -181,7 +181,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testAllowByTailComment() throws Exception { + void allowByTailComment() throws Exception { final String[] expected = { "17:38: " + getCheckMessage(MSG_KEY), "25:38: " + getCheckMessage(MSG_KEY), @@ -216,7 +216,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testAllowAllCharactersEscaped() throws Exception { + void allowAllCharactersEscaped() throws Exception { final String[] expected = { "17:38: " + getCheckMessage(MSG_KEY), "19:38: " + getCheckMessage(MSG_KEY), @@ -249,7 +249,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void allowNonPrintableEscapes() throws Exception { + void allowNonPrintableEscapes() throws Exception { final String[] expected = { "17:38: " + getCheckMessage(MSG_KEY), "19:38: " + getCheckMessage(MSG_KEY), @@ -288,7 +288,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testAllowByTailCommentWithEmoji() throws Exception { + void allowByTailCommentWithEmoji() throws Exception { final String[] expected = { "15:24: " + getCheckMessage(MSG_KEY), "18:24: " + getCheckMessage(MSG_KEY), @@ -302,7 +302,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testAvoidEscapedUnicodeCharactersTextBlocksAllowByComment() throws Exception { + void avoidEscapedUnicodeCharactersTextBlocksAllowByComment() throws Exception { final String[] expected = { "18:30: " + getCheckMessage(MSG_KEY), "20:30: " + getCheckMessage(MSG_KEY), @@ -319,7 +319,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testAvoidEscapedUnicodeCharactersTextBlocks() throws Exception { + void avoidEscapedUnicodeCharactersTextBlocks() throws Exception { final String[] expected = { "17:30: " + getCheckMessage(MSG_KEY), "18:30: " + getCheckMessage(MSG_KEY), @@ -335,7 +335,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testAvoidEscapedUnicodeCharactersEscapedS() throws Exception { + void avoidEscapedUnicodeCharactersEscapedS() throws Exception { final String[] expected = { "17:21: " + getCheckMessage(MSG_KEY), "18:22: " + getCheckMessage(MSG_KEY), @@ -349,7 +349,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AvoidEscapedUnicodeCharactersCheck check = new AvoidEscapedUnicodeCharactersCheck(); final int[] actual = check.getAcceptableTokens(); final int[] expected = { @@ -359,7 +359,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu } @Test - public void testAllowEscapesForControlCharacterSetForAllCharacters() throws Exception { + void allowEscapesForControlCharacterSetForAllCharacters() throws Exception { final int indexOfStartLineInInputFile = 16; final String message = getCheckMessage(MSG_KEY); @@ -383,7 +383,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu * @throws Exception when code tested throws some exception */ @Test - public void testCountMatches() throws Exception { + void countMatches() throws Exception { final AvoidEscapedUnicodeCharactersCheck check = new AvoidEscapedUnicodeCharactersCheck(); final int actual = TestUtil.invokeMethod( @@ -396,7 +396,7 @@ public class AvoidEscapedUnicodeCharactersCheckTest extends AbstractModuleTestSu * convenient for the sake of maintainability. */ @Test - public void testNonPrintableCharsAreSorted() { + void nonPrintableCharsAreSorted() { String expression = TestUtil.getInternalStaticState( AvoidEscapedUnicodeCharactersCheck.class, "NON_PRINTABLE_CHARS") --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class DescendantTokenCheckTest extends AbstractModuleTestSupport { +final class DescendantTokenCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,13 +36,13 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputDescendantTokenIllegalTokens.java"), expected); } @Test - public void testMaximumNumber() throws Exception { + void maximumNumber() throws Exception { final String[] expected = { "32:12: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "LITERAL_NATIVE", "LITERAL_NATIVE"), }; @@ -50,7 +50,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testMessage() throws Exception { + void message() throws Exception { final String[] expected = { "32:12: Using 'native' is not allowed.", }; @@ -58,7 +58,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testMinimumNumber() throws Exception { + void minimumNumber() throws Exception { final String[] expected = { "24:9: " + getCheckMessage(MSG_KEY_MIN, 1, 2, "LITERAL_SWITCH", "LITERAL_DEFAULT"), }; @@ -66,19 +66,19 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testMinimumDepth() throws Exception { + void minimumDepth() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputDescendantTokenIllegalTokens5.java"), expected); } @Test - public void testMaximumDepth() throws Exception { + void maximumDepth() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputDescendantTokenIllegalTokens6.java"), expected); } @Test - public void testEmptyStatements() throws Exception { + void emptyStatements() throws Exception { final String[] expected = { "22:7: Empty statement.", @@ -103,7 +103,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingSwitchDefault() throws Exception { + void missingSwitchDefault() throws Exception { final String[] expected = { "32:9: switch without \"default\" clause.", @@ -114,7 +114,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testStringLiteralEquality() throws Exception { + void stringLiteralEquality() throws Exception { final String[] expected = { "22:18: Literal Strings should be compared using equals(), not '=='.", "27:20: Literal Strings should be compared using equals(), not '=='.", @@ -125,7 +125,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokenDefault() throws Exception { + void illegalTokenDefault() throws Exception { final String[] expected = { "23:9: Using 'LITERAL_SWITCH' is not allowed.", @@ -136,7 +136,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokenNative() throws Exception { + void illegalTokenNative() throws Exception { final String[] expected = { "32:12: Using 'LITERAL_NATIVE' is not allowed.", @@ -145,7 +145,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testReturnFromCatch() throws Exception { + void returnFromCatch() throws Exception { final String[] expected = { "22:11: Return from catch is not allowed.", "30:11: Return from catch is not allowed.", @@ -155,7 +155,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testReturnFromFinally() throws Exception { + void returnFromFinally() throws Exception { final String[] expected = { "22:11: Return from finally is not allowed.", "30:11: Return from finally is not allowed.", @@ -165,7 +165,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoSum() throws Exception { + void noSum() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -173,7 +173,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithSumCustomMsg() throws Exception { + void withSumCustomMsg() throws Exception { final String[] expected = { "37:32: this cannot be null.", @@ -186,7 +186,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithSumDefaultMsg() throws Exception { + void withSumDefaultMsg() throws Exception { final String[] expected = { "37:32: " + getCheckMessage(MSG_KEY_SUM_MAX, 2, 1, "EQUAL"), @@ -199,7 +199,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithSumLessThenMinDefMsg() throws Exception { + void withSumLessThenMinDefMsg() throws Exception { final String[] expected = { "32:44: " + getCheckMessage(MSG_KEY_SUM_MIN, 0, 3, "EQUAL"), @@ -215,7 +215,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithSumLessThenMinCustomMsg() throws Exception { + void withSumLessThenMinCustomMsg() throws Exception { final String[] expected = { "31:44: custom message", @@ -231,7 +231,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testMaxTokenType() throws Exception { + void maxTokenType() throws Exception { final String[] expected = { "21:48: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "OBJBLOCK", "LCURLY"), "21:48: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "OBJBLOCK", "RCURLY"), @@ -240,7 +240,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testMaxTokenTypeReverseOrder() throws Exception { + void maxTokenTypeReverseOrder() throws Exception { final String[] expected = { "21:49: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "OBJBLOCK", "LCURLY"), "21:49: " + getCheckMessage(MSG_KEY_MAX, 1, 0, "OBJBLOCK", "RCURLY"), @@ -249,7 +249,7 @@ public class DescendantTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testLimitedToken() throws Exception { + void limitedToken() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputDescendantTokenTestLimitedToken.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class FinalParametersCheckTest extends AbstractModuleTestSupport { +final class FinalParametersCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class FinalParametersCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultTokens() throws Exception { + void defaultTokens() throws Exception { final String[] expected = { "27:26: " + getCheckMessage(MSG_KEY, "s"), "42:26: " + getCheckMessage(MSG_KEY, "i"), @@ -51,7 +51,7 @@ public class FinalParametersCheckTest extends AbstractModuleTestSupport { } @Test - public void testCtorToken() throws Exception { + void ctorToken() throws Exception { final String[] expected = { "28:27: " + getCheckMessage(MSG_KEY, "s"), "43:27: " + getCheckMessage(MSG_KEY, "i"), @@ -61,7 +61,7 @@ public class FinalParametersCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodToken() throws Exception { + void methodToken() throws Exception { final String[] expected = { "58:17: " + getCheckMessage(MSG_KEY, "s"), "74:17: " + getCheckMessage(MSG_KEY, "s"), @@ -76,7 +76,7 @@ public class FinalParametersCheckTest extends AbstractModuleTestSupport { } @Test - public void testCatchToken() throws Exception { + void catchToken() throws Exception { final String[] expected = { "130:16: " + getCheckMessage(MSG_KEY, "npe"), "136:16: " + getCheckMessage(MSG_KEY, "e"), @@ -86,7 +86,7 @@ public class FinalParametersCheckTest extends AbstractModuleTestSupport { } @Test - public void testForEachClauseToken() throws Exception { + void forEachClauseToken() throws Exception { final String[] expected = { "157:13: " + getCheckMessage(MSG_KEY, "s"), "165:13: " + getCheckMessage(MSG_KEY, "s"), }; @@ -94,7 +94,7 @@ public class FinalParametersCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnorePrimitiveTypesParameters() throws Exception { + void ignorePrimitiveTypesParameters() throws Exception { final String[] expected = { "14:22: " + getCheckMessage(MSG_KEY, "k"), "15:15: " + getCheckMessage(MSG_KEY, "s"), @@ -108,7 +108,7 @@ public class FinalParametersCheckTest extends AbstractModuleTestSupport { } @Test - public void testPrimitiveTypesParameters() throws Exception { + void primitiveTypesParameters() throws Exception { final String[] expected = { "13:14: " + getCheckMessage(MSG_KEY, "i"), "14:15: " + getCheckMessage(MSG_KEY, "i"), @@ -129,7 +129,7 @@ public class FinalParametersCheckTest extends AbstractModuleTestSupport { } @Test - public void testReceiverParameters() throws Exception { + void receiverParameters() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFinalParametersReceiver.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckTest.java @@ -40,7 +40,7 @@ import java.util.List; import java.util.Set; import org.junit.jupiter.api.Test; -public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { +final class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -48,13 +48,13 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewlineLfAtEndOfFile() throws Exception { + void newlineLfAtEndOfFile() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNewlineAtEndOfFileLf.java"), expected); } @Test - public void testNewlineLfAtEndOfFileLfNotOverlapWithCrLf() throws Exception { + void newlineLfAtEndOfFileLfNotOverlapWithCrLf() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_WRONG_ENDING), }; @@ -62,19 +62,19 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewlineCrlfAtEndOfFile() throws Exception { + void newlineCrlfAtEndOfFile() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNewlineAtEndOfFileCrlf3.java"), expected); } @Test - public void testNewlineCrAtEndOfFile() throws Exception { + void newlineCrAtEndOfFile() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNewlineAtEndOfFileCr.java"), expected); } @Test - public void testAnyNewlineAtEndOfFile() throws Exception { + void anyNewlineAtEndOfFile() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNewlineAtEndOfFileCrlf2.java"), expected); verifyWithInlineConfigParser(getPath("InputNewlineAtEndOfFileLf2.java"), expected); @@ -82,7 +82,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoNewlineLfAtEndOfFile() throws Exception { + void noNewlineLfAtEndOfFile() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_NEWLINE_EOF), }; @@ -90,7 +90,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoNewlineAtEndOfFile() throws Exception { + void noNewlineAtEndOfFile() throws Exception { final String msgKeyNoNewlineEof = "File does not end with a newline :)"; final String[] expected = { "1: " + msgKeyNoNewlineEof, @@ -99,7 +99,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testSetLineSeparatorFailure() throws Exception { + void setLineSeparatorFailure() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(NewlineAtEndOfFileCheck.class); checkConfig.addProperty("lineSeparator", "ct"); try { @@ -116,7 +116,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyFileFile() throws Exception { + void emptyFileFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(NewlineAtEndOfFileCheck.class); checkConfig.addProperty("lineSeparator", LineSeparatorOption.LF.toString()); final String[] expected = { @@ -126,7 +126,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithEmptyLineOnly() throws Exception { + void fileWithEmptyLineOnly() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(NewlineAtEndOfFileCheck.class); checkConfig.addProperty("lineSeparator", LineSeparatorOption.LF.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -134,7 +134,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithEmptyLineOnlyWithLfCrCrlf() throws Exception { + void fileWithEmptyLineOnlyWithLfCrCrlf() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(NewlineAtEndOfFileCheck.class); checkConfig.addProperty("lineSeparator", LineSeparatorOption.LF_CR_CRLF.toString()); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -142,7 +142,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongFile() throws Exception { + void wrongFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(NewlineAtEndOfFileCheck.class); final NewlineAtEndOfFileCheck check = new NewlineAtEndOfFileCheck(); check.configure(checkConfig); @@ -159,7 +159,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongSeparatorLength() throws Exception { + void wrongSeparatorLength() throws Exception { try (RandomAccessFile file = new ReadZeroRandomAccessFile(getPath("InputNewlineAtEndOfFileLf.java"), "r")) { TestUtil.invokeMethod( @@ -175,7 +175,7 @@ public class NewlineAtEndOfFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNewlineAtEndOfFileTestTrimProperty.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/NoCodeInFileCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/NoCodeInFileCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NoCodeInFileCheckTest extends AbstractModuleTestSupport { +final class NoCodeInFileCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class NoCodeInFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final NoCodeInFileCheck checkObj = new NoCodeInFileCheck(); assertWithMessage("Required tokens array is not empty") .that(checkObj.getRequiredTokens()) @@ -43,7 +43,7 @@ public class NoCodeInFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final NoCodeInFileCheck checkObj = new NoCodeInFileCheck(); assertWithMessage("Acceptable tokens array is not empty") .that(checkObj.getAcceptableTokens()) @@ -51,7 +51,7 @@ public class NoCodeInFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testBlank() throws Exception { + void blank() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(NoCodeInFileCheck.class); final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_CODE), @@ -60,7 +60,7 @@ public class NoCodeInFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testSingleLineComment() throws Exception { + void singleLineComment() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(NoCodeInFileCheck.class); final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_CODE), @@ -69,7 +69,7 @@ public class NoCodeInFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiLineComment() throws Exception { + void multiLineComment() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_CODE), }; @@ -77,12 +77,12 @@ public class NoCodeInFileCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileContainingCode() throws Exception { + void fileContainingCode() throws Exception { verifyWithInlineConfigParser(getPath("InputNoCodeInFile4.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testBothSingleLineAndMultiLineComment() throws Exception { + void bothSingleLineAndMultiLineComment() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_CODE), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/OrderedPropertiesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/OrderedPropertiesCheckTest.java @@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck.MSG_IO_EXCEPTION_KEY; import static com.puppycrawl.tools.checkstyle.checks.OrderedPropertiesCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.api.FileText; @@ -33,11 +34,10 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.NoSuchFileException; -import java.util.Collections; import java.util.SortedSet; import org.junit.jupiter.api.Test; -public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { +final class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -46,7 +46,7 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { /** Tests the ordinal work of a check. Test of sub keys, repeating key pairs in wrong order */ @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final String[] expected = { "8: " + getCheckMessage(MSG_KEY, "key1", "key2"), @@ -58,7 +58,7 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testKeysOnly() throws Exception { + void keysOnly() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final String[] expected = { "3: " + getCheckMessage(MSG_KEY, "key1", "key2"), @@ -67,7 +67,7 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyKeys() throws Exception { + void emptyKeys() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final String[] expected = { "3: " + getCheckMessage(MSG_KEY, "key11", "key2"), @@ -76,7 +76,7 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testMalformedValue() throws Exception { + void malformedValue() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final String fileName = getPath("InputOrderedProperties3MalformedValue.properties"); @@ -87,7 +87,7 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentsMultiLine() throws Exception { + void commentsMultiLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final String[] expected = { "5: " + getCheckMessage(MSG_KEY, "aKey", "multi.line"), @@ -96,7 +96,7 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testLineNumberRepeatingPreviousKey() throws Exception { + void lineNumberRepeatingPreviousKey() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final String[] expected = { "3: " + getCheckMessage(MSG_KEY, "a", "b"), @@ -106,7 +106,7 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testShouldNotProcessFilesWithWrongFileExtension() throws Exception { + void shouldNotProcessFilesWithWrongFileExtension() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verify(checkConfig, getPath("InputOrderedProperties.txt"), expected); @@ -114,13 +114,13 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { /** Tests IO exception, that can occur during reading of properties file. */ @Test - public void testIoException() throws Exception { + void ioException() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final OrderedPropertiesCheck check = new OrderedPropertiesCheck(); check.configure(checkConfig); final String fileName = getPath("InputOrderedPropertiesCheckNotExisting.properties"); final File file = new File(fileName); - final FileText fileText = new FileText(file, Collections.emptyList()); + final FileText fileText = new FileText(file, ImmutableList.of()); final SortedSet violations = check.process(file, fileText); assertWithMessage("Wrong violations count").that(violations).hasSize(1); final Violation violation = violations.iterator().next(); @@ -140,21 +140,21 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { * returning zero size. This will keep the for loop intact. */ @Test - public void testKeepForLoopIntact() throws Exception { + void keepForLoopIntact() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final OrderedPropertiesCheck check = new OrderedPropertiesCheck(); check.configure(checkConfig); final String fileName = getPath("InputOrderedProperties2EmptyValue.properties"); final File file = new File(fileName); - final FileText fileText = new FileText(file, Collections.emptyList()); + final FileText fileText = new FileText(file, ImmutableList.of()); final SortedSet violations = check.process(file, fileText); assertWithMessage("Wrong violations count").that(violations).hasSize(1); } @Test - public void testFileExtension() { + void fileExtension() { final OrderedPropertiesCheck check = new OrderedPropertiesCheck(); assertWithMessage("File extension should be set") @@ -163,7 +163,7 @@ public class OrderedPropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OrderedPropertiesCheck.class); final String[] expected = { "3: " + getCheckMessage(MSG_KEY, " A ", " B"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheckTest.java @@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle.checks; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -31,7 +32,7 @@ import java.io.File; import java.util.List; import org.junit.jupiter.api.Test; -public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { +final class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +40,7 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final OuterTypeFilenameCheck checkObj = new OuterTypeFilenameCheck(); final int[] expected = { TokenTypes.CLASS_DEF, @@ -54,19 +55,19 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGood1() throws Exception { + void good1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOuterTypeFilenameIllegalTokens.java"), expected); } @Test - public void testGood2() throws Exception { + void good2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOuterTypeFilename15Extensions.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final OuterTypeFilenameCheck check = new OuterTypeFilenameCheck(); final int[] actual = check.getAcceptableTokens(); final int[] expected = { @@ -82,13 +83,13 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNestedClass() throws Exception { + void nestedClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOuterTypeFilename1.java"), expected); } @Test - public void testNestedClass2() throws Exception { + void nestedClass2() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), }; @@ -96,19 +97,19 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinePublic() throws Exception { + void finePublic() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOuterTypeFilename2.java"), expected); } @Test - public void testPublicClassIsNotFirst() throws Exception { + void publicClassIsNotFirst() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOuterTypeFilenameCheckPublic.java"), expected); } @Test - public void testNoPublicClasses() throws Exception { + void noPublicClasses() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), }; @@ -116,13 +117,13 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testFineDefault() throws Exception { + void fineDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOuterTypeFilename3.java"), expected); } @Test - public void testWrongDefault() throws Exception { + void wrongDefault() throws Exception { final String[] expected = { "10:2: " + getCheckMessage(MSG_KEY), }; @@ -130,7 +131,7 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageAnnotation() throws Exception { + void packageAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -138,7 +139,7 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testOuterTypeFilenameRecords() throws Exception { + void outerTypeFilenameRecords() throws Exception { final String[] expected = { "10:1: " + getCheckMessage(MSG_KEY), @@ -148,7 +149,7 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testOuterTypeFilenameRecordsMethodRecordDef() throws Exception { + void outerTypeFilenameRecordsMethodRecordDef() throws Exception { final String[] expected = { "10:1: " + getCheckMessage(MSG_KEY), @@ -158,7 +159,7 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testStateIsClearedOnBeginTree2() throws Exception { + void stateIsClearedOnBeginTree2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String file1 = getPath("InputOuterTypeFilenameBeginTree1.java"); final String file2 = getPath("InputOuterTypeFilenameBeginTree2.java"); @@ -175,12 +176,12 @@ public class OuterTypeFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testStateIsClearedOnBeginTree3() throws Exception { + void stateIsClearedOnBeginTree3() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OuterTypeFilenameCheck.class); final String file1 = getPath("InputOuterTypeFilenameBeginTree1.java"); final String file2 = getPath("InputOuterTypeFilename1a.java"); final List expectedFirstInput = List.of(CommonUtil.EMPTY_STRING_ARRAY); - final List expectedSecondInput = List.of("9:1: " + getCheckMessage(MSG_KEY)); + final List expectedSecondInput = ImmutableList.of("9:1: " + getCheckMessage(MSG_KEY)); final File[] inputs = {new File(file1), new File(file2)}; verify( --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java @@ -48,7 +48,7 @@ import java.util.Optional; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { +final class SuppressWarningsHolderTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -56,7 +56,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @AfterEach - public void cleanUp() { + void cleanUp() { // clear cache that may have been set by tests new SuppressWarningsHolder().beginTree(null); @@ -67,7 +67,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testGet() { + void get() { final SuppressWarningsHolder checkObj = new SuppressWarningsHolder(); final int[] expected = {TokenTypes.ANNOTATION}; assertWithMessage("Required token array differs from expected") @@ -79,14 +79,14 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testOnComplexAnnotations() throws Exception { + void onComplexAnnotations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSuppressWarningsHolder.java"), expected); } @Test - public void testOnComplexAnnotationsNonConstant() throws Exception { + void onComplexAnnotationsNonConstant() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -94,14 +94,14 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testCustomAnnotation() throws Exception { + void customAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSuppressWarningsHolder5.java"), expected); } @Test - public void testAll() throws Exception { + void all() throws Exception { final String[] expected = { "21:23: " + getCheckMessage( @@ -112,7 +112,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testGetDefaultAlias() { + void getDefaultAlias() { assertWithMessage("Default alias differs from expected") .that(SuppressWarningsHolder.getDefaultAlias("SomeName")) .isEqualTo("somename"); @@ -122,7 +122,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testSetAliasListEmpty() { + void setAliasListEmpty() { final SuppressWarningsHolder holder = new SuppressWarningsHolder(); holder.setAliasList(""); assertWithMessage("Empty alias list should not be set") @@ -131,7 +131,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testSetAliasListCorrect() { + void setAliasListCorrect() { final SuppressWarningsHolder holder = new SuppressWarningsHolder(); holder.setAliasList("alias=value"); assertWithMessage("Alias differs from expected") @@ -140,7 +140,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testSetAliasListWrong() { + void setAliasListWrong() { final SuppressWarningsHolder holder = new SuppressWarningsHolder(); try { @@ -154,7 +154,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIsSuppressed() throws Exception { + void isSuppressed() throws Exception { populateHolder("MockEntry", 100, 100, 350, 350); final AuditEvent event = createAuditEvent("check", 100, 10); @@ -164,7 +164,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIsSuppressedByName() throws Exception { + void isSuppressedByName() throws Exception { populateHolder("check", 100, 100, 350, 350); final SuppressWarningsHolder holder = new SuppressWarningsHolder(); final AuditEvent event = createAuditEvent("id", 110, 10); @@ -176,7 +176,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIsSuppressedByModuleId() throws Exception { + void isSuppressedByModuleId() throws Exception { populateHolder("check", 100, 100, 350, 350); final AuditEvent event = createAuditEvent("check", 350, 350); @@ -186,7 +186,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIsSuppressedAfterEventEnd() throws Exception { + void isSuppressedAfterEventEnd() throws Exception { populateHolder("check", 100, 100, 350, 350); final AuditEvent event = createAuditEvent("check", 350, 352); @@ -196,7 +196,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIsSuppressedAfterEventEnd2() throws Exception { + void isSuppressedAfterEventEnd2() throws Exception { populateHolder("check", 100, 100, 350, 350); final AuditEvent event = createAuditEvent("check", 400, 10); @@ -206,7 +206,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIsSuppressedAfterEventStart() throws Exception { + void isSuppressedAfterEventStart() throws Exception { populateHolder("check", 100, 100, 350, 350); final AuditEvent event = createAuditEvent("check", 100, 100); @@ -216,7 +216,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIsSuppressedAfterEventStart2() throws Exception { + void isSuppressedAfterEventStart2() throws Exception { populateHolder("check", 100, 100, 350, 350); final AuditEvent event = createAuditEvent("check", 100, 0); @@ -226,7 +226,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIsSuppressedWithAllArgument() throws Exception { + void isSuppressedWithAllArgument() throws Exception { populateHolder("all", 100, 100, 350, 350); final Checker source = new Checker(); @@ -254,21 +254,21 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationInTry() throws Exception { + void annotationInTry() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSuppressWarningsHolder2.java"), expected); } @Test - public void testEmptyAnnotation() throws Exception { + void emptyAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSuppressWarningsHolder3.java"), expected); } @Test - public void testGetAllAnnotationValuesWrongArg() throws ReflectiveOperationException { + void getAllAnnotationValuesWrongArg() throws ReflectiveOperationException { final SuppressWarningsHolder holder = new SuppressWarningsHolder(); final Method getAllAnnotationValues = holder.getClass().getDeclaredMethod("getAllAnnotationValues", DetailAST.class); @@ -304,7 +304,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testGetAnnotationValuesWrongArg() throws ReflectiveOperationException { + void getAnnotationValuesWrongArg() throws ReflectiveOperationException { final SuppressWarningsHolder holder = new SuppressWarningsHolder(); final Method getAllAnnotationValues = holder.getClass().getDeclaredMethod("getAnnotationValues", DetailAST.class); @@ -334,7 +334,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testGetAnnotationTargetWrongArg() throws ReflectiveOperationException { + void getAnnotationTargetWrongArg() throws ReflectiveOperationException { final SuppressWarningsHolder holder = new SuppressWarningsHolder(); final Method getAnnotationTarget = holder.getClass().getDeclaredMethod("getAnnotationTarget", DetailAST.class); @@ -368,7 +368,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testAstWithoutChildren() { + void astWithoutChildren() { final SuppressWarningsHolder holder = new SuppressWarningsHolder(); final DetailAstImpl methodDef = new DetailAstImpl(); methodDef.setType(TokenTypes.METHOD_DEF); @@ -384,22 +384,22 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationWithFullName() throws Exception { + void annotationWithFullName() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSuppressWarningsHolder4.java"), expected); } @Test - public void testSuppressWarningsAsAnnotationProperty() throws Exception { + void suppressWarningsAsAnnotationProperty() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSuppressWarningsHolder7.java"), expected); } - @Test @SuppressWarnings("unchecked") - public void testClearState() throws Exception { + @Test + void clearState() throws Exception { final SuppressWarningsHolder check = new SuppressWarningsHolder(); final Optional annotationDef = @@ -414,7 +414,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - annotationDef.get(), + annotationDef.orElseThrow(), "ENTRIES", entries -> ((ThreadLocal>) entries).get().isEmpty())) .isTrue(); @@ -445,7 +445,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testSuppressWarningsTextBlocks() throws Exception { + void suppressWarningsTextBlocks() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { @@ -465,7 +465,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testWithAndWithoutCheckSuffixDifferentCases() throws Exception { + void withAndWithoutCheckSuffixDifferentCases() throws Exception { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { "16:30: " @@ -479,7 +479,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testAliasList() throws Exception { + void aliasList() throws Exception { final String[] expected = { "16:17: " + getCheckMessage(ParameterNumberCheck.class, ParameterNumberCheck.MSG_KEY, 7, 8), "28:17: " + getCheckMessage(ParameterNumberCheck.class, ParameterNumberCheck.MSG_KEY, 7, 8), @@ -488,7 +488,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testAliasList2() throws Exception { + void aliasList2() throws Exception { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { "16:29: " @@ -503,14 +503,14 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void testIdent() throws Exception { + void ident() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputSuppressWarningsHolder1.java"), expected); } @Test - public void testIdent2() throws Exception { + void ident2() throws Exception { final String[] expected = { "37:9: " + getCheckMessage(UnusedLocalVariableCheck.class, MSG_UNUSED_LOCAL_VARIABLE, "a"), "42:9: " + getCheckMessage(UnusedLocalVariableCheck.class, MSG_UNUSED_LOCAL_VARIABLE, "a"), @@ -520,7 +520,7 @@ public class SuppressWarningsHolderTest extends AbstractModuleTestSupport { } @Test - public void test3() throws Exception { + void test3() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class TodoCommentCheckTest extends AbstractModuleTestSupport { +final class TodoCommentCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class TodoCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final TodoCommentCheck checkObj = new TodoCommentCheck(); final int[] expected = {TokenTypes.COMMENT_CONTENT}; assertWithMessage("Required tokens differs from expected") @@ -43,7 +43,7 @@ public class TodoCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "1:3: " + getCheckMessage(MSG_KEY, "FIXME:"), "164:7: " + getCheckMessage(MSG_KEY, "FIXME:"), @@ -54,7 +54,7 @@ public class TodoCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final int[] expected = {TokenTypes.COMMENT_CONTENT}; final TodoCommentCheck check = new TodoCommentCheck(); final int[] actual = check.getAcceptableTokens(); @@ -65,7 +65,7 @@ public class TodoCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "11:16: " + getCheckMessage(MSG_KEY, "TODO:"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class TrailingCommentCheckTest extends AbstractModuleTestSupport { +final class TrailingCommentCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class TrailingCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final TrailingCommentCheck checkObj = new TrailingCommentCheck(); final int[] expected = { TokenTypes.SINGLE_LINE_COMMENT, TokenTypes.BLOCK_COMMENT_BEGIN, @@ -46,7 +46,7 @@ public class TrailingCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final TrailingCommentCheck checkObj = new TrailingCommentCheck(); final int[] expected = { TokenTypes.SINGLE_LINE_COMMENT, TokenTypes.BLOCK_COMMENT_BEGIN, @@ -57,7 +57,7 @@ public class TrailingCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaults() throws Exception { + void defaults() throws Exception { final String[] expected = { "13:12: " + getCheckMessage(MSG_KEY), "17:12: " + getCheckMessage(MSG_KEY), @@ -72,7 +72,7 @@ public class TrailingCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testLegalComment() throws Exception { + void legalComment() throws Exception { final String[] expected = { "13:12: " + getCheckMessage(MSG_KEY), "17:12: " + getCheckMessage(MSG_KEY), @@ -86,7 +86,7 @@ public class TrailingCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testFormat() throws Exception { + void format() throws Exception { final String[] expected = { "1:1: " + getCheckMessage(MSG_KEY), "12:12: " + getCheckMessage(MSG_KEY), @@ -111,7 +111,7 @@ public class TrailingCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testLegalCommentWithNoPrecedingWhitespace() throws Exception { + void legalCommentWithNoPrecedingWhitespace() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -119,7 +119,7 @@ public class TrailingCommentCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithEmoji() throws Exception { + void withEmoji() throws Exception { final String[] expected = { "13:24: " + getCheckMessage(MSG_KEY), "15:27: " + getCheckMessage(MSG_KEY), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheckTest.java @@ -22,7 +22,9 @@ package com.puppycrawl.tools.checkstyle.checks; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.TranslationCheck.MSG_KEY; import static com.puppycrawl.tools.checkstyle.checks.TranslationCheck.MSG_KEY_MISSING_TRANSLATION_FILE; +import static java.nio.charset.StandardCharsets.UTF_8; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean.OutputStreamOptions; import com.puppycrawl.tools.checkstyle.AbstractXmlTestSupport; @@ -44,7 +46,6 @@ import java.io.Writer; import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.util.Collections; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -52,7 +53,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.w3c.dom.Node; -public class TranslationCheckTest extends AbstractXmlTestSupport { +final class TranslationCheckTest extends AbstractXmlTestSupport { @TempDir public File temporaryFolder; @@ -62,7 +63,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testTranslation() throws Exception { + void translation() throws Exception { final Configuration checkConfig = createModuleConfig(TranslationCheck.class); final String[] expected = { "1: " + getCheckMessage(MSG_KEY, "only.english"), @@ -79,7 +80,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testDifferentBases() throws Exception { + void differentBases() throws Exception { final Configuration checkConfig = createModuleConfig(TranslationCheck.class); final String[] expected = { "1: " + getCheckMessage(MSG_KEY, "only.english"), @@ -98,9 +99,9 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testDifferentPaths() throws Exception { + void differentPaths() throws Exception { final File file = new File(temporaryFolder, "messages_test_de.properties"); - try (Writer writer = Files.newBufferedWriter(file.toPath(), StandardCharsets.UTF_8)) { + try (Writer writer = Files.newBufferedWriter(file.toPath(), UTF_8)) { final String content = "hello=Hello\ncancel=Cancel"; writer.write(content); } @@ -122,7 +123,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { * @throws Exception when code tested throws exception */ @Test - public void testStateIsCleared() throws Exception { + void stateIsCleared() throws Exception { final File fileToProcess = new File(getPath("InputTranslationCheckFireErrors_de.properties")); final String charset = StandardCharsets.UTF_8.name(); final TranslationCheck check = new TranslationCheck(); @@ -138,7 +139,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testFileExtension() throws Exception { + void fileExtension() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("baseName", "^InputTranslation.*$"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -149,7 +150,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testLogOutput() throws Exception { + void logOutput() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "ja,de"); checkConfig.addProperty("baseName", "^InputTranslation.*$"); @@ -176,9 +177,9 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { checker, propertyFiles, ImmutableMap.of( - ":1", Collections.singletonList(" " + firstErrorMessage), + ":1", ImmutableList.of(" " + firstErrorMessage), "InputTranslationCheckFireErrors_de.properties", - Collections.singletonList(line + secondErrorMessage))); + ImmutableList.of(line + secondErrorMessage))); verifyXml( getPath("ExpectedTranslationLog.xml"), @@ -189,7 +190,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testOnePropertyFileSet() throws Exception { + void onePropertyFileSet() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final File[] propertyFiles = { @@ -199,7 +200,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testLogIoExceptionFileNotFound() throws Exception { + void logIoExceptionFileNotFound() throws Exception { // I can't put wrong file here. Checkstyle fails before check started. // I saw some usage of file or handling of wrong file in Checker, or somewhere // in checks running part. So I had to do it with reflection to improve coverage. @@ -231,7 +232,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testLogIoException() throws Exception { + void logIoException() throws Exception { // I can't put wrong file here. Checkstyle fails before check started. // I saw some usage of file or handling of wrong file in Checker, or somewhere // in checks running part. So I had to do it with reflection to improve coverage. @@ -263,7 +264,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testLogIllegalArgumentException() throws Exception { + void logIllegalArgumentException() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("baseName", "^bad.*$"); final String[] expected = { @@ -277,7 +278,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testDefaultTranslationFileIsMissing() throws Exception { + void defaultTranslationFileIsMissing() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "ja,,, de, ja"); @@ -293,7 +294,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testTranslationFilesAreMissing() throws Exception { + void translationFilesAreMissing() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "ja, de"); @@ -310,7 +311,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testBaseNameWithSeparatorDefaultTranslationIsMissing() throws Exception { + void baseNameWithSeparatorDefaultTranslationIsMissing() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "fr"); @@ -325,7 +326,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testBaseNameWithSeparatorTranslationsAreMissing() throws Exception { + void baseNameWithSeparatorTranslationsAreMissing() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "fr, tr"); @@ -342,7 +343,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testIsNotMessagesBundle() throws Exception { + void isNotMessagesBundle() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "de"); @@ -355,7 +356,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testTranslationFileWithLanguageCountryVariantIsMissing() throws Exception { + void translationFileWithLanguageCountryVariantIsMissing() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "es, de"); @@ -372,7 +373,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testTranslationFileWithLanguageCountryVariantArePresent() throws Exception { + void translationFileWithLanguageCountryVariantArePresent() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "es, fr"); @@ -387,7 +388,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testBaseNameOption() throws Exception { + void baseNameOption() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "de, es, fr, ja"); checkConfig.addProperty("baseName", "^.*Labels$"); @@ -409,7 +410,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testFileExtensions() throws Exception { + void fileExtensions() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "de, es, fr, ja"); checkConfig.addProperty("fileExtensions", "properties,translation"); @@ -435,7 +436,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testEqualBaseNamesButDifferentExtensions() throws Exception { + void equalBaseNamesButDifferentExtensions() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "de, es, fr, ja"); checkConfig.addProperty("fileExtensions", "properties,translations"); @@ -461,7 +462,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testEqualBaseNamesButDifferentExtensions2() throws Exception { + void equalBaseNamesButDifferentExtensions2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "de, es"); checkConfig.addProperty("fileExtensions", "properties, translations"); @@ -484,7 +485,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testRegexpToMatchPartOfBaseName() throws Exception { + void regexpToMatchPartOfBaseName() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "de, es, fr, ja"); checkConfig.addProperty("fileExtensions", "properties,translations"); @@ -505,7 +506,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testBundlesWithSameNameButDifferentPaths() throws Exception { + void bundlesWithSameNameButDifferentPaths() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(TranslationCheck.class); checkConfig.addProperty("requiredTranslations", "de"); checkConfig.addProperty("fileExtensions", "properties"); @@ -524,7 +525,7 @@ public class TranslationCheckTest extends AbstractXmlTestSupport { } @Test - public void testWrongUserSpecifiedLanguageCodes() { + void wrongUserSpecifiedLanguageCodes() { final TranslationCheck check = new TranslationCheck(); try { check.setRequiredTranslations("11"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheckTest.java @@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle.checks; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.UncommentedMainCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -33,7 +34,7 @@ import java.util.List; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class UncommentedMainCheckTest extends AbstractModuleTestSupport { +final class UncommentedMainCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,7 +42,7 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaults() throws Exception { + void defaults() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY), "26:5: " + getCheckMessage(MSG_KEY), @@ -52,7 +53,7 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludedClasses() throws Exception { + void excludedClasses() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY), "35:5: " + getCheckMessage(MSG_KEY), @@ -62,7 +63,7 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokens() { + void tokens() { final UncommentedMainCheck check = new UncommentedMainCheck(); assertWithMessage("Required tokens should not be null") .that(check.getRequiredTokens()) @@ -79,13 +80,13 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { } @Test - public void testDeepDepth() throws Exception { + void deepDepth() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputUncommentedMain2.java"), expected); } @Test - public void testVisitPackage() throws Exception { + void visitPackage() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY), }; @@ -93,19 +94,19 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongName() throws Exception { + void wrongName() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputUncommentedMain3.java"), expected); } @Test - public void testWrongArrayType() throws Exception { + void wrongArrayType() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputUncommentedMain4.java"), expected); } @Test - public void testIllegalStateException() { + void illegalStateException() { final UncommentedMainCheck check = new UncommentedMainCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(new CommonToken(TokenTypes.CTOR_DEF, "ctor")); @@ -120,7 +121,7 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecords() throws Exception { + void records() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY), @@ -133,13 +134,13 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { } @Test - public void testStateIsClearedOnBeginTree() throws Exception { + void stateIsClearedOnBeginTree() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(UncommentedMainCheck.class); final String file1 = getNonCompilablePath("InputUncommentedMainRecords2.java"); final String file2 = getNonCompilablePath("InputUncommentedMainBeginTree2.java"); final List expectedFirstInput = - List.of("12:5: " + getCheckMessage(MSG_KEY), "21:24: " + getCheckMessage(MSG_KEY)); - final List expectedSecondInput = List.of("13:13: " + getCheckMessage(MSG_KEY)); + ImmutableList.of("12:5: " + getCheckMessage(MSG_KEY), "21:24: " + getCheckMessage(MSG_KEY)); + final List expectedSecondInput = ImmutableList.of("13:13: " + getCheckMessage(MSG_KEY)); final File[] inputs = {new File(file1), new File(file2)}; verify( @@ -151,7 +152,7 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { } @Test - public void testStateIsClearedOnBeginTree2() throws Exception { + void stateIsClearedOnBeginTree2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(UncommentedMainCheck.class); checkConfig.addProperty( "excludedClasses", "uncommentedmain\\.InputUncommentedMainBeginTreePackage2"); @@ -159,7 +160,7 @@ public class UncommentedMainCheckTest extends AbstractModuleTestSupport { final String file2 = getPath("InputUncommentedMainBeginTreePackage2.java"); final List expectedFirstInput = List.of(CommonUtil.EMPTY_STRING_ARRAY); final List expectedSecondInput = - List.of("3:5: " + getCheckMessage(MSG_KEY), "12:5: " + getCheckMessage(MSG_KEY)); + ImmutableList.of("3:5: " + getCheckMessage(MSG_KEY), "12:5: " + getCheckMessage(MSG_KEY)); final File[] inputs = {new File(file1), new File(file2)}; verify( --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckTest.java @@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.UniquePropertiesCheck.MSG_IO_EXCEPTION_KEY; import static com.puppycrawl.tools.checkstyle.checks.UniquePropertiesCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.api.FileText; @@ -36,14 +37,13 @@ import java.lang.reflect.Method; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.SortedSet; import org.junit.jupiter.api.Test; -public class UniquePropertiesCheckTest extends AbstractModuleTestSupport { +final class UniquePropertiesCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -55,14 +55,14 @@ public class UniquePropertiesCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testLineSeparatorOptionValueOf() { + void lineSeparatorOptionValueOf() { final LineSeparatorOption option = LineSeparatorOption.valueOf("CR"); assertWithMessage("Invalid valueOf result").that(option).isEqualTo(LineSeparatorOption.CR); } /** Tests the ordinal work of a check. */ @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(UniquePropertiesCheck.class); final String[] expected = { "3: " + getCheckMessage(MSG_KEY, "general.exception", 2), @@ -82,7 +82,7 @@ public class UniquePropertiesCheckTest extends AbstractModuleTestSupport { * @noinspectionreason JavadocReference - reference is required to specify method under test */ @Test - public void testNotFoundKey() throws Exception { + void notFoundKey() throws Exception { final List testStrings = new ArrayList<>(3); final Method getLineNumber = UniquePropertiesCheck.class.getDeclaredMethod( @@ -100,7 +100,7 @@ public class UniquePropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testDuplicatedProperty() throws Exception { + void duplicatedProperty() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(UniquePropertiesCheck.class); final String[] expected = { "2: " + getCheckMessage(MSG_KEY, "key", 2), @@ -109,7 +109,7 @@ public class UniquePropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testShouldNotProcessFilesWithWrongFileExtension() throws Exception { + void shouldNotProcessFilesWithWrongFileExtension() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(UniquePropertiesCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verify(checkConfig, getPath("InputUniqueProperties.txt"), expected); @@ -117,13 +117,13 @@ public class UniquePropertiesCheckTest extends AbstractModuleTestSupport { /** Tests IO exception, that can occur during reading of properties file. */ @Test - public void testIoException() throws Exception { + void ioException() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(UniquePropertiesCheck.class); final UniquePropertiesCheck check = new UniquePropertiesCheck(); check.configure(checkConfig); final String fileName = getPath("InputUniquePropertiesCheckNotExisting.properties"); final File file = new File(fileName); - final FileText fileText = new FileText(file, Collections.emptyList()); + final FileText fileText = new FileText(file, ImmutableList.of()); final SortedSet violations = check.process(file, fileText); assertWithMessage("Wrong messages count: " + violations.size()).that(violations).hasSize(1); final Violation violation = violations.iterator().next(); @@ -137,7 +137,7 @@ public class UniquePropertiesCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongKeyTypeInProperties() throws Exception { + void wrongKeyTypeInProperties() throws Exception { final Class uniquePropertiesClass = Class.forName( "com.puppycrawl.tools.checkstyle.checks." + "UniquePropertiesCheck$UniqueProperties"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/UpperEllCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/UpperEllCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class UpperEllCheckTest extends AbstractModuleTestSupport { +final class UpperEllCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class UpperEllCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final UpperEllCheck checkObj = new UpperEllCheck(); final int[] expected = {TokenTypes.NUM_LONG}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class UpperEllCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithChecker() throws Exception { + void withChecker() throws Exception { final String[] expected = { "96:40: " + getCheckMessage(MSG_KEY), }; @@ -51,7 +51,7 @@ public class UpperEllCheckTest extends AbstractModuleTestSupport { } @Test - public void testAcceptableTokens() { + void acceptableTokens() { final int[] expected = {TokenTypes.NUM_LONG}; final UpperEllCheck check = new UpperEllCheck(); final int[] actual = check.getAcceptableTokens(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { +final class AnnotationLocationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AnnotationLocationCheck checkObj = new AnnotationLocationCheck(); assertWithMessage( "AnnotationLocationCheck#getRequiredTokens should return empty array by default") @@ -45,14 +45,14 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotationLocationCorrect.java"), expected); } @Test - public void testIncorrectOne() throws Exception { + void incorrectOne() throws Exception { final String[] expected = { "15:11: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnn"), "20:15: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation1"), @@ -82,7 +82,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrectTwo() throws Exception { + void incorrectTwo() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnn_21", 0, 3), }; @@ -90,7 +90,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrectAllTokensOne() throws Exception { + void incorrectAllTokensOne() throws Exception { final String[] expected = { "15:11: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnn3"), "20:15: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation_13"), @@ -120,7 +120,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrectAllTokensTwo() throws Exception { + void incorrectAllTokensTwo() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnn_23", 0, 3), }; @@ -128,7 +128,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AnnotationLocationCheck constantNameCheckObj = new AnnotationLocationCheck(); final int[] actual = constantNameCheckObj.getAcceptableTokens(); final int[] expected = { @@ -149,13 +149,13 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithoutAnnotations() throws Exception { + void withoutAnnotations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotationLocationEmpty.java"), expected); } @Test - public void testWithParametersOne() throws Exception { + void withParametersOne() throws Exception { final String[] expected = { "25:9: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation_12", 8, 4), "33:9: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnnotation_12", 8, 4), @@ -174,7 +174,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithParametersTwo() throws Exception { + void withParametersTwo() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "MyAnn_22", 0, 3), }; @@ -182,7 +182,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithMultipleAnnotations() throws Exception { + void withMultipleAnnotations() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation11"), "14:17: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "MyAnnotation12"), @@ -193,14 +193,14 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllTokens() throws Exception { + void allTokens() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAnnotationLocationWithoutAnnotations.java"), expected); } @Test - public void testAnnotation() throws Exception { + void annotation() throws Exception { final String[] expected = { "18:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "AnnotationAnnotation", 2, 0), "20:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "AnnotationAnnotation"), @@ -211,7 +211,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testClass() throws Exception { + void testClass() throws Exception { final String[] expected = { "18:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "ClassAnnotation", 2, 0), "20:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "ClassAnnotation"), @@ -224,7 +224,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnum() throws Exception { + void testEnum() throws Exception { final String[] expected = { "18:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "EnumAnnotation", 2, 0), "19:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "EnumAnnotation"), @@ -235,7 +235,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterface() throws Exception { + void testInterface() throws Exception { final String[] expected = { "18:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "InterfaceAnnotation", 2, 0), "20:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "InterfaceAnnotation"), @@ -246,7 +246,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackage() throws Exception { + void testPackage() throws Exception { final String[] expected = { "12:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION, "PackageAnnotation", 2, 0), "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "PackageAnnotation"), @@ -255,20 +255,20 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationInForEachLoopParameterAndVariableDef() throws Exception { + void annotationInForEachLoopParameterAndVariableDef() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAnnotationLocationDeprecatedAndCustom.java"), expected); } @Test - public void testAnnotationMultiple() throws Exception { + void annotationMultiple() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotationLocationMultiple.java"), expected); } @Test - public void testAnnotationParameterized() throws Exception { + void annotationParameterized() throws Exception { final String[] expected = { "18:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Annotation"), "20:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Annotation"), @@ -282,7 +282,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationSingleParameterless() throws Exception { + void annotationSingleParameterless() throws Exception { final String[] expected = { "23:17: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Annotation"), "25:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Annotation"), @@ -297,7 +297,7 @@ public class AnnotationLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationLocationRecordsAndCompactCtors() throws Exception { + void annotationLocationRecordsAndCompactCtors() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "SuppressWarnings"), "24:5: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "SuppressWarnings"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationOnSameLineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationOnSameLineCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { +final class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AnnotationOnSameLineCheck check = new AnnotationOnSameLineCheck(); assertWithMessage( "AnnotationOnSameLineCheck#getRequiredTokens should return empty array by default") @@ -44,7 +44,7 @@ public class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AnnotationOnSameLineCheck constantNameCheckObj = new AnnotationOnSameLineCheck(); final int[] actual = constantNameCheckObj.getAcceptableTokens(); final int[] expected = { @@ -70,7 +70,7 @@ public class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationOnSameLineCheckPublicMethodAndVariable() throws Exception { + void annotationOnSameLineCheckPublicMethodAndVariable() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation"), "18:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation"), @@ -82,7 +82,7 @@ public class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationOnSameLineCheckTokensOnMethodAndVar() throws Exception { + void annotationOnSameLineCheckTokensOnMethodAndVar() throws Exception { final String[] expected = { "18:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation3"), "19:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation"), @@ -94,7 +94,7 @@ public class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationOnSameLineCheckPrivateAndDeprecatedVar() throws Exception { + void annotationOnSameLineCheckPrivateAndDeprecatedVar() throws Exception { final String[] expected = { "19:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Ann"), "24:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "SuppressWarnings"), @@ -106,7 +106,7 @@ public class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationOnSameLineCheckInterfaceAndEnum() throws Exception { + void annotationOnSameLineCheckInterfaceAndEnum() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Ann"), "17:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Ann"), @@ -130,7 +130,7 @@ public class AnnotationOnSameLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationOnSameLineRecordsAndCompactCtors() throws Exception { + void annotationOnSameLineRecordsAndCompactCtors() throws Exception { final String[] expected = { "13:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "NonNull1"), "17:5: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "SuppressWarnings"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheckTest.java @@ -33,7 +33,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import de.thetaphi.forbiddenapis.SuppressForbidden; import org.junit.jupiter.api.Test; -public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { +final class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -45,7 +45,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testElementStyleOptionValueOf() { + void elementStyleOptionValueOf() { final AnnotationUseStyleCheck.ElementStyleOption option = AnnotationUseStyleCheck.ElementStyleOption.valueOf("COMPACT"); assertWithMessage("Invalid valueOf result") @@ -58,7 +58,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testTrailingArrayCommaOptionValueOf() { + void trailingArrayCommaOptionValueOf() { final AnnotationUseStyleCheck.TrailingArrayCommaOption option = AnnotationUseStyleCheck.TrailingArrayCommaOption.valueOf("ALWAYS"); assertWithMessage("Invalid valueOf result") @@ -71,7 +71,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testClosingParensOptionValueOf() { + void closingParensOptionValueOf() { final AnnotationUseStyleCheck.ClosingParensOption option = AnnotationUseStyleCheck.ClosingParensOption.valueOf("ALWAYS"); assertWithMessage("Invalid valueOf result") @@ -88,7 +88,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { */ @SuppressForbidden @Test - public void testNonTrimmedInput() throws Exception { + void nonTrimmedInput() throws Exception { final DefaultConfiguration configuration = createModuleConfig(AnnotationUseStyleCheck.class); configuration.addProperty("elementStyle", "ignore"); configuration.addProperty("closingParens", " ignore "); @@ -100,7 +100,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), @@ -123,7 +123,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { /** Test that annotation parens are always present. */ @Test - public void testParensAlways() throws Exception { + void parensAlways() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_MISSING), "27:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_MISSING), @@ -139,7 +139,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { /** Test that annotation parens are never present. */ @Test - public void testParensNever() throws Exception { + void parensNever() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_PRESENT), "40:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_PRESENT), @@ -152,7 +152,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testStyleExpanded() throws Exception { + void styleExpanded() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), "21:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), @@ -170,7 +170,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testStyleCompact() throws Exception { + void styleCompact() throws Exception { final String[] expected = { "52:5: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT"), "56:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT"), @@ -183,7 +183,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testStyleCompactNoArray() throws Exception { + void styleCompactNoArray() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), "14:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), @@ -200,7 +200,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommaAlwaysViolations() throws Exception { + void commaAlwaysViolations() throws Exception { final String[] expected = { "12:20: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), "15:30: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), @@ -221,7 +221,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommaAlwaysViolationsNonCompilable() throws Exception { + void commaAlwaysViolationsNonCompilable() throws Exception { final String[] expected = { "15:37: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), "15:65: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), @@ -232,7 +232,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommaAlwaysNoViolations() throws Exception { + void commaAlwaysNoViolations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -240,7 +240,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommaAlwaysNoViolationsNonCompilable() throws Exception { + void commaAlwaysNoViolationsNonCompilable() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -248,7 +248,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrailingArrayIgnore() throws Exception { + void trailingArrayIgnore() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), "23:13: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), @@ -261,7 +261,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommaNeverViolations() throws Exception { + void commaNeverViolations() throws Exception { final String[] expected = { "16:32: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), "21:42: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_PRESENT), @@ -278,7 +278,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommaNeverNoViolations() throws Exception { + void commaNeverNoViolations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -286,21 +286,21 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testEverythingMixed() throws Exception { + void everythingMixed() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotationUseStyleEverythingMixed.java"), expected); } @Test - public void testAnnotationsWithoutDefaultValues() throws Exception { + void annotationsWithoutDefaultValues() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotationUseStyleParams.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AnnotationUseStyleCheck constantNameCheckObj = new AnnotationUseStyleCheck(); final int[] actual = constantNameCheckObj.getAcceptableTokens(); final int[] expected = {TokenTypes.ANNOTATION}; @@ -308,7 +308,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetOption() { + void getOption() { final AnnotationUseStyleCheck check = new AnnotationUseStyleCheck(); try { check.setElementStyle("SHOULD_PRODUCE_ERROR"); @@ -323,7 +323,7 @@ public class AnnotationUseStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testStyleNotInList() throws Exception { + void styleNotInList() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotationUseStyle.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { +final class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetDefaultJavadocTokens() { + void getDefaultJavadocTokens() { final MissingDeprecatedCheck missingDeprecatedCheck = new MissingDeprecatedCheck(); final int[] expected = { JavadocTokenTypes.JAVADOC, @@ -48,7 +48,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredJavadocTokens() { + void getRequiredJavadocTokens() { final MissingDeprecatedCheck checkObj = new MissingDeprecatedCheck(); final int[] expected = { JavadocTokenTypes.JAVADOC, @@ -60,7 +60,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { /** Tests that members that are only deprecated via javadoc are flagged. */ @Test - public void testBadDeprecatedAnnotation() throws Exception { + void badDeprecatedAnnotation() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -79,7 +79,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { /** Tests that members that are only deprecated via the annotation are flagged. */ @Test - public void testBadDeprecatedJavadoc() throws Exception { + void badDeprecatedJavadoc() throws Exception { final String[] expected = { "18: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -94,7 +94,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { /** Tests various special deprecation conditions such as duplicate or empty tags. */ @Test - public void testSpecialCaseDeprecated() throws Exception { + void specialCaseDeprecated() throws Exception { final String[] expected = { "12: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), @@ -114,7 +114,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { /** Tests that good forms of deprecation are not flagged. */ @Test - public void testGoodDeprecated() throws Exception { + void goodDeprecated() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -122,7 +122,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { } @Test - public void testTwoInJavadocWithoutAnnotation() throws Exception { + void twoInJavadocWithoutAnnotation() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_KEY_JAVADOC_DUPLICATE_TAG, "@deprecated"), @@ -133,7 +133,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyJavadocLine() throws Exception { + void emptyJavadocLine() throws Exception { final String[] expected = { "18: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -143,7 +143,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageInfo() throws Exception { + void packageInfo() throws Exception { final String[] expected = { "9: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -153,7 +153,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { } @Test - public void testDepPackageInfoBelowComment() throws Exception { + void depPackageInfoBelowComment() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), @@ -163,7 +163,7 @@ public class MissingDeprecatedCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageInfoBelowComment() throws Exception { + void packageInfoBelowComment() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MissingOverrideCheckTest extends AbstractModuleTestSupport { +final class MissingOverrideCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -40,7 +40,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * including the inheritDoc tag. */ @Test - public void testBadOverrideFromObject() throws Exception { + void badOverrideFromObject() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), @@ -59,7 +59,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * including the inheritDoc tag even in Java 5 compatibility mode. */ @Test - public void testBadOverrideFromObjectJ5Compatible() throws Exception { + void badOverrideFromObjectJ5Compatible() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), @@ -77,7 +77,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * including the inheritDoc tag. */ @Test - public void testBadOverrideFromOther() throws Exception { + void badOverrideFromOther() throws Exception { final String[] expected = { "17:3: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), "33:3: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), @@ -100,7 +100,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * compatibility mode. */ @Test - public void testBadOverrideFromOtherJ5Compatible() throws Exception { + void badOverrideFromOtherJ5Compatible() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -113,7 +113,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * including the inheritDoc tag. */ @Test - public void testBadAnnotationOverride() throws Exception { + void badAnnotationOverride() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), "23:9: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE), @@ -129,7 +129,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * compatibility mode. */ @Test - public void testBadAnnotationOverrideJ5Compatible() throws Exception { + void badAnnotationOverrideJ5Compatible() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMissingOverrideBadAnnotationJava5.java"), expected); @@ -139,7 +139,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * Tests that inheritDoc misuse is properly flagged or missing Javadocs do not cause a problem. */ @Test - public void testNotOverride() throws Exception { + void notOverride() throws Exception { final String[] expected = { "15:3: " + getCheckMessage(MSG_KEY_TAG_NOT_VALID_ON, "{@inheritDoc}"), "20:3: " + getCheckMessage(MSG_KEY_TAG_NOT_VALID_ON, "{@inheritDoc}"), @@ -153,7 +153,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * including the inheritDoc tag. */ @Test - public void testGoodOverrideFromObject() throws Exception { + void goodOverrideFromObject() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -166,7 +166,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * including the inheritDoc tag even in Java 5 compatibility mode. */ @Test - public void testGoodOverrideFromObjectJ5Compatible() throws Exception { + void goodOverrideFromObjectJ5Compatible() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -179,7 +179,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * including the inheritDoc tag. */ @Test - public void testGoodOverrideFromOther() throws Exception { + void goodOverrideFromOther() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -191,7 +191,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * compatibility mode. */ @Test - public void testGoodOverrideFromOtherJ5Compatible() throws Exception { + void goodOverrideFromOtherJ5Compatible() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -204,7 +204,7 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * including the inheritDoc tag. */ @Test - public void testGoodAnnotationOverride() throws Exception { + void goodAnnotationOverride() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMissingOverrideGoodOverride.java"), expected); @@ -215,14 +215,14 @@ public class MissingOverrideCheckTest extends AbstractModuleTestSupport { * compatibility mode. */ @Test - public void testGoodAnnotationOverrideJ5Compatible() throws Exception { + void goodAnnotationOverrideJ5Compatible() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMissingOverrideGoodOverrideJava5.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final int[] expectedTokens = {TokenTypes.METHOD_DEF}; final MissingOverrideCheck check = new MissingOverrideCheck(); final int[] actual = check.getAcceptableTokens(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/PackageAnnotationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/PackageAnnotationCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class PackageAnnotationCheckTest extends AbstractModuleTestSupport { +final class PackageAnnotationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class PackageAnnotationCheckTest extends AbstractModuleTestSupport { /** This tests a package annotation that is in the package-info.java file. */ @Test - public void testGoodPackageAnnotation() throws Exception { + void goodPackageAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -44,7 +44,7 @@ public class PackageAnnotationCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final PackageAnnotationCheck constantNameCheckObj = new PackageAnnotationCheck(); final int[] actual = constantNameCheckObj.getAcceptableTokens(); final int[] expected = {TokenTypes.PACKAGE_DEF}; @@ -52,7 +52,7 @@ public class PackageAnnotationCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoPackageAnnotation() throws Exception { + void noPackageAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -60,7 +60,7 @@ public class PackageAnnotationCheckTest extends AbstractModuleTestSupport { } @Test - public void testBadPackageAnnotation() throws Exception { + void badPackageAnnotation() throws Exception { final String[] expected = { "10:1: " + getCheckMessage(MSG_KEY), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { +final class SuppressWarningsCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings with default regex. */ @Test - public void testSingleDefault() throws Exception { + void singleDefault() throws Exception { final String[] expected = { "18:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -53,7 +53,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings all warnings disabled on everything. */ @Test - public void testSingleAll() throws Exception { + void singleAll() throws Exception { final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -91,7 +91,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked warning disabled on everything. */ @Test - public void testSingleNoUnchecked() throws Exception { + void singleNoUnchecked() throws Exception { final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -110,7 +110,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked warning disabled on certain tokens. */ @Test - public void testSingleNoUncheckedTokens() throws Exception { + void singleNoUncheckedTokens() throws Exception { final String[] expected = { "13:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -126,7 +126,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings un* warning disabled on everything. */ @Test - public void testSingleNoUnWildcard() throws Exception { + void singleNoUnWildcard() throws Exception { final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -154,7 +154,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked, unused warning disabled on everything. */ @Test - public void testSingleNoUncheckedUnused() throws Exception { + void singleNoUncheckedUnused() throws Exception { final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -179,7 +179,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings *, unchecked, unused warning disabled on everything. */ @Test - public void testSingleNoUncheckedUnusedAll() throws Exception { + void singleNoUncheckedUnusedAll() throws Exception { final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -217,7 +217,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings with default regex. */ @Test - public void testCompactDefault() throws Exception { + void compactDefault() throws Exception { final String[] expected = { "18:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -230,7 +230,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testCompactDefaultNonConstant() throws Exception { + void compactDefaultNonConstant() throws Exception { final String[] expected = { "18:24: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -255,7 +255,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings all warnings disabled on everything. */ @Test - public void testCompactAll() throws Exception { + void compactAll() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -281,7 +281,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testCompactAllNonConstant() throws Exception { + void compactAllNonConstant() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -334,7 +334,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked warning disabled on everything. */ @Test - public void testCompactNoUnchecked() throws Exception { + void compactNoUnchecked() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -349,7 +349,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked warning disabled on certain tokens. */ @Test - public void testCompactNoUncheckedTokens() throws Exception { + void compactNoUncheckedTokens() throws Exception { final String[] expected = { "13:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -359,7 +359,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testCompactNoUncheckedTokensNonConstant() throws Exception { + void compactNoUncheckedTokensNonConstant() throws Exception { final String[] expected = { "13:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -373,7 +373,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings un* warning disabled on everything. */ @Test - public void testCompactNoUnWildcard() throws Exception { + void compactNoUnWildcard() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -392,7 +392,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testCompactNoUnWildcardNonConstant() throws Exception { + void compactNoUnWildcardNonConstant() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -426,7 +426,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked, unused warning disabled on everything. */ @Test - public void testCompactNoUncheckedUnused() throws Exception { + void compactNoUncheckedUnused() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -444,7 +444,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testCompactNoUncheckedUnusedNonConstant() throws Exception { + void compactNoUncheckedUnusedNonConstant() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -477,7 +477,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings *, unchecked, unused warning disabled on everything. */ @Test - public void testCompactNoUncheckedUnusedAll() throws Exception { + void compactNoUncheckedUnusedAll() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -503,7 +503,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testCompactNoUncheckedUnusedAllNonConstant() throws Exception { + void compactNoUncheckedUnusedAllNonConstant() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -556,7 +556,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings with default regex. */ @Test - public void testExpandedDefault() throws Exception { + void expandedDefault() throws Exception { final String[] expected = { "18:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -569,7 +569,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testExpandedDefaultNonConstant() throws Exception { + void expandedDefaultNonConstant() throws Exception { final String[] expected = { "18:30: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, " "), @@ -594,7 +594,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings all warnings disabled on everything. */ @Test - public void testExpandedAll() throws Exception { + void expandedAll() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -620,7 +620,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testExpandedAllNonConstant() throws Exception { + void expandedAllNonConstant() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -673,7 +673,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked warning disabled on everything. */ @Test - public void testExpandedNoUnchecked() throws Exception { + void expandedNoUnchecked() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -687,7 +687,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testExpandedNoUncheckedNonConstant() throws Exception { + void expandedNoUncheckedNonConstant() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -711,7 +711,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked warning disabled on certain tokens. */ @Test - public void testExpandedNoUncheckedTokens() throws Exception { + void expandedNoUncheckedTokens() throws Exception { final String[] expected = { "13:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -721,7 +721,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testExpandedNoUncheckedTokensNonConstant() throws Exception { + void expandedNoUncheckedTokensNonConstant() throws Exception { final String[] expected = { "13:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -735,7 +735,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings un* warning disabled on everything. */ @Test - public void testExpandedNoUnWildcard() throws Exception { + void expandedNoUnWildcard() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -754,7 +754,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testExpandedNoUnWildcardNonConstant() throws Exception { + void expandedNoUnWildcardNonConstant() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -788,7 +788,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings unchecked, unused warning disabled on everything. */ @Test - public void testExpandedNoUncheckedUnused() throws Exception { + void expandedNoUncheckedUnused() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -806,7 +806,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testExpandedNoUncheckedUnusedNonConstant() throws Exception { + void expandedNoUncheckedUnusedNonConstant() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -839,7 +839,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { /** Tests SuppressWarnings *, unchecked, unused warning disabled on everything. */ @Test - public void testExpandedNoUncheckedUnusedAll() throws Exception { + void expandedNoUncheckedUnusedAll() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -865,7 +865,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testExpandedNoUncheckedUnusedAllNonConstant() throws Exception { + void expandedNoUncheckedUnusedAllNonConstant() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), @@ -917,7 +917,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testUncheckedInConstant() throws Exception { + void uncheckedInConstant() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -925,7 +925,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testValuePairAnnotation() throws Exception { + void valuePairAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -933,7 +933,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testWorkingProperlyOnComplexAnnotations() throws Exception { + void workingProperlyOnComplexAnnotations() throws Exception { final String[] expected = { "30:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), @@ -945,7 +945,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testWorkingProperlyOnComplexAnnotationsNonConstant() throws Exception { + void workingProperlyOnComplexAnnotationsNonConstant() throws Exception { final String[] expected = { "30:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), @@ -959,7 +959,7 @@ public class SuppressWarningsCheckTest extends AbstractModuleTestSupport { } @Test - public void testSuppressWarningsRecords() throws Exception { + void suppressWarningsRecords() throws Exception { final String[] expected = { "24:28: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unchecked"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class AvoidNestedBlocksCheckTest extends AbstractModuleTestSupport { +final class AvoidNestedBlocksCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class AvoidNestedBlocksCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AvoidNestedBlocksCheck checkObj = new AvoidNestedBlocksCheck(); final int[] expected = {TokenTypes.SLIST}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class AvoidNestedBlocksCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrictSettings() throws Exception { + void strictSettings() throws Exception { final String[] expected = { "25:9: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), "47:17: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), @@ -54,7 +54,7 @@ public class AvoidNestedBlocksCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowSwitchInCase() throws Exception { + void allowSwitchInCase() throws Exception { final String[] expected = { "21:9: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), @@ -65,7 +65,7 @@ public class AvoidNestedBlocksCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AvoidNestedBlocksCheck constantNameCheckObj = new AvoidNestedBlocksCheck(); final int[] actual = constantNameCheckObj.getAcceptableTokens(); final int[] expected = {TokenTypes.SLIST}; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyBlockCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyBlockCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class EmptyBlockCheckTest extends AbstractModuleTestSupport { +final class EmptyBlockCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -40,13 +40,13 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testBlockOptionValueOf() { + void blockOptionValueOf() { final BlockOption option = BlockOption.valueOf("TEXT"); assertWithMessage("Invalid valueOf result").that(option).isEqualTo(BlockOption.TEXT); } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "38:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), "40:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), @@ -61,7 +61,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testText() throws Exception { + void text() throws Exception { final String[] expected = { "38:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "try"), "40:17: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "finally"), @@ -73,7 +73,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testStatement() throws Exception { + void statement() throws Exception { final String[] expected = { "38:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), "40:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), @@ -88,7 +88,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void allowEmptyLoops() throws Exception { + void allowEmptyLoops() throws Exception { final String[] expected = { "21:21: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), "24:34: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT), @@ -99,7 +99,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void allowEmptyLoopsText() throws Exception { + void allowEmptyLoopsText() throws Exception { final String[] expected = { "26:21: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "if"), "29:34: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "if"), @@ -110,7 +110,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -129,7 +129,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowEmptyCaseWithText() throws Exception { + void allowEmptyCaseWithText() throws Exception { final String[] expected = { "16:28: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "case"), "22:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "case"), @@ -141,7 +141,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testForbidCaseWithoutStmt() throws Exception { + void forbidCaseWithoutStmt() throws Exception { final String[] expected = { "16:28: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"), "22:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "case"), @@ -155,7 +155,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowEmptyDefaultWithText() throws Exception { + void allowEmptyDefaultWithText() throws Exception { final String[] expected = { "15:30: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "default"), "21:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "default"), @@ -168,7 +168,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testForbidDefaultWithoutStatement() throws Exception { + void forbidDefaultWithoutStatement() throws Exception { final String[] expected = { "15:30: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "default"), "21:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "default"), @@ -184,7 +184,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyBlockWithEmoji() throws Exception { + void emptyBlockWithEmoji() throws Exception { final String[] expected = { "15:12: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "STATIC_INIT"), "25:27: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "if"), @@ -199,14 +199,14 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationDefaultKeyword() throws Exception { + void annotationDefaultKeyword() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final String path = getPath("InputEmptyBlockAnnotationDefaultKeyword.java"); verifyWithInlineConfigParser(path, expected); } @Test - public void testEmptyBlockSwitchExpressions() throws Exception { + void emptyBlockSwitchExpressions() throws Exception { final String[] expected = { "17:30: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "default"), }; @@ -215,7 +215,7 @@ public class EmptyBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testUppercaseProperty() throws Exception { + void uppercaseProperty() throws Exception { final String[] expected = { "16:30: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "default"), "22:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "default"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class EmptyCatchBlockCheckTest extends AbstractModuleTestSupport { +final class EmptyCatchBlockCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class EmptyCatchBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final EmptyCatchBlockCheck checkObj = new EmptyCatchBlockCheck(); final int[] expected = {TokenTypes.LITERAL_CATCH}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class EmptyCatchBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "25:31: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), "32:83: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), @@ -52,7 +52,7 @@ public class EmptyCatchBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithUserSetValues() throws Exception { + void withUserSetValues() throws Exception { final String[] expected = { "26:31: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), "54:78: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), @@ -67,7 +67,7 @@ public class EmptyCatchBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testLinesAreProperlySplitSystemIndependently() throws Exception { + void linesAreProperlySplitSystemIndependently() throws Exception { final String[] expected = { "25:31: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), "53:78: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), @@ -88,7 +88,7 @@ public class EmptyCatchBlockCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final EmptyCatchBlockCheck constantNameCheckObj = new EmptyCatchBlockCheck(); final int[] actual = constantNameCheckObj.getAcceptableTokens(); final int[] expected = {TokenTypes.LITERAL_CATCH}; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class LeftCurlyCheckTest extends AbstractModuleTestSupport { +final class LeftCurlyCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,13 +42,13 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testLeftCurlyOptionValueOf() { + void leftCurlyOptionValueOf() { final LeftCurlyOption option = LeftCurlyOption.valueOf("NL"); assertWithMessage("Invalid valueOf result").that(option).isEqualTo(LeftCurlyOption.NL); } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final LeftCurlyCheck checkObj = new LeftCurlyCheck(); assertWithMessage("LeftCurlyCheck#getRequiredTokens should return empty array by default") .that(checkObj.getRequiredTokens()) @@ -56,7 +56,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "19:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -68,7 +68,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNl() throws Exception { + void nl() throws Exception { final String[] expected = { "36:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14), "40:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14), @@ -85,7 +85,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNlow() throws Exception { + void nlow() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "19:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -104,7 +104,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault2() throws Exception { + void default2() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "22:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -126,7 +126,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewline2() throws Exception { + void newline2() throws Exception { final String[] expected = { "19:44: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 44), "26:20: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 20), @@ -141,7 +141,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault3() throws Exception { + void default3() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "20:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -174,7 +174,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewline3() throws Exception { + void newline3() throws Exception { final String[] expected = { "31:33: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 33), "96:19: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 19), @@ -187,7 +187,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingBraces() throws Exception { + void missingBraces() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "20:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -201,7 +201,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultWithAnnotations() throws Exception { + void defaultWithAnnotations() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "27:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -215,7 +215,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNlWithAnnotations() throws Exception { + void nlWithAnnotations() throws Exception { final String[] expected = { "48:55: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 55), "51:41: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 41), @@ -226,7 +226,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNlowWithAnnotations() throws Exception { + void nlowWithAnnotations() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "27:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -239,7 +239,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testLineBreakAfter() throws Exception { + void lineBreakAfter() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "25:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -262,7 +262,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreEnumsOptionTrue() throws Exception { + void ignoreEnumsOptionTrue() throws Exception { final String[] expectedWhileTrue = { "21:44: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 44), }; @@ -271,7 +271,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreEnumsOptionFalse() throws Exception { + void ignoreEnumsOptionFalse() throws Exception { final String[] expectedWhileFalse = { "17:17: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 17), "21:44: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 44), @@ -281,7 +281,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultLambda() throws Exception { + void defaultLambda() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 1), "24:32: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 32), @@ -291,7 +291,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewLineOptionWithLambda() throws Exception { + void newLineOptionWithLambda() throws Exception { final String[] expected = { "18:32: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 32), "24:32: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 32), @@ -301,7 +301,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testEolSwitch() throws Exception { + void eolSwitch() throws Exception { final String[] expected = { "22:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 13), "26:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 13), @@ -313,7 +313,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNlSwitch() throws Exception { + void nlSwitch() throws Exception { final String[] expected = { "24:21: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 21), "56:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 14), @@ -322,7 +322,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNlowSwitch() throws Exception { + void nlowSwitch() throws Exception { final String[] expected = { "22:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 13), }; @@ -330,7 +330,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testLeftCurlySwitchExpressions() throws Exception { + void leftCurlySwitchExpressions() throws Exception { final String[] expected = { "20:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 9), "22:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 17), @@ -348,7 +348,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testLeftCurlySwitchExpressionsNewLine() throws Exception { + void leftCurlySwitchExpressionsNewLine() throws Exception { final String[] expected = { "17:57: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 57), @@ -361,7 +361,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final LeftCurlyCheck check = new LeftCurlyCheck(); final int[] actual = check.getAcceptableTokens(); final int[] expected = { @@ -394,13 +394,13 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testFirstLine() throws Exception { + void firstLine() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLeftCurlyTestFirstLine.java"), expected); } @Test - public void testCoverageIncrease() throws Exception { + void coverageIncrease() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), "30:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -416,7 +416,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testLeftCurlyRecordsAndCompactCtors() throws Exception { + void leftCurlyRecordsAndCompactCtors() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), "24:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 9), @@ -430,7 +430,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testLeftCurlyWithEmoji() throws Exception { + void leftCurlyWithEmoji() throws Exception { final String[] expected = { "17:32: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 32), "37:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 9), @@ -448,7 +448,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testLeftCurlyWithEmojiNewLine() throws Exception { + void leftCurlyWithEmojiNewLine() throws Exception { final String[] expected = { "18:32: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 32), "20:27: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 27), @@ -468,7 +468,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -487,7 +487,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = { "13:12: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 12), "20:16: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", 16), @@ -496,7 +496,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testForEnumConstantDef() throws Exception { + void forEnumConstantDef() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), "19:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), @@ -505,7 +505,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void commentBeforeLeftCurly() throws Exception { + void commentBeforeLeftCurly() throws Exception { final String[] expected = { "32:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 5), }; @@ -513,7 +513,7 @@ public class LeftCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void commentBeforeLeftCurly2() throws Exception { + void commentBeforeLeftCurly2() throws Exception { final String[] expected = { "54:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", 9), "66:29: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{", 29), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheckTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NeedBracesCheckTest extends AbstractModuleTestSupport { +final class NeedBracesCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "30:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "do"), "42:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), @@ -63,7 +63,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testItWithAllowsOn() throws Exception { + void itWithAllowsOn() throws Exception { final String[] expected = { "44:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), "47:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), @@ -88,7 +88,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testSingleLineStatements() throws Exception { + void singleLineStatements() throws Exception { final String[] expected = { "32:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), "38:43: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), @@ -106,7 +106,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testSingleLineLambda() throws Exception { + void singleLineLambda() throws Exception { final String[] expected = { "16:29: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), "19:22: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), @@ -117,7 +117,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testDoNotAllowSingleLineLambda() throws Exception { + void doNotAllowSingleLineLambda() throws Exception { final String[] expected = { "14:28: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), "15:29: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), @@ -131,7 +131,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testSingleLineCaseDefault() throws Exception { + void singleLineCaseDefault() throws Exception { final String[] expected = { "81:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "84:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), @@ -143,14 +143,14 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testSingleLineCaseDefault2() throws Exception { + void singleLineCaseDefault2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNeedBracesTestSingleLineCaseDefault2.java"), expected); } @Test - public void testSingleLineCaseDefaultNoSingleLine() throws Exception { + void singleLineCaseDefaultNoSingleLine() throws Exception { final String[] expected = { "18:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "19:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), @@ -164,13 +164,13 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testCycles() throws Exception { + void cycles() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNeedBracesTestCycles.java"), expected); } @Test - public void testConditions() throws Exception { + void conditions() throws Exception { final String[] expected = { "50:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "53:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), @@ -180,7 +180,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowEmptyLoopBodyTrue() throws Exception { + void allowEmptyLoopBodyTrue() throws Exception { final String[] expected = { "106:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), }; @@ -188,7 +188,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowEmptyLoopBodyFalse() throws Exception { + void allowEmptyLoopBodyFalse() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), "23:9: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), @@ -212,14 +212,14 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptySingleLineDefaultStmt() throws Exception { + void emptySingleLineDefaultStmt() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNeedBracesEmptySingleLineDefaultStmt.java"), expected); } @Test - public void testNeedBracesSwitchExpressionNoSingleLine() throws Exception { + void needBracesSwitchExpressionNoSingleLine() throws Exception { final String[] expected = { "16:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "18:47: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), @@ -243,7 +243,7 @@ public class NeedBracesCheckTest extends AbstractModuleTestSupport { } @Test - public void testNeedBracesSwitchExpression() throws Exception { + void needBracesSwitchExpression() throws Exception { final String[] expected = { "16:13: " + getCheckMessage(MSG_KEY_NEED_BRACES, "case"), "18:47: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class RightCurlyCheckTest extends AbstractModuleTestSupport { +final class RightCurlyCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,13 +41,13 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testRightCurlyOptionValueOf() { + void rightCurlyOptionValueOf() { final RightCurlyOption option = RightCurlyOption.valueOf("ALONE"); assertWithMessage("Invalid valueOf result").that(option).isEqualTo(RightCurlyOption.ALONE); } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "25:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17), "28:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17), @@ -59,7 +59,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSame() throws Exception { + void same() throws Exception { final String[] expected = { "26:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17), "29:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 17), @@ -74,19 +74,19 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSameOmitOneLiners() throws Exception { + void sameOmitOneLiners() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRightCurlyTestSameOmitOneLiners.java"), expected); } @Test - public void testSameDoesNotComplainForNonMultilineConstructs() throws Exception { + void sameDoesNotComplainForNonMultilineConstructs() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRightCurlyTestSame.java"), expected); } @Test - public void testAlone() throws Exception { + void alone() throws Exception { final String[] expected = { "57:13: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 13), "94:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27), @@ -103,7 +103,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewLine() throws Exception { + void newLine() throws Exception { final String[] expected = { "86:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "111:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -126,7 +126,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testShouldStartLine2() throws Exception { + void shouldStartLine2() throws Exception { final String[] expected = { "86:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "111:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -144,7 +144,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testForceLineBreakBefore() throws Exception { + void forceLineBreakBefore() throws Exception { final String[] expected = { "38:43: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 43), "41:17: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 17), @@ -156,20 +156,20 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testForceLineBreakBefore2() throws Exception { + void forceLineBreakBefore2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestForceLineBreakBefore2.java"), expected); } @Test - public void testNullPointerException() throws Exception { + void nullPointerException() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRightCurlyTestNullPointerException.java"), expected); } @Test - public void testWithAnnotations() throws Exception { + void withAnnotations() throws Exception { final String[] expected = { "18:77: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 77), "21:65: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 65), @@ -246,7 +246,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testAloneOrSingleLine() throws Exception { + void aloneOrSingleLine() throws Exception { final String[] expected = { "70:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26), "84:42: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 42), @@ -293,7 +293,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testCatchWithoutFinally() throws Exception { + void catchWithoutFinally() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9), }; @@ -301,7 +301,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSingleLineClass() throws Exception { + void singleLineClass() throws Exception { final String[] expected = { "29:56: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 56), }; @@ -309,7 +309,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -328,7 +328,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlySameAndLiteralDo() throws Exception { + void rightCurlySameAndLiteralDo() throws Exception { final String[] expected = { "70:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9), "75:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13), @@ -338,7 +338,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResourceSame() throws Exception { + void tryWithResourceSame() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 9), "33:67: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 67), @@ -349,7 +349,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResourceAlone() throws Exception { + void tryWithResourceAlone() throws Exception { final String[] expected = { "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), "33:67: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 67), @@ -364,7 +364,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResourceAloneSingle() throws Exception { + void tryWithResourceAloneSingle() throws Exception { final String[] expected = { "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), "36:64: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 64), @@ -376,7 +376,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testBracePolicyAloneAndSinglelineIfBlocks() throws Exception { + void bracePolicyAloneAndSinglelineIfBlocks() throws Exception { final String[] expected = { "13:32: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 32), "15:45: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 45), @@ -386,26 +386,26 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlyIsAloneLambda() throws Exception { + void rightCurlyIsAloneLambda() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRightCurlyTestIsAloneLambda.java"), expected); } @Test - public void testRightCurlyIsAloneOrSinglelineLambda() throws Exception { + void rightCurlyIsAloneOrSinglelineLambda() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRightCurlyTestIsAloneOrSinglelineLambda.java"), expected); } @Test - public void testRightCurlyIsSameLambda() throws Exception { + void rightCurlyIsSameLambda() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRightCurlyTestIsSameLambda.java"), expected); } @Test - public void testOptionAlone() throws Exception { + void optionAlone() throws Exception { final String[] expected = { "16:15: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 15), "17:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 21), @@ -433,7 +433,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testOptionAloneOrSingleLine() throws Exception { + void optionAloneOrSingleLine() throws Exception { final String[] expected = { "21:26: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 26), "30:37: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 37), @@ -450,7 +450,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testBlocksEndingWithSemiOptionSame() throws Exception { + void blocksEndingWithSemiOptionSame() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "21:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -471,7 +471,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testBlocksEndingWithSemiOptionAlone() throws Exception { + void blocksEndingWithSemiOptionAlone() throws Exception { final String[] expected = { "13:31: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 31), "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -499,7 +499,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testBlocksEndingWithSemiOptionAloneOrSingleLine() throws Exception { + void blocksEndingWithSemiOptionAloneOrSingleLine() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "21:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -520,7 +520,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewTokensAlone() throws Exception { + void newTokensAlone() throws Exception { final String[] expected = { "13:19: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 19), "16:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20), @@ -530,7 +530,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewTokensAloneOrSingleLine() throws Exception { + void newTokensAloneOrSingleLine() throws Exception { final String[] expected = { "16:20: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 20), }; @@ -539,7 +539,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewTokensSame() throws Exception { + void newTokensSame() throws Exception { final String[] expected = { "16:20: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 20), }; @@ -547,7 +547,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlyDoubleBrace() throws Exception { + void rightCurlyDoubleBrace() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 1), "14:2: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 2), @@ -556,13 +556,13 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlyEmptyOnSingleLine() throws Exception { + void rightCurlyEmptyOnSingleLine() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRightCurlyTestEmptyOnSingleLine.java"), expected); } @Test - public void testRightCurlyEndOfFile() throws Exception { + void rightCurlyEndOfFile() throws Exception { final String[] expected = { "16:2: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 2), "16:3: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 3), @@ -571,7 +571,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlyRecordsAndCompactCtors() throws Exception { + void rightCurlyRecordsAndCompactCtors() throws Exception { final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), "23:11: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 11), @@ -585,7 +585,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlyWithEmoji() throws Exception { + void rightCurlyWithEmoji() throws Exception { final String[] expected = { "24:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13), "28:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", 13), @@ -598,7 +598,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlyWithEmojiAloneOrSingleLine() throws Exception { + void rightCurlyWithEmojiAloneOrSingleLine() throws Exception { final String[] expected = { "24:38: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 38), "30:43: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 43), @@ -611,7 +611,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testUppercaseOptionProperty() throws Exception { + void uppercaseOptionProperty() throws Exception { final String[] expected = { "16:46: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 46), "21:35: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 35), @@ -621,7 +621,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlyWithIfElseAlone() throws Exception { + void rightCurlyWithIfElseAlone() throws Exception { final String[] expected = { "19:12: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 12), "27:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), @@ -630,7 +630,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchCase() throws Exception { + void switchCase() throws Exception { final String[] expected = { "20:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24), "27:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27), @@ -644,7 +644,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchCase2() throws Exception { + void switchCase2() throws Exception { final String[] expected = { "20:24: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 24), "27:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 27), @@ -654,7 +654,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchCase3() throws Exception { + void switchCase3() throws Exception { final String[] expected = { "15:22: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 22), "17:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), @@ -677,7 +677,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchCase4() throws Exception { + void switchCase4() throws Exception { final String[] expected = { "17:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), "19:36: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 36), @@ -693,7 +693,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchCase5() throws Exception { + void switchCase5() throws Exception { final String[] expected = { "17:9: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 9), "19:36: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}", 36), @@ -710,7 +710,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchExpression() throws Exception { + void switchExpression() throws Exception { final String[] expected = { "48:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "56:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -721,7 +721,7 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchExpression2() throws Exception { + void switchExpression2() throws Exception { final String[] expected = { "46:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), "54:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 5), @@ -733,14 +733,14 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchExpression3() throws Exception { + void switchExpression3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputRightCurlyTestSwitchExpression3.java"), expected); } @Test - public void testSwitchExpression4() throws Exception { + void switchExpression4() throws Exception { final String[] expected = { "117:28: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 28), }; @@ -749,14 +749,14 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchExpression5() throws Exception { + void switchExpression5() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputRightCurlyTestSwitchExpression5.java"), expected); } @Test - public void testSwitchWithComment() throws Exception { + void switchWithComment() throws Exception { final String[] expected = { "16:66: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 66), "23:61: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", 61), @@ -770,14 +770,14 @@ public class RightCurlyCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchExpression6() throws Exception { + void switchExpression6() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputRightCurlyTestSwitchExpression6.java"), expected); } @Test - public void testSwitchExpression7() throws Exception { + void switchExpression7() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputRightCurlyTestSwitchExpression7.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ArrayTrailingCommaCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ArrayTrailingCommaCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.ArrayTrailingCommaCh import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class ArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { +final class ArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class ArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY), "43:9: " + getCheckMessage(MSG_KEY), @@ -44,7 +44,7 @@ public class ArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final ArrayTrailingCommaCheck check = new ArrayTrailingCommaCheck(); assertWithMessage("Invalid acceptable tokens").that(check.getAcceptableTokens()).isNotNull(); assertWithMessage("Invalid default tokens").that(check.getDefaultTokens()).isNotNull(); @@ -52,7 +52,7 @@ public class ArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testAlwaysDemandTrailingComma() throws Exception { + void alwaysDemandTrailingComma() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY), "22:29: " + getCheckMessage(MSG_KEY), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidDoubleBraceInitializationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidDoubleBraceInitializationCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class AvoidDoubleBraceInitializationCheckTest extends AbstractModuleTestSupport { +final class AvoidDoubleBraceInitializationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class AvoidDoubleBraceInitializationCheckTest extends AbstractModuleTestS } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "14:53: " + getCheckMessage(MSG_KEY), "19:40: " + getCheckMessage(MSG_KEY), @@ -54,7 +54,7 @@ public class AvoidDoubleBraceInitializationCheckTest extends AbstractModuleTestS } @Test - public void testTokensNotNull() { + void tokensNotNull() { final AvoidDoubleBraceInitializationCheck check = new AvoidDoubleBraceInitializationCheck(); final int[] expected = { TokenTypes.OBJBLOCK, --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidInlineConditionalsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidInlineConditionalsCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.AvoidInlineCondition import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class AvoidInlineConditionalsCheckTest extends AbstractModuleTestSupport { +final class AvoidInlineConditionalsCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class AvoidInlineConditionalsCheckTest extends AbstractModuleTestSupport } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "34:29: " + getCheckMessage(MSG_KEY), "35:20: " + getCheckMessage(MSG_KEY), @@ -43,7 +43,7 @@ public class AvoidInlineConditionalsCheckTest extends AbstractModuleTestSupport } @Test - public void testTokensNotNull() { + void tokensNotNull() { final AvoidInlineConditionalsCheck check = new AvoidInlineConditionalsCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class AvoidNoArgumentSuperConstructorCallCheckTest extends AbstractModuleTestSupport { +final class AvoidNoArgumentSuperConstructorCallCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class AvoidNoArgumentSuperConstructorCallCheckTest extends AbstractModule } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "12:9: " + getCheckMessage(MSG_CTOR), @@ -47,7 +47,7 @@ public class AvoidNoArgumentSuperConstructorCallCheckTest extends AbstractModule } @Test - public void testTokens() { + void tokens() { final AvoidNoArgumentSuperConstructorCallCheck check = new AvoidNoArgumentSuperConstructorCallCheck(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/CovariantEqualsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/CovariantEqualsCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class CovariantEqualsCheckTest extends AbstractModuleTestSupport { +final class CovariantEqualsCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class CovariantEqualsCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "17:24: " + getCheckMessage(MSG_KEY), "36:20: " + getCheckMessage(MSG_KEY), @@ -46,7 +46,7 @@ public class CovariantEqualsCheckTest extends AbstractModuleTestSupport { } @Test - public void testCovariantEqualsRecords() throws Exception { + void covariantEqualsRecords() throws Exception { final String[] expected = { "13:24: " + getCheckMessage(MSG_KEY), "29:28: " + getCheckMessage(MSG_KEY), }; @@ -55,7 +55,7 @@ public class CovariantEqualsCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final CovariantEqualsCheck check = new CovariantEqualsCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckTest.java @@ -33,7 +33,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.SortedSet; import org.junit.jupiter.api.Test; -public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { +final class DeclarationOrderCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,7 +41,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_ACCESS), @@ -70,7 +70,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testOnlyConstructors() throws Exception { + void onlyConstructors() throws Exception { final String[] expected = { "53:9: " + getCheckMessage(MSG_STATIC), @@ -85,7 +85,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testOnlyModifiers() throws Exception { + void onlyModifiers() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_ACCESS), @@ -112,7 +112,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final DeclarationOrderCheck check = new DeclarationOrderCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -126,7 +126,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testParents() { + void parents() { final DetailAstImpl parent = new DetailAstImpl(); parent.setType(TokenTypes.STATIC_INIT); final DetailAstImpl method = new DetailAstImpl(); @@ -150,7 +150,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testImproperToken() { + void improperToken() { final DetailAstImpl parent = new DetailAstImpl(); parent.setType(TokenTypes.STATIC_INIT); final DetailAstImpl array = new DetailAstImpl(); @@ -166,7 +166,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testForwardReference() throws Exception { + void forwardReference() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_ACCESS), "21:5: " + getCheckMessage(MSG_ACCESS), @@ -182,7 +182,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testDeclarationOrderRecordsAndCompactCtors() throws Exception { + void declarationOrderRecordsAndCompactCtors() throws Exception { final String[] expected = { "21:9: " + getCheckMessage(MSG_CONSTRUCTOR), "24:9: " + getCheckMessage(MSG_STATIC), @@ -195,7 +195,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testDeclarationOrderInterfaceMemberScopeIsPublic() throws Exception { + void declarationOrderInterfaceMemberScopeIsPublic() throws Exception { final String[] expected = { "21:3: " + getCheckMessage(MSG_STATIC), }; @@ -204,7 +204,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testVariableAccess() throws Exception { + void variableAccess() throws Exception { final String[] expected = { "23:5: " + getCheckMessage(MSG_ACCESS), }; @@ -212,7 +212,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testAvoidDuplicatesForStaticFinalFields() throws Exception { + void avoidDuplicatesForStaticFinalFields() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_STATIC), }; @@ -221,7 +221,7 @@ public class DeclarationOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputDeclarationOrder2.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class DefaultComesLastCheckTest extends AbstractModuleTestSupport { +final class DefaultComesLastCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class DefaultComesLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testSkipIfLastAndSharedWithCase() throws Exception { + void skipIfLastAndSharedWithCase() throws Exception { final String[] expected = { "23:13: " + getCheckMessage(MSG_KEY_SKIP_IF_LAST_AND_SHARED_WITH_CASE), "31:13: " + getCheckMessage(MSG_KEY_SKIP_IF_LAST_AND_SHARED_WITH_CASE), @@ -52,7 +52,7 @@ public class DefaultComesLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "31:9: " + getCheckMessage(MSG_KEY), "38:24: " + getCheckMessage(MSG_KEY), @@ -73,14 +73,14 @@ public class DefaultComesLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultMethodsInJava8() throws Exception { + void defaultMethodsInJava8() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDefaultComesLastDefaultMethodsInInterface.java"), expected); } @Test - public void testDefaultComesLastSwitchExpressions() throws Exception { + void defaultComesLastSwitchExpressions() throws Exception { final String[] expected = { "16:13: " + getCheckMessage(MSG_KEY), "32:13: " + getCheckMessage(MSG_KEY), @@ -91,7 +91,7 @@ public class DefaultComesLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultComesLastSwitchExpressionsSkipIfLast() throws Exception { + void defaultComesLastSwitchExpressionsSkipIfLast() throws Exception { final String[] expected = { "33:13: " + getCheckMessage(MSG_KEY), "48:13: " + getCheckMessage(MSG_KEY), @@ -101,7 +101,7 @@ public class DefaultComesLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final DefaultComesLastCheck check = new DefaultComesLastCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -115,7 +115,7 @@ public class DefaultComesLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultMethodsInJava8Interface2() throws Exception { + void defaultMethodsInJava8Interface2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDefaultComesLastDefaultMethodsInInterface2.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck. import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class EmptyStatementCheckTest extends AbstractModuleTestSupport { +final class EmptyStatementCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class EmptyStatementCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyStatements() throws Exception { + void emptyStatements() throws Exception { final String[] expected = { "18:7: " + getCheckMessage(MSG_KEY), "23:7: " + getCheckMessage(MSG_KEY), @@ -57,7 +57,7 @@ public class EmptyStatementCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final EmptyStatementCheck check = new EmptyStatementCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheckTest.java @@ -26,7 +26,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.EqualsAvoidNullCheck import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { +final class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualsWithDefault() throws Exception { + void equalsWithDefault() throws Exception { final String[] expected = { "44:27: " + getCheckMessage(MSG_EQUALS_IGNORE_CASE_AVOID_NULL), @@ -97,7 +97,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualsWithoutEqualsIgnoreCase() throws Exception { + void equalsWithoutEqualsIgnoreCase() throws Exception { final String[] expected = { "245:21: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -148,7 +148,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualsOnTheSameLine() throws Exception { + void equalsOnTheSameLine() throws Exception { final String[] expected = { "14:28: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -158,7 +158,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualsNested() throws Exception { + void equalsNested() throws Exception { final String[] expected = { "25:34: " + getCheckMessage(MSG_EQUALS_IGNORE_CASE_AVOID_NULL), @@ -174,7 +174,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualsSuperClass() throws Exception { + void equalsSuperClass() throws Exception { final String[] expected = { "23:35: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -183,7 +183,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputEqualsAvoidNullEnhancedInstanceof() throws Exception { + void inputEqualsAvoidNullEnhancedInstanceof() throws Exception { final String[] expected = { "15:45: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -198,7 +198,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testMisc() throws Exception { + void misc() throws Exception { final String[] expected = { "20:17: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -207,7 +207,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordsAndCompactCtors() throws Exception { + void recordsAndCompactCtors() throws Exception { final String[] expected = { "15:23: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -221,7 +221,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualsAvoidNullTextBlocks() throws Exception { + void equalsAvoidNullTextBlocks() throws Exception { final String[] expected = { "13:24: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), @@ -235,7 +235,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final EqualsAvoidNullCheck check = new EqualsAvoidNullCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -249,7 +249,7 @@ public class EqualsAvoidNullCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualAvoidNull() throws Exception { + void equalAvoidNull() throws Exception { final String[] expected = { "12:17: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), "13:17: " + getCheckMessage(MSG_EQUALS_AVOID_NULL), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsHashCodeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsHashCodeCheckTest.java @@ -23,17 +23,17 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck.MSG_KEY_EQUALS; import static com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck.MSG_KEY_HASHCODE; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; -public class EqualsHashCodeCheckTest extends AbstractModuleTestSupport { +final class EqualsHashCodeCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,7 +41,7 @@ public class EqualsHashCodeCheckTest extends AbstractModuleTestSupport { } @Test - public void testSemantic() throws Exception { + void semantic() throws Exception { final String[] expected = { "96:13: " + getCheckMessage(MSG_KEY_HASHCODE), }; @@ -49,7 +49,7 @@ public class EqualsHashCodeCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoEquals() throws Exception { + void noEquals() throws Exception { final String[] expected = { "10:5: " + getCheckMessage(MSG_KEY_EQUALS), }; @@ -57,19 +57,19 @@ public class EqualsHashCodeCheckTest extends AbstractModuleTestSupport { } @Test - public void testBooleanMethods() throws Exception { + void booleanMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputEqualsHashCode.java"), expected); } @Test - public void testMultipleInputs() throws Exception { + void multipleInputs() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(EqualsHashCodeCheck.class); final List expectedFirstInputErrors = - Collections.singletonList("10:5: " + getCheckMessage(MSG_KEY_EQUALS)); + ImmutableList.of("10:5: " + getCheckMessage(MSG_KEY_EQUALS)); final List expectedSecondInputErrors = - Collections.singletonList("96:13: " + getCheckMessage(MSG_KEY_HASHCODE)); + ImmutableList.of("96:13: " + getCheckMessage(MSG_KEY_HASHCODE)); final List expectedThirdInputErrors = Arrays.asList(CommonUtil.EMPTY_STRING_ARRAY); final String firstInput = getPath("InputEqualsHashCodeNoEquals.java"); @@ -90,7 +90,7 @@ public class EqualsHashCodeCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualsParameter() throws Exception { + void equalsParameter() throws Exception { final String[] expected = { "16:9: " + getCheckMessage(MSG_KEY_EQUALS), "24:9: " + getCheckMessage(MSG_KEY_HASHCODE), @@ -106,7 +106,7 @@ public class EqualsHashCodeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final EqualsHashCodeCheck check = new EqualsHashCodeCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.ExplicitInitializati import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class ExplicitInitializationCheckTest extends AbstractModuleTestSupport { +final class ExplicitInitializationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class ExplicitInitializationCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "11:17: " + getCheckMessage(MSG_KEY, "x", 0), "12:20: " + getCheckMessage(MSG_KEY, "bar", "null"), @@ -62,7 +62,7 @@ public class ExplicitInitializationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final ExplicitInitializationCheck check = new ExplicitInitializationCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -76,7 +76,7 @@ public class ExplicitInitializationCheckTest extends AbstractModuleTestSupport { } @Test - public void testOnlyObjectReferences() throws Exception { + void onlyObjectReferences() throws Exception { final String[] expected = { "12:20: " + getCheckMessage(MSG_KEY, "bar", "null"), "21:22: " + getCheckMessage(MSG_KEY, "str1", "null"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class FallThroughCheckTest extends AbstractModuleTestSupport { +final class FallThroughCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "22:13: " + getCheckMessage(MSG_FALL_THROUGH), "46:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -65,13 +65,13 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResources() throws Exception { + void tryWithResources() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getNonCompilablePath("InputFallThrough.java"), expected); } @Test - public void testTryCatchInSwitch() throws Exception { + void tryCatchInSwitch() throws Exception { final String[] expected = { "37:13: " + getCheckMessage(MSG_FALL_THROUGH), }; @@ -79,7 +79,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testStringSwitch() throws Exception { + void stringSwitch() throws Exception { final String[] expected = { "21:9: " + getCheckMessage(MSG_FALL_THROUGH), }; @@ -87,7 +87,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testCharacterSwitch() throws Exception { + void characterSwitch() throws Exception { final String[] expected = { "19:13: " + getCheckMessage(MSG_FALL_THROUGH), "30:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -100,7 +100,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testLastCaseGroup() throws Exception { + void lastCaseGroup() throws Exception { final String[] expected = { "22:13: " + getCheckMessage(MSG_FALL_THROUGH), "46:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -126,7 +126,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testOwnPattern() throws Exception { + void ownPattern() throws Exception { final String[] expected = { "22:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -170,7 +170,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testOwnPatternTryWithResources() throws Exception { + void ownPatternTryWithResources() throws Exception { final String[] expected = { "54:9: " + getCheckMessage(MSG_FALL_THROUGH), @@ -183,7 +183,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithEmoji() throws Exception { + void withEmoji() throws Exception { final String[] expected = { "22:17: " + getCheckMessage(MSG_FALL_THROUGH), "25:17: " + getCheckMessage(MSG_FALL_THROUGH), @@ -194,7 +194,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final FallThroughCheck check = new FallThroughCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -208,7 +208,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testFallThroughNoElse() throws Exception { + void fallThroughNoElse() throws Exception { final String[] expected = { "28:13: " + getCheckMessage(MSG_FALL_THROUGH), "43:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -224,7 +224,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testYield() throws Exception { + void yield() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_FALL_THROUGH), }; @@ -232,7 +232,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testLastCase() throws Exception { + void lastCase() throws Exception { final String[] expected = { "48:11: " + getCheckMessage(MSG_FALL_THROUGH_LAST), "83:11: " + getCheckMessage(MSG_FALL_THROUGH_LAST), @@ -242,7 +242,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testIfElse() throws Exception { + void ifElse() throws Exception { final String[] expected = { "94:13: " + getCheckMessage(MSG_FALL_THROUGH), }; @@ -250,7 +250,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testFallThrough() throws Exception { + void fallThrough() throws Exception { final String[] expected = { "23:13: " + getCheckMessage(MSG_FALL_THROUGH), "27:13: " + getCheckMessage(MSG_FALL_THROUGH), @@ -264,13 +264,13 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testFallThroughNonCompilable4() throws Exception { + void fallThroughNonCompilable4() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getNonCompilablePath("InputFallThrough4.java"), expected); } @Test - public void testFallThroughComment() throws Exception { + void fallThroughComment() throws Exception { final String[] expected = { "20:13: " + getCheckMessage(MSG_FALL_THROUGH), "43:13: " + getCheckMessage(MSG_FALL_THROUGH), }; @@ -279,14 +279,14 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testFallThroughComment2() throws Exception { + void fallThroughComment2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFallThroughFallThroughLotsOfComment2.java"), expected); } @Test - public void testFallThrough7() throws Exception { + void fallThrough7() throws Exception { final String[] expected = { "21:13: " + getCheckMessage(MSG_FALL_THROUGH_LAST), "36:13: " + getCheckMessage(MSG_FALL_THROUGH_LAST), @@ -299,7 +299,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testLastLine() throws Exception { + void lastLine() throws Exception { final String[] expected = { "21:13: " + getCheckMessage(MSG_FALL_THROUGH), // until https://github.com/checkstyle/checkstyle/issues/13553 @@ -312,7 +312,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testLastLine2() throws Exception { + void lastLine2() throws Exception { final String[] expected = { "19:13: " + getCheckMessage(MSG_FALL_THROUGH_LAST), "22:13: " + getCheckMessage(MSG_FALL_THROUGH_LAST), @@ -321,7 +321,7 @@ public class FallThroughCheckTest extends AbstractModuleTestSupport { } @Test - public void testReliefCommentBetweenMultipleComment() throws Exception { + void reliefCommentBetweenMultipleComment() throws Exception { final String[] expected = { // until https://github.com/checkstyle/checkstyle/issues/13553 "25:17: " + getCheckMessage(MSG_FALL_THROUGH), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { +final class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariableOne() throws Exception { + void inputFinalLocalVariableOne() throws Exception { final String[] expected = { "17:13: " + getCheckMessage(MSG_KEY, "i"), @@ -59,7 +59,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariableTwo() throws Exception { + void inputFinalLocalVariableTwo() throws Exception { final String[] expected = { "24:17: " + getCheckMessage(MSG_KEY, "weird"), "25:17: " + getCheckMessage(MSG_KEY, "j"), @@ -69,7 +69,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariableThree() throws Exception { + void inputFinalLocalVariableThree() throws Exception { final String[] expected = { "14:17: " + getCheckMessage(MSG_KEY, "x"), "20:21: " + getCheckMessage(MSG_KEY, "x"), @@ -86,7 +86,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariableFour() throws Exception { + void inputFinalLocalVariableFour() throws Exception { final String[] expected = { "16:17: " + getCheckMessage(MSG_KEY, "shouldBeFinal"), "28:17: " + getCheckMessage(MSG_KEY, "shouldBeFinal"), @@ -98,7 +98,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalLocalVariableFive() throws Exception { + void finalLocalVariableFive() throws Exception { final String[] expected = { "15:17: " + getCheckMessage(MSG_KEY, "shouldBeFinal"), "26:17: " + getCheckMessage(MSG_KEY, "shouldBeFinal"), @@ -110,7 +110,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordsInput() throws Exception { + void recordsInput() throws Exception { final String[] expected = { "20:17: " + getCheckMessage(MSG_KEY, "b"), }; @@ -119,7 +119,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariable2One() throws Exception { + void inputFinalLocalVariable2One() throws Exception { final String[] expected = { "52:28: " + getCheckMessage(MSG_KEY, "aArg"), @@ -128,7 +128,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariable2Two() throws Exception { + void inputFinalLocalVariable2Two() throws Exception { final String[] excepted = { "78:36: " + getCheckMessage(MSG_KEY, "_o"), "83:37: " + getCheckMessage(MSG_KEY, "_o1"), @@ -137,7 +137,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariable2Three() throws Exception { + void inputFinalLocalVariable2Three() throws Exception { final String[] excepted = {}; @@ -145,7 +145,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariable2Four() throws Exception { + void inputFinalLocalVariable2Four() throws Exception { final String[] excepted = {}; @@ -153,7 +153,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputFinalLocalVariable2Five() throws Exception { + void inputFinalLocalVariable2Five() throws Exception { final String[] excepted = {}; @@ -161,21 +161,21 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testNativeMethods() throws Exception { + void nativeMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFinalLocalVariableNativeMethods.java"), expected); } @Test - public void testFalsePositive() throws Exception { + void falsePositive() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFinalLocalVariableFalsePositive.java"), expected); } @Test - public void testEnhancedForLoopVariableTrue() throws Exception { + void enhancedForLoopVariableTrue() throws Exception { final String[] expected = { "16:20: " + getCheckMessage(MSG_KEY, "a"), "23:13: " + getCheckMessage(MSG_KEY, "x"), @@ -190,7 +190,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnhancedForLoopVariableFalse() throws Exception { + void enhancedForLoopVariableFalse() throws Exception { final String[] expected = { "23:13: " + getCheckMessage(MSG_KEY, "x"), "29:66: " + getCheckMessage(MSG_KEY, "snippets"), @@ -202,7 +202,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambda() throws Exception { + void lambda() throws Exception { final String[] expected = { "40:16: " + getCheckMessage(MSG_KEY, "result"), }; @@ -210,7 +210,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testVariableNameShadowing() throws Exception { + void variableNameShadowing() throws Exception { final String[] expected = { "12:28: " + getCheckMessage(MSG_KEY, "text"), "25:13: " + getCheckMessage(MSG_KEY, "x"), @@ -219,7 +219,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testImproperToken() { + void improperToken() { final FinalLocalVariableCheck check = new FinalLocalVariableCheck(); final DetailAstImpl lambdaAst = new DetailAstImpl(); @@ -234,7 +234,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testVariableWhichIsAssignedMultipleTimes() throws Exception { + void variableWhichIsAssignedMultipleTimes() throws Exception { final String[] expected = { "57:13: " + getCheckMessage(MSG_KEY, "i"), @@ -249,7 +249,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testVariableIsAssignedInsideAndOutsideSwitchBlock() throws Exception { + void variableIsAssignedInsideAndOutsideSwitchBlock() throws Exception { final String[] expected = { "39:13: " + getCheckMessage(MSG_KEY, "b"), }; @@ -258,7 +258,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalLocalVariableFalsePositives() throws Exception { + void finalLocalVariableFalsePositives() throws Exception { final String[] expected = { "352:16: " + getCheckMessage(MSG_KEY, "c2"), "2195:16: " + getCheckMessage(MSG_KEY, "b"), }; @@ -266,27 +266,27 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultipleAndNestedConditions() throws Exception { + void multipleAndNestedConditions() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFinalLocalVariableMultipleAndNestedConditions.java"), expected); } @Test - public void testMultiTypeCatch() throws Exception { + void multiTypeCatch() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFinalLocalVariableMultiCatch.java"), expected); } @Test - public void testLeavingSlistToken() throws Exception { + void leavingSlistToken() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFinalLocalVariableLeavingSlistToken.java"), expected); } @Test - public void testBreakOrReturn() throws Exception { + void breakOrReturn() throws Exception { final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY, "e"), }; @@ -294,7 +294,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnonymousClass() throws Exception { + void anonymousClass() throws Exception { final String[] expected = { "13:16: " + getCheckMessage(MSG_KEY, "testSupport"), }; @@ -302,14 +302,14 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testReceiverParameter() throws Exception { + void receiverParameter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputFinalLocalVariableReceiverParameter.java"), expected); } @Test - public void testFinalLocalVariableSwitchExpressions() throws Exception { + void finalLocalVariableSwitchExpressions() throws Exception { final String[] expected = { "15:19: " + getCheckMessage(MSG_KEY, "e"), "53:19: " + getCheckMessage(MSG_KEY, "e"), @@ -321,7 +321,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalLocalVariableSwitchAssignment() throws Exception { + void finalLocalVariableSwitchAssignment() throws Exception { final String[] expected = { "21:13: " + getCheckMessage(MSG_KEY, "a"), "44:13: " + getCheckMessage(MSG_KEY, "b"), @@ -334,13 +334,13 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalLocalVariableSwitchStatement() throws Exception { + void finalLocalVariableSwitchStatement() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFinalLocalVariableSwitchStatement.java"), expected); } @Test - public void testConstructor() throws Exception { + void constructor() throws Exception { final String[] expected = { "14:44: " + getCheckMessage(MSG_KEY, "a"), "18:44: " + getCheckMessage(MSG_KEY, "a"), @@ -352,7 +352,7 @@ public class FinalLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "20:17: " + getCheckMessage(MSG_KEY, "start"), "22:17: " + getCheckMessage(MSG_KEY, "end"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckTest.java @@ -34,7 +34,7 @@ import java.util.Optional; import java.util.function.Predicate; import org.junit.jupiter.api.Test; -public class HiddenFieldCheckTest extends AbstractModuleTestSupport { +final class HiddenFieldCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,7 +42,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticVisibilityFromLambdas() throws Exception { + void staticVisibilityFromLambdas() throws Exception { final String[] expected = { "31:34: " + getCheckMessage(MSG_KEY, "value"), "63:31: " + getCheckMessage(MSG_KEY, "languageCode"), @@ -65,7 +65,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticVisibilityFromAnonymousClasses() throws Exception { + void staticVisibilityFromAnonymousClasses() throws Exception { final String[] expected = { "22:45: " + getCheckMessage(MSG_KEY, "other"), "28:42: " + getCheckMessage(MSG_KEY, "other"), @@ -77,7 +77,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoParameters() throws Exception { + void noParameters() throws Exception { final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "39:13: " + getCheckMessage(MSG_KEY, "hidden"), @@ -102,7 +102,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "33:34: " + getCheckMessage(MSG_KEY, "hidden"), @@ -145,7 +145,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { /** Tests ignoreFormat property. */ @Test - public void testIgnoreFormat() throws Exception { + void ignoreFormat() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HiddenFieldCheck.class); checkConfig.addProperty("ignoreFormat", "^i.*$"); assertWithMessage("Ignore format should not be null") @@ -186,7 +186,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { /** Tests ignoreSetter property. */ @Test - public void testIgnoreSetter() throws Exception { + void ignoreSetter() throws Exception { final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "33:34: " + getCheckMessage(MSG_KEY, "hidden"), @@ -225,7 +225,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { /** Tests ignoreSetter and setterCanReturnItsClass properties. */ @Test - public void testIgnoreChainSetter() throws Exception { + void ignoreChainSetter() throws Exception { final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "33:34: " + getCheckMessage(MSG_KEY, "hidden"), @@ -262,7 +262,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { /** Tests ignoreConstructorParameter property. */ @Test - public void testIgnoreConstructorParameter() throws Exception { + void ignoreConstructorParameter() throws Exception { final String[] expected = { "29:13: " + getCheckMessage(MSG_KEY, "hidden"), "38:13: " + getCheckMessage(MSG_KEY, "hidden"), @@ -302,7 +302,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { /** Test against a class with field declarations in different order. */ @Test - public void testReordered() throws Exception { + void reordered() throws Exception { final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), "33:40: " + getCheckMessage(MSG_KEY, "hidden"), @@ -329,7 +329,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreAbstractMethods() throws Exception { + void ignoreAbstractMethods() throws Exception { final String[] expected = { "30:13: " + getCheckMessage(MSG_KEY, "hidden"), @@ -371,13 +371,13 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testReceiverParameter() throws Exception { + void receiverParameter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputHiddenFieldReceiver.java"), expected); } @Test - public void testHiddenFieldEnhancedInstanceof() throws Exception { + void hiddenFieldEnhancedInstanceof() throws Exception { final String[] expected = { "26:39: " + getCheckMessage(MSG_KEY, "price"), @@ -388,7 +388,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testHiddenFieldSwitchExpression() throws Exception { + void hiddenFieldSwitchExpression() throws Exception { final String[] expected = { "28:13: " + getCheckMessage(MSG_KEY, "x"), @@ -411,7 +411,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testHiddenFieldRecords() throws Exception { + void hiddenFieldRecords() throws Exception { final String[] expected = { "23:17: " + getCheckMessage(MSG_KEY, "myHiddenInt"), @@ -428,7 +428,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testHiddenFieldLambdasInNestedScope() throws Exception { + void hiddenFieldLambdasInNestedScope() throws Exception { final String[] expected = { "21:34: " + getCheckMessage(MSG_KEY, "value"), }; @@ -436,7 +436,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassNestedInRecord() throws Exception { + void classNestedInRecord() throws Exception { final String[] expected = { "23:26: " + getCheckMessage(MSG_KEY, "a"), @@ -446,7 +446,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testHiddenFieldInnerRecordsImplicitlyStatic() throws Exception { + void hiddenFieldInnerRecordsImplicitlyStatic() throws Exception { final String[] expected = { "35:30: " + getCheckMessage(MSG_KEY, "pointer"), @@ -457,7 +457,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { } @Test - public void testHiddenFieldRecordsImplicitlyStaticClassComparison() throws Exception { + void hiddenFieldRecordsImplicitlyStaticClassComparison() throws Exception { final String[] expected = { "49:27: " + getCheckMessage(MSG_KEY, "x"), @@ -475,7 +475,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws exception */ @Test - public void testClearState() throws Exception { + void clearState() throws Exception { final HiddenFieldCheck check = new HiddenFieldCheck(); final DetailAST root = JavaParser.parseFile( @@ -487,7 +487,7 @@ public class HiddenFieldCheckTest extends AbstractModuleTestSupport { assertWithMessage("State is not cleared on beginTree") .that( TestUtil.isStatefulFieldClearedDuringBeginTree( - check, classDef.get(), "frame", new CheckIfStatefulFieldCleared())) + check, classDef.orElseThrow(), "frame", new CheckIfStatefulFieldCleared())) .isTrue(); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.IllegalCatchCheck.MS import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class IllegalCatchCheckTest extends AbstractModuleTestSupport { +final class IllegalCatchCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class IllegalCatchCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalCatchCheckDefaultTokens() throws Exception { + void illegalCatchCheckDefaultTokens() throws Exception { final String[] expected = { "14:11: " + getCheckMessage(MSG_KEY, "RuntimeException"), @@ -48,7 +48,7 @@ public class IllegalCatchCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalCatchCheckSuperclassThrowable() throws Exception { + void illegalCatchCheckSuperclassThrowable() throws Exception { final String[] expected = { "14:11: " + getCheckMessage(MSG_KEY, "Exception"), "15:11: " + getCheckMessage(MSG_KEY, "Throwable"), @@ -61,7 +61,7 @@ public class IllegalCatchCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalCatchCheckSuperclassException() throws Exception { + void illegalCatchCheckSuperclassException() throws Exception { // check that incorrect names don't break the Check final String[] expected = { "15:11: " + getCheckMessage(MSG_KEY, "Exception"), @@ -73,7 +73,7 @@ public class IllegalCatchCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalCatchCheckMultipleExceptions() throws Exception { + void illegalCatchCheckMultipleExceptions() throws Exception { final String[] expected = { "15:11: " + getCheckMessage(MSG_KEY, "RuntimeException"), "15:11: " + getCheckMessage(MSG_KEY, "SQLException"), @@ -93,7 +93,7 @@ public class IllegalCatchCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final IllegalCatchCheck check = new IllegalCatchCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckTest.java @@ -37,7 +37,7 @@ import java.util.List; import java.util.Optional; import org.junit.jupiter.api.Test; -public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { +final class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -45,13 +45,13 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputIllegalInstantiationSemantic.java"), expected); } @Test - public void testClasses() throws Exception { + void classes() throws Exception { final String[] expected = { "24:21: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), "29:21: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), @@ -68,20 +68,20 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { } @Test - public void testSameClassNameAsJavaLang() throws Exception { + void sameClassNameAsJavaLang() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputIllegalInstantiationSameClassNameJavaLang.java"), expected); } @Test - public void testJava8() throws Exception { + void java8() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputIllegalInstantiation.java"), expected); } @Test - public void testNoPackage() throws Exception { + void noPackage() throws Exception { final String[] expected = { "10:20: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), }; @@ -89,7 +89,7 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavaLangPackage() throws Exception { + void javaLangPackage() throws Exception { final String[] expected = { "13:19: " + getCheckMessage(MSG_KEY, "java.lang.Boolean"), "21:20: " + getCheckMessage(MSG_KEY, "java.lang.String"), @@ -99,27 +99,27 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongPackage() throws Exception { + void wrongPackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputIllegalInstantiationLang2.java"), expected); } @Test - public void testJavaLangPackage3() throws Exception { + void javaLangPackage3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputIllegalInstantiationLang3.java"), expected); } @Test - public void testNameSimilarToStandardClass() throws Exception { + void nameSimilarToStandardClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputIllegalInstantiationNameSimilarToStandardClasses.java"), expected); } @Test - public void testTokensNotNull() { + void tokensNotNull() { final IllegalInstantiationCheck check = new IllegalInstantiationCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -133,7 +133,7 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { } @Test - public void testImproperToken() { + void improperToken() { final IllegalInstantiationCheck check = new IllegalInstantiationCheck(); final DetailAstImpl lambdaAst = new DetailAstImpl(); @@ -153,9 +153,9 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { * * @throws Exception when code tested throws exception */ - @Test @SuppressWarnings("unchecked") - public void testClearStateClassNames() throws Exception { + @Test + void clearStateClassNames() throws Exception { final IllegalInstantiationCheck check = new IllegalInstantiationCheck(); final DetailAST root = JavaParser.parseFile( @@ -169,7 +169,7 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - classDef.get(), + classDef.orElseThrow(), "classNames", classNames -> ((Collection) classNames).isEmpty())) .isTrue(); @@ -182,7 +182,7 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws exception */ @Test - public void testClearStateImports() throws Exception { + void clearStateImports() throws Exception { final IllegalInstantiationCheck check = new IllegalInstantiationCheck(); final DetailAST root = JavaParser.parseFile( @@ -195,7 +195,10 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { assertWithMessage("State is not cleared on beginTree") .that( TestUtil.isStatefulFieldClearedDuringBeginTree( - check, importDef.get(), "imports", imports -> ((Collection) imports).isEmpty())) + check, + importDef.orElseThrow(), + "imports", + imports -> ((Collection) imports).isEmpty())) .isTrue(); } @@ -205,9 +208,9 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { * * @throws Exception when code tested throws exception */ - @Test @SuppressWarnings("unchecked") - public void testClearStateInstantiations() throws Exception { + @Test + void clearStateInstantiations() throws Exception { final IllegalInstantiationCheck check = new IllegalInstantiationCheck(); final DetailAST root = JavaParser.parseFile( @@ -221,14 +224,14 @@ public class IllegalInstantiationCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - literalNew.get(), + literalNew.orElseThrow(), "instantiations", instantiations -> ((Collection) instantiations).isEmpty())) .isTrue(); } @Test - public void testStateIsClearedOnBeginTreePackageName() throws Exception { + void stateIsClearedOnBeginTreePackageName() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IllegalInstantiationCheck.class); checkConfig.addProperty( "classes", --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { +final class IllegalThrowsCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "19:51: " + getCheckMessage(MSG_KEY, "RuntimeException"), @@ -46,7 +46,7 @@ public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalClassNames() throws Exception { + void illegalClassNames() throws Exception { // check that incorrect names don't break the Check final String[] expected = { "15:33: " + getCheckMessage(MSG_KEY, "NullPointerException"), @@ -58,7 +58,7 @@ public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { /** Test to validate the IllegalThrowsCheck with ignoredMethodNames attribute. */ @Test - public void testIgnoreMethodNames() throws Exception { + void ignoreMethodNames() throws Exception { final String[] expected = { "19:51: " + getCheckMessage(MSG_KEY, "RuntimeException"), @@ -70,7 +70,7 @@ public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { /** Test to validate the IllegalThrowsCheck with both the attributes specified. */ @Test - public void testIllegalClassNamesWithIgnoreMethodNames() throws Exception { + void illegalClassNamesWithIgnoreMethodNames() throws Exception { final String[] expected = { "14:33: " + getCheckMessage(MSG_KEY, "NullPointerException"), "27:35: " + getCheckMessage(MSG_KEY, "Throwable"), @@ -81,7 +81,7 @@ public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { /** Test to validate the IllegalThrowsCheck with ignoreOverriddenMethods property. */ @Test - public void testIgnoreOverriddenMethods() throws Exception { + void ignoreOverriddenMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -91,7 +91,7 @@ public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { /** Test to validate the IllegalThrowsCheck without ignoreOverriddenMethods property. */ @Test - public void testNotIgnoreOverriddenMethods() throws Exception { + void notIgnoreOverriddenMethods() throws Exception { final String[] expected = { "17:36: " + getCheckMessage(MSG_KEY, "RuntimeException"), @@ -103,7 +103,7 @@ public class IllegalThrowsCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final IllegalThrowsCheck check = new IllegalThrowsCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenCheckTest.java @@ -20,14 +20,14 @@ package com.puppycrawl.tools.checkstyle.checks.coding; import static com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenCheck.MSG_KEY; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil; import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; -import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; -public class IllegalTokenCheckTest extends AbstractModuleTestSupport { +final class IllegalTokenCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class IllegalTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokensCheckDefaultTokenLabel() throws Exception { + void illegalTokensCheckDefaultTokenLabel() throws Exception { final String[] expected = { "36:14: " + getCheckMessage(MSG_KEY, "label:"), "38:25: " + getCheckMessage(MSG_KEY, "anotherLabel:"), @@ -45,7 +45,7 @@ public class IllegalTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokensCheckSwitchAndPostIncDec() throws Exception { + void illegalTokensCheckSwitchAndPostIncDec() throws Exception { final String[] expected = { "18:9: " + getCheckMessage(MSG_KEY, "switch"), "21:18: " + getCheckMessage(MSG_KEY, "--"), @@ -56,7 +56,7 @@ public class IllegalTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokensCheckTokenNative() throws Exception { + void illegalTokensCheckTokenNative() throws Exception { final String[] expected = { "27:12: " + getCheckMessage(MSG_KEY, "native"), }; @@ -64,10 +64,10 @@ public class IllegalTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokensCheckCommentsContent() throws Exception { + void illegalTokensCheckCommentsContent() throws Exception { final String path = getPath("InputIllegalTokensCheckCommentsContent.java"); - final String lineSeparator = CheckUtil.getLineSeparatorForFile(path, StandardCharsets.UTF_8); + final String lineSeparator = CheckUtil.getLineSeparatorForFile(path, UTF_8); final String[] expected = { "1:3: " + getCheckMessage( @@ -101,7 +101,7 @@ public class IllegalTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokensCheckBlockCommentBegin() throws Exception { + void illegalTokensCheckBlockCommentBegin() throws Exception { final String[] expected = { "1:1: " + getCheckMessage(MSG_KEY, "/*"), "10:1: " + getCheckMessage(MSG_KEY, "/*"), @@ -111,7 +111,7 @@ public class IllegalTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokensCheckBlockCommentEnd() throws Exception { + void illegalTokensCheckBlockCommentEnd() throws Exception { final String[] expected = { "6:1: " + getCheckMessage(MSG_KEY, "*/"), "12:2: " + getCheckMessage(MSG_KEY, "*/"), @@ -120,7 +120,7 @@ public class IllegalTokenCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokensCheckSingleLineComment() throws Exception { + void illegalTokensCheckSingleLineComment() throws Exception { final String[] expected = { "38:27: " + getCheckMessage(MSG_KEY, "//"), "42:26: " + getCheckMessage(MSG_KEY, "//"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheckTest.java @@ -21,6 +21,7 @@ package com.puppycrawl.tools.checkstyle.checks.coding; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck.MSG_KEY; +import static java.util.regex.Pattern.CASE_INSENSITIVE; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; @@ -31,7 +32,7 @@ import java.util.List; import java.util.regex.Pattern; import org.junit.jupiter.api.Test; -public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { +final class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +40,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testCaseSensitive() throws Exception { + void caseSensitive() throws Exception { final String[] expected = { "34:28: " + getCheckMessage(MSG_KEY, "a href"), }; @@ -47,7 +48,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testCaseInSensitive() throws Exception { + void caseInSensitive() throws Exception { final String[] expected = { "34:28: " + getCheckMessage(MSG_KEY, "a href"), "35:32: " + getCheckMessage(MSG_KEY, "a href"), @@ -56,7 +57,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomMessage() throws Exception { + void customMessage() throws Exception { final String[] expected = { "34:28: " + "My custom message", @@ -65,7 +66,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testNullCustomMessage() throws Exception { + void nullCustomMessage() throws Exception { final String[] expected = { "34:28: " + getCheckMessage(MSG_KEY, "a href"), @@ -74,7 +75,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokenTextTextBlocks() throws Exception { + void illegalTokenTextTextBlocks() throws Exception { final String[] expected = { "16:28: " + getCheckMessage(MSG_KEY, "a href"), @@ -88,7 +89,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTokenTextTextBlocksQuotes() throws Exception { + void illegalTokenTextTextBlocksQuotes() throws Exception { final String[] expected = { "16:28: " + getCheckMessage(MSG_KEY, "\""), @@ -104,7 +105,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final IllegalTokenTextCheck check = new IllegalTokenTextCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -121,7 +122,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentToken() throws Exception { + void commentToken() throws Exception { final String[] expected = { "1:3: " + getCheckMessage(MSG_KEY, "a href"), "45:28: " + getCheckMessage(MSG_KEY, "a href"), @@ -130,7 +131,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testStringTemplate() throws Exception { + void stringTemplate() throws Exception { final String[] expected = { "29:28: " + getCheckMessage(MSG_KEY, "x"), @@ -146,19 +147,19 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testOrderOfProperties() { + void orderOfProperties() { // pure class must be used as configuration doesn't guarantee order of // attributes final IllegalTokenTextCheck check = new IllegalTokenTextCheck(); check.setFormat("test"); check.setIgnoreCase(true); final Pattern actual = TestUtil.getInternalState(check, "format"); - assertWithMessage("should match").that(actual.flags()).isEqualTo(Pattern.CASE_INSENSITIVE); + assertWithMessage("should match").that(actual.flags()).isEqualTo(CASE_INSENSITIVE); assertWithMessage("should match").that(actual.pattern()).isEqualTo("test"); } @Test - public void testAcceptableTokensMakeSense() { + void acceptableTokensMakeSense() { final int expectedTokenTypesTotalNumber = 195; assertWithMessage( "Total number of TokenTypes has changed, acceptable tokens in" @@ -192,7 +193,7 @@ public class IllegalTokenTextCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultFormat() throws Exception { + void defaultFormat() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputIllegalTokenTextDefaultFormat.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckTest.java @@ -31,7 +31,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import org.junit.jupiter.api.Test; -public class IllegalTypeCheckTest extends AbstractModuleTestSupport { +final class IllegalTypeCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidateAbstractClassNamesSetToTrue() throws Exception { + void validateAbstractClassNamesSetToTrue() throws Exception { final String[] expected = { "27:38: " + getCheckMessage(MSG_KEY, "AbstractClass"), "44:5: " + getCheckMessage(MSG_KEY, "AbstractClass"), @@ -52,7 +52,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidateAbstractClassNamesSetToFalse() throws Exception { + void validateAbstractClassNamesSetToFalse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -60,7 +60,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaults() throws Exception { + void defaults() throws Exception { final String[] expected = { "34:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), "35:13: " + getCheckMessage(MSG_KEY, "TreeSet"), @@ -72,7 +72,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultsEmptyStringMemberModifiers() throws Exception { + void defaultsEmptyStringMemberModifiers() throws Exception { final String[] expected = { "34:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), @@ -86,7 +86,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreMethodNames() throws Exception { + void ignoreMethodNames() throws Exception { final String[] expected = { "23:13: " + getCheckMessage(MSG_KEY, "AbstractClass"), "26:13: " @@ -104,7 +104,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testFormat() throws Exception { + void format() throws Exception { final String[] expected = { "34:13: " + getCheckMessage(MSG_KEY, "java.util.TreeSet"), @@ -117,7 +117,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testLegalAbstractClassNames() throws Exception { + void legalAbstractClassNames() throws Exception { final String[] expected = { "26:13: " @@ -136,7 +136,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testSameFileNameFalsePositive() throws Exception { + void sameFileNameFalsePositive() throws Exception { final String[] expected = { "28:5: " + getCheckMessage(MSG_KEY, "SubCal"), "43:5: " + getCheckMessage(MSG_KEY, "java.util.List"), @@ -147,7 +147,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testSameFileNameGeneral() throws Exception { + void sameFileNameGeneral() throws Exception { final String[] expected = { "25:5: " + getCheckMessage(MSG_KEY, "InputIllegalTypeGregCal"), "29:43: " + getCheckMessage(MSG_KEY, "InputIllegalTypeGregCal"), @@ -162,7 +162,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayTypes() throws Exception { + void arrayTypes() throws Exception { final String[] expected = { "20:12: " + getCheckMessage(MSG_KEY, "Boolean[]"), "22:12: " + getCheckMessage(MSG_KEY, "Boolean[][]"), @@ -175,7 +175,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testPlainAndArrayTypes() throws Exception { + void plainAndArrayTypes() throws Exception { final String[] expected = { "20:12: " + getCheckMessage(MSG_KEY, "Boolean"), "24:12: " + getCheckMessage(MSG_KEY, "Boolean[][]"), @@ -187,7 +187,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testGenerics() throws Exception { + void generics() throws Exception { final String[] expected = { "28:16: " + getCheckMessage(MSG_KEY, "Boolean"), "29:31: " + getCheckMessage(MSG_KEY, "Boolean"), @@ -211,7 +211,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testExtendsImplements() throws Exception { + void extendsImplements() throws Exception { final String[] expected = { "24:17: " + getCheckMessage(MSG_KEY, "Hashtable"), "25:14: " + getCheckMessage(MSG_KEY, "Boolean"), @@ -227,7 +227,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testStarImports() throws Exception { + void starImports() throws Exception { final String[] expected = { "24:5: " + getCheckMessage(MSG_KEY, "List"), @@ -237,7 +237,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticImports() throws Exception { + void staticImports() throws Exception { final String[] expected = { "26:6: " + getCheckMessage(MSG_KEY, "SomeStaticClass"), @@ -248,7 +248,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testMemberModifiers() throws Exception { + void memberModifiers() throws Exception { final String[] expected = { "22:13: " + getCheckMessage(MSG_KEY, "AbstractClass"), "25:13: " + getCheckMessage(MSG_KEY, "java.util.AbstractList"), @@ -263,7 +263,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageClassName() throws Exception { + void packageClassName() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -271,7 +271,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testClearDataBetweenFiles() throws Exception { + void clearDataBetweenFiles() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IllegalTypeCheck.class); final String violationFile = getPath("InputIllegalTypeTestClearDataBetweenFiles.java"); checkConfig.addProperty("illegalClassNames", "java.util.TreeSet"); @@ -290,7 +290,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTypeEnhancedInstanceof() throws Exception { + void illegalTypeEnhancedInstanceof() throws Exception { final String[] expected = { "28:9: " + getCheckMessage(MSG_KEY, "LinkedHashMap"), "31:28: " + getCheckMessage(MSG_KEY, "LinkedHashMap"), @@ -304,7 +304,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTypeRecordsAndCompactCtors() throws Exception { + void illegalTypeRecordsAndCompactCtors() throws Exception { final String[] expected = { "27:14: " + getCheckMessage(MSG_KEY, "LinkedHashMap"), "31:52: " + getCheckMessage(MSG_KEY, "Cloneable"), @@ -320,7 +320,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTypeNewArrayStructure() throws Exception { + void illegalTypeNewArrayStructure() throws Exception { final String[] expected = { "26:13: " + getCheckMessage(MSG_KEY, "HashMap"), @@ -330,7 +330,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentsDefault() throws Exception { + void recordComponentsDefault() throws Exception { final String[] expected = { "45:9: " + getCheckMessage(MSG_KEY, "HashSet"), "53:23: " + getCheckMessage(MSG_KEY, "HashSet"), @@ -341,7 +341,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentsFinal() throws Exception { + void recordComponentsFinal() throws Exception { final String[] expected = { "45:9: " + getCheckMessage(MSG_KEY, "HashSet"), "53:23: " + getCheckMessage(MSG_KEY, "HashSet"), @@ -352,7 +352,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentsPrivateFinal() throws Exception { + void recordComponentsPrivateFinal() throws Exception { final String[] expected = { "45:9: " + getCheckMessage(MSG_KEY, "HashSet"), "53:23: " + getCheckMessage(MSG_KEY, "HashSet"), @@ -364,7 +364,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentsPublicProtectedStatic() throws Exception { + void recordComponentsPublicProtectedStatic() throws Exception { final String[] expected = {"45:9: " + getCheckMessage(MSG_KEY, "HashSet")}; verifyWithInlineConfigParser( @@ -374,13 +374,13 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrailingWhitespaceInConfig() throws Exception { + void trailingWhitespaceInConfig() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputIllegalTypeWhitespaceInConfig.java"), expected); } @Test - public void testTokensNotNull() { + void tokensNotNull() { final IllegalTypeCheck check = new IllegalTypeCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -394,7 +394,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testImproperToken() { + void improperToken() { final IllegalTypeCheck check = new IllegalTypeCheck(); final DetailAstImpl classDefAst = new DetailAstImpl(); @@ -414,7 +414,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { * beneficial. */ @Test - public void testImproperLeaveToken() { + void improperLeaveToken() { final IllegalTypeCheck check = new IllegalTypeCheck(); final DetailAstImpl enumAst = new DetailAstImpl(); enumAst.setType(TokenTypes.ENUM_DEF); @@ -430,7 +430,7 @@ public class IllegalTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalTypeAbstractClassNameFormat() throws Exception { + void illegalTypeAbstractClassNameFormat() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY, "Gitter"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class InnerAssignmentCheckTest extends AbstractModuleTestSupport { +final class InnerAssignmentCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class InnerAssignmentCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "22:15: " + getCheckMessage(MSG_KEY), "22:19: " + getCheckMessage(MSG_KEY), @@ -46,7 +46,7 @@ public class InnerAssignmentCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethod() throws Exception { + void method() throws Exception { final String[] expected = { "73:22: " + getCheckMessage(MSG_KEY), }; @@ -54,7 +54,7 @@ public class InnerAssignmentCheckTest extends AbstractModuleTestSupport { } @Test - public void testDemoBug1195047Comment3() throws Exception { + void demoBug1195047Comment3() throws Exception { final String[] expected = { "18:16: " + getCheckMessage(MSG_KEY), "19:24: " + getCheckMessage(MSG_KEY), @@ -74,13 +74,13 @@ public class InnerAssignmentCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaExpression() throws Exception { + void lambdaExpression() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputInnerAssignmentLambdaExpressions.java"), expected); } @Test - public void testInnerAssignmentNotInLoopContext() throws Exception { + void innerAssignmentNotInLoopContext() throws Exception { final String[] expected = { "12:28: " + getCheckMessage(MSG_KEY), }; @@ -88,7 +88,7 @@ public class InnerAssignmentCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final InnerAssignmentCheck check = new InnerAssignmentCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MagicNumberCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MagicNumberCheckTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MagicNumberCheckTest extends AbstractModuleTestSupport { +final class MagicNumberCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,13 +33,13 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testLocalVariables() throws Exception { + void localVariables() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMagicNumberLocalVariables.java"), expected); } @Test - public void testLocalVariables2() throws Exception { + void localVariables2() throws Exception { final String[] expected = { "25:17: " + getCheckMessage(MSG_KEY, "8"), }; @@ -47,7 +47,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault1() throws Exception { + void default1() throws Exception { final String[] expected = { "54:26: " + getCheckMessage(MSG_KEY, "3_000"), "55:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -75,7 +75,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault2() throws Exception { + void default2() throws Exception { final String[] expected = { "21:14: " + getCheckMessage(MSG_KEY, "0xffffffffL"), "28:30: " + getCheckMessage(MSG_KEY, "+3"), @@ -92,7 +92,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault3() throws Exception { + void default3() throws Exception { final String[] expected = { "20:16: " + getCheckMessage(MSG_KEY, "31"), "25:16: " + getCheckMessage(MSG_KEY, "42"), @@ -114,7 +114,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreSome1() throws Exception { + void ignoreSome1() throws Exception { final String[] expected = { "36:25: " + getCheckMessage(MSG_KEY, "2"), "42:35: " + getCheckMessage(MSG_KEY, "2"), @@ -136,7 +136,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreSome2() throws Exception { + void ignoreSome2() throws Exception { final String[] expected = { "21:14: " + getCheckMessage(MSG_KEY, "0xffffffffL"), "30:29: " + getCheckMessage(MSG_KEY, "-2"), @@ -156,7 +156,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreSome3() throws Exception { + void ignoreSome3() throws Exception { final String[] expected = { "21:16: " + getCheckMessage(MSG_KEY, "31"), "26:16: " + getCheckMessage(MSG_KEY, "42"), @@ -174,7 +174,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreNone1() throws Exception { + void ignoreNone1() throws Exception { final String[] expected = { "41:24: " + getCheckMessage(MSG_KEY, "1"), "42:25: " + getCheckMessage(MSG_KEY, "2"), @@ -223,7 +223,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreNone2() throws Exception { + void ignoreNone2() throws Exception { final String[] expected = { "19:14: " + getCheckMessage(MSG_KEY, "0xffffffffL"), "26:30: " + getCheckMessage(MSG_KEY, "+3"), @@ -244,7 +244,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreNone3() throws Exception { + void ignoreNone3() throws Exception { final String[] expected = { "20:16: " + getCheckMessage(MSG_KEY, "31"), "25:16: " + getCheckMessage(MSG_KEY, "42"), @@ -262,7 +262,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIntegersOnly1() throws Exception { + void integersOnly1() throws Exception { final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "57:27: " + getCheckMessage(MSG_KEY, "3"), @@ -288,7 +288,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIntegersOnly2() throws Exception { + void integersOnly2() throws Exception { final String[] expected = { "20:14: " + getCheckMessage(MSG_KEY, "0xffffffffL"), "28:30: " + getCheckMessage(MSG_KEY, "+3"), @@ -303,7 +303,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIntegersOnly3() throws Exception { + void integersOnly3() throws Exception { final String[] expected = { "20:16: " + getCheckMessage(MSG_KEY, "31"), "25:16: " + getCheckMessage(MSG_KEY, "42"), @@ -321,7 +321,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreNegativeOctalHex1() throws Exception { + void ignoreNegativeOctalHex1() throws Exception { final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "57:27: " + getCheckMessage(MSG_KEY, "3"), @@ -347,7 +347,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreNegativeOctalHex2() throws Exception { + void ignoreNegativeOctalHex2() throws Exception { final String[] expected = { "20:14: " + getCheckMessage(MSG_KEY, "0xffffffffL"), "28:30: " + getCheckMessage(MSG_KEY, "+3"), @@ -357,7 +357,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreNegativeOctalHex3() throws Exception { + void ignoreNegativeOctalHex3() throws Exception { final String[] expected = { "20:16: " + getCheckMessage(MSG_KEY, "31"), "25:16: " + getCheckMessage(MSG_KEY, "42"), @@ -375,7 +375,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreHashCodeMethod() throws Exception { + void ignoreHashCodeMethod() throws Exception { final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "56:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -403,7 +403,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreHashCodeMethod2() throws Exception { + void ignoreHashCodeMethod2() throws Exception { final String[] expected = { "20:14: " + getCheckMessage(MSG_KEY, "0xffffffffL"), "27:30: " + getCheckMessage(MSG_KEY, "+3"), @@ -420,7 +420,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreHashCodeMethod3() throws Exception { + void ignoreHashCodeMethod3() throws Exception { final String[] expected = { "25:16: " + getCheckMessage(MSG_KEY, "42"), "30:16: " + getCheckMessage(MSG_KEY, "13"), @@ -437,7 +437,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreFieldDeclaration1() throws Exception { + void ignoreFieldDeclaration1() throws Exception { final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "56:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -464,7 +464,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreFieldDeclaration2() throws Exception { + void ignoreFieldDeclaration2() throws Exception { final String[] expected = { "49:20: " + getCheckMessage(MSG_KEY, "378"), }; @@ -472,7 +472,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreFieldDeclaration3() throws Exception { + void ignoreFieldDeclaration3() throws Exception { final String[] expected = { "20:16: " + getCheckMessage(MSG_KEY, "31"), "25:16: " + getCheckMessage(MSG_KEY, "42"), @@ -490,7 +490,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testWaiverParentToken() throws Exception { + void waiverParentToken() throws Exception { final String[] expected = { "55:26: " + getCheckMessage(MSG_KEY, "3_000"), "56:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -518,7 +518,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testWaiverParentToken2() throws Exception { + void waiverParentToken2() throws Exception { final String[] expected = { "20:14: " + getCheckMessage(MSG_KEY, "0xffffffffL"), "28:30: " + getCheckMessage(MSG_KEY, "+3"), @@ -540,7 +540,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testWaiverParentToken3() throws Exception { + void waiverParentToken3() throws Exception { final String[] expected = { "20:16: " + getCheckMessage(MSG_KEY, "31"), "25:16: " + getCheckMessage(MSG_KEY, "42"), @@ -563,7 +563,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testMagicNumberRecordsDefault() throws Exception { + void magicNumberRecordsDefault() throws Exception { final String[] expected = { "19:11: " + getCheckMessage(MSG_KEY, "6"), "21:36: " + getCheckMessage(MSG_KEY, "7"), @@ -576,7 +576,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testMagicNumberIgnoreFieldDeclarationRecords() throws Exception { + void magicNumberIgnoreFieldDeclarationRecords() throws Exception { final String[] expected = { "19:11: " + getCheckMessage(MSG_KEY, "6"), "25:29: " + getCheckMessage(MSG_KEY, "8"), @@ -588,7 +588,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreInAnnotationElementDefault() throws Exception { + void ignoreInAnnotationElementDefault() throws Exception { final String[] expected = { "18:29: " + getCheckMessage(MSG_KEY, "10"), "19:33: " + getCheckMessage(MSG_KEY, "11"), }; @@ -596,7 +596,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testMagicNumber() throws Exception { + void magicNumber() throws Exception { final String[] expected = { "38:29: " + getCheckMessage(MSG_KEY, "3.0"), "39:32: " + getCheckMessage(MSG_KEY, "1.5_0"), @@ -635,7 +635,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testMagicNumber2() throws Exception { + void magicNumber2() throws Exception { final String[] expected = { "25:17: " + getCheckMessage(MSG_KEY, "9"), "27:20: " + getCheckMessage(MSG_KEY, "5.5"), @@ -659,7 +659,7 @@ public class MagicNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testMagicNumber3() throws Exception { + void magicNumber3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMagicNumberMagicNumber3.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MatchXpathCheckTest extends AbstractModuleTestSupport { +final class MatchXpathCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,25 +38,25 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckWithEmptyQuery() throws Exception { + void checkWithEmptyQuery() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMatchXpath.java"), expected); } @Test - public void testNoStackoverflowError() throws Exception { + void noStackoverflowError() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMatchXpathNoStackoverflowError.java"), expected); } @Test - public void testCheckWithImplicitEmptyQuery() throws Exception { + void checkWithImplicitEmptyQuery() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMatchXpath2.java"), expected); } @Test - public void testCheckWithMatchingMethodNames() throws Exception { + void checkWithMatchingMethodNames() throws Exception { final String[] expected = { "11:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), "13:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), @@ -65,13 +65,13 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckWithNoMatchingMethodName() throws Exception { + void checkWithNoMatchingMethodName() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMatchXpath4.java"), expected); } @Test - public void testCheckWithSingleLineCommentsStartsWithSpace() throws Exception { + void checkWithSingleLineCommentsStartsWithSpace() throws Exception { final String[] expected = { "13:25: " + getCheckMessage(MatchXpathCheck.MSG_KEY), "14:27: " + getCheckMessage(MatchXpathCheck.MSG_KEY), @@ -80,7 +80,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckWithBlockComments() throws Exception { + void checkWithBlockComments() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), "14:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), @@ -89,7 +89,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckWithMultilineComments() throws Exception { + void checkWithMultilineComments() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), "20:5: " + getCheckMessage(MatchXpathCheck.MSG_KEY), @@ -98,7 +98,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckWithDoubleBraceInitialization() throws Exception { + void checkWithDoubleBraceInitialization() throws Exception { final String[] expected = { "18:35: Do not use double-brace initialization", }; @@ -106,7 +106,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testImitateIllegalThrowsCheck() throws Exception { + void imitateIllegalThrowsCheck() throws Exception { final String[] expected = { "13:25: Illegal throws statement", "15:25: Illegal throws statement", @@ -116,7 +116,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testImitateExecutableStatementCountCheck() throws Exception { + void imitateExecutableStatementCountCheck() throws Exception { final String[] expected = { "25:5: Executable number of statements exceed threshold", }; @@ -124,7 +124,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testForbidPrintStackTrace() throws Exception { + void forbidPrintStackTrace() throws Exception { final String[] expected = { "18:27: printStackTrace() method calls are forbidden", }; @@ -132,7 +132,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testForbidParameterizedConstructor() throws Exception { + void forbidParameterizedConstructor() throws Exception { final String[] expected = { "13:5: Parameterized constructors are not allowed", "15:5: Parameterized constructors are not allowed", @@ -142,7 +142,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testAvoidInstanceCreationWithoutVar() throws Exception { + void avoidInstanceCreationWithoutVar() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(MatchXpathCheck.MSG_KEY), }; @@ -151,7 +151,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidQuery() { + void invalidQuery() { final MatchXpathCheck matchXpathCheck = new MatchXpathCheck(); try { @@ -163,7 +163,7 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testEvaluationException() { + void evaluationException() { final MatchXpathCheck matchXpathCheck = new MatchXpathCheck(); matchXpathCheck.setQuery("count(*) div 0"); @@ -182,25 +182,25 @@ public class MatchXpathCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetDefaultTokens() { + void getDefaultTokens() { final MatchXpathCheck matchXpathCheck = new MatchXpathCheck(); assertWithMessage("Expected empty array").that(matchXpathCheck.getDefaultTokens()).isEmpty(); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MatchXpathCheck matchXpathCheck = new MatchXpathCheck(); assertWithMessage("Expected empty array").that(matchXpathCheck.getAcceptableTokens()).isEmpty(); } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MatchXpathCheck matchXpathCheck = new MatchXpathCheck(); assertWithMessage("Expected empty array").that(matchXpathCheck.getRequiredTokens()).isEmpty(); } @Test - public void testMatchXpathWithFailedEvaluation() { + void matchXpathWithFailedEvaluation() { final CheckstyleException ex = assertThrows( CheckstyleException.class, --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingCtorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingCtorCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.MissingCtorCheck.MSG import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class MissingCtorCheckTest extends AbstractModuleTestSupport { +final class MissingCtorCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class MissingCtorCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingSwitchDefault() throws Exception { + void missingSwitchDefault() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), @@ -43,7 +43,7 @@ public class MissingCtorCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final MissingCtorCheck check = new MissingCtorCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -57,7 +57,7 @@ public class MissingCtorCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingCtorClassOnOneLine() throws Exception { + void missingCtorClassOnOneLine() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingSwitchDefaultCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingSwitchDefaultCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { +final class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingSwitchDefault() throws Exception { + void missingSwitchDefault() throws Exception { final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY, "default"), "35:17: " + getCheckMessage(MSG_KEY, "default"), @@ -45,7 +45,7 @@ public class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final MissingSwitchDefaultCheck check = new MissingSwitchDefaultCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -59,7 +59,7 @@ public class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingSwitchDefaultSwitchExpressions() throws Exception { + void missingSwitchDefaultSwitchExpressions() throws Exception { final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY, "default"), }; @@ -68,14 +68,14 @@ public class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { } @Test - public void testNullCaseLabel() throws Exception { + void nullCaseLabel() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputMissingSwitchDefaultCheckNullCaseLabel.java"), expected); } @Test - public void testMissingSwitchDefaultSwitchExpressionsTwo() throws Exception { + void missingSwitchDefaultSwitchExpressionsTwo() throws Exception { final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY, "default"), "26:9: " + getCheckMessage(MSG_KEY, "default"), @@ -85,7 +85,7 @@ public class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingSwitchDefaultSwitchExpressionsThree() throws Exception { + void missingSwitchDefaultSwitchExpressionsThree() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputMissingSwitchDefaultCheckSwitchExpressionsThree.java"), @@ -93,7 +93,7 @@ public class MissingSwitchDefaultCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingSwitchDefaultCaseLabelElements() throws Exception { + void missingSwitchDefaultCaseLabelElements() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputMissingSwitchDefaultCaseLabelElements.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckTest.java @@ -35,7 +35,7 @@ import java.util.Optional; import java.util.Set; import org.junit.jupiter.api.Test; -public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport { +final class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -43,7 +43,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport } @Test - public void testModifiedControlVariable() throws Exception { + void modifiedControlVariable() throws Exception { final String[] expected = { "17:14: " + getCheckMessage(MSG_KEY, "i"), "20:15: " + getCheckMessage(MSG_KEY, "i"), @@ -60,7 +60,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport } @Test - public void testEnhancedForLoopVariableTrue() throws Exception { + void enhancedForLoopVariableTrue() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -68,7 +68,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport } @Test - public void testEnhancedForLoopVariableFalse() throws Exception { + void enhancedForLoopVariableFalse() throws Exception { final String[] expected = { "16:18: " + getCheckMessage(MSG_KEY, "line"), @@ -78,7 +78,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport } @Test - public void testEnhancedForLoopVariable2() throws Exception { + void enhancedForLoopVariable2() throws Exception { final String[] expected = { "21:18: " + getCheckMessage(MSG_KEY, "i"), @@ -88,7 +88,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport } @Test - public void testTokensNotNull() { + void tokensNotNull() { final ModifiedControlVariableCheck check = new ModifiedControlVariableCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -102,7 +102,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport } @Test - public void testImproperToken() { + void improperToken() { final ModifiedControlVariableCheck check = new ModifiedControlVariableCheck(); final DetailAstImpl classDefAst = new DetailAstImpl(); @@ -124,7 +124,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport } @Test - public void testVariousAssignments() throws Exception { + void variousAssignments() throws Exception { final String[] expected = { "14:15: " + getCheckMessage(MSG_KEY, "i"), "15:15: " + getCheckMessage(MSG_KEY, "k"), @@ -154,7 +154,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport } @Test - public void testRecordDecompositionInEnhancedForLoop() throws Exception { + void recordDecompositionInEnhancedForLoop() throws Exception { final String[] expected = { "32:15: " + getCheckMessage(MSG_KEY, "p"), }; @@ -168,9 +168,9 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport * * @throws Exception when code tested throws exception */ - @Test @SuppressWarnings("unchecked") - public void testClearState() throws Exception { + @Test + void clearState() throws Exception { final ModifiedControlVariableCheck check = new ModifiedControlVariableCheck(); final Optional methodDef = TestUtil.findTokenInAstByPredicate( @@ -184,7 +184,7 @@ public class ModifiedControlVariableCheckTest extends AbstractModuleTestSupport .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - methodDef.get(), + methodDef.orElseThrow(), "variableStack", variableStack -> ((Collection>) variableStack).isEmpty())) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheckTest.java @@ -31,7 +31,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { +final class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "14:16: " + getCheckMessage(MSG_KEY, "\"StringContents\"", 3), @@ -51,7 +51,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testItIgnoreEmpty() throws Exception { + void itIgnoreEmpty() throws Exception { final String[] expected = { "14:16: " + getCheckMessage(MSG_KEY, "\"StringContents\"", 3), @@ -62,7 +62,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultipleInputs() throws Exception { + void multipleInputs() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(MultipleStringLiteralsCheck.class); checkConfig.addProperty("allowedDuplicates", "2"); @@ -84,7 +84,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testItIgnoreEmptyAndComspace() throws Exception { + void itIgnoreEmptyAndComspace() throws Exception { final String[] expected = { "14:16: " + getCheckMessage(MSG_KEY, "\"StringContents\"", 3), @@ -94,7 +94,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testItWithoutIgnoringAnnotations() throws Exception { + void itWithoutIgnoringAnnotations() throws Exception { final String[] expected = { "28:23: " + getCheckMessage(MSG_KEY, "\"unchecked\"", 4), @@ -104,7 +104,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final MultipleStringLiteralsCheck check = new MultipleStringLiteralsCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -118,7 +118,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = { "14:16: " + getCheckMessage(MSG_KEY, "\"StringContents\"", 3), "16:17: " + getCheckMessage(MSG_KEY, "\"DoubleString\"", 2), @@ -129,7 +129,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnores() throws Exception { + void ignores() throws Exception { final String[] expected = { "28:23: " + getCheckMessage(MSG_KEY, "\"unchecked\"", 4), }; @@ -138,7 +138,7 @@ public class MultipleStringLiteralsCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultipleStringLiteralsTextBlocks() throws Exception { + void multipleStringLiteralsTextBlocks() throws Exception { final String[] expected = { "14:22: " + getCheckMessage(MSG_KEY, "\"string\"", 3), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheckTest.java @@ -26,7 +26,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDecl import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class MultipleVariableDeclarationsCheckTest extends AbstractModuleTestSupport { +final class MultipleVariableDeclarationsCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class MultipleVariableDeclarationsCheckTest extends AbstractModuleTestSup } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "11:5: " + getCheckMessage(MSG_MULTIPLE_COMMA), @@ -52,7 +52,7 @@ public class MultipleVariableDeclarationsCheckTest extends AbstractModuleTestSup } @Test - public void testTokensNotNull() { + void tokensNotNull() { final MultipleVariableDeclarationsCheck check = new MultipleVariableDeclarationsCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -66,7 +66,7 @@ public class MultipleVariableDeclarationsCheckTest extends AbstractModuleTestSup } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "11:5: " + getCheckMessage(MSG_MULTIPLE), "14:5: " + getCheckMessage(MSG_MULTIPLE), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NestedForDepthCheckTest extends AbstractModuleTestSupport { +final class NestedForDepthCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,7 +41,7 @@ public class NestedForDepthCheckTest extends AbstractModuleTestSupport { * @throws Exception necessary to fulfill JUnit's interface-requirements for test-methods. */ @Test - public void testNestedTooDeep() throws Exception { + void nestedTooDeep() throws Exception { final String[] expected = { "32:11: " + getCheckMessage(MSG_KEY, 3, 2), @@ -60,7 +60,7 @@ public class NestedForDepthCheckTest extends AbstractModuleTestSupport { * @throws Exception necessary to fulfill JUnit's interface-requirements for test-methods. */ @Test - public void testNestedOk() throws Exception { + void nestedOk() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -68,7 +68,7 @@ public class NestedForDepthCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final NestedForDepthCheck check = new NestedForDepthCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -82,7 +82,7 @@ public class NestedForDepthCheckTest extends AbstractModuleTestSupport { } @Test - public void testNestedDefault() throws Exception { + void nestedDefault() throws Exception { final String[] expected = { "27:9: " + getCheckMessage(MSG_KEY, 2, 1), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NestedIfDepthCheckTest extends AbstractModuleTestSupport { +final class NestedIfDepthCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class NestedIfDepthCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "26:17: " + getCheckMessage(MSG_KEY, 2, 1), @@ -48,7 +48,7 @@ public class NestedIfDepthCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomizedDepth() throws Exception { + void customizedDepth() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -56,7 +56,7 @@ public class NestedIfDepthCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final NestedIfDepthCheck check = new NestedIfDepthCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck. import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class NestedTryDepthCheckTest extends AbstractModuleTestSupport { +final class NestedTryDepthCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class NestedTryDepthCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "29:17: " + getCheckMessage(MSG_KEY, 2, 1), @@ -45,7 +45,7 @@ public class NestedTryDepthCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomizedDepth() throws Exception { + void customizedDepth() throws Exception { final String[] expected = { "41:21: " + getCheckMessage(MSG_KEY, 3, 2), @@ -55,7 +55,7 @@ public class NestedTryDepthCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final NestedTryDepthCheck check = new NestedTryDepthCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoArrayTrailingCommaCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoArrayTrailingCommaCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.NoArrayTrailingComma import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class NoArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { +final class NoArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { @Override public String getPackageLocation() { @@ -33,7 +33,7 @@ public class NoArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "20:14: " + getCheckMessage(MSG_KEY), "25:32: " + getCheckMessage(MSG_KEY), @@ -47,7 +47,7 @@ public class NoArrayTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final NoArrayTrailingCommaCheck check = new NoArrayTrailingCommaCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoCloneCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoCloneCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.NoCloneCheck.MSG_KEY import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class NoCloneCheckTest extends AbstractModuleTestSupport { +final class NoCloneCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class NoCloneCheckTest extends AbstractModuleTestSupport { } @Test - public void testHasClone() throws Exception { + void hasClone() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY), "34:5: " + getCheckMessage(MSG_KEY), @@ -47,7 +47,7 @@ public class NoCloneCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final NoCloneCheck check = new NoCloneCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoEnumTrailingCommaCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoEnumTrailingCommaCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.NoEnumTrailingCommaC import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class NoEnumTrailingCommaCheckTest extends AbstractModuleTestSupport { +final class NoEnumTrailingCommaCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class NoEnumTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultOne() throws Exception { + void defaultOne() throws Exception { final String[] expected = { "23:12: " + getCheckMessage(MSG_KEY), "28:12: " + getCheckMessage(MSG_KEY), @@ -48,7 +48,7 @@ public class NoEnumTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultTwo() throws Exception { + void defaultTwo() throws Exception { final String[] expected = { "20:55: " + getCheckMessage(MSG_KEY), "24:14: " + getCheckMessage(MSG_KEY), @@ -64,7 +64,7 @@ public class NoEnumTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultThree() throws Exception { + void defaultThree() throws Exception { final String[] expected = { "13:21: " + getCheckMessage(MSG_KEY), "33:10: " + getCheckMessage(MSG_KEY), @@ -76,7 +76,7 @@ public class NoEnumTrailingCommaCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final NoEnumTrailingCommaCheck check = new NoEnumTrailingCommaCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoFinalizerCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/NoFinalizerCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** NoFinalizerCheck test. */ -public class NoFinalizerCheckTest extends AbstractModuleTestSupport { +final class NoFinalizerCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class NoFinalizerCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final NoFinalizerCheck noFinalizerCheck = new NoFinalizerCheck(); final int[] expected = {TokenTypes.METHOD_DEF}; @@ -46,7 +46,7 @@ public class NoFinalizerCheckTest extends AbstractModuleTestSupport { } @Test - public void testHasFinalizer() throws Exception { + void hasFinalizer() throws Exception { final String[] expected = { "11:5: " + getCheckMessage(MSG_KEY), }; @@ -54,13 +54,13 @@ public class NoFinalizerCheckTest extends AbstractModuleTestSupport { } @Test - public void testHasNoFinalizer() throws Exception { + void hasNoFinalizer() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNoFinalizerFallThrough.java"), expected); } @Test - public void testHasNoFinalizerTryWithResource() throws Exception { + void hasNoFinalizerTryWithResource() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputNoFinalizerFallThrough.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OneStatementPerLineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OneStatementPerLineCheckTest.java @@ -22,13 +22,14 @@ package com.puppycrawl.tools.checkstyle.checks.coding; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.List; import org.junit.jupiter.api.Test; -public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { +final class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +37,7 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiCaseSmallTalkStyle() throws Exception { + void multiCaseSmallTalkStyle() throws Exception { final String[] expected = { "13:59: " + getCheckMessage(MSG_KEY), "87:21: " + getCheckMessage(MSG_KEY), }; @@ -45,7 +46,7 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiCaseLoops() throws Exception { + void multiCaseLoops() throws Exception { final String[] expected = { "27:18: " + getCheckMessage(MSG_KEY), "53:17: " + getCheckMessage(MSG_KEY), @@ -58,14 +59,14 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiCaseDeclarations() throws Exception { + void multiCaseDeclarations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOneStatementPerLineSingleLineForDeclarations.java"), expected); } @Test - public void testTokensNotNull() { + void tokensNotNull() { final OneStatementPerLineCheck check = new OneStatementPerLineCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -79,7 +80,7 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testDeclarationsWithMultilineStatements() throws Exception { + void declarationsWithMultilineStatements() throws Exception { final String[] expected = { "49:21: " + getCheckMessage(MSG_KEY), "66:17: " + getCheckMessage(MSG_KEY), @@ -92,7 +93,7 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testLoopsAndTryWithResourceWithMultilineStatements() throws Exception { + void loopsAndTryWithResourceWithMultilineStatements() throws Exception { final String[] expected = { "53:39: " + getCheckMessage(MSG_KEY), "86:44: " + getCheckMessage(MSG_KEY), @@ -103,7 +104,7 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void oneStatementNonCompilableInputTest() throws Exception { + void oneStatementNonCompilableInputTest() throws Exception { final String[] expected = { "39:4: " + getCheckMessage(MSG_KEY), "44:54: " + getCheckMessage(MSG_KEY), @@ -117,7 +118,7 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testResourceReferenceVariableIgnored() throws Exception { + void resourceReferenceVariableIgnored() throws Exception { final String[] expected = { "32:42: " + getCheckMessage(MSG_KEY), "36:43: " + getCheckMessage(MSG_KEY), @@ -130,14 +131,14 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testResourcesIgnored() throws Exception { + void resourcesIgnored() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputOneStatementPerLineTryWithResourcesIgnore.java"), expected); } @Test - public void testAllTheCodeInSingleLine() throws Exception { + void allTheCodeInSingleLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OneStatementPerLineCheck.class); final String[] expected = { @@ -154,22 +155,22 @@ public class OneStatementPerLineCheckTest extends AbstractModuleTestSupport { } @Test - public void testStateIsClearedOnBeginTreeForLastStatementEnd() throws Exception { + void stateIsClearedOnBeginTreeForLastStatementEnd() throws Exception { final String inputWithWarnings = getPath("InputOneStatementPerLineBeginTree1.java"); final String inputWithoutWarnings = getPath("InputOneStatementPerLineBeginTree2.java"); - final List expectedFirstInput = List.of("6:96: " + getCheckMessage(MSG_KEY)); + final List expectedFirstInput = ImmutableList.of("6:96: " + getCheckMessage(MSG_KEY)); final List expectedSecondInput = List.of(CommonUtil.EMPTY_STRING_ARRAY); verifyWithInlineConfigParser( inputWithWarnings, inputWithoutWarnings, expectedFirstInput, expectedSecondInput); } @Test - public void testStateIsClearedOnBeginTreeForLastVariableStatement() throws Exception { + void stateIsClearedOnBeginTreeForLastVariableStatement() throws Exception { final String file1 = getPath("InputOneStatementPerLineBeginTreeLastVariableResourcesStatementEnd1.java"); final String file2 = getPath("InputOneStatementPerLineBeginTreeLastVariableResourcesStatementEnd2.java"); - final List expectedFirstInput = List.of("15:59: " + getCheckMessage(MSG_KEY)); + final List expectedFirstInput = ImmutableList.of("15:59: " + getCheckMessage(MSG_KEY)); final List expectedSecondInput = List.of(CommonUtil.EMPTY_STRING_ARRAY); verifyWithInlineConfigParser(file1, file2, expectedFirstInput, expectedSecondInput); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OverloadMethodsDeclarationOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/OverloadMethodsDeclarationOrderCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class OverloadMethodsDeclarationOrderCheckTest extends AbstractModuleTestSupport { +final class OverloadMethodsDeclarationOrderCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class OverloadMethodsDeclarationOrderCheckTest extends AbstractModuleTest } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "32:5: " + getCheckMessage(MSG_KEY, 21), @@ -46,7 +46,7 @@ public class OverloadMethodsDeclarationOrderCheckTest extends AbstractModuleTest } @Test - public void testOverloadMethodsDeclarationOrderRecords() throws Exception { + void overloadMethodsDeclarationOrderRecords() throws Exception { final String[] expected = { "21:9: " + getCheckMessage(MSG_KEY, 15), @@ -58,7 +58,7 @@ public class OverloadMethodsDeclarationOrderCheckTest extends AbstractModuleTest } @Test - public void testOverloadMethodsDeclarationOrderPrivateAndStaticMethods() throws Exception { + void overloadMethodsDeclarationOrderPrivateAndStaticMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -67,7 +67,7 @@ public class OverloadMethodsDeclarationOrderCheckTest extends AbstractModuleTest } @Test - public void testTokensNotNull() { + void tokensNotNull() { final OverloadMethodsDeclarationOrderCheck check = new OverloadMethodsDeclarationOrderCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/PackageDeclarationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/PackageDeclarationCheckTest.java @@ -31,7 +31,7 @@ import de.thetaphi.forbiddenapis.SuppressForbidden; import java.io.File; import org.junit.jupiter.api.Test; -public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { +final class PackageDeclarationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultNoPackage() throws Exception { + void defaultNoPackage() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISSING), @@ -49,7 +49,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultWithPackage() throws Exception { + void defaultWithPackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -57,7 +57,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testOnFileWithCommentOnly() throws Exception { + void onFileWithCommentOnly() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -65,7 +65,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileForDiffDirectoryMismatch() throws Exception { + void fileForDiffDirectoryMismatch() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISMATCH), @@ -76,7 +76,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileForDirectoryMismatchAtParent() throws Exception { + void fileForDirectoryMismatchAtParent() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISMATCH), @@ -87,7 +87,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileForDirectoryMismatchAtSubpackage() throws Exception { + void fileForDirectoryMismatchAtSubpackage() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISMATCH), @@ -98,7 +98,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileIgnoreDiffDirectoryMismatch() throws Exception { + void fileIgnoreDiffDirectoryMismatch() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -106,7 +106,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileIgnoreDirectoryMismatchAtParent() throws Exception { + void fileIgnoreDirectoryMismatchAtParent() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -114,7 +114,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileIgnoreDirectoryMismatchAtSubpackage() throws Exception { + void fileIgnoreDirectoryMismatchAtSubpackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -122,7 +122,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoPackage() throws Exception { + void noPackage() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY_MISSING), }; @@ -133,7 +133,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { @SuppressForbidden @Test - public void testEmptyFile() throws Exception { + void emptyFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -141,7 +141,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final PackageDeclarationCheck check = new PackageDeclarationCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -155,7 +155,7 @@ public class PackageDeclarationCheckTest extends AbstractModuleTestSupport { } @Test - public void testBeginTreeClear() throws Exception { + void beginTreeClear() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(PackageDeclarationCheck.class); final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_MISSING), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckTest.java @@ -34,7 +34,7 @@ import java.util.Optional; import java.util.Set; import org.junit.jupiter.api.Test; -public class ParameterAssignmentCheckTest extends AbstractModuleTestSupport { +final class ParameterAssignmentCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,7 +42,7 @@ public class ParameterAssignmentCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "17:15: " + getCheckMessage(MSG_KEY, "field"), "18:15: " + getCheckMessage(MSG_KEY, "field"), @@ -61,13 +61,13 @@ public class ParameterAssignmentCheckTest extends AbstractModuleTestSupport { } @Test - public void testReceiverParameter() throws Exception { + void receiverParameter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParameterAssignmentReceiver.java"), expected); } @Test - public void testEnhancedSwitch() throws Exception { + void enhancedSwitch() throws Exception { final String[] expected = { "14:28: " + getCheckMessage(MSG_KEY, "a"), "21:16: " + getCheckMessage(MSG_KEY, "result"), }; @@ -76,7 +76,7 @@ public class ParameterAssignmentCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final ParameterAssignmentCheck check = new ParameterAssignmentCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -95,9 +95,9 @@ public class ParameterAssignmentCheckTest extends AbstractModuleTestSupport { * * @throws Exception when code tested throws exception */ - @Test @SuppressWarnings("unchecked") - public void testClearState() throws Exception { + @Test + void clearState() throws Exception { final ParameterAssignmentCheck check = new ParameterAssignmentCheck(); final Optional methodDef = TestUtil.findTokenInAstByPredicate( @@ -111,7 +111,7 @@ public class ParameterAssignmentCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - methodDef.get(), + methodDef.orElseThrow(), "parameterNamesStack", parameterNamesStack -> ((Collection>) parameterNamesStack).isEmpty())) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/RequireThisCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/RequireThisCheckTest.java @@ -39,7 +39,7 @@ import java.util.SortedSet; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class RequireThisCheckTest extends AbstractModuleTestSupport { +final class RequireThisCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -47,7 +47,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "20:9: " + getCheckMessage(MSG_VARIABLE, "i", ""), "26:9: " + getCheckMessage(MSG_METHOD, "method1", ""), @@ -73,7 +73,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodsOnly() throws Exception { + void methodsOnly() throws Exception { final String[] expected = { "25:9: " + getCheckMessage(MSG_METHOD, "method1", ""), "124:9: " + getCheckMessage(MSG_METHOD, "instanceMethod", ""), @@ -85,7 +85,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testFieldsOnly() throws Exception { + void fieldsOnly() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_VARIABLE, "i", ""), "39:9: " + getCheckMessage(MSG_VARIABLE, "i", ""), @@ -107,7 +107,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testFieldsInExpressions() throws Exception { + void fieldsInExpressions() throws Exception { final String[] expected = { "18:28: " + getCheckMessage(MSG_VARIABLE, "id", ""), "19:28: " + getCheckMessage(MSG_VARIABLE, "length", ""), @@ -133,13 +133,13 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testGenerics() throws Exception { + void generics() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRequireThis15Extensions.java"), expected); } @Test - public void testGithubIssue41() throws Exception { + void githubIssue41() throws Exception { final String[] expected = { "16:19: " + getCheckMessage(MSG_VARIABLE, "number", ""), "17:16: " + getCheckMessage(MSG_METHOD, "other", ""), @@ -148,7 +148,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final RequireThisCheck check = new RequireThisCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -162,7 +162,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithAnonymousClass() throws Exception { + void withAnonymousClass() throws Exception { final String[] expected = { "29:25: " + getCheckMessage(MSG_METHOD, "doSideEffect", ""), "33:24: " + getCheckMessage(MSG_VARIABLE, "bar", "InputRequireThisAnonymousEmpty."), @@ -172,7 +172,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultSwitch() { + void defaultSwitch() { final RequireThisCheck check = new RequireThisCheck(); final DetailAstImpl ast = new DetailAstImpl(); @@ -185,7 +185,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidateOnlyOverlappingFalse() throws Exception { + void validateOnlyOverlappingFalse() throws Exception { final String[] expected = { "29:9: " + getCheckMessage(MSG_VARIABLE, "field1", ""), "30:9: " + getCheckMessage(MSG_VARIABLE, "fieldFinal1", ""), @@ -238,7 +238,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidateOnlyOverlappingFalseLeaves() throws Exception { + void validateOnlyOverlappingFalseLeaves() throws Exception { final String[] expected = { "26:31: " + getCheckMessage(MSG_METHOD, "id", ""), "36:16: " + getCheckMessage(MSG_VARIABLE, "_a", ""), @@ -248,7 +248,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidateOnlyOverlappingTrue() throws Exception { + void validateOnlyOverlappingTrue() throws Exception { final String[] expected = { "29:9: " + getCheckMessage(MSG_VARIABLE, "field1", ""), "52:9: " + getCheckMessage(MSG_VARIABLE, "field1", ""), @@ -268,32 +268,32 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidateOnlyOverlappingTrue2() throws Exception { + void validateOnlyOverlappingTrue2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisValidateOnlyOverlappingTrue2.java"), expected); } @Test - public void testReceiverParameter() throws Exception { + void receiverParameter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRequireThisReceiver.java"), expected); } @Test - public void testBraceAlone() throws Exception { + void braceAlone() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRequireThisBraceAlone.java"), expected); } @Test - public void testStatic() throws Exception { + void testStatic() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRequireThisStatic.java"), expected); } @Test - public void testMethodReferences() throws Exception { + void methodReferences() throws Exception { final String[] expected = { "24:9: " + getCheckMessage(MSG_VARIABLE, "tags", ""), }; @@ -301,7 +301,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowLocalVars() throws Exception { + void allowLocalVars() throws Exception { final String[] expected = { "18:9: " + getCheckMessage(MSG_VARIABLE, "s1", ""), "26:9: " + getCheckMessage(MSG_VARIABLE, "s1", ""), @@ -314,7 +314,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowLambdaParameters() throws Exception { + void allowLambdaParameters() throws Exception { final String[] expected = { "24:9: " + getCheckMessage(MSG_VARIABLE, "s1", ""), "46:21: " + getCheckMessage(MSG_VARIABLE, "z", ""), @@ -326,13 +326,13 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResources() throws Exception { + void tryWithResources() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRequireThisTryWithResources.java"), expected); } @Test - public void testTryWithResourcesOnlyOverlappingFalse() throws Exception { + void tryWithResourcesOnlyOverlappingFalse() throws Exception { final String[] expected = { "44:23: " + getCheckMessage(MSG_VARIABLE, "fldCharset", ""), "57:13: " + getCheckMessage(MSG_VARIABLE, "fldCharset", ""), @@ -350,7 +350,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testCatchVariables() throws Exception { + void catchVariables() throws Exception { final String[] expected = { "38:21: " + getCheckMessage(MSG_VARIABLE, "ex", ""), }; @@ -358,19 +358,19 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnumConstant() throws Exception { + void enumConstant() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRequireThisEnumConstant.java"), expected); } @Test - public void testAnnotationInterface() throws Exception { + void annotationInterface() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRequireThisAnnotationInterface.java"), expected); } @Test - public void testFor() throws Exception { + void testFor() throws Exception { final String[] expected = { "22:13: " + getCheckMessage(MSG_VARIABLE, "bottom", ""), "30:34: " + getCheckMessage(MSG_VARIABLE, "name", ""), @@ -379,7 +379,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalInstanceVariable() throws Exception { + void finalInstanceVariable() throws Exception { final String[] expected = { "18:9: " + getCheckMessage(MSG_VARIABLE, "y", ""), "19:9: " + getCheckMessage(MSG_VARIABLE, "z", ""), @@ -388,13 +388,13 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRequireThisCaseGroup.java"), expected); } @Test - public void testExtendedMethod() throws Exception { + void extendedMethod() throws Exception { final String[] expected = { "31:9: " + getCheckMessage(MSG_VARIABLE, "EXPR", ""), }; @@ -402,7 +402,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordsAndCompactCtors() throws Exception { + void recordsAndCompactCtors() throws Exception { final String[] expected = { "18:13: " + getCheckMessage(MSG_METHOD, "method1", ""), "19:13: " + getCheckMessage(MSG_METHOD, "method2", ""), @@ -418,14 +418,14 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordCompactCtors() throws Exception { + void recordCompactCtors() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputRequireThisRecordCompactCtors.java"), expected); } @Test - public void testRecordsAsTopLevel() throws Exception { + void recordsAsTopLevel() throws Exception { final String[] expected = { "17:9: " + getCheckMessage(MSG_METHOD, "method1", ""), "18:9: " + getCheckMessage(MSG_METHOD, "method2", ""), @@ -440,7 +440,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordsDefault() throws Exception { + void recordsDefault() throws Exception { final String[] expected = { "26:9: " + getCheckMessage(MSG_VARIABLE, "x", ""), }; @@ -449,14 +449,14 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordsWithCheckFields() throws Exception { + void recordsWithCheckFields() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputRequireThisRecordsWithCheckFields.java"), expected); } @Test - public void testRecordsWithCheckFieldsOverlap() throws Exception { + void recordsWithCheckFieldsOverlap() throws Exception { final String[] expected = { "20:20: " + getCheckMessage(MSG_VARIABLE, "a", ""), "39:20: " + getCheckMessage(MSG_VARIABLE, "a", ""), @@ -467,7 +467,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { } @Test - public void testLocalClassesInsideLambdas() throws Exception { + void localClassesInsideLambdas() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRequireThisLocalClassesInsideLambdas.java"), expected); @@ -480,7 +480,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws an exception. */ @Test - public void testUnusedMethodCatch() throws Exception { + void unusedMethodCatch() throws Exception { final DetailAstImpl ident = new DetailAstImpl(); ident.setText("testName"); @@ -503,7 +503,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws an exception. */ @Test - public void testUnusedMethodFor() throws Exception { + void unusedMethodFor() throws Exception { final DetailAstImpl ident = new DetailAstImpl(); ident.setText("testName"); @@ -524,7 +524,7 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws exception */ @Test - public void testClearState() throws Exception { + void clearState() throws Exception { final RequireThisCheck check = new RequireThisCheck(); final DetailAST root = JavaParser.parseFile( @@ -536,7 +536,10 @@ public class RequireThisCheckTest extends AbstractModuleTestSupport { assertWithMessage("State is not cleared on beginTree") .that( TestUtil.isStatefulFieldClearedDuringBeginTree( - check, classDef.get(), "current", current -> ((Collection) current).isEmpty())) + check, + classDef.orElseThrow(), + "current", + current -> ((Collection) current).isEmpty())) .isTrue(); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckTest.java @@ -37,7 +37,7 @@ import java.util.Optional; import java.util.Set; import org.junit.jupiter.api.Test; -public class ReturnCountCheckTest extends AbstractModuleTestSupport { +final class ReturnCountCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -45,7 +45,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "28:5: " + getCheckMessage(MSG_KEY_VOID, 7, 1), "40:5: " + getCheckMessage(MSG_KEY_VOID, 2, 1), @@ -56,7 +56,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testFormat() throws Exception { + void format() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY, 7, 2), "28:5: " + getCheckMessage(MSG_KEY_VOID, 7, 1), @@ -68,7 +68,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodsAndLambdas() throws Exception { + void methodsAndLambdas() throws Exception { final String[] expected = { "25:55: " + getCheckMessage(MSG_KEY, 2, 1), "37:49: " + getCheckMessage(MSG_KEY, 2, 1), @@ -80,7 +80,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdasOnly() throws Exception { + void lambdasOnly() throws Exception { final String[] expected = { "43:42: " + getCheckMessage(MSG_KEY, 3, 2), }; @@ -88,7 +88,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodsOnly() throws Exception { + void methodsOnly() throws Exception { final String[] expected = { "35:5: " + getCheckMessage(MSG_KEY, 3, 2), "42:5: " + getCheckMessage(MSG_KEY, 4, 2), @@ -99,13 +99,13 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithReturnOnlyAsTokens() throws Exception { + void withReturnOnlyAsTokens() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputReturnCountLambda4.java"), expected); } @Test - public void testImproperToken() { + void improperToken() { final ReturnCountCheck check = new ReturnCountCheck(); final DetailAstImpl classDefAst = new DetailAstImpl(); @@ -127,7 +127,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testMaxForVoid() throws Exception { + void maxForVoid() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY_VOID, 1, 0), "18:5: " + getCheckMessage(MSG_KEY_VOID, 1, 0), @@ -144,9 +144,9 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { * * @throws Exception when code tested throws exception */ - @Test @SuppressWarnings("unchecked") - public void testClearState() throws Exception { + @Test + void clearState() throws Exception { final ReturnCountCheck check = new ReturnCountCheck(); final Optional methodDef = TestUtil.findTokenInAstByPredicate( @@ -160,7 +160,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - methodDef.get(), + methodDef.orElseThrow(), "contextStack", contextStack -> ((Collection>) contextStack).isEmpty())) .isTrue(); @@ -172,7 +172,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { * beneficial. */ @Test - public void testImproperVisitToken() { + void improperVisitToken() { final ReturnCountCheck check = new ReturnCountCheck(); final DetailAstImpl classDefAst = new DetailAstImpl(); classDefAst.setType(TokenTypes.CLASS_DEF); @@ -193,7 +193,7 @@ public class ReturnCountCheckTest extends AbstractModuleTestSupport { * beneficial. */ @Test - public void testImproperLeaveToken() { + void improperLeaveToken() { final ReturnCountCheck check = new ReturnCountCheck(); final DetailAstImpl classDefAst = new DetailAstImpl(); classDefAst.setType(TokenTypes.CLASS_DEF); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanExpressionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanExpressionCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpre import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class SimplifyBooleanExpressionCheckTest extends AbstractModuleTestSupport { +final class SimplifyBooleanExpressionCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class SimplifyBooleanExpressionCheckTest extends AbstractModuleTestSuppor } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "22:18: " + getCheckMessage(MSG_KEY), "43:36: " + getCheckMessage(MSG_KEY), @@ -53,7 +53,7 @@ public class SimplifyBooleanExpressionCheckTest extends AbstractModuleTestSuppor } @Test - public void testTokensNotNull() { + void tokensNotNull() { final SimplifyBooleanExpressionCheck check = new SimplifyBooleanExpressionCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanReturnCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanReturnCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanRetur import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class SimplifyBooleanReturnCheckTest extends AbstractModuleTestSupport { +final class SimplifyBooleanReturnCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class SimplifyBooleanReturnCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "22:9: " + getCheckMessage(MSG_KEY), "35:9: " + getCheckMessage(MSG_KEY), }; @@ -41,7 +41,7 @@ public class SimplifyBooleanReturnCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final SimplifyBooleanReturnCheck check = new SimplifyBooleanReturnCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/StringLiteralEqualityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/StringLiteralEqualityCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualit import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { +final class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "17:18: " + getCheckMessage(MSG_KEY, "=="), "22:20: " + getCheckMessage(MSG_KEY, "=="), @@ -43,7 +43,7 @@ public class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { } @Test - public void testStringLiteralEqualityTextBlocks() throws Exception { + void stringLiteralEqualityTextBlocks() throws Exception { final String[] expected = { "14:34: " + getCheckMessage(MSG_KEY, "=="), "22:21: " + getCheckMessage(MSG_KEY, "=="), @@ -55,7 +55,7 @@ public class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { } @Test - public void testConcatenatedStringLiterals() throws Exception { + void concatenatedStringLiterals() throws Exception { final String[] expected = { "14:15: " + getCheckMessage(MSG_KEY, "=="), "17:24: " + getCheckMessage(MSG_KEY, "=="), @@ -74,7 +74,7 @@ public class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { } @Test - public void testConcatenatedTextBlocks() throws Exception { + void concatenatedTextBlocks() throws Exception { final String[] expected = { "15:15: " + getCheckMessage(MSG_KEY, "=="), "21:23: " + getCheckMessage(MSG_KEY, "=="), @@ -91,7 +91,7 @@ public class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "32:24: " + getCheckMessage(MSG_KEY, "=="), }; @@ -99,7 +99,7 @@ public class StringLiteralEqualityCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensNotNull() { + void tokensNotNull() { final StringLiteralEqualityCheck check = new StringLiteralEqualityCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperCloneCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperCloneCheckTest.java @@ -34,7 +34,7 @@ import java.util.Optional; import java.util.Set; import org.junit.jupiter.api.Test; -public class SuperCloneCheckTest extends AbstractModuleTestSupport { +final class SuperCloneCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,7 +42,7 @@ public class SuperCloneCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "33:19: " + getCheckMessage(MSG_KEY, "clone", "super.clone"), "41:19: " + getCheckMessage(MSG_KEY, "clone", "super.clone"), @@ -52,7 +52,7 @@ public class SuperCloneCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnotherInputFile() throws Exception { + void anotherInputFile() throws Exception { final String[] expected = { "14:17: " + getCheckMessage(MSG_KEY, "clone", "super.clone"), "48:17: " + getCheckMessage(MSG_KEY, "clone", "super.clone"), @@ -61,13 +61,13 @@ public class SuperCloneCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodReference() throws Exception { + void methodReference() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSuperCloneMethodReference.java"), expected); } @Test - public void testTokensNotNull() { + void tokensNotNull() { final SuperCloneCheck check = new SuperCloneCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -86,9 +86,9 @@ public class SuperCloneCheckTest extends AbstractModuleTestSupport { * * @throws Exception when code tested throws exception */ - @Test @SuppressWarnings("unchecked") - public void testClearState() throws Exception { + @Test + void clearState() throws Exception { final AbstractSuperCheck check = new SuperCloneCheck(); final Optional methodDef = TestUtil.findTokenInAstByPredicate( @@ -102,7 +102,7 @@ public class SuperCloneCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - methodDef.get(), + methodDef.orElseThrow(), "methodStack", methodStack -> ((Collection>) methodStack).isEmpty())) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.AbstractSuperCheck.M import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class SuperFinalizeCheckTest extends AbstractModuleTestSupport { +final class SuperFinalizeCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class SuperFinalizeCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "34:17: " + getCheckMessage(MSG_KEY, "finalize", "super.finalize"), "41:17: " + getCheckMessage(MSG_KEY, "finalize", "super.finalize"), @@ -42,7 +42,7 @@ public class SuperFinalizeCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodReference() throws Exception { + void methodReference() throws Exception { final String[] expected = { "23:20: " + getCheckMessage(MSG_KEY, "finalize", "super.finalize"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckTest.java @@ -33,7 +33,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Test fixture for the UnnecessaryParenthesesCheck. */ -public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { +final class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,7 +41,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "18:22: " + getCheckMessage(MSG_ASSIGN), @@ -97,7 +97,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void test15Extensions() throws Exception { + void test15Extensions() throws Exception { final String[] expected = { "28:23: " + getCheckMessage(MSG_EXPR), "28:51: " + getCheckMessage(MSG_LITERAL, "1"), @@ -107,7 +107,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdas() throws Exception { + void lambdas() throws Exception { final String[] expected = { "17:35: " + getCheckMessage(MSG_LAMBDA), "18:35: " + getCheckMessage(MSG_LAMBDA), @@ -122,7 +122,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testReturn() throws Exception { + void testReturn() throws Exception { final String[] expected = { "21:33: " + getCheckMessage(MSG_RETURN), "22:16: " + getCheckMessage(MSG_RETURN), @@ -135,7 +135,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnnecessaryParenthesesSwitchExpression() throws Exception { + void unnecessaryParenthesesSwitchExpression() throws Exception { final String[] expected = { "21:31: " + getCheckMessage(MSG_ASSIGN), "24:13: " + getCheckMessage(MSG_LITERAL, 2), @@ -154,7 +154,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnnecessaryParenthesesTextBlocks() throws Exception { + void unnecessaryParenthesesTextBlocks() throws Exception { final String[] expected = { "19:23: " + getCheckMessage(MSG_STRING, "\"this\""), "19:34: " + getCheckMessage(MSG_STRING, "\"that\""), @@ -170,14 +170,14 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnnecessaryParenthesesPatterns() throws Exception { + void unnecessaryParenthesesPatterns() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputUnnecessaryParenthesesCheckPatterns.java"), expected); } @Test - public void testTokensNotNull() { + void tokensNotNull() { final UnnecessaryParenthesesCheck check = new UnnecessaryParenthesesCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -191,7 +191,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testIfStatement() throws Exception { + void ifStatement() throws Exception { final String[] expected = { "20:20: " + getCheckMessage(MSG_EXPR), @@ -225,7 +225,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testIfStatement2() throws Exception { + void ifStatement2() throws Exception { final String[] expected = { "28:17: " + getCheckMessage(MSG_EXPR), "39:17: " + getCheckMessage(MSG_EXPR), @@ -241,7 +241,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testIdentifier() throws Exception { + void identifier() throws Exception { final String[] expected = { "22:17: " + getCheckMessage(MSG_IDENT, "test"), "31:18: " + getCheckMessage(MSG_ASSIGN), @@ -259,7 +259,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testOperator1() throws Exception { + void operator1() throws Exception { final String[] expected = { "20:17: " + getCheckMessage(MSG_EXPR), "22:17: " + getCheckMessage(MSG_EXPR), @@ -293,7 +293,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testOperator2() throws Exception { + void operator2() throws Exception { final String[] expected = { "66:18: " + getCheckMessage(MSG_EXPR), "67:17: " + getCheckMessage(MSG_EXPR), @@ -311,7 +311,7 @@ public class UnnecessaryParenthesesCheckTest extends AbstractModuleTestSupport { } @Test - public void testOperator3() throws Exception { + void operator3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputUnnecessaryParenthesesOperator3.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest +final class UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest extends AbstractModuleTestSupport { @Override @@ -37,7 +37,7 @@ public class UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "28:2: " + getCheckMessage(MSG_SEMI), @@ -51,7 +51,7 @@ public class UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest } @Test - public void testUnnecessarySemicolonAfterOuterTypeDeclarationRecords() throws Exception { + void unnecessarySemicolonAfterOuterTypeDeclarationRecords() throws Exception { final String[] expected = { "17:2: " + getCheckMessage(MSG_SEMI), "23:2: " + getCheckMessage(MSG_SEMI), @@ -63,7 +63,7 @@ public class UnnecessarySemicolonAfterOuterTypeDeclarationCheckTest } @Test - public void testTokens() { + void tokens() { final UnnecessarySemicolonAfterOuterTypeDeclarationCheck check = new UnnecessarySemicolonAfterOuterTypeDeclarationCheck(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest +final class UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest extends AbstractModuleTestSupport { @Override @@ -37,7 +37,7 @@ public class UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "13:5: " + getCheckMessage(MSG_SEMI), @@ -61,7 +61,7 @@ public class UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest } @Test - public void testUnnecessarySemicolonAfterTypeMemberDeclarationRecords() throws Exception { + void unnecessarySemicolonAfterTypeMemberDeclarationRecords() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_SEMI), @@ -79,7 +79,7 @@ public class UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest } @Test - public void testTokens() { + void tokens() { final UnnecessarySemicolonAfterTypeMemberDeclarationCheck check = new UnnecessarySemicolonAfterTypeMemberDeclarationCheck(); final int[] expected = { @@ -109,7 +109,7 @@ public class UnnecessarySemicolonAfterTypeMemberDeclarationCheckTest } @Test - public void testIsSemicolonWithNullAst() throws Exception { + void isSemicolonWithNullAst() throws Exception { final String[] expected = {"24:32: " + getCheckMessage(MSG_SEMI)}; verifyWithInlineConfigParser( --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInEnumerationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInEnumerationCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; /** Test fixture for the UnnecessarySemicolonInEnumerationCheck. */ -public class UnnecessarySemicolonInEnumerationCheckTest extends AbstractModuleTestSupport { +final class UnnecessarySemicolonInEnumerationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class UnnecessarySemicolonInEnumerationCheckTest extends AbstractModuleTe } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "30:12: " + getCheckMessage(MSG_SEMI), @@ -55,7 +55,7 @@ public class UnnecessarySemicolonInEnumerationCheckTest extends AbstractModuleTe } @Test - public void testTokensNotNull() { + void tokensNotNull() { final UnnecessarySemicolonInEnumerationCheck check = new UnnecessarySemicolonInEnumerationCheck(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInTryWithResourcesCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInTryWithResourcesCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class UnnecessarySemicolonInTryWithResourcesCheckTest extends AbstractModuleTestSupport { +final class UnnecessarySemicolonInTryWithResourcesCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class UnnecessarySemicolonInTryWithResourcesCheckTest extends AbstractMod } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "17:42: " + getCheckMessage(MSG_SEMI), "18:72: " + getCheckMessage(MSG_SEMI), @@ -46,7 +46,7 @@ public class UnnecessarySemicolonInTryWithResourcesCheckTest extends AbstractMod } @Test - public void testNoBraceAfterAllowed() throws Exception { + void noBraceAfterAllowed() throws Exception { final String[] expected = { "16:42: " + getCheckMessage(MSG_SEMI), "19:13: " + getCheckMessage(MSG_SEMI), @@ -58,7 +58,7 @@ public class UnnecessarySemicolonInTryWithResourcesCheckTest extends AbstractMod } @Test - public void testTokensAreCorrect() { + void tokensAreCorrect() { final UnnecessarySemicolonInTryWithResourcesCheck check = new UnnecessarySemicolonInTryWithResourcesCheck(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnusedLocalVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/UnusedLocalVariableCheckTest.java @@ -36,7 +36,7 @@ import java.util.Optional; import java.util.function.Predicate; import org.junit.jupiter.api.Test; -public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { +final class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -44,7 +44,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final UnusedLocalVariableCheck checkObj = new UnusedLocalVariableCheck(); final int[] actual = checkObj.getRequiredTokens(); final int[] expected = { @@ -73,7 +73,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final UnusedLocalVariableCheck typeParameterNameCheckObj = new UnusedLocalVariableCheck(); final int[] actual = typeParameterNameCheckObj.getAcceptableTokens(); final int[] expected = { @@ -102,7 +102,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVariable() throws Exception { + void unusedLocalVariable() throws Exception { final String[] expected = { "27:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "sameName"), "28:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "b"), @@ -122,7 +122,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVar2() throws Exception { + void unusedLocalVar2() throws Exception { final String[] expected = { "17:14: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "i"), "19:14: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "j"), @@ -138,7 +138,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarInAnonInnerClasses() throws Exception { + void unusedLocalVarInAnonInnerClasses() throws Exception { final String[] expected = { "14:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "a"), "15:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "b"), @@ -155,7 +155,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarGenericAnonInnerClasses() throws Exception { + void unusedLocalVarGenericAnonInnerClasses() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "l"), "14:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "obj"), @@ -171,7 +171,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarDepthOfClasses() throws Exception { + void unusedLocalVarDepthOfClasses() throws Exception { final String[] expected = { "28:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "r"), "49:21: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "a"), @@ -182,7 +182,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarNestedClasses() throws Exception { + void unusedLocalVarNestedClasses() throws Exception { final String[] expected = { "21:13: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "V"), "23:13: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "S"), @@ -196,7 +196,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarNestedClasses2() throws Exception { + void unusedLocalVarNestedClasses2() throws Exception { final String[] expected = { "29:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "q"), "30:51: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "obj"), @@ -208,7 +208,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarNestedClasses3() throws Exception { + void unusedLocalVarNestedClasses3() throws Exception { final String[] expected = { "36:17: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "p2"), "54:13: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "o"), @@ -220,7 +220,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarTestWarningSeverity() throws Exception { + void unusedLocalVarTestWarningSeverity() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -228,7 +228,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarEnum() throws Exception { + void unusedLocalVarEnum() throws Exception { final String[] expected = { "22:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "a"), "50:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "a"), @@ -240,7 +240,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarRecords() throws Exception { + void unusedLocalVarRecords() throws Exception { final String[] expected = { "16:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "var1"), "25:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "var1"), @@ -252,7 +252,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVarWithoutPackageStatement() throws Exception { + void unusedLocalVarWithoutPackageStatement() throws Exception { final String[] expected = { "12:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "a"), "24:9: " + getCheckMessage(MSG_UNUSED_LOCAL_VARIABLE, "var2"), @@ -263,14 +263,14 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedLocalVariableTernaryAndExpressions() throws Exception { + void unusedLocalVariableTernaryAndExpressions() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUnusedLocalVariableTernaryAndExpressions.java"), expected); } @Test - public void testClearStateVariables() throws Exception { + void clearStateVariables() throws Exception { final UnusedLocalVariableCheck check = new UnusedLocalVariableCheck(); final Optional methodDef = TestUtil.findTokenInAstByPredicate( @@ -280,7 +280,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { ast -> ast.getType() == TokenTypes.METHOD_DEF); assertWithMessage("Ast should contain METHOD_DEF").that(methodDef.isPresent()).isTrue(); final DetailAST variableDef = - methodDef.get().getLastChild().findFirstToken(TokenTypes.VARIABLE_DEF); + methodDef.orElseThrow().getLastChild().findFirstToken(TokenTypes.VARIABLE_DEF); assertWithMessage("State is not cleared on beginTree") .that( TestUtil.isStatefulFieldClearedDuringBeginTree( @@ -294,7 +294,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testClearStateClasses() throws Exception { + void clearStateClasses() throws Exception { final UnusedLocalVariableCheck check = new UnusedLocalVariableCheck(); final Optional classDef = TestUtil.findTokenInAstByPredicate( @@ -303,7 +303,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { JavaParser.Options.WITHOUT_COMMENTS), ast -> ast.getType() == TokenTypes.CLASS_DEF); assertWithMessage("Ast should contain CLASS_DEF").that(classDef.isPresent()).isTrue(); - final DetailAST classDefToken = classDef.get(); + final DetailAST classDefToken = classDef.orElseThrow(); assertWithMessage("State is not cleared on beginTree") .that( TestUtil.isStatefulFieldClearedDuringBeginTree( @@ -337,7 +337,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testClearStateAnonInnerClass() throws Exception { + void clearStateAnonInnerClass() throws Exception { final UnusedLocalVariableCheck check = new UnusedLocalVariableCheck(); final DetailAST root = JavaParser.parseFile( @@ -351,7 +351,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { assertWithMessage("Ast should contain LITERAL_NEW").that(literalNew.isPresent()).isTrue(); check.beginTree(root); check.visitToken(classDefAst); - check.visitToken(literalNew.get()); + check.visitToken(literalNew.orElseThrow()); check.beginTree(null); final Predicate isClear = anonInnerAstToTypeDesc -> { @@ -370,7 +370,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testClearStatePackageDef() throws Exception { + void clearStatePackageDef() throws Exception { final UnusedLocalVariableCheck check = new UnusedLocalVariableCheck(); final Optional packageDef = TestUtil.findTokenInAstByPredicate( @@ -379,7 +379,7 @@ public class UnusedLocalVariableCheckTest extends AbstractModuleTestSupport { JavaParser.Options.WITHOUT_COMMENTS), ast -> ast.getType() == TokenTypes.PACKAGE_DEF); assertWithMessage("Ast should contain PACKAGE_DEF").that(packageDef.isPresent()).isTrue(); - final DetailAST packageDefToken = packageDef.get(); + final DetailAST packageDefToken = packageDef.orElseThrow(); assertWithMessage("State is not cleared on beginTree") .that( TestUtil.isStatefulFieldClearedDuringBeginTree( --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTestSupport { +final class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testGeneralLogic() throws Exception { + void generalLogic() throws Exception { final String[] expected = { "42:9: " + getCheckMessage(MSG_KEY, "a", 2, 1), "50:9: " + getCheckMessage(MSG_KEY, "temp", 2, 1), @@ -79,7 +79,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testGeneralLogic2() throws Exception { + void generalLogic2() throws Exception { final String[] expected = { "17:9: " + getCheckMessage(MSG_KEY, "first", 5, 1), "29:9: " + getCheckMessage(MSG_KEY, "allInvariants", 2, 1), @@ -89,7 +89,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testIfStatements() throws Exception { + void ifStatements() throws Exception { final String[] expected = { "18:9: " + getCheckMessage(MSG_KEY, "a", 4, 1), "28:9: " + getCheckMessage(MSG_KEY, "a", 2, 1), @@ -105,7 +105,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testDistance() throws Exception { + void distance() throws Exception { final String[] expected = { "83:9: " + getCheckMessage(MSG_KEY, "count", 4, 3), "231:9: " + getCheckMessage(MSG_KEY, "t", 5, 3), @@ -121,7 +121,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testVariableRegExp() throws Exception { + void variableRegExp() throws Exception { final String[] expected = { "50:9: " + getCheckMessage(MSG_KEY, "temp", 2, 1), "56:9: " + getCheckMessage(MSG_KEY, "temp", 2, 1), @@ -154,7 +154,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testValidateBetweenScopesOption() throws Exception { + void validateBetweenScopesOption() throws Exception { final String[] expected = { "42:9: " + getCheckMessage(MSG_KEY, "a", 2, 1), "50:9: " + getCheckMessage(MSG_KEY, "temp", 2, 1), @@ -186,7 +186,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testIgnoreFinalOption() throws Exception { + void ignoreFinalOption() throws Exception { final String[] expected = { "42:9: " + getCheckMessage(MSG_KEY_EXT, "a", 2, 1), "50:9: " + getCheckMessage(MSG_KEY_EXT, "temp", 2, 1), @@ -228,7 +228,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testTokensNotNull() { + void tokensNotNull() { final VariableDeclarationUsageDistanceCheck check = new VariableDeclarationUsageDistanceCheck(); assertWithMessage("Acceptable tokens should not be null") .that(check.getAcceptableTokens()) @@ -242,7 +242,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = { "83:9: " + getCheckMessage(MSG_KEY_EXT, "count", 4, 3), "231:9: " + getCheckMessage(MSG_KEY_EXT, "t", 5, 3), @@ -258,7 +258,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testDefaultConfiguration2() throws Exception { + void defaultConfiguration2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -266,7 +266,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testAnonymousClass() throws Exception { + void anonymousClass() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY_EXT, "prefs", 4, 3), }; @@ -276,7 +276,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testLabels() throws Exception { + void labels() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -284,7 +284,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testVariableDeclarationUsageDistanceSwitchExpressions() throws Exception { + void variableDeclarationUsageDistanceSwitchExpressions() throws Exception { final int maxDistance = 1; final String[] expected = { @@ -303,7 +303,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testVariableDeclarationUsageDistanceSwitchExpressions2() throws Exception { + void variableDeclarationUsageDistanceSwitchExpressions2() throws Exception { final int maxDistance = 1; final String[] expected = { "16:9: " + getCheckMessage(MSG_KEY, "i", 2, maxDistance), @@ -314,7 +314,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testGeneralClass3() throws Exception { + void generalClass3() throws Exception { final String[] expected = { "46:9: " + getCheckMessage(MSG_KEY, "a", 2, 1), }; @@ -324,7 +324,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testGeneralClass4() throws Exception { + void generalClass4() throws Exception { final String[] expected = { "26:9: " + getCheckMessage(MSG_KEY, "z", 3, 1), }; @@ -334,7 +334,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testVariableDeclarationUsageDistanceTryResources() throws Exception { + void variableDeclarationUsageDistanceTryResources() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY, "a", 2, 1), "20:9: " + getCheckMessage(MSG_KEY, "b", 2, 1), @@ -345,14 +345,14 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testVariableDeclarationUsageDistance4() throws Exception { + void variableDeclarationUsageDistance4() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputVariableDeclarationUsageDistance3.java"), expected); } @Test - public void testVariableDeclarationUsageDistanceScope2() throws Exception { + void variableDeclarationUsageDistanceScope2() throws Exception { final String[] expected = { "16:9: " + getCheckMessage(MSG_KEY, "i", 5, 1), }; @@ -362,7 +362,7 @@ public class VariableDeclarationUsageDistanceCheckTest extends AbstractModuleTes } @Test - public void testVariableDeclarationUsageDistance1() throws Exception { + void variableDeclarationUsageDistance1() throws Exception { final String[] expected = { "15:9: " + getCheckMessage(MSG_KEY, "i", 2, 1), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { +final class DesignForExtensionCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final DesignForExtensionCheck checkObj = new DesignForExtensionCheck(); final int[] expected = {TokenTypes.METHOD_DEF}; assertWithMessage("Default required tokens are invalid") @@ -44,7 +44,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "50:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtension", "doh"), "104:9: " + getCheckMessage(MSG_KEY, "anotherNonFinalClass", "someMethod"), @@ -53,7 +53,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final DesignForExtensionCheck obj = new DesignForExtensionCheck(); final int[] expected = {TokenTypes.METHOD_DEF}; assertWithMessage("Default acceptable tokens are invalid") @@ -62,7 +62,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testOverridableMethods() throws Exception { + void overridableMethods() throws Exception { final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY, "A", "foo1"), "38:9: " + getCheckMessage(MSG_KEY, "A", "foo8"), @@ -89,7 +89,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoredAnnotationsOption() throws Exception { + void ignoredAnnotationsOption() throws Exception { final String[] expected = { "39:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtensionIgnoredAnnotations", "foo1"), "149:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtensionIgnoredAnnotations", "foo21"), @@ -102,14 +102,14 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreAnnotationsOptionWithMultipleAnnotations() throws Exception { + void ignoreAnnotationsOptionWithMultipleAnnotations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputDesignForExtensionMultipleAnnotations.java"), expected); } @Test - public void testNativeMethods() throws Exception { + void nativeMethods() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtensionNativeMethods", "foo1"), "32:5: " + getCheckMessage(MSG_KEY, "InputDesignForExtensionNativeMethods", "foo6"), @@ -118,7 +118,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testDesignForExtensionRecords() throws Exception { + void designForExtensionRecords() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -127,7 +127,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testRequiredJavadocPhrase() throws Exception { + void requiredJavadocPhrase() throws Exception { final String className = "InputDesignForExtensionRequiredJavadocPhrase"; final String[] expected = { "41:5: " + getCheckMessage(MSG_KEY, className, "foo5"), @@ -140,7 +140,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testRequiredJavadocPhraseMultiLine() throws Exception { + void requiredJavadocPhraseMultiLine() throws Exception { final String className = "InputDesignForExtensionRequiredJavadocPhraseMultiLine"; final String[] expected = { "23:5: " + getCheckMessage(MSG_KEY, className, "foo2"), @@ -150,7 +150,7 @@ public class DesignForExtensionCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfaceMemberScopeIsPublic() throws Exception { + void interfaceMemberScopeIsPublic() throws Exception { final String[] expected = { "15:9: " + getCheckMessage(MSG_KEY, "Inner", "getProperty"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheckTest.java @@ -32,7 +32,7 @@ import java.io.File; import java.util.Optional; import org.junit.jupiter.api.Test; -public class FinalClassCheckTest extends AbstractModuleTestSupport { +final class FinalClassCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -40,7 +40,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final FinalClassCheck checkObj = new FinalClassCheck(); final int[] expected = { TokenTypes.ANNOTATION_DEF, @@ -58,7 +58,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClass() throws Exception { + void finalClass() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_KEY, "InputFinalClass"), "19:4: " + getCheckMessage(MSG_KEY, "test4"), @@ -72,7 +72,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassWithPrivateCtorAndNestedExtendingSubclass() throws Exception { + void classWithPrivateCtorAndNestedExtendingSubclass() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(MSG_KEY, "ExtendA"), "18:9: " + getCheckMessage(MSG_KEY, "ExtendB"), @@ -85,7 +85,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassWithPrivateCtorAndNestedExtendingSubclassWithoutPackage() throws Exception { + void classWithPrivateCtorAndNestedExtendingSubclassWithoutPackage() throws Exception { final String[] expected = { "11:9: " + getCheckMessage(MSG_KEY, "ExtendA"), "14:5: " + getCheckMessage(MSG_KEY, "C"), @@ -98,7 +98,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassConstructorInRecord() throws Exception { + void finalClassConstructorInRecord() throws Exception { final String[] expected = { "27:9: " + getCheckMessage(MSG_KEY, "F"), @@ -109,7 +109,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testImproperToken() { + void improperToken() { final FinalClassCheck finalClassCheck = new FinalClassCheck(); final DetailAstImpl badAst = new DetailAstImpl(); final int unsupportedTokenByCheck = TokenTypes.COMPILATION_UNIT; @@ -125,7 +125,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final FinalClassCheck obj = new FinalClassCheck(); final int[] expected = { TokenTypes.ANNOTATION_DEF, @@ -143,7 +143,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassInnerAndNestedClasses() throws Exception { + void finalClassInnerAndNestedClasses() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY, "SubClass"), "19:5: " + getCheckMessage(MSG_KEY, "SameName"), @@ -155,7 +155,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassStaticNestedClasses() throws Exception { + void finalClassStaticNestedClasses() throws Exception { final String[] expected = { "14:17: " + getCheckMessage(MSG_KEY, "C"), @@ -171,7 +171,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassEnum() throws Exception { + void finalClassEnum() throws Exception { final String[] expected = { "35:5: " + getCheckMessage(MSG_KEY, "DerivedClass"), }; @@ -179,7 +179,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassAnnotation() throws Exception { + void finalClassAnnotation() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY, "DerivedClass"), }; @@ -187,7 +187,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassInterface() throws Exception { + void finalClassInterface() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY, "DerivedClass"), }; @@ -195,7 +195,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassAnonymousInnerClass() throws Exception { + void finalClassAnonymousInnerClass() throws Exception { final String[] expected = { "11:9: " + getCheckMessage(MSG_KEY, "b"), "27:9: " + getCheckMessage(MSG_KEY, "m"), @@ -210,7 +210,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassNestedInInterface() throws Exception { + void finalClassNestedInInterface() throws Exception { final String[] expected = { "24:5: " + getCheckMessage(MSG_KEY, "b"), "28:13: " + getCheckMessage(MSG_KEY, "m"), @@ -221,7 +221,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassNestedInEnum() throws Exception { + void finalClassNestedInEnum() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(MSG_KEY, "j"), "27:9: " + getCheckMessage(MSG_KEY, "n"), }; @@ -230,7 +230,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalClassNestedInRecord() throws Exception { + void finalClassNestedInRecord() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(MSG_KEY, "c"), "31:13: " + getCheckMessage(MSG_KEY, "j"), @@ -247,7 +247,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws exception */ @Test - public void testClearState() throws Exception { + void clearState() throws Exception { final FinalClassCheck check = new FinalClassCheck(); final DetailAST root = JavaParser.parseFile( @@ -260,14 +260,14 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - packageDef.get(), + packageDef.orElseThrow(), "packageName", packageName -> ((String) packageName).isEmpty())) .isTrue(); } @Test - public void testPrivateClassWithDefaultCtor() throws Exception { + void privateClassWithDefaultCtor() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, "Some2"), "19:1: " + getCheckMessage(MSG_KEY, "Some"), @@ -286,7 +286,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testPrivateClassWithDefaultCtor2() throws Exception { + void privateClassWithDefaultCtor2() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY, "PrivateClass"), "34:5: " + getCheckMessage(MSG_KEY, "Check"), @@ -297,7 +297,7 @@ public class FinalClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testPrivateClassWithDefaultCtor3() throws Exception { + void privateClassWithDefaultCtor3() throws Exception { final String[] expected = { "26:5: " + getCheckMessage(MSG_KEY, "MyClass"), "30:5: " + getCheckMessage(MSG_KEY, "Check2"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class HideUtilityClassConstructorCheckTest extends AbstractModuleTestSupport { +final class HideUtilityClassConstructorCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class HideUtilityClassConstructorCheckTest extends AbstractModuleTestSupp } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final HideUtilityClassConstructorCheck checkObj = new HideUtilityClassConstructorCheck(); final int[] expected = {TokenTypes.CLASS_DEF}; assertWithMessage("Default required tokens are invalid") @@ -44,7 +44,7 @@ public class HideUtilityClassConstructorCheckTest extends AbstractModuleTestSupp } @Test - public void testUtilClass() throws Exception { + void utilClass() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), }; @@ -53,7 +53,7 @@ public class HideUtilityClassConstructorCheckTest extends AbstractModuleTestSupp } @Test - public void testUtilClassPublicCtor() throws Exception { + void utilClassPublicCtor() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY), }; @@ -61,69 +61,69 @@ public class HideUtilityClassConstructorCheckTest extends AbstractModuleTestSupp } @Test - public void testUtilClassPrivateCtor() throws Exception { + void utilClassPrivateCtor() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputHideUtilityClassConstructorPrivate.java"), expected); } /** Non-static methods - always OK. */ @Test - public void testNonUtilClass() throws Exception { + void nonUtilClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorDesignForExtension.java"), expected); } @Test - public void testDerivedNonUtilClass() throws Exception { + void derivedNonUtilClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorNonUtilityClass.java"), expected); } @Test - public void testOnlyNonStaticFieldNonUtilClass() throws Exception { + void onlyNonStaticFieldNonUtilClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorRegression.java"), expected); } @Test - public void testEmptyAbstractClass() throws Exception { + void emptyAbstractClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorAbstractSerializable.java"), expected); } @Test - public void testEmptyAbstractClass2() throws Exception { + void emptyAbstractClass2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorAbstract.java"), expected); } @Test - public void testEmptyClassWithOnlyPrivateFields() throws Exception { + void emptyClassWithOnlyPrivateFields() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorSerializable.java"), expected); } @Test - public void testClassWithStaticInnerClass() throws Exception { + void classWithStaticInnerClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputHideUtilityClassConstructorSerializableInnerStatic.java"), expected); } @Test - public void testProtectedCtor() throws Exception { + void protectedCtor() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputHideUtilityClassConstructor.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final HideUtilityClassConstructorCheck obj = new HideUtilityClassConstructorCheck(); final int[] expected = {TokenTypes.CLASS_DEF}; assertWithMessage("Default acceptable tokens are invalid") --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import org.junit.jupiter.api.Test; -public class InnerTypeLastCheckTest extends AbstractModuleTestSupport { +final class InnerTypeLastCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class InnerTypeLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final InnerTypeLastCheck checkObj = new InnerTypeLastCheck(); final int[] expected = { TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.RECORD_DEF, @@ -48,7 +48,7 @@ public class InnerTypeLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testMembersBeforeInner() throws Exception { + void membersBeforeInner() throws Exception { final String[] expected = { "50:9: " + getCheckMessage(MSG_KEY), "71:9: " + getCheckMessage(MSG_KEY), @@ -60,19 +60,19 @@ public class InnerTypeLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testIfRootClassChecked() throws Exception { + void ifRootClassChecked() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputInnerTypeLastClassRootClass.java"), expected); } @Test - public void testIfRootClassChecked2() throws Exception { + void ifRootClassChecked2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputInnerTypeLastClassRootClass2.java"), expected); } @Test - public void testIfRootClassChecked3() throws Exception { + void ifRootClassChecked3() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(InnerTypeLastCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verify( @@ -86,7 +86,7 @@ public class InnerTypeLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testInnerTypeBeforeCtor() throws Exception { + void innerTypeBeforeCtor() throws Exception { final String[] expected = { "13:5: " + getCheckMessage(MSG_KEY), "22:5: " + getCheckMessage(MSG_KEY), @@ -96,7 +96,7 @@ public class InnerTypeLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testInnerTypeLastRecords() throws Exception { + void innerTypeLastRecords() throws Exception { final String[] expected = { "17:9: " + getCheckMessage(MSG_KEY), @@ -111,7 +111,7 @@ public class InnerTypeLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testInnerTypeLastCstyleArray() throws Exception { + void innerTypeLastCstyleArray() throws Exception { final String[] expected = { "11:5: " + getCheckMessage(MSG_KEY), "12:5: " + getCheckMessage(MSG_KEY), @@ -122,7 +122,7 @@ public class InnerTypeLastCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final InnerTypeLastCheck obj = new InnerTypeLastCheck(); final int[] expected = { TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.RECORD_DEF, --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InterfaceIsTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/InterfaceIsTypeCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class InterfaceIsTypeCheckTest extends AbstractModuleTestSupport { +final class InterfaceIsTypeCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class InterfaceIsTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "28:5: " + getCheckMessage(MSG_KEY), }; @@ -42,7 +42,7 @@ public class InterfaceIsTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowMarker() throws Exception { + void allowMarker() throws Exception { final String[] expected = { "23:5: " + getCheckMessage(MSG_KEY), "28:5: " + getCheckMessage(MSG_KEY), }; @@ -50,7 +50,7 @@ public class InterfaceIsTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final InterfaceIsTypeCheck obj = new InterfaceIsTypeCheck(); final int[] expected = {TokenTypes.INTERFACE_DEF}; assertWithMessage("Default acceptable tokens are invalid") @@ -59,7 +59,7 @@ public class InterfaceIsTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final InterfaceIsTypeCheck obj = new InterfaceIsTypeCheck(); final int[] expected = {TokenTypes.INTERFACE_DEF}; assertWithMessage("Default required tokens are invalid") --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckTest.java @@ -34,7 +34,7 @@ import java.util.List; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class MutableExceptionCheckTest extends AbstractModuleTestSupport { +final class MutableExceptionCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,7 +42,7 @@ public class MutableExceptionCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassExtendsGenericClass() throws Exception { + void classExtendsGenericClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -51,7 +51,7 @@ public class MutableExceptionCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY, "errorCode"), @@ -63,7 +63,7 @@ public class MutableExceptionCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultipleInputs() throws Exception { + void multipleInputs() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(MutableExceptionCheck.class); final String filePath1 = getPath("InputMutableException2.java"); final String filePath2 = getPath("InputMutableExceptionMultipleInputs.java"); @@ -87,7 +87,7 @@ public class MutableExceptionCheckTest extends AbstractModuleTestSupport { } @Test - public void testFormat() throws Exception { + void format() throws Exception { final String[] expected = { "42:13: " + getCheckMessage(MSG_KEY, "errorCode"), }; @@ -96,7 +96,7 @@ public class MutableExceptionCheckTest extends AbstractModuleTestSupport { } @Test - public void testNested() throws Exception { + void nested() throws Exception { final String[] expected = { "15:9: " + getCheckMessage(MSG_KEY, "code"), @@ -106,7 +106,7 @@ public class MutableExceptionCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MutableExceptionCheck obj = new MutableExceptionCheck(); final int[] expected = {TokenTypes.CLASS_DEF, TokenTypes.VARIABLE_DEF}; assertWithMessage("Default acceptable tokens are invalid") @@ -115,7 +115,7 @@ public class MutableExceptionCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MutableExceptionCheck obj = new MutableExceptionCheck(); final int[] expected = {TokenTypes.CLASS_DEF, TokenTypes.VARIABLE_DEF}; assertWithMessage("Default required tokens are invalid") @@ -124,7 +124,7 @@ public class MutableExceptionCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongTokenType() { + void wrongTokenType() { final MutableExceptionCheck obj = new MutableExceptionCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(new CommonToken(TokenTypes.INTERFACE_DEF, "interface")); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckTest.java @@ -32,7 +32,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { +final class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -40,7 +40,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final OneTopLevelClassCheck checkObj = new OneTopLevelClassCheck(); final int[] expected = {TokenTypes.COMPILATION_UNIT}; assertWithMessage("Required tokens are invalid.") @@ -49,7 +49,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testClearState() throws Exception { + void clearState() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(OneTopLevelClassCheck.class); final String firstInputFilePath = getPath("InputOneTopLevelClassDeclarationOrder.java"); final String secondInputFilePath = getPath("InputOneTopLevelClassInterface2.java"); @@ -75,7 +75,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testAcceptableTokens() { + void acceptableTokens() { final OneTopLevelClassCheck check = new OneTopLevelClassCheck(); final int[] expected = {TokenTypes.COMPILATION_UNIT}; assertWithMessage("Default required tokens are invalid") @@ -84,31 +84,31 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithOneTopLevelClass() throws Exception { + void fileWithOneTopLevelClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOneTopLevelClass.java"), expected); } @Test - public void testFileWithOneTopLevelInterface() throws Exception { + void fileWithOneTopLevelInterface() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOneTopLevelClassInterface.java"), expected); } @Test - public void testFileWithOneTopLevelEnum() throws Exception { + void fileWithOneTopLevelEnum() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOneTopLevelClassEnum.java"), expected); } @Test - public void testFileWithOneTopLevelAnnotation() throws Exception { + void fileWithOneTopLevelAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOneTopLevelClassAnnotation.java"), expected); } @Test - public void testFileWithNoPublicTopLevelClass() throws Exception { + void fileWithNoPublicTopLevelClass() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassNoPublic2"), }; @@ -116,7 +116,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithThreeTopLevelInterface() throws Exception { + void fileWithThreeTopLevelInterface() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassInterface3inner1"), "17:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassInterface3inner2"), @@ -125,7 +125,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithThreeTopLevelEnum() throws Exception { + void fileWithThreeTopLevelEnum() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassEnum2inner1"), "17:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassEnum2inner2"), @@ -134,7 +134,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithThreeTopLevelAnnotation() throws Exception { + void fileWithThreeTopLevelAnnotation() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassAnnotation2A"), "20:1: " + getCheckMessage(MSG_KEY, "InputOneTopLevelClassAnnotation2B"), @@ -143,7 +143,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithFewTopLevelClasses() throws Exception { + void fileWithFewTopLevelClasses() throws Exception { final String[] expected = { "31:1: " + getCheckMessage(MSG_KEY, "NoSuperClone"), "35:1: " + getCheckMessage(MSG_KEY, "InnerClone"), @@ -157,7 +157,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithSecondEnumTopLevelClass() throws Exception { + void fileWithSecondEnumTopLevelClass() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_KEY, "InputDeclarationOrderEnum2"), "26:1: " + getCheckMessage(MSG_KEY, "InputDeclarationOrderAnnotation2"), @@ -166,13 +166,13 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageInfoWithNoTypesDeclared() throws Exception { + void packageInfoWithNoTypesDeclared() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getNonCompilablePath("package-info.java"), expected); } @Test - public void testFileWithMultipleSameLine() throws Exception { + void fileWithMultipleSameLine() throws Exception { final String[] expected = { "9:47: " + getCheckMessage(MSG_KEY, "ViolatingSecondType"), }; @@ -180,7 +180,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileWithIndentation() throws Exception { + void fileWithIndentation() throws Exception { final String[] expected = { "13:2: " + getCheckMessage(MSG_KEY, "ViolatingIndentedClass1"), "17:5: " + getCheckMessage(MSG_KEY, "ViolatingIndentedClass2"), @@ -190,7 +190,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testOneTopLevelClassRecords() throws Exception { + void oneTopLevelClassRecords() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY, "TestRecord1"), "17:1: " + getCheckMessage(MSG_KEY, "TestRecord2"), @@ -200,7 +200,7 @@ public class OneTopLevelClassCheckTest extends AbstractModuleTestSupport { } @Test - public void testOneTopLevelClassEmpty() throws Exception { + void oneTopLevelClassEmpty() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getNonCompilablePath("InputOneTopLevelClassEmpty.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class ThrowsCountCheckTest extends AbstractModuleTestSupport { +final class ThrowsCountCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class ThrowsCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "25:20: " + getCheckMessage(MSG_KEY, 5, 4), @@ -49,7 +49,7 @@ public class ThrowsCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testMax() throws Exception { + void max() throws Exception { final String[] expected = { "35:20: " + getCheckMessage(MSG_KEY, 6, 5), @@ -59,7 +59,7 @@ public class ThrowsCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final ThrowsCountCheck obj = new ThrowsCountCheck(); final int[] expected = {TokenTypes.LITERAL_THROWS}; assertWithMessage("Default acceptable tokens are invalid") @@ -68,7 +68,7 @@ public class ThrowsCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final ThrowsCountCheck obj = new ThrowsCountCheck(); final int[] expected = {TokenTypes.LITERAL_THROWS}; assertWithMessage("Default required tokens are invalid") @@ -77,7 +77,7 @@ public class ThrowsCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongTokenType() { + void wrongTokenType() { final ThrowsCountCheck obj = new ThrowsCountCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(new CommonToken(TokenTypes.CLASS_DEF, "class")); @@ -92,7 +92,7 @@ public class ThrowsCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotIgnorePrivateMethod() throws Exception { + void notIgnorePrivateMethod() throws Exception { final String[] expected = { "25:20: " + getCheckMessage(MSG_KEY, 5, 4), "30:20: " + getCheckMessage(MSG_KEY, 5, 4), @@ -104,7 +104,7 @@ public class ThrowsCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodWithAnnotation() throws Exception { + void methodWithAnnotation() throws Exception { final String[] expected = { "26:26: " + getCheckMessage(MSG_KEY, 5, 4), }; @@ -112,7 +112,7 @@ public class ThrowsCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testOverriding() throws Exception { + void overriding() throws Exception { final String[] expected = { "17:20: " + getCheckMessage(MSG_KEY, 1, 0), "21:20: " + getCheckMessage(MSG_KEY, 1, 0), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckTest.java @@ -33,7 +33,7 @@ import java.io.File; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { +final class VisibilityModifierCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,7 +41,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final VisibilityModifierCheck checkObj = new VisibilityModifierCheck(); final int[] expected = { TokenTypes.VARIABLE_DEF, TokenTypes.IMPORT, @@ -52,7 +52,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testInner() throws Exception { + void inner() throws Exception { final String[] expected = { "47:24: " + getCheckMessage(MSG_KEY, "rData"), "50:27: " + getCheckMessage(MSG_KEY, "protectedVariable"), @@ -66,7 +66,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreAccess() throws Exception { + void ignoreAccess() throws Exception { final String[] expected = { "34:20: " + getCheckMessage(MSG_KEY, "fData"), "94:20: " + getCheckMessage(MSG_KEY, "someValue"), @@ -75,7 +75,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testSimple() throws Exception { + void simple() throws Exception { final String[] expected = { "49:19: " + getCheckMessage(MSG_KEY, "mNumCreated2"), "59:23: " + getCheckMessage(MSG_KEY, "sTest1"), @@ -88,7 +88,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrictJavadoc() throws Exception { + void strictJavadoc() throws Exception { final String[] expected = { "49:9: " + getCheckMessage(MSG_KEY, "mLen"), "50:19: " + getCheckMessage(MSG_KEY, "mDeer"), @@ -98,7 +98,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowPublicFinalFieldsInImmutableClass() throws Exception { + void allowPublicFinalFieldsInImmutableClass() throws Exception { final String[] expected = { "33:39: " + getCheckMessage(MSG_KEY, "includes"), "34:39: " + getCheckMessage(MSG_KEY, "excludes"), @@ -112,7 +112,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowPublicFinalFieldsInImmutableClassWithNonCanonicalClasses() throws Exception { + void allowPublicFinalFieldsInImmutableClassWithNonCanonicalClasses() throws Exception { final String[] expected = { "28:39: " + getCheckMessage(MSG_KEY, "includes"), "29:39: " + getCheckMessage(MSG_KEY, "excludes"), @@ -130,7 +130,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testDisAllowPublicFinalAndImmutableFieldsInImmutableClass() throws Exception { + void disAllowPublicFinalAndImmutableFieldsInImmutableClass() throws Exception { final String[] expected = { "32:22: " + getCheckMessage(MSG_KEY, "someIntValue"), "33:39: " + getCheckMessage(MSG_KEY, "includes"), @@ -152,7 +152,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowPublicFinalFieldsInNonFinalClass() throws Exception { + void allowPublicFinalFieldsInNonFinalClass() throws Exception { final String[] expected = { "55:20: " + getCheckMessage(MSG_KEY, "value"), "57:24: " + getCheckMessage(MSG_KEY, "bValue"), @@ -162,7 +162,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testUserSpecifiedImmutableClassesList() throws Exception { + void userSpecifiedImmutableClassesList() throws Exception { final String[] expected = { "30:29: " + getCheckMessage(MSG_KEY, "money"), "47:35: " + getCheckMessage(MSG_KEY, "uri"), @@ -177,7 +177,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testImmutableSpecifiedSameTypeName() throws Exception { + void immutableSpecifiedSameTypeName() throws Exception { final String[] expected = { "23:46: " + getCheckMessage(MSG_KEY, "calendar"), "26:36: " + getCheckMessage(MSG_KEY, "address"), @@ -188,7 +188,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testImmutableValueSameTypeName() throws Exception { + void immutableValueSameTypeName() throws Exception { final String[] expected = { "28:46: " + getCheckMessage(MSG_KEY, "calendar"), "29:59: " + getCheckMessage(MSG_KEY, "calendar2"), @@ -199,21 +199,21 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testImmutableStarImportFalseNegative() throws Exception { + void immutableStarImportFalseNegative() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputVisibilityModifierImmutableStarImport.java"), expected); } @Test - public void testImmutableStarImportNoWarn() throws Exception { + void immutableStarImportNoWarn() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputVisibilityModifierImmutableStarImport2.java"), expected); } @Test - public void testDefaultAnnotationPatterns() throws Exception { + void defaultAnnotationPatterns() throws Exception { final String[] expected = { "61:19: " + getCheckMessage(MSG_KEY, "customAnnotatedPublic"), "64:12: " + getCheckMessage(MSG_KEY, "customAnnotatedPackage"), @@ -226,7 +226,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomAnnotationPatterns() throws Exception { + void customAnnotationPatterns() throws Exception { final String[] expected = { "37:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"), "40:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"), @@ -246,7 +246,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreAnnotationNoPattern() throws Exception { + void ignoreAnnotationNoPattern() throws Exception { final String[] expected = { "36:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"), "39:28: " + getCheckMessage(MSG_KEY, "fqPublicJUnitRule"), @@ -269,7 +269,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreAnnotationSameName() throws Exception { + void ignoreAnnotationSameName() throws Exception { final String[] expected = { "33:28: " + getCheckMessage(MSG_KEY, "publicJUnitRule"), "36:28: " + getCheckMessage(MSG_KEY, "publicJUnitClassRule"), @@ -279,7 +279,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final VisibilityModifierCheck obj = new VisibilityModifierCheck(); final int[] expected = { TokenTypes.VARIABLE_DEF, TokenTypes.IMPORT, @@ -290,7 +290,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testPublicImmutableFieldsNotAllowed() throws Exception { + void publicImmutableFieldsNotAllowed() throws Exception { final String[] expected = { "31:22: " + getCheckMessage(MSG_KEY, "someIntValue"), "32:39: " + getCheckMessage(MSG_KEY, "includes"), @@ -302,7 +302,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testPublicFinalFieldsNotAllowed() throws Exception { + void publicFinalFieldsNotAllowed() throws Exception { final String[] expected = { "31:22: " + getCheckMessage(MSG_KEY, "someIntValue"), "32:39: " + getCheckMessage(MSG_KEY, "includes"), @@ -315,14 +315,14 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testPublicFinalFieldsAllowed() throws Exception { + void publicFinalFieldsAllowed() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputVisibilityModifiersPublicImmutable3.java"), expected); } @Test - public void testPublicFinalFieldInEnum() throws Exception { + void publicFinalFieldInEnum() throws Exception { final String[] expected = { "35:23: " + getCheckMessage(MSG_KEY, "hole"), }; @@ -330,7 +330,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongTokenType() { + void wrongTokenType() { final VisibilityModifierCheck obj = new VisibilityModifierCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(new CommonToken(TokenTypes.CLASS_DEF, "class")); @@ -345,7 +345,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testNullModifiers() throws Exception { + void nullModifiers() throws Exception { final String[] expected = { "32:50: " + getCheckMessage(MSG_KEY, "i"), }; @@ -353,7 +353,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisibilityModifiersOfGenericFields() throws Exception { + void visibilityModifiersOfGenericFields() throws Exception { final String[] expected = { "31:56: " + getCheckMessage(MSG_KEY, "perfSeries"), "32:66: " + getCheckMessage(MSG_KEY, "peopleMap"), @@ -388,7 +388,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { * @throws Exception when exception occurred during execution. */ @Test - public void testIsStarImportNullAst() throws Exception { + void isStarImportNullAst() throws Exception { final DetailAST importAst = JavaParser.parseFile( new File(getPath("InputVisibilityModifierIsStarImport.java")), @@ -402,7 +402,7 @@ public class VisibilityModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageClassName() throws Exception { + void packageClassName() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputVisibilityModifierPackageClassName.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/header/HeaderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/header/HeaderCheckTest.java @@ -35,12 +35,13 @@ import java.io.File; import java.io.IOException; import java.io.LineNumberReader; import java.net.URI; +import java.nio.file.Files; import java.util.Set; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; import org.mockito.MockedConstruction; -public class HeaderCheckTest extends AbstractModuleTestSupport { +final class HeaderCheckTest extends AbstractModuleTestSupport { @TempDir public File temporaryFolder; @@ -50,7 +51,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticHeader() throws Exception { + void staticHeader() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputHeaderjava.header")); checkConfig.addProperty("ignoreLines", ""); @@ -61,7 +62,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoHeader() throws Exception { + void noHeader() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); createChecker(checkConfig); @@ -70,7 +71,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceHeader() throws Exception { + void whitespaceHeader() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("header", "\n \n"); @@ -80,7 +81,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonExistentHeaderFile() throws Exception { + void nonExistentHeaderFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("nonExistent.file")); final CheckstyleException ex = @@ -106,7 +107,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidCharset() throws Exception { + void invalidCharset() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputHeaderjava.header")); checkConfig.addProperty("charset", "XSO-8859-1"); @@ -133,7 +134,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyFilename() { + void emptyFilename() { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", ""); final CheckstyleException ex = @@ -161,7 +162,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNullFilename() { + void nullFilename() { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", null); final CheckstyleException ex = @@ -180,7 +181,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotMatch() throws Exception { + void notMatch() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputHeaderjava.header")); checkConfig.addProperty("ignoreLines", ""); @@ -195,7 +196,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnore() throws Exception { + void ignore() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputHeaderjava.header")); checkConfig.addProperty("ignoreLines", "2"); @@ -204,7 +205,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSetHeaderTwice() { + void setHeaderTwice() { final HeaderCheck check = new HeaderCheck(); check.setHeader("Header"); final IllegalArgumentException ex = @@ -220,7 +221,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIoExceptionWhenLoadingHeaderFile() throws Exception { + void ioExceptionWhenLoadingHeaderFile() throws Exception { final HeaderCheck check = new HeaderCheck(); check.setHeaderFile(new URI("test://bad")); @@ -236,12 +237,12 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCacheHeaderFile() throws Exception { + void cacheHeaderFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputHeaderjava.header")); final DefaultConfiguration checkerConfig = createRootConfig(checkConfig); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); final String[] expected = { @@ -254,12 +255,12 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCacheHeaderWithoutFile() throws Exception { + void cacheHeaderWithoutFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("header", "Test"); final DefaultConfiguration checkerConfig = createRootConfig(checkConfig); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); final String[] expected = { @@ -270,7 +271,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreLinesSorted() throws Exception { + void ignoreLinesSorted() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputHeaderjava.header")); checkConfig.addProperty("ignoreLines", "4,2,3"); @@ -279,7 +280,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testLoadHeaderFileTwice() { + void loadHeaderFileTwice() { final HeaderCheck check = new HeaderCheck(); check.setHeader("Header"); final ReflectiveOperationException ex = @@ -294,21 +295,21 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testHeaderIsValidWithBlankLines() throws Exception { + void headerIsValidWithBlankLines() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputHeaderjava.blank-lines.header")); verify(checkConfig, getPath("InputHeaderBlankLines.java")); } @Test - public void testHeaderIsValidWithBlankLinesBlockStyle() throws Exception { + void headerIsValidWithBlankLinesBlockStyle() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(HeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputHeaderjava.blank-lines2.header")); verify(checkConfig, getPath("InputHeaderBlankLines2.java")); } @Test - public void testExternalResource() throws Exception { + void externalResource() throws Exception { final HeaderCheck check = new HeaderCheck(); final URI uri = CommonUtil.getUriByFilename(getPath("InputHeaderjava.header")); check.setHeaderFile(uri); @@ -320,7 +321,7 @@ public class HeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIoExceptionWhenLoadingHeader() { + void ioExceptionWhenLoadingHeader() { final HeaderCheck check = new HeaderCheck(); try (MockedConstruction mocked = mockConstruction( --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheckTest.java @@ -34,7 +34,7 @@ import java.util.regex.Pattern; import org.junit.jupiter.api.Test; /** Unit test for RegexpHeaderCheck. */ -public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { +final class RegexpHeaderCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -43,7 +43,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { /** Test of setHeader method, of class RegexpHeaderCheck. */ @Test - public void testSetHeaderNull() { + void setHeaderNull() { // check null passes final RegexpHeaderCheck instance = new RegexpHeaderCheck(); // recreate for each test because multiple invocations fail @@ -58,7 +58,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { /** Test of setHeader method, of class RegexpHeaderCheck. */ @Test - public void testSetHeaderEmpty() { + void setHeaderEmpty() { // check null passes final RegexpHeaderCheck instance = new RegexpHeaderCheck(); // check empty string passes @@ -73,7 +73,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { /** Test of setHeader method, of class RegexpHeaderCheck. */ @Test - public void testSetHeaderSimple() { + void setHeaderSimple() { final RegexpHeaderCheck instance = new RegexpHeaderCheck(); // check valid header passes final String header = "abc.*"; @@ -87,7 +87,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { /** Test of setHeader method, of class RegexpHeaderCheck. */ @Test - public void testSetHeader() { + void setHeader() { // check invalid header passes final RegexpHeaderCheck instance = new RegexpHeaderCheck(); try { @@ -107,7 +107,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); createChecker(checkConfig); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -115,7 +115,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyFilename() throws Exception { + void emptyFilename() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", ""); try { @@ -132,7 +132,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeader() throws Exception { + void regexpHeader() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader.header")); final String[] expected = { @@ -142,7 +142,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingRegexpHeader() throws Exception { + void nonMatchingRegexpHeader() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("header", "\\/\\/ Nth Line of Header\\n\\/\\/ Nth Line of Header\\n"); checkConfig.addProperty("multiLines", "1"); @@ -153,7 +153,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderUrl() throws Exception { + void regexpHeaderUrl() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getUriString("InputRegexpHeader.header")); final String[] expected = { @@ -163,7 +163,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInlineRegexpHeader() throws Exception { + void inlineRegexpHeader() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("header", "^/*$\\n// .*\\n// Created: 2002\\n^//.*\\n^//.*"); final String[] expected = { @@ -173,7 +173,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testFailureForMultilineRegexp() throws Exception { + void failureForMultilineRegexp() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("header", "^(.*\\n.*)"); try { @@ -191,7 +191,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInlineRegexpHeaderConsecutiveNewlines() throws Exception { + void inlineRegexpHeaderConsecutiveNewlines() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("header", "^/*$\\n// .*\\n\\n// Created: 2017\\n^//.*"); final String[] expected = { @@ -201,7 +201,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInlineRegexpHeaderConsecutiveNewlinesThroughConfigFile() throws Exception { + void inlineRegexpHeaderConsecutiveNewlinesThroughConfigFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getUriString("InputRegexpHeaderNewLines.header")); final String[] expected = { @@ -211,7 +211,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderIgnore() throws Exception { + void regexpHeaderIgnore() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader1.header")); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -219,7 +219,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderMulti1() throws Exception { + void regexpHeaderMulti1() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader2.header")); checkConfig.addProperty("multiLines", "3, 6"); @@ -228,7 +228,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderMulti2() throws Exception { + void regexpHeaderMulti2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader2.header")); checkConfig.addProperty("multiLines", "3, 6"); @@ -237,7 +237,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderMulti3() throws Exception { + void regexpHeaderMulti3() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader2.header")); checkConfig.addProperty("multiLines", "3, 7"); @@ -246,7 +246,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderMulti4() throws Exception { + void regexpHeaderMulti4() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader2.header")); checkConfig.addProperty("multiLines", "3, 5, 6, 7"); @@ -255,7 +255,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderMulti5() throws Exception { + void regexpHeaderMulti5() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader2.header")); checkConfig.addProperty("multiLines", "3"); @@ -266,7 +266,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderMulti6() throws Exception { + void regexpHeaderMulti6() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader2_4.header")); checkConfig.addProperty("multiLines", "8974382"); @@ -275,7 +275,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderSmallHeader() throws Exception { + void regexpHeaderSmallHeader() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader2.header")); checkConfig.addProperty("multiLines", "3, 6"); @@ -284,7 +284,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyMultiline() throws Exception { + void emptyMultiline() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader2.header")); checkConfig.addProperty("multiLines", ""); @@ -295,7 +295,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegexpHeaderMulti52() throws Exception { + void regexpHeaderMulti52() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader3.header")); final String[] expected = { @@ -305,7 +305,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreLinesSorted() throws Exception { + void ignoreLinesSorted() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader5.header")); checkConfig.addProperty("multiLines", "7,5,3"); @@ -314,7 +314,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testHeaderWithInvalidRegexp() throws Exception { + void headerWithInvalidRegexp() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader.invalid.header")); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -330,7 +330,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoWarningIfSingleLinedLeft() throws Exception { + void noWarningIfSingleLinedLeft() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader4.header")); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -338,7 +338,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoHeaderMissingErrorInCaseHeaderSizeEqualToFileSize() throws Exception { + void noHeaderMissingErrorInCaseHeaderSizeEqualToFileSize() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader3.header")); checkConfig.addProperty("multiLines", "1"); @@ -349,7 +349,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCharsetProperty1() throws Exception { + void charsetProperty1() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader7.header")); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -358,7 +358,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCharsetProperty2() throws Exception { + void charsetProperty2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("charset", "US-ASCII"); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader7.header")); @@ -371,7 +371,7 @@ public class RegexpHeaderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCharsetProperty3() throws Exception { + void charsetProperty3() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpHeaderCheck.class); checkConfig.addProperty("headerFile", getPath("InputRegexpHeader7.header")); checkConfig.addProperty("charset", "US-ASCII"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AccessResultTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AccessResultTest.java @@ -23,14 +23,14 @@ import static com.google.common.truth.Truth.assertWithMessage; import org.junit.jupiter.api.Test; -public class AccessResultTest { +final class AccessResultTest { /* Additional test for jacoco, since valueOf() * is generated by javac and jacoco reports that * valueOf() is uncovered. */ @Test - public void testAccessResultValueOf() { + void accessResultValueOf() { final AccessResult result = AccessResult.valueOf("ALLOWED"); assertWithMessage("Invalid access result").that(result).isEqualTo(AccessResult.ALLOWED); } @@ -40,7 +40,7 @@ public class AccessResultTest { * values() is uncovered. */ @Test - public void testAccessResultValues() { + void accessResultValues() { final AccessResult[] actual = AccessResult.values(); final AccessResult[] expected = { AccessResult.ALLOWED, AccessResult.DISALLOWED, AccessResult.UNKNOWN, --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStarImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStarImportCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class AvoidStarImportCheckTest extends AbstractModuleTestSupport { +final class AvoidStarImportCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class AvoidStarImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultOperation() throws Exception { + void defaultOperation() throws Exception { final String[] expected = { "12:15: " + getCheckMessage(MSG_KEY, "java.io.*"), "13:17: " + getCheckMessage(MSG_KEY, "java.lang.*"), @@ -47,7 +47,7 @@ public class AvoidStarImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludes() throws Exception { + void excludes() throws Exception { // allow the java.io/java.lang,javax.swing.WindowConstants star imports final String[] expected2 = { "31:27: " + getCheckMessage(MSG_KEY, "java.io.File.*"), @@ -56,7 +56,7 @@ public class AvoidStarImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowClassImports() throws Exception { + void allowClassImports() throws Exception { // allow all class star imports final String[] expected2 = { "28:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -67,7 +67,7 @@ public class AvoidStarImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowStaticMemberImports() throws Exception { + void allowStaticMemberImports() throws Exception { // allow all static star imports final String[] expected2 = { "12:15: " + getCheckMessage(MSG_KEY, "java.io.*"), @@ -77,7 +77,7 @@ public class AvoidStarImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AvoidStarImportCheck testCheckObject = new AvoidStarImportCheck(); final int[] actual = testCheckObject.getAcceptableTokens(); final int[] expected = {TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT}; @@ -85,7 +85,7 @@ public class AvoidStarImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AvoidStarImportCheck testCheckObject = new AvoidStarImportCheck(); final int[] actual = testCheckObject.getRequiredTokens(); final int[] expected = {TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT}; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { +final class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AvoidStaticImportCheck checkObj = new AvoidStaticImportCheck(); final int[] expected = {TokenTypes.STATIC_IMPORT}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultOperation() throws Exception { + void defaultOperation() throws Exception { final String[] expected = { "24:27: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), "26:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -67,7 +67,7 @@ public class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testStarExcludes() throws Exception { + void starExcludes() throws Exception { // allow the "java.io.File.*" AND "sun.net.ftpclient.FtpClient.*" star imports final String[] expected = { "26:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -88,7 +88,7 @@ public class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testMemberExcludes() throws Exception { + void memberExcludes() throws Exception { // allow the java.io.File.listRoots and java.lang.Math.E member imports final String[] expected = { "26:42: " + getCheckMessage(MSG_KEY, "javax.swing.WindowConstants.*"), @@ -110,7 +110,7 @@ public class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testBogusMemberExcludes() throws Exception { + void bogusMemberExcludes() throws Exception { // should NOT mask anything final String[] expected = { "26:27: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), @@ -134,7 +134,7 @@ public class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testInnerClassMemberExcludesStar() throws Exception { + void innerClassMemberExcludesStar() throws Exception { // should mask com.puppycrawl.tools.checkstyle.imports.avoidstaticimport. // InputAvoidStaticImportNestedClass.InnerClass.one final String[] expected = { @@ -154,7 +154,7 @@ public class AvoidStaticImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AvoidStaticImportCheck testCheckObject = new AvoidStaticImportCheck(); final int[] actual = testCheckObject.getAcceptableTokens(); final int[] expected = {TokenTypes.STATIC_IMPORT}; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ClassImportRuleTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ClassImportRuleTest.java @@ -23,10 +23,10 @@ import static com.google.common.truth.Truth.assertWithMessage; import org.junit.jupiter.api.Test; -public class ClassImportRuleTest { +final class ClassImportRuleTest { @Test - public void testClassImportRule() { + void classImportRule() { final ClassImportRule rule = new ClassImportRule(true, false, "pkg.a", false); assertWithMessage("Class import rule should not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") @@ -50,7 +50,7 @@ public class ClassImportRuleTest { } @Test - public void testClassImportRuleRegexpSimple() { + void classImportRuleRegexpSimple() { final ClassImportRule rule = new ClassImportRule(true, false, "pkg.a", true); assertWithMessage("Class import rule should not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") @@ -74,7 +74,7 @@ public class ClassImportRuleTest { } @Test - public void testClassImportRuleRegexp() { + void classImportRuleRegexp() { final ClassImportRule rule = new ClassImportRule(true, false, "pk[gx]\\.a", true); assertWithMessage("Class import rule should not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckTest.java @@ -38,7 +38,7 @@ import java.io.File; import java.lang.reflect.Method; import org.junit.jupiter.api.Test; -public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { +final class CustomImportOrderCheckTest extends AbstractModuleTestSupport { /** Shortcuts to make code more compact. */ private static final String STATIC = CustomImportOrderCheck.STATIC_RULE_GROUP; @@ -54,7 +54,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final CustomImportOrderCheck checkObj = new CustomImportOrderCheck(); final int[] expected = { TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT, TokenTypes.PACKAGE_DEF, @@ -65,7 +65,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustom() throws Exception { + void custom() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "17:1: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", "java.io.File.createTempFile"), @@ -90,7 +90,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { * configuration. */ @Test - public void testStaticStandardThird() throws Exception { + void staticStandardThird() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "17:1: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", "java.io.File.createTempFile"), @@ -109,7 +109,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticStandardThirdListCustomRules() throws Exception { + void staticStandardThirdListCustomRules() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "17:1: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", "java.io.File.createTempFile"), @@ -128,7 +128,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticStandardThirdListCustomRulesWhitespace() throws Exception { + void staticStandardThirdListCustomRulesWhitespace() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -136,7 +136,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputCustomImportOrderSingleLineList() throws Exception { + void inputCustomImportOrderSingleLineList() throws Exception { final String[] expected = { "14:112: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.util.Map"), "15:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.google.common.annotations.Beta"), @@ -148,7 +148,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { /** Checks different combinations for same_package group. */ @Test - public void testNonSpecifiedImports() throws Exception { + void nonSpecifiedImports() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "17:1: " + getCheckMessage(MSG_LEX, "java.awt.print.Paper.*", "java.io.File.createTempFile"), @@ -166,7 +166,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testOrderRuleEmpty() throws Exception { + void orderRuleEmpty() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.List"), }; @@ -175,7 +175,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testOrderRuleWithOneGroup() throws Exception { + void orderRuleWithOneGroup() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), "19:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.List"), @@ -207,7 +207,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticSamePackage() throws Exception { + void staticSamePackage() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_LEX, "java.util.*", "java.util.StringTokenizer"), "18:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.*"), @@ -226,7 +226,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithoutLineSeparator() throws Exception { + void withoutLineSeparator() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_LEX, "java.util.*", "java.util.StringTokenizer"), "18:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.*"), @@ -245,7 +245,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithoutLineSeparator2() throws Exception { + void withoutLineSeparator2() throws Exception { final String[] expected = { "16:1: " + getCheckMessage( @@ -261,14 +261,14 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoValid() throws Exception { + void noValid() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputCustomImportOrderNoValid.java"), expected); } @Test - public void testPossibleIndexOutOfBoundsException() throws Exception { + void possibleIndexOutOfBoundsException() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, THIRD, "org.w3c.dom.Node"), }; @@ -278,7 +278,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultPackage2() throws Exception { + void defaultPackage2() throws Exception { final String[] expected = { "19:1: " + getCheckMessage(MSG_LEX, "java.awt.Button.ABORT", "java.io.File.createTempFile"), @@ -301,7 +301,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithoutThirdPartyPackage() throws Exception { + void withoutThirdPartyPackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -309,7 +309,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testThirdPartyAndSpecialImports() throws Exception { + void thirdPartyAndSpecialImports() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_ORDER, THIRD, SPECIAL, "com.google.common.collect.HashMultimap"), @@ -320,7 +320,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCompareImports() throws Exception { + void compareImports() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_LEX, "java.util.Map", "java.util.Map.Entry"), }; @@ -329,7 +329,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testFindBetterPatternMatch() throws Exception { + void findBetterPatternMatch() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_ORDER, THIRD, SPECIAL, "com.google.common.annotations.Beta"), }; @@ -339,7 +339,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testBeginTreeClear() throws Exception { + void beginTreeClear() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(CustomImportOrderCheck.class); checkConfig.addProperty("specialImportsRegExp", "com"); checkConfig.addProperty("separateLineBetweenGroups", "false"); @@ -355,7 +355,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportsContainingJava() throws Exception { + void importsContainingJava() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.google.errorprone.annotations.*"), }; @@ -365,7 +365,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final CustomImportOrderCheck testCheckObject = new CustomImportOrderCheck(); final int[] actual = testCheckObject.getAcceptableTokens(); final int[] expected = { @@ -378,7 +378,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { @Test // UT uses Reflection to avoid removing null-validation from static method, // which is a candidate for utility method in the future - public void testGetFullImportIdent() throws Exception { + void getFullImportIdent() throws Exception { final Class clazz = CustomImportOrderCheck.class; final Object t = clazz.getConstructor().newInstance(); final Method method = clazz.getDeclaredMethod("getFullImportIdent", DetailAST.class); @@ -390,7 +390,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSamePackageDepth2() throws Exception { + void samePackageDepth2() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.*"), "21:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.List"), @@ -410,7 +410,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSamePackageDepth3() throws Exception { + void samePackageDepth3() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.*"), "24:1: " @@ -425,7 +425,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSamePackageDepth4() throws Exception { + void samePackageDepth4() throws Exception { final String[] expected = { "25:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, SAME, "java.util.concurrent.locks.LockSupport"), @@ -436,7 +436,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSamePackageDepthLongerThenActualPackage() throws Exception { + void samePackageDepthLongerThenActualPackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -444,7 +444,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSamePackageDepthNegative() throws Exception { + void samePackageDepthNegative() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -469,7 +469,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSamePackageDepthZero() throws Exception { + void samePackageDepthZero() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -492,7 +492,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnsupportedRule() throws Exception { + void unsupportedRule() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -514,7 +514,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSamePackageDepthNotInt() throws Exception { + void samePackageDepthNotInt() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -536,14 +536,14 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoImports() throws Exception { + void noImports() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputCustomImportOrder_NoImports.java"), expected); } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.awt.Button"), "32:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.io.*"), @@ -553,7 +553,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testRulesWithOverlappingPatterns() throws Exception { + void rulesWithOverlappingPatterns() throws Exception { final String[] expected = { "23:1: " + getCheckMessage( @@ -596,28 +596,28 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiplePatternMatchesSecondPatternIsLonger() throws Exception { + void multiplePatternMatchesSecondPatternIsLonger() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputCustomImportOrder_MultiplePatternMatches.java"), expected); } @Test - public void testMultiplePatternMatchesFirstPatternHasLaterPosition() throws Exception { + void multiplePatternMatchesFirstPatternHasLaterPosition() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputCustomImportOrder_MultiplePatternMatches2.java"), expected); } @Test - public void testMultiplePatternMatchesFirstPatternHasEarlierPosition() throws Exception { + void multiplePatternMatchesFirstPatternHasEarlierPosition() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputCustomImportOrder_MultiplePatternMatches3.java"), expected); } @Test - public void testMultiplePatternMultipleImportFirstPatternHasLaterPosition() throws Exception { + void multiplePatternMultipleImportFirstPatternHasLaterPosition() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "org.junit.Test"), }; @@ -626,7 +626,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoPackage() throws Exception { + void noPackage() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.*"), "19:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.HashMap"), @@ -638,7 +638,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoPackage2() throws Exception { + void noPackage2() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.sun.accessibility.internal.resources.*"), "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Arrays"), @@ -651,7 +651,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoPackage3() throws Exception { + void noPackage3() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.util.Map"), "25:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "org.apache.*"), @@ -662,7 +662,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputCustomImportOrderSingleLine() throws Exception { + void inputCustomImportOrderSingleLine() throws Exception { final String[] expected = { "14:112: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.util.Map"), "15:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "com.google.common.annotations.Beta"), @@ -673,7 +673,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputCustomImportOrderSingleLine2() throws Exception { + void inputCustomImportOrderSingleLine2() throws Exception { final String[] expected = { "14:118: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.util.Map"), }; @@ -682,7 +682,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputCustomImportOrderThirdPartyAndSpecial2() throws Exception { + void inputCustomImportOrderThirdPartyAndSpecial2() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "javax.swing.WindowConstants.*"), "24:1: " + getCheckMessage(MSG_LINE_SEPARATOR, "java.awt.Button"), @@ -701,7 +701,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputCustomImportOrderMultipleViolationsSameLine() throws Exception { + void inputCustomImportOrderMultipleViolationsSameLine() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STATIC, "java.util.Collections.*"), "18:1: " @@ -715,7 +715,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputCustomImportOrderSpanMultipleLines() throws Exception { + void inputCustomImportOrderSpanMultipleLines() throws Exception { final String[] expected = { "30:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.BitSet"), "45:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.HashSet"), @@ -728,7 +728,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputCustomImportOrderEclipseDefaultPositive() throws Exception { + void inputCustomImportOrderEclipseDefaultPositive() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "java.awt.Button"), "23:1: " + getCheckMessage(MSG_NONGROUP_EXPECTED, STD, "java.awt.Dialog"), @@ -744,7 +744,7 @@ public class CustomImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputCustomImportOrderSpecialImportsRegExp() throws Exception { + void inputCustomImportOrderSpecialImportsRegExp() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputCustomImportOrderSpecialImportsRegExp.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/FileImportControlTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/FileImportControlTest.java @@ -24,7 +24,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class FileImportControlTest { +final class FileImportControlTest { private final PkgImportControl root = new PkgImportControl("com.kazgroup.courtlink", false, MismatchStrategy.DISALLOWED); @@ -33,7 +33,7 @@ public class FileImportControlTest { private final FileImportControl fileRegexpNode = new FileImportControl(root, ".*Other.*", true); @BeforeEach - public void setUp() { + void setUp() { root.addChild(fileNode); root.addChild(fileRegexpNode); @@ -43,7 +43,7 @@ public class FileImportControlTest { } @Test - public void testLocateFinest() { + void locateFinest() { assertWithMessage("Unexpected response") .that(root.locateFinest("com.kazgroup.courtlink.domain", "Random")) .isEqualTo(root); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/IllegalImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/IllegalImportCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class IllegalImportCheckTest extends AbstractModuleTestSupport { +final class IllegalImportCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final IllegalImportCheck checkObj = new IllegalImportCheck(); final int[] expected = {TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithSupplied() throws Exception { + void withSupplied() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_KEY, "java.io.*"), "26:1: " + getCheckMessage(MSG_KEY, "java.io.File.listRoots"), @@ -53,13 +53,13 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithDefault() throws Exception { + void withDefault() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("InputIllegalImportDefault2.java"), expected); } @Test - public void testCustomSunPackageWithRegexp() throws Exception { + void customSunPackageWithRegexp() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY, "sun.reflect.*"), }; @@ -67,7 +67,7 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final IllegalImportCheck testCheckObject = new IllegalImportCheck(); final int[] actual = testCheckObject.getAcceptableTokens(); final int[] expected = {TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT}; @@ -76,7 +76,7 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalClasses() throws Exception { + void illegalClasses() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY, "java.sql.Connection"), "18:1: " + getCheckMessage(MSG_KEY, "org.junit.jupiter.api.*"), @@ -86,7 +86,7 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalClassesStarImport() throws Exception { + void illegalClassesStarImport() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_KEY, "java.io.*"), "18:1: " + getCheckMessage(MSG_KEY, "org.junit.jupiter.api.*"), @@ -96,7 +96,7 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalPackagesRegularExpression() throws Exception { + void illegalPackagesRegularExpression() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_KEY, "java.util.List"), "16:1: " + getCheckMessage(MSG_KEY, "java.util.List"), @@ -110,7 +110,7 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalClassesRegularExpression() throws Exception { + void illegalClassesRegularExpression() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_KEY, "java.util.List"), "16:1: " + getCheckMessage(MSG_KEY, "java.util.List"), @@ -120,7 +120,7 @@ public class IllegalImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalPackagesAndClassesRegularExpression() throws Exception { + void illegalPackagesAndClassesRegularExpression() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_KEY, "java.util.List"), "16:1: " + getCheckMessage(MSG_KEY, "java.util.List"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlCheckTest.java @@ -39,7 +39,7 @@ import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -public class ImportControlCheckTest extends AbstractModuleTestSupport { +final class ImportControlCheckTest extends AbstractModuleTestSupport { @TempDir public File temporaryFolder; @@ -49,7 +49,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final ImportControlCheck checkObj = new ImportControlCheck(); final int[] expected = { TokenTypes.PACKAGE_DEF, TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT, @@ -60,14 +60,14 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testOne() throws Exception { + void one() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl.java"), expected); } @Test - public void testTwo() throws Exception { + void two() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "javax.swing.border.*"), @@ -78,31 +78,31 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrong() throws Exception { + void wrong() throws Exception { final String[] expected = {"9:1: " + getCheckMessage(MSG_UNKNOWN_PKG)}; verifyWithInlineConfigParser(getPath("InputImportControl3.java"), expected); } @Test - public void testMissing() throws Exception { + void missing() throws Exception { final String[] expected = {"9:1: " + getCheckMessage(MSG_MISSING_FILE)}; verifyWithInlineConfigParser(getPath("InputImportControl4.java"), expected); } @Test - public void testEmpty() throws Exception { + void empty() throws Exception { final String[] expected = {"9:1: " + getCheckMessage(MSG_MISSING_FILE)}; verifyWithInlineConfigParser(getPath("InputImportControl5.java"), expected); } @Test - public void testNull() throws Exception { + void testNull() throws Exception { final String[] expected = {"9:1: " + getCheckMessage(MSG_MISSING_FILE)}; verifyWithInlineConfigParser(getPath("InputImportControl6.java"), expected); } @Test - public void testUnknown() throws Exception { + void unknown() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportControl7.java"), expected); @@ -118,7 +118,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testBroken() throws Exception { + void broken() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportControl8.java"), expected); @@ -134,14 +134,14 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testOneRegExp() throws Exception { + void oneRegExp() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl9.java"), expected); } @Test - public void testTwoRegExp() throws Exception { + void twoRegExp() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "javax.swing.border.*"), @@ -152,14 +152,14 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotRegExpNoMatch() throws Exception { + void notRegExpNoMatch() throws Exception { verifyWithInlineConfigParser( getPath("InputImportControl11.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testBlacklist() throws Exception { + void blacklist() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.util.stream.Stream"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "java.util.Date"), @@ -171,7 +171,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrategyOnMismatchOne() throws Exception { + void strategyOnMismatchOne() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "javax.swing.border.*"), @@ -182,7 +182,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrategyOnMismatchTwo() throws Exception { + void strategyOnMismatchTwo() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "14:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Button.ABORT"), @@ -192,7 +192,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrategyOnMismatchThree() throws Exception { + void strategyOnMismatchThree() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), }; @@ -201,7 +201,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrategyOnMismatchFour() throws Exception { + void strategyOnMismatchFour() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), "12:1: " + getCheckMessage(MSG_DISALLOWED, "javax.swing.border.*"), @@ -211,7 +211,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithoutRegexAndWithStrategyOnMismatch() throws Exception { + void withoutRegexAndWithStrategyOnMismatch() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -219,28 +219,28 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testPkgRegExpInParent() throws Exception { + void pkgRegExpInParent() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl16.java"), expected); } @Test - public void testPkgRegExpInChild() throws Exception { + void pkgRegExpInChild() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl162.java"), expected); } @Test - public void testPkgRegExpInBoth() throws Exception { + void pkgRegExpInBoth() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl163.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final ImportControlCheck testCheckObject = new ImportControlCheck(); final int[] actual = testCheckObject.getAcceptableTokens(); final int[] expected = { @@ -251,14 +251,14 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testResource() throws Exception { + void resource() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl17.java"), expected); } @Test - public void testResourceUnableToLoad() throws Exception { + void resourceUnableToLoad() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportControl18.java"), expected); @@ -274,14 +274,14 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testUrlInFileProperty() throws Exception { + void urlInFileProperty() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl19.java"), expected); } @Test - public void testUrlInFilePropertyUnableToLoad() throws Exception { + void urlInFilePropertyUnableToLoad() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -298,7 +298,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testCacheWhenFileExternalResourceContentDoesNotChange() throws Exception { + void cacheWhenFileExternalResourceContentDoesNotChange() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(ImportControlCheck.class); checkConfig.addProperty("file", getPath("InputImportControlOneRegExp.xml")); @@ -306,10 +306,11 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { treeWalkerConfig.addChild(checkConfig); final DefaultConfiguration checkerConfig = createRootConfig(treeWalkerConfig); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); - final String filePath = File.createTempFile("empty", ".java", temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "empty", ".java").toFile().getPath(); execute(checkerConfig, filePath); // One more time to use cache. @@ -322,35 +323,35 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testPathRegexMatches() throws Exception { + void pathRegexMatches() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl21.java"), expected); } @Test - public void testPathRegexMatchesPartially() throws Exception { + void pathRegexMatchesPartially() throws Exception { final String[] expected = {"13:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File")}; verifyWithInlineConfigParser(getPath("InputImportControl22.java"), expected); } @Test - public void testPathRegexDoesntMatch() throws Exception { + void pathRegexDoesntMatch() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportControl23.java"), expected); } @Test - public void testPathRegexDoesntMatchPartially() throws Exception { + void pathRegexDoesntMatchPartially() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportControl24.java"), expected); } @Test - public void testDisallowClassOfAllowPackage() throws Exception { + void disallowClassOfAllowPackage() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_DISALLOWED, "java.util.Date"), }; @@ -360,7 +361,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileName() throws Exception { + void fileName() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), }; @@ -369,7 +370,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithRegex() throws Exception { + void withRegex() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.io.File"), }; @@ -378,7 +379,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileNameNoExtension() throws Exception { + void fileNameNoExtension() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), }; @@ -387,7 +388,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testBeginTreeCurrentImportControl() throws Exception { + void beginTreeCurrentImportControl() throws Exception { final String file1 = getPath("InputImportControlBeginTree1.java"); final String file2 = getPath("InputImportControlBeginTree2.java"); final List expectedFirstInput = @@ -399,7 +400,7 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportControlFileName() throws Exception { + void importControlFileName() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_DISALLOWED, "java.awt.Image"), }; @@ -408,14 +409,14 @@ public class ImportControlCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportControlFileName2() throws Exception { + void importControlFileName2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportControlTestRegexpInFile2.java"), expected); } @Test - public void testImportControlTestException() { + void importControlTestException() { final CheckstyleException ex = assertThrows( CheckstyleException.class, --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportControlLoaderTest.java @@ -40,7 +40,7 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.AttributesImpl; -public class ImportControlLoaderTest { +final class ImportControlLoaderTest { private static String getPath(String filename) { return "src/test/resources/com/puppycrawl/tools/" @@ -49,14 +49,14 @@ public class ImportControlLoaderTest { } @Test - public void testLoad() throws CheckstyleException { + void load() throws CheckstyleException { final AbstractImportControl root = ImportControlLoader.load(new File(getPath("InputImportControlLoaderComplete.xml")).toURI()); assertWithMessage("Import root should not be null").that(root).isNotNull(); } @Test - public void testWrongFormatUri() throws Exception { + void wrongFormatUri() throws Exception { try { ImportControlLoader.load(new URI("aaa://" + getPath("InputImportControlLoaderComplete.xml"))); assertWithMessage("exception expected").fail(); @@ -73,7 +73,7 @@ public class ImportControlLoaderTest { } @Test - public void testExtraElementInConfig() throws Exception { + void extraElementInConfig() throws Exception { final AbstractImportControl root = ImportControlLoader.load( new File(getPath("InputImportControlLoaderWithNewElement.xml")).toURI()); @@ -82,7 +82,7 @@ public class ImportControlLoaderTest { @Test // UT uses Reflection to avoid removing null-validation from static method - public void testSafeGetThrowsException() { + void safeGetThrowsException() { final AttributesImpl attr = new AttributesImpl() { @Override @@ -113,7 +113,7 @@ public class ImportControlLoaderTest { // UT uses Reflection to cover IOException from 'loader.parseInputSource(source);' // because this is possible situation (though highly unlikely), which depends on hardware // and is difficult to emulate - public void testLoadThrowsException() { + void loadThrowsException() { final InputSource source = new InputSource(); try { final Class clazz = ImportControlLoader.class; @@ -135,7 +135,7 @@ public class ImportControlLoaderTest { } @Test - public void testInputStreamFailsOnRead() throws Exception { + void inputStreamFailsOnRead() throws Exception { try (InputStream inputStream = mock()) { final int available = doThrow(IOException.class).when(inputStream).available(); final URL url = mock(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckTest.java @@ -38,7 +38,7 @@ import java.util.Optional; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class ImportOrderCheckTest extends AbstractModuleTestSupport { +final class ImportOrderCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -46,14 +46,14 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testVeryPreciseGrouping() throws Exception { + void veryPreciseGrouping() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getNonCompilablePath("InputImportOrder6.java"), expected); } @Test - public void testGetTokens() { + void getTokens() { final ImportOrderCheck checkObj = new ImportOrderCheck(); final int[] expected = {TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT}; assertWithMessage("Default tokens differs from expected") @@ -72,13 +72,13 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testImportOrderOptionValueOf() { + void importOrderOptionValueOf() { final ImportOrderOption option = ImportOrderOption.valueOf("TOP"); assertWithMessage("Invalid valueOf result").that(option).isEqualTo(ImportOrderOption.TOP); } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "25:1: " + getCheckMessage(MSG_ORDERING, "javax.swing.JComponent"), @@ -92,7 +92,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongSequenceInNonStaticImports() throws Exception { + void wrongSequenceInNonStaticImports() throws Exception { final String[] expected = { "19:1: " + getCheckMessage(MSG_ORDERING, "java.util.HashMap"), @@ -103,14 +103,14 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultilineImport() throws Exception { + void multilineImport() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getNonCompilablePath("InputImportOrderMultiline.java"), expected); } @Test - public void testGroups() throws Exception { + void groups() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "29:1: " + getCheckMessage(MSG_ORDERING, "java.io.IOException"), @@ -123,7 +123,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGroupsRegexp() throws Exception { + void groupsRegexp() throws Exception { final String[] expected = { "27:1: " + getCheckMessage(MSG_ORDERING, "java.io.File"), "34:1: " @@ -134,7 +134,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSeparated() throws Exception { + void separated() throws Exception { final String[] expected = { "25:1: " + getCheckMessage(MSG_SEPARATION, "javax.swing.JComponent"), "27:1: " + getCheckMessage(MSG_SEPARATION, "java.io.File"), @@ -145,7 +145,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticImportSeparated() throws Exception { + void staticImportSeparated() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.cos"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.junit.Assert.assertEquals"), @@ -155,7 +155,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoGapBetweenStaticImports() throws Exception { + void noGapBetweenStaticImports() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -163,7 +163,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSortStaticImportsAlphabeticallyFalse() throws Exception { + void sortStaticImportsAlphabeticallyFalse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -171,7 +171,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSortStaticImportsAlphabeticallyTrue() throws Exception { + void sortStaticImportsAlphabeticallyTrue() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_ORDERING, "javax.xml.transform.TransformerFactory.newInstance"), @@ -184,14 +184,14 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCaseInsensitive() throws Exception { + void caseInsensitive() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportOrderCaseInsensitive.java"), expected); } @Test - public void testContainerCaseInsensitive() throws Exception { + void containerCaseInsensitive() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -199,7 +199,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSimilarGroupPattern() throws Exception { + void similarGroupPattern() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -207,7 +207,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -226,7 +226,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testTop() throws Exception { + void top() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.awt.Button"), "28:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.io.IOException"), @@ -239,7 +239,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testAbove() throws Exception { + void above() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Button.ABORT"), "24:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), @@ -252,7 +252,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testInFlow() throws Exception { + void inFlow() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "25:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "javax.swing.JComponent"), @@ -268,7 +268,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnder() throws Exception { + void under() throws Exception { // is default (testDefault) final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), @@ -281,7 +281,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testBottom() throws Exception { + void bottom() throws Exception { final String[] expected = { "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.io.IOException"), "27:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "javax.swing.JComponent"), @@ -296,7 +296,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetGroupNumber() throws Exception { + void getGroupNumber() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -304,7 +304,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testHonorsTokenProperty() throws Exception { + void honorsTokenProperty() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Button.ABORT"), "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), @@ -315,7 +315,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testWildcard() throws Exception { + void wildcard() throws Exception { final String[] expected = { "24:1: " + getCheckMessage(MSG_ORDERING, "javax.crypto.Cipher"), }; @@ -324,7 +324,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testWildcardUnspecified() throws Exception { + void wildcardUnspecified() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "javax.crypto.Cipher"), }; @@ -333,14 +333,14 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoFailureForRedundantImports() throws Exception { + void noFailureForRedundantImports() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputImportOrder_NoFailureForRedundantImports.java"), expected); } @Test - public void testStaticGroupsAlphabeticalOrder() throws Exception { + void staticGroupsAlphabeticalOrder() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.antlr.v4.runtime.*"), "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), @@ -350,7 +350,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsOrder() throws Exception { + void staticGroupsOrder() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.antlr.v4.runtime.*"), "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), @@ -359,7 +359,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsAlphabeticalOrderBottom() throws Exception { + void staticGroupsAlphabeticalOrderBottom() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.PI"), @@ -368,7 +368,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsAlphabeticalOrderBottomNegative() throws Exception { + void staticGroupsAlphabeticalOrderBottomNegative() throws Exception { final String[] expected = { "24:1: " + getCheckMessage(MSG_ORDERING, "java.util.Set"), }; @@ -380,7 +380,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { * Tests that a non-static import after a static import correctly gives an error if order=bottom. */ @Test - public void testStaticGroupsAlphabeticalOrderTopNegative() throws Exception { + void staticGroupsAlphabeticalOrderTopNegative() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.lang.Math.PI"), }; @@ -392,7 +392,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { * Tests that a non-static import before a static import correctly gives an error if order=top. */ @Test - public void testStaticGroupsAlphabeticalOrderBottomNegative2() throws Exception { + void staticGroupsAlphabeticalOrderBottomNegative2() throws Exception { final String[] expected = { "24:1: " + getCheckMessage(MSG_ORDERING, "java.util.Set"), }; @@ -401,7 +401,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsOrderBottom() throws Exception { + void staticGroupsOrderBottom() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.PI"), @@ -410,19 +410,19 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportReception() throws Exception { + void importReception() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportOrderRepetition.java"), expected); } @Test - public void testStaticImportReceptionTop() throws Exception { + void staticImportReceptionTop() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputImportOrderStaticRepetition1.java"), expected); } @Test - public void testStaticImportReception() throws Exception { + void staticImportReception() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_SEPARATION, "org.antlr.v4.runtime.CommonToken.*"), "23:1: " + getCheckMessage(MSG_ORDERING, "java.util.Set"), @@ -431,7 +431,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsOrderAbove() throws Exception { + void staticGroupsOrderAbove() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.PI"), @@ -442,7 +442,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticOnDemandGroupsOrder() throws Exception { + void staticOnDemandGroupsOrder() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.antlr.v4.runtime.*"), "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), @@ -453,7 +453,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticOnDemandGroupsAlphabeticalOrder() throws Exception { + void staticOnDemandGroupsAlphabeticalOrder() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.antlr.v4.runtime.*"), "24:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), @@ -464,7 +464,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticOnDemandGroupsOrderBottom() throws Exception { + void staticOnDemandGroupsOrderBottom() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.*"), @@ -474,7 +474,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticOnDemandGroupsAlphabeticalOrderBottom() throws Exception { + void staticOnDemandGroupsAlphabeticalOrderBottom() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.*"), @@ -484,7 +484,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticOnDemandGroupsOrderAbove() throws Exception { + void staticOnDemandGroupsOrderAbove() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.util.Set"), "23:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "java.lang.Math.*"), @@ -496,7 +496,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGroupWithSlashes() throws Exception { + void groupWithSlashes() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(ImportOrderCheck.class); checkConfig.addProperty("groups", "/^javax"); @@ -518,7 +518,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGroupWithDot() throws Exception { + void groupWithDot() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "java.awt.Dialog"), "23:1: " + getCheckMessage(MSG_ORDERING, "javax.swing.JComponent"), @@ -527,7 +527,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiplePatternMatches() throws Exception { + void multiplePatternMatches() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.*"), }; @@ -543,7 +543,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { * given, so there is no other way to cover this code. */ @Test - public void testVisitTokenSwitchReflection() { + void visitTokenSwitchReflection() { // Create mock ast final DetailAstImpl astImport = mockAST(TokenTypes.IMPORT, "import", 0, 0); final DetailAstImpl astIdent = mockAST(TokenTypes.IDENT, "myTestImport", 0, 0); @@ -584,7 +584,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testEclipseDefaultPositive() throws Exception { + void eclipseDefaultPositive() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -592,14 +592,14 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticImportEclipseRepetition() throws Exception { + void staticImportEclipseRepetition() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputImportOrderEclipseStaticRepetition.java"), expected); } @Test - public void testEclipseDefaultNegative() throws Exception { + void eclipseDefaultNegative() throws Exception { final String[] expected = { "28:1: " + getCheckMessage(MSG_SEPARATION, "javax.swing.JComponent"), "33:1: " + getCheckMessage(MSG_ORDERING, "org.junit.Test"), @@ -610,14 +610,14 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testUseContainerOrderingForStaticTrue() throws Exception { + void useContainerOrderingForStaticTrue() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputImportOrderEclipseStatic1.java"), expected); } @Test - public void testUseContainerOrderingForStaticFalse() throws Exception { + void useContainerOrderingForStaticFalse() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_ORDERING, "io.netty.handler.codec.http.HttpHeaders.Names.addDate"), @@ -627,7 +627,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testUseContainerOrderingForStaticTrueCaseSensitive() throws Exception { + void useContainerOrderingForStaticTrueCaseSensitive() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_ORDERING, "io.netty.handler.codec.http.HttpHeaders.Names.DATE"), @@ -637,7 +637,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testUseContainerOrderingForStatic() throws Exception { + void useContainerOrderingForStatic() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_ORDERING, "io.netty.handler.Codec.HTTP.HttpHeaders.tmp.same"), "23:1: " + getCheckMessage(MSG_ORDERING, "io.netty.handler.Codec.HTTP.HttpHeaders.TKN.same"), @@ -647,7 +647,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportGroupsRedundantSeparatedInternally() throws Exception { + void importGroupsRedundantSeparatedInternally() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_SEPARATED_IN_GROUP, "org.*"), }; @@ -656,7 +656,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsAbove() throws Exception { + void staticGroupsAbove() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -664,7 +664,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsBottom() throws Exception { + void staticGroupsBottom() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -672,7 +672,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsBottomSeparated() throws Exception { + void staticGroupsBottomSeparated() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -680,7 +680,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsInflow() throws Exception { + void staticGroupsInflow() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -688,7 +688,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsNegative() throws Exception { + void staticGroupsNegative() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_ORDERING, "org.junit.Assert.fail"), "23:1: " + getCheckMessage(MSG_ORDERING, "org.infinispan.test.TestingUtil.extract"), @@ -699,7 +699,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsTop() throws Exception { + void staticGroupsTop() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -707,7 +707,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsTopSeparated() throws Exception { + void staticGroupsTopSeparated() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -715,7 +715,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticGroupsUnordered() throws Exception { + void staticGroupsUnordered() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -723,7 +723,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOption() throws Exception { + void trimOption() throws Exception { final String[] expected = { "25:1: " + getCheckMessage(MSG_ORDERING, "java.util.Set"), }; @@ -739,7 +739,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws exception */ @Test - public void testClearState() throws Exception { + void clearState() throws Exception { final ImportOrderCheck check = new ImportOrderCheck(); final DetailAST root = JavaParser.parseFile( @@ -753,7 +753,7 @@ public class ImportOrderCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - staticImport.get(), + staticImport.orElseThrow(), "lastImportStatic", lastImportStatic -> !((boolean) lastImportStatic))) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/PkgImportControlTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/PkgImportControlTest.java @@ -24,7 +24,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class PkgImportControlTest { +final class PkgImportControlTest { private final PkgImportControl icRoot = new PkgImportControl("com.kazgroup.courtlink", false, MismatchStrategy.DISALLOWED); @@ -44,7 +44,7 @@ public class PkgImportControlTest { new PkgImportControl(icRootRegexpParent, "bo+t", true, MismatchStrategy.DELEGATE_TO_PARENT); @BeforeEach - public void setUp() { + void setUp() { icRoot.addChild(icCommon); icRoot.addImportRule(new PkgImportRule(false, false, "org.springframework", false, false)); icRoot.addImportRule(new PkgImportRule(false, false, "org.hibernate", false, false)); @@ -66,14 +66,14 @@ public class PkgImportControlTest { } @Test - public void testDotMetaCharacter() { + void dotMetaCharacter() { assertWithMessage("Unexpected response") .that(icUncommon.locateFinest("com-kazgroup.courtlink.uncommon.regexp", "MyClass")) .isNull(); } @Test - public void testLocateFinest() { + void locateFinest() { assertWithMessage("Unexpected response") .that(icRoot.locateFinest("com.kazgroup.courtlink.domain", "MyClass")) .isEqualTo(icRoot); @@ -84,7 +84,7 @@ public class PkgImportControlTest { } @Test - public void testEnsureTrailingDot() { + void ensureTrailingDot() { assertWithMessage("Unexpected response") .that(icRoot.locateFinest("com.kazgroup.courtlinkkk", "MyClass")) .isNull(); @@ -94,7 +94,7 @@ public class PkgImportControlTest { } @Test - public void testCheckAccess() { + void checkAccess() { assertWithMessage("Unexpected access result") .that( icCommon.checkAccess( @@ -125,14 +125,14 @@ public class PkgImportControlTest { } @Test - public void testUnknownPkg() { + void unknownPkg() { assertWithMessage("Unexpected response") .that(icRoot.locateFinest("net.another", "MyClass")) .isNull(); } @Test - public void testRegExpChildLocateFinest() { + void regExpChildLocateFinest() { assertWithMessage("Unexpected response") .that(icRootRegexpChild.locateFinest("com.kazgroup.courtlink.domain", "MyClass")) .isEqualTo(icRootRegexpChild); @@ -145,7 +145,7 @@ public class PkgImportControlTest { } @Test - public void testRegExpChildCheckAccess() { + void regExpChildCheckAccess() { assertWithMessage("Unexpected access result") .that( icCommonRegexpChild.checkAccess( @@ -204,14 +204,14 @@ public class PkgImportControlTest { } @Test - public void testRegExpChildUnknownPkg() { + void regExpChildUnknownPkg() { assertWithMessage("Unexpected response") .that(icRootRegexpChild.locateFinest("net.another", "MyClass")) .isNull(); } @Test - public void testRegExpParentInRootIsConsidered() { + void regExpParentInRootIsConsidered() { assertWithMessage("Package should not be null") .that(icRootRegexpParent.locateFinest("com", "MyClass")) .isNull(); @@ -230,7 +230,7 @@ public class PkgImportControlTest { } @Test - public void testRegExpParentInSubpackageIsConsidered() { + void regExpParentInSubpackageIsConsidered() { assertWithMessage("Invalid package") .that(icRootRegexpParent.locateFinest("com.kazgroup.courtlink.boot.api", "MyClass")) .isEqualTo(icBootRegexpParen); @@ -240,7 +240,7 @@ public class PkgImportControlTest { } @Test - public void testRegExpParentEnsureTrailingDot() { + void regExpParentEnsureTrailingDot() { assertWithMessage("Invalid package") .that(icRootRegexpParent.locateFinest("com.kazgroup.courtlinkkk", "MyClass")) .isNull(); @@ -250,7 +250,7 @@ public class PkgImportControlTest { } @Test - public void testRegExpParentAlternationInParentIsHandledCorrectly() { + void regExpParentAlternationInParentIsHandledCorrectly() { // the regular expression has to be adjusted to (com\.foo|com\.bar) final PkgImportControl root = new PkgImportControl("com\\.foo|com\\.bar", true, MismatchStrategy.DISALLOWED); @@ -272,7 +272,7 @@ public class PkgImportControlTest { } @Test - public void testRegExpParentAlternationInParentIfUserCaresForIt() { + void regExpParentAlternationInParentIfUserCaresForIt() { // the regular expression has to be adjusted to (com\.foo|com\.bar) final PkgImportControl root = new PkgImportControl("(com\\.foo|com\\.bar)", true, MismatchStrategy.DISALLOWED); @@ -294,7 +294,7 @@ public class PkgImportControlTest { } @Test - public void testRegExpParentAlternationInSubpackageIsHandledCorrectly() { + void regExpParentAlternationInSubpackageIsHandledCorrectly() { final PkgImportControl root = new PkgImportControl("org.somewhere", false, MismatchStrategy.DISALLOWED); // the regular expression has to be adjusted to (foo|bar) @@ -313,7 +313,7 @@ public class PkgImportControlTest { } @Test - public void testRegExpParentUnknownPkg() { + void regExpParentUnknownPkg() { assertWithMessage("Package should not be null") .that(icRootRegexpParent.locateFinest("net.another", "MyClass")) .isNull(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/PkgImportRuleTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/PkgImportRuleTest.java @@ -23,10 +23,10 @@ import static com.google.common.truth.Truth.assertWithMessage; import org.junit.jupiter.api.Test; -public class PkgImportRuleTest { +final class PkgImportRuleTest { @Test - public void testPkgImportRule() { + void pkgImportRule() { final PkgImportRule rule = new PkgImportRule(true, false, "pkg", false, false); assertWithMessage("Rule must not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") @@ -50,7 +50,7 @@ public class PkgImportRuleTest { } @Test - public void testPkgImportRuleExactMatch() { + void pkgImportRuleExactMatch() { final PkgImportRule rule = new PkgImportRule(true, false, "pkg", true, false); assertWithMessage("Rule must not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") @@ -71,7 +71,7 @@ public class PkgImportRuleTest { } @Test - public void testPkgImportRuleRegexpSimple() { + void pkgImportRuleRegexpSimple() { final PkgImportRule rule = new PkgImportRule(true, false, "pkg", false, true); assertWithMessage("Rule must not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") @@ -95,7 +95,7 @@ public class PkgImportRuleTest { } @Test - public void testPkgImportRuleExactMatchRegexpSimple() { + void pkgImportRuleExactMatchRegexpSimple() { final PkgImportRule rule = new PkgImportRule(true, false, "pkg", true, true); assertWithMessage("Rule must not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") @@ -116,7 +116,7 @@ public class PkgImportRuleTest { } @Test - public void testPkgImportRuleRegexp() { + void pkgImportRuleRegexp() { final PkgImportRule rule = new PkgImportRule(true, false, "(pkg|hallo)", false, true); assertWithMessage("Rule must not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") @@ -152,7 +152,7 @@ public class PkgImportRuleTest { } @Test - public void testPkgImportRuleNoRegexp() { + void pkgImportRuleNoRegexp() { final PkgImportRule rule = new PkgImportRule(true, false, "(pkg|hallo)", false, false); assertWithMessage("Rule must not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") @@ -185,7 +185,7 @@ public class PkgImportRuleTest { } @Test - public void testPkgImportRuleExactMatchRegexp() { + void pkgImportRuleExactMatchRegexp() { final PkgImportRule rule = new PkgImportRule(true, false, "(pkg|hallo)", true, true); assertWithMessage("Rule must not be null").that(rule).isNotNull(); assertWithMessage("Invalid access result") --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckTest.java @@ -34,7 +34,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class RedundantImportCheckTest extends AbstractModuleTestSupport { +final class RedundantImportCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,7 +42,7 @@ public class RedundantImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final RedundantImportCheck checkObj = new RedundantImportCheck(); final int[] expected = { TokenTypes.IMPORT, TokenTypes.STATIC_IMPORT, TokenTypes.PACKAGE_DEF, @@ -53,7 +53,7 @@ public class RedundantImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testStateIsClearedOnBeginTree1() throws Exception { + void stateIsClearedOnBeginTree1() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RedundantImportCheck.class); final String inputWithWarnings = getPath("InputRedundantImportCheckClearState.java"); final String inputWithoutWarnings = getPath("InputRedundantImportWithoutWarnings.java"); @@ -73,7 +73,7 @@ public class RedundantImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithChecker() throws Exception { + void withChecker() throws Exception { final String[] expected = { "9:1: " + getCheckMessage( @@ -92,7 +92,7 @@ public class RedundantImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnnamedPackage() throws Exception { + void unnamedPackage() throws Exception { final String[] expected = { "10:1: " + getCheckMessage(MSG_DUPLICATE, 9, "java.util.List"), "12:1: " + getCheckMessage(MSG_LANG, "java.lang.String"), @@ -102,7 +102,7 @@ public class RedundantImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final RedundantImportCheck testCheckObject = new RedundantImportCheck(); final int[] actual = testCheckObject.getAcceptableTokens(); final int[] expected = { @@ -113,7 +113,7 @@ public class RedundantImportCheckTest extends AbstractModuleTestSupport { } @Test - public void testBeginTreePackage() throws Exception { + void beginTreePackage() throws Exception { final String file1 = getPath("InputRedundantImportCheckClearState.java"); final String file2 = getPath("InputRedundantImportWithoutPackage.java"); final List expectedFirstInput = --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckTest.java @@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle.checks.imports; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck.MSG_KEY; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -32,7 +33,7 @@ import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; -public class UnusedImportsCheckTest extends AbstractModuleTestSupport { +final class UnusedImportsCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -40,7 +41,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testReferencedStateIsCleared() throws Exception { + void referencedStateIsCleared() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(UnusedImportsCheck.class); final String inputWithoutWarnings = getPath("InputUnusedImportsWithoutWarnings.java"); final String inputWithWarnings = getPath("InputUnusedImportsCheckClearState.java"); @@ -72,7 +73,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithoutProcessJavadoc() throws Exception { + void withoutProcessJavadoc() throws Exception { final String[] expected = { "11:8: " + getCheckMessage(MSG_KEY, "com.google.errorprone.annotations." + "concurrent.GuardedBy"), @@ -106,7 +107,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testProcessJavadoc() throws Exception { + void processJavadoc() throws Exception { final String[] expected = { "11:8: " + getCheckMessage(MSG_KEY, "com.google.errorprone.annotations." + "concurrent.GuardedBy"), @@ -125,27 +126,27 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testProcessJavadocWithLinkTag() throws Exception { + void processJavadocWithLinkTag() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputUnusedImportsWithValueTag.java"), expected); } @Test - public void testProcessJavadocWithBlockTagContainingMethodParameters() throws Exception { + void processJavadocWithBlockTagContainingMethodParameters() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUnusedImportsWithBlockMethodParameters.java"), expected); } @Test - public void testAnnotations() throws Exception { + void annotations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputUnusedImportsAnnotations.java"), expected); } @Test - public void testArrayRef() throws Exception { + void arrayRef() throws Exception { final String[] expected = { "13:8: " + getCheckMessage(MSG_KEY, "java.util.ArrayList"), }; @@ -153,20 +154,20 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testBug() throws Exception { + void bug() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputUnusedImportsBug.java"), expected); } @Test - public void testNewlinesInsideTags() throws Exception { + void newlinesInsideTags() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputUnusedImportsWithNewlinesInsideTags.java"), expected); } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final UnusedImportsCheck testCheckObject = new UnusedImportsCheck(); final int[] actual = testCheckObject.getRequiredTokens(); final int[] expected = { @@ -194,7 +195,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final UnusedImportsCheck testCheckObject = new UnusedImportsCheck(); final int[] actual = testCheckObject.getAcceptableTokens(); final int[] expected = { @@ -222,7 +223,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testFileInUnnamedPackage() throws Exception { + void fileInUnnamedPackage() throws Exception { final String[] expected = { "12:8: " + getCheckMessage(MSG_KEY, "java.util.Arrays"), "13:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), @@ -232,7 +233,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportsFromJavaLang() throws Exception { + void importsFromJavaLang() throws Exception { final String[] expected = { "10:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), "11:8: " + getCheckMessage(MSG_KEY, "java.lang.Math"), @@ -250,7 +251,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportsJavadocQualifiedName() throws Exception { + void importsJavadocQualifiedName() throws Exception { final String[] expected = { "11:8: " + getCheckMessage(MSG_KEY, "java.util.List"), }; @@ -258,7 +259,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testSingleWordPackage() throws Exception { + void singleWordPackage() throws Exception { final String[] expected = { "10:8: " + getCheckMessage(MSG_KEY, "module"), }; @@ -267,7 +268,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordsAndCompactCtors() throws Exception { + void recordsAndCompactCtors() throws Exception { final String[] expected = { "19:8: " + getCheckMessage(MSG_KEY, "javax.swing.JToolBar"), "20:8: " + getCheckMessage(MSG_KEY, "javax.swing.JToggleButton"), @@ -277,7 +278,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testShadowedImports() throws Exception { + void shadowedImports() throws Exception { final String[] expected = { "12:8: " + getCheckMessage(MSG_KEY, "java.util.Map"), "13:8: " + getCheckMessage(MSG_KEY, "java.util.Set"), @@ -291,7 +292,7 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnusedImports3() throws Exception { + void unusedImports3() throws Exception { final String[] expected = { "11:8: " + getCheckMessage(MSG_KEY, "java.awt.Rectangle"), "13:8: " + getCheckMessage(MSG_KEY, "java.awt.event.KeyEvent"), @@ -300,14 +301,15 @@ public class UnusedImportsCheckTest extends AbstractModuleTestSupport { } @Test - public void testStateIsClearedOnBeginTreeCollect() throws Exception { + void stateIsClearedOnBeginTreeCollect() throws Exception { final String file1 = getNonCompilablePath("InputUnusedImportsRecordsAndCompactCtors.java"); final String file2 = getNonCompilablePath("InputUnusedImportsSingleWordPackage.java"); final List expectedFirstInput = - List.of( + ImmutableList.of( "19:8: " + getCheckMessage(MSG_KEY, "javax.swing.JToolBar"), "20:8: " + getCheckMessage(MSG_KEY, "javax.swing.JToggleButton")); - final List expectedSecondInput = List.of("10:8: " + getCheckMessage(MSG_KEY, "module")); + final List expectedSecondInput = + ImmutableList.of("10:8: " + getCheckMessage(MSG_KEY, "module")); verifyWithInlineConfigParser(file1, file2, expectedFirstInput, expectedSecondInput); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { +final class CommentsIndentationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsAtTheEndOfBlockOne() throws Exception { + void commentIsAtTheEndOfBlockOne() throws Exception { final String[] expected = { "25:26: " + getCheckMessage(MSG_KEY_SINGLE, 24, 25, 8), "40:6: " + getCheckMessage(MSG_KEY_SINGLE, 42, 5, 4), @@ -54,7 +54,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsAtTheEndOfBlockTwo() throws Exception { + void commentIsAtTheEndOfBlockTwo() throws Exception { final String[] expected = { "22:30: " + getCheckMessage(MSG_KEY_SINGLE, 23, 29, 12), "45:27: " + getCheckMessage(MSG_KEY_SINGLE, 38, 26, 8), @@ -68,7 +68,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsAtTheEndOfBlockThree() throws Exception { + void commentIsAtTheEndOfBlockThree() throws Exception { final String[] expected = { "21:1: " + getCheckMessage(MSG_KEY_SINGLE, 20, 0, 8), "35:13: " + getCheckMessage(MSG_KEY_SINGLE, 32, 12, 8), @@ -84,7 +84,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsAtTheEndOfBlockFour() throws Exception { + void commentIsAtTheEndOfBlockFour() throws Exception { final String[] expected = { "22:10: " + getCheckMessage(MSG_KEY_SINGLE, 21, 9, 8), "28:1: " + getCheckMessage(MSG_KEY_SINGLE, 29, 0, 4), @@ -100,7 +100,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsAtTheEndOfBlockFive() throws Exception { + void commentIsAtTheEndOfBlockFive() throws Exception { final String[] expected = { "61:1: " + getCheckMessage(MSG_KEY_SINGLE, 59, 0, 8), "77:11: " + getCheckMessage(MSG_KEY_BLOCK, 73, 10, 8), @@ -114,7 +114,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsAtTheEndOfBlockSix() throws Exception { + void commentIsAtTheEndOfBlockSix() throws Exception { final String[] expected = { "26:11: " + getCheckMessage(MSG_KEY_SINGLE, 19, 10, 8), "33:1: " + getCheckMessage(MSG_KEY_SINGLE, 30, 0, 8), @@ -132,7 +132,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsInsideSwitchBlockOne() throws Exception { + void commentIsInsideSwitchBlockOne() throws Exception { final String[] expected = { "27:13: " + getCheckMessage(MSG_KEY_BLOCK, 28, 12, 16), "33:20: " + getCheckMessage(MSG_KEY_SINGLE, "32, 34", 19, "16, 12"), @@ -148,7 +148,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsInsideSwitchBlockTwo() throws Exception { + void commentIsInsideSwitchBlockTwo() throws Exception { final String[] expected = { "18:25: " + getCheckMessage(MSG_KEY_SINGLE, 19, 24, 20), "43:16: " + getCheckMessage(MSG_KEY_SINGLE, "42, 44", 15, "17, 12"), @@ -161,7 +161,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsInsideSwitchBlockThree() throws Exception { + void commentIsInsideSwitchBlockThree() throws Exception { final String[] expected = { "18:25: " + getCheckMessage(MSG_KEY_SINGLE, 19, 24, 20), "45:5: " + getCheckMessage(MSG_KEY_SINGLE, "44, 46", 4, "12, 12"), @@ -175,7 +175,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsInsideSwitchBlockFour() throws Exception { + void commentIsInsideSwitchBlockFour() throws Exception { final String[] expected = { "18:25: " + getCheckMessage(MSG_KEY_SINGLE, 19, 24, 20), "34:12: " + getCheckMessage(MSG_KEY_BLOCK, "33, 37", 11, "16, 12"), @@ -187,7 +187,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIsInsideEmptyBlock() throws Exception { + void commentIsInsideEmptyBlock() throws Exception { final String[] expected = { "16:20: " + getCheckMessage(MSG_KEY_SINGLE, 19, 19, 31), "17:24: " + getCheckMessage(MSG_KEY_BLOCK, 19, 23, 31), @@ -202,7 +202,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testSurroundingCodeOne() throws Exception { + void surroundingCodeOne() throws Exception { final String[] expected = { "20:15: " + getCheckMessage(MSG_KEY_SINGLE, 21, 14, 12), "31:17: " + getCheckMessage(MSG_KEY_BLOCK, 32, 16, 12), @@ -218,7 +218,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testSurroundingCodeTwo() throws Exception { + void surroundingCodeTwo() throws Exception { final String[] expected = { "20:34: " + getCheckMessage(MSG_KEY_SINGLE, 21, 33, 8), "42:13: " + getCheckMessage(MSG_KEY_BLOCK, 43, 12, 8), @@ -230,14 +230,14 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoNpeWhenBlockCommentEndsClassFile() throws Exception { + void noNpeWhenBlockCommentEndsClassFile() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final String testInputFile = "InputCommentsIndentationNoNpe.java"; verifyWithInlineConfigParser(getPath(testInputFile), expected); } @Test - public void testCheckOnlySingleLineComments() throws Exception { + void checkOnlySingleLineComments() throws Exception { final String[] expected = { "20:15: " + getCheckMessage(MSG_KEY_SINGLE, 21, 14, 12), "57:28: " + getCheckMessage(MSG_KEY_SINGLE, 60, 27, 36), @@ -250,7 +250,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckOnlyBlockCommentsOne() throws Exception { + void checkOnlyBlockCommentsOne() throws Exception { final String[] expected = { "30:17: " + getCheckMessage(MSG_KEY_BLOCK, 31, 16, 12), "32:17: " + getCheckMessage(MSG_KEY_BLOCK, 34, 16, 12), @@ -262,7 +262,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckOnlyBlockCommentsTwo() throws Exception { + void checkOnlyBlockCommentsTwo() throws Exception { final String[] expected = { "40:13: " + getCheckMessage(MSG_KEY_BLOCK, 41, 12, 8), "46:5: " + getCheckMessage(MSG_KEY_BLOCK, 47, 4, 8), @@ -273,7 +273,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitToken() { + void visitToken() { final CommentsIndentationCheck check = new CommentsIndentationCheck(); final DetailAstImpl methodDef = new DetailAstImpl(); methodDef.setType(TokenTypes.METHOD_DEF); @@ -290,7 +290,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadoc() throws Exception { + void javadoc() throws Exception { final String[] expected = { "10:3: " + getCheckMessage(MSG_KEY_BLOCK, 13, 2, 0), "16:1: " + getCheckMessage(MSG_KEY_BLOCK, 17, 0, 4), @@ -302,7 +302,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiblockStructuresOne() throws Exception { + void multiblockStructuresOne() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY_SINGLE, 18, 8, 12), "25:17: " + getCheckMessage(MSG_KEY_SINGLE, "24, 26", 16, "12, 8"), @@ -325,7 +325,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultiblockStructuresTwo() throws Exception { + void multiblockStructuresTwo() throws Exception { final String[] expected = { "20:9: " + getCheckMessage(MSG_KEY_SINGLE, 19, 8, 12), "26:17: " + getCheckMessage(MSG_KEY_SINGLE, "25, 27", 16, "12, 8"), @@ -336,7 +336,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentsAfterAnnotation() throws Exception { + void commentsAfterAnnotation() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY_SINGLE, 22, 4, 0), "25:9: " + getCheckMessage(MSG_KEY_SINGLE, 26, 8, 4), @@ -349,7 +349,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentsInSameMethodCallWithSameIndent() throws Exception { + void commentsInSameMethodCallWithSameIndent() throws Exception { final String[] expected = { "23:7: " + getCheckMessage(MSG_KEY_SINGLE, 24, 6, 4), "30:11: " + getCheckMessage(MSG_KEY_SINGLE, 31, 10, 4), @@ -359,7 +359,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentIndentationWithEmoji() throws Exception { + void commentIndentationWithEmoji() throws Exception { final String[] expected = { "14:9: " + getCheckMessage(MSG_KEY_SINGLE, 15, 8, 16), "25:13: " + getCheckMessage(MSG_KEY_SINGLE, 24, 12, 8), @@ -376,7 +376,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentsBlockCommentBeforePackage() throws Exception { + void commentsBlockCommentBeforePackage() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY_BLOCK, 11, 0, 1), }; @@ -385,7 +385,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentsAfterRecordsAndCompactCtors() throws Exception { + void commentsAfterRecordsAndCompactCtors() throws Exception { final String[] expected = { "15:17: " + getCheckMessage(MSG_KEY_SINGLE, 16, 16, 20), "28:1: " + getCheckMessage(MSG_KEY_SINGLE, 29, 0, 4), @@ -398,7 +398,7 @@ public class CommentsIndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentsAtTheEndOfMethodCall() throws Exception { + void commentsAtTheEndOfMethodCall() throws Exception { final String[] expected = { "24:16: " + getCheckMessage(MSG_KEY_SINGLE, 20, 15, 8), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java @@ -19,11 +19,13 @@ package com.puppycrawl.tools.checkstyle.checks.indentation; +import static com.google.common.base.Preconditions.checkState; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.MSG_CHILD_ERROR; import static com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.MSG_CHILD_ERROR_MULTI; import static com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.MSG_ERROR; import static com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck.MSG_ERROR_MULTI; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.Checker; @@ -34,9 +36,8 @@ import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.BufferedReader; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -46,7 +47,7 @@ import java.util.regex.Pattern; import org.junit.jupiter.api.Test; /** Unit test for IndentationCheck. */ -public class IndentationCheckTest extends AbstractModuleTestSupport { +final class IndentationCheckTest extends AbstractModuleTestSupport { private static final Pattern LINE_WITH_COMMENT_REGEX = Pattern.compile( @@ -57,8 +58,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { private static IndentComment[] getLinesWithWarnAndCheckComments( String aFileName, final int tabWidth) throws IOException { final List result = new ArrayList<>(); - try (BufferedReader br = - Files.newBufferedReader(Paths.get(aFileName), StandardCharsets.UTF_8)) { + try (BufferedReader br = Files.newBufferedReader(Path.of(aFileName), UTF_8)) { int lineNumber = 1; for (String line = br.readLine(); line != null; line = br.readLine()) { final Matcher match = LINE_WITH_COMMENT_REGEX.matcher(line); @@ -66,26 +66,24 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { final IndentComment warn = new IndentComment(match, lineNumber); final int actualIndent = getLineStart(line, tabWidth); - if (actualIndent != warn.getIndent()) { - throw new IllegalStateException( - String.format( - Locale.ROOT, - "File \"%1$s\" has incorrect indentation in comment. " - + "Line %2$d: comment:%3$d, actual:%4$d.", - aFileName, - lineNumber, - warn.getIndent(), - actualIndent)); - } + checkState( + actualIndent == warn.getIndent(), + String.format( + Locale.ROOT, + "File \"%1$s\" has incorrect indentation in comment. " + + "Line %2$d: comment:%3$d, actual:%4$d.", + aFileName, + lineNumber, + warn.getIndent(), + actualIndent)); - if (!isCommentConsistent(warn)) { - throw new IllegalStateException( - String.format( - Locale.ROOT, - "File \"%1$s\" has inconsistent comment on line %2$d", - aFileName, - lineNumber)); - } + checkState( + isCommentConsistent(warn), + String.format( + Locale.ROOT, + "File \"%1$s\" has inconsistent comment on line %2$d", + aFileName, + lineNumber)); if (warn.isWarning()) { result.add(warn); @@ -169,7 +167,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final IndentationCheck checkObj = new IndentationCheck(); final int[] requiredTokens = checkObj.getRequiredTokens(); final HandlerFactory handlerFactory = new HandlerFactory(); @@ -182,7 +180,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final IndentationCheck checkObj = new IndentationCheck(); final int[] acceptableTokens = checkObj.getAcceptableTokens(); final HandlerFactory handlerFactory = new HandlerFactory(); @@ -195,7 +193,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testThrowsIndentProperty() { + void throwsIndentProperty() { final IndentationCheck indentationCheck = new IndentationCheck(); indentationCheck.setThrowsIndent(1); @@ -206,7 +204,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrictCondition() throws Exception { + void strictCondition() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -225,7 +223,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void forbidOldStyle() throws Exception { + void forbidOldStyle() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -243,7 +241,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testZeroCaseLevel() throws Exception { + void zeroCaseLevel() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -258,7 +256,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAndroidStyle() throws Exception { + void androidStyle() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -283,7 +281,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodCallLineWrap() throws Exception { + void methodCallLineWrap() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -303,7 +301,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testDifficultAnnotations() throws Exception { + void difficultAnnotations() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -329,7 +327,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationClosingParenthesisEndsInSameIndentationAsOpening() throws Exception { + void annotationClosingParenthesisEndsInSameIndentationAsOpening() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("basicOffset", "4"); @@ -352,7 +350,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnonClassesFromGuava() throws Exception { + void anonClassesFromGuava() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -368,7 +366,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotations() throws Exception { + void annotations() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -384,7 +382,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCorrectIfAndParameters() throws Exception { + void correctIfAndParameters() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -407,7 +405,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnonymousClasses() throws Exception { + void anonymousClasses() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -423,7 +421,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrays() throws Exception { + void arrays() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "2"); @@ -439,7 +437,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLabels() throws Exception { + void labels() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -455,7 +453,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassesAndMethods() throws Exception { + void classesAndMethods() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -471,7 +469,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCtorCall() throws Exception { + void ctorCall() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("basicOffset", "2"); @@ -504,7 +502,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testMembers() throws Exception { + void members() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -524,7 +522,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationArrayInit() throws Exception { + void annotationArrayInit() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "6"); @@ -560,7 +558,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationArrayInitTwo() throws Exception { + void annotationArrayInitTwo() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "0"); @@ -588,7 +586,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationArrayInitWithEmoji() throws Exception { + void annotationArrayInitWithEmoji() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "0"); @@ -626,7 +624,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testOddAnnotations() throws Exception { + void oddAnnotations() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "3"); @@ -648,7 +646,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationOddStyles() throws Exception { + void annotationOddStyles() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "8"); @@ -661,7 +659,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testZeroAnnotationArrayInit() throws Exception { + void zeroAnnotationArrayInit() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "0"); @@ -683,7 +681,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationArrayInitGoodCase() throws Exception { + void annotationArrayInitGoodCase() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -700,7 +698,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationArrayInitGoodCaseTwo() throws Exception { + void annotationArrayInitGoodCaseTwo() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -717,7 +715,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidLabel() throws Exception { + void invalidLabel() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -740,7 +738,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidLabelWithWhileLoop() throws Exception { + void invalidLabelWithWhileLoop() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -760,7 +758,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidLabel() throws Exception { + void validLabel() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -776,7 +774,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidIfWithChecker() throws Exception { + void validIfWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -795,7 +793,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidDotWithChecker() throws Exception { + void validDotWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -812,7 +810,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidMethodWithChecker() throws Exception { + void validMethodWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -832,7 +830,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidMethodWithChecker() throws Exception { + void invalidMethodWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -885,7 +883,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAlternativeGoogleStyleSwitchCaseAndEnums() throws Exception { + void alternativeGoogleStyleSwitchCaseAndEnums() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -908,7 +906,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidSwitchWithChecker() throws Exception { + void invalidSwitchWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -955,7 +953,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIfElseWithNoCurly() throws Exception { + void ifElseWithNoCurly() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -979,7 +977,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhileWithNoCurly() throws Exception { + void whileWithNoCurly() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1002,7 +1000,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testForWithNoCurly() throws Exception { + void forWithNoCurly() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1026,7 +1024,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testDoWhileWithoutCurly() throws Exception { + void doWhileWithoutCurly() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1047,7 +1045,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidSwitchWithChecker() throws Exception { + void validSwitchWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1064,7 +1062,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewKeyword() throws Exception { + void newKeyword() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("basicOffset", "4"); @@ -1077,7 +1075,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewKeyword2() throws Exception { + void newKeyword2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("basicOffset", "4"); @@ -1090,7 +1088,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidNewKeywordWithForceStrictCondition() throws Exception { + void validNewKeywordWithForceStrictCondition() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("basicOffset", "4"); @@ -1103,7 +1101,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidNewKeywordWithForceStrictCondition() throws Exception { + void invalidNewKeywordWithForceStrictCondition() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("basicOffset", "4"); @@ -1131,7 +1129,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidArrayInitDefaultIndentWithChecker() throws Exception { + void validArrayInitDefaultIndentWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1148,7 +1146,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidArrayInitWithChecker() throws Exception { + void validArrayInitWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "8"); @@ -1165,7 +1163,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidArrayInitTwoDimensional() throws Exception { + void validArrayInitTwoDimensional() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "2"); @@ -1182,7 +1180,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidArrayInitTwoDimensional() throws Exception { + void invalidArrayInitTwoDimensional() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "2"); @@ -1212,7 +1210,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidArrayInit() throws Exception { + void validArrayInit() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "2"); @@ -1229,7 +1227,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidArrayInitWithChecker() throws Exception { + void invalidArrayInitWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1291,7 +1289,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayInitWithEmoji() throws Exception { + void arrayInitWithEmoji() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "2"); @@ -1315,7 +1313,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testChainedMethodCalling() throws Exception { + void chainedMethodCalling() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "2"); @@ -1337,7 +1335,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidArrayInitWithTrueStrictCondition() throws Exception { + void invalidArrayInitWithTrueStrictCondition() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1399,7 +1397,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidTryWithChecker() throws Exception { + void validTryWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1416,7 +1414,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidTryWithChecker() throws Exception { + void invalidTryWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1462,7 +1460,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidClassDefWithChecker() throws Exception { + void invalidClassDefWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1514,7 +1512,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidBlockWithChecker() throws Exception { + void invalidBlockWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1578,7 +1576,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidIfWithChecker() throws Exception { + void invalidIfWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1670,7 +1668,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidWhileWithChecker() throws Exception { + void invalidWhileWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1716,7 +1714,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidInvalidAnonymousClass() throws Exception { + void invalidInvalidAnonymousClass() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1733,7 +1731,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidForWithChecker() throws Exception { + void invalidForWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1781,7 +1779,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidForWithChecker() throws Exception { + void validForWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1798,7 +1796,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidDoWhileWithChecker() throws Exception { + void validDoWhileWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1815,7 +1813,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidDoWhileWithChecker() throws Exception { + void invalidDoWhileWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1850,7 +1848,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidBlockWithChecker() throws Exception { + void validBlockWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1867,7 +1865,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidWhileWithChecker() throws Exception { + void validWhileWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1884,7 +1882,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidClassDefWithChecker() throws Exception { + void validClassDefWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1904,7 +1902,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidInterfaceDefWithChecker() throws Exception { + void validInterfaceDefWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1921,7 +1919,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidCommaWithChecker() throws Exception { + void validCommaWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1938,7 +1936,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTabs() throws Exception { + void tabs() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1956,7 +1954,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationLevel() throws Exception { + void indentationLevel() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1974,7 +1972,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testThrowsIndentationLevel() throws Exception { + void throwsIndentationLevel() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -1990,7 +1988,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testThrowsIndentationLevel2() throws Exception { + void throwsIndentationLevel2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("basicOffset", "1"); @@ -2017,7 +2015,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testCaseLevel() throws Exception { + void caseLevel() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -2035,7 +2033,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testBraceAdjustment() throws Exception { + void braceAdjustment() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -2057,7 +2055,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidAssignWithChecker() throws Exception { + void invalidAssignWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -2078,7 +2076,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidImportIndent() throws Exception { + void invalidImportIndent() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("basicOffset", "8"); checkConfig.addProperty("tabWidth", "4"); @@ -2090,7 +2088,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testValidAssignWithChecker() throws Exception { + void validAssignWithChecker() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -2106,7 +2104,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void test15Extensions() throws Exception { + void test15Extensions() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -2122,7 +2120,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryResources() throws Exception { + void tryResources() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -2138,7 +2136,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchCustom() throws Exception { + void switchCustom() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); @@ -2154,7 +2152,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testSynchronizedStatement() throws Exception { + void synchronizedStatement() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2172,7 +2170,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testSynchronizedMethod() throws Exception { + void synchronizedMethod() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2187,7 +2185,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnonymousClassInMethod() throws Exception { + void anonymousClassInMethod() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "8"); checkConfig.addProperty("basicOffset", "2"); @@ -2208,7 +2206,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnonymousClassInMethodWithCurlyOnNewLine() throws Exception { + void anonymousClassInMethodWithCurlyOnNewLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2233,7 +2231,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationDefinition() throws Exception { + void annotationDefinition() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -2241,7 +2239,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageDeclaration() throws Exception { + void packageDeclaration() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2251,7 +2249,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageDeclaration2() throws Exception { + void packageDeclaration2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2261,7 +2259,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageDeclaration3() throws Exception { + void packageDeclaration3() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -2269,7 +2267,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageDeclaration4() throws Exception { + void packageDeclaration4() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2280,7 +2278,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambda1() throws Exception { + void lambda1() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "2"); checkConfig.addProperty("basicOffset", "2"); @@ -2300,7 +2298,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambda2() throws Exception { + void lambda2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2310,7 +2308,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambda3() throws Exception { + void lambda3() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2327,7 +2325,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambda4() throws Exception { + void lambda4() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2337,7 +2335,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambda5() throws Exception { + void lambda5() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "3"); checkConfig.addProperty("basicOffset", "3"); @@ -2348,7 +2346,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaFalseForceStrictCondition() throws Exception { + void lambdaFalseForceStrictCondition() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2367,7 +2365,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaTrueForceStrictCondition() throws Exception { + void lambdaTrueForceStrictCondition() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2396,7 +2394,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaOddConditions() throws Exception { + void lambdaOddConditions() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "3"); @@ -2409,7 +2407,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testSeparatedStatements() throws Exception { + void separatedStatements() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String fileName = getPath("InputIndentationSeparatedStatements.java"); @@ -2418,7 +2416,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testSeparatedLineWithJustSpaces() throws Exception { + void separatedLineWithJustSpaces() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String fileName = getPath("InputIndentationSeparatedStatementWithSpaces.java"); @@ -2427,7 +2425,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTwoStatementsPerLine() throws Exception { + void twoStatementsPerLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2437,7 +2435,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodChaining() throws Exception { + void methodChaining() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2447,7 +2445,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultipleAnnotationsWithWrappedLines() throws Exception { + void multipleAnnotationsWithWrappedLines() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2459,7 +2457,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodPrecedeByAnnotationsWithParameterOnSeparateLine() throws Exception { + void methodPrecedeByAnnotationsWithParameterOnSeparateLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "2"); @@ -2475,7 +2473,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationIncorrect() throws Exception { + void annotationIncorrect() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2491,7 +2489,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputAnnotationScopeIndentationCheck() throws Exception { + void inputAnnotationScopeIndentationCheck() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2505,7 +2503,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInputAnnotationDefIndentationCheck() throws Exception { + void inputAnnotationDefIndentationCheck() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("arrayInitIndent", "4"); @@ -2550,7 +2548,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryResourcesStrict() throws Exception { + void tryResourcesStrict() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("forceStrictCondition", "true"); @@ -2585,7 +2583,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryResourcesNotStrict() throws Exception { + void tryResourcesNotStrict() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("braceAdjustment", "0"); @@ -2624,7 +2622,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { * @see IndentComment#getExpectedMessagePostfix(String) */ @Test - public void testArgumentOrderOfErrorMessages() { + void argumentOrderOfErrorMessages() { final Object[] arguments = {"##0##", "##1##", "##2##"}; final String[] messages = { getCheckMessage(MSG_ERROR, arguments), @@ -2651,7 +2649,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyArray() throws Exception { + void emptyArray() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -2659,7 +2657,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewHandler() throws Exception { + void newHandler() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2673,7 +2671,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryHandler() throws Exception { + void tryHandler() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("braceAdjustment", "0"); @@ -2684,7 +2682,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryHandler2() throws Exception { + void tryHandler2() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("braceAdjustment", "0"); @@ -2698,7 +2696,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testChainedMethodWithBracketOnNewLine() throws Exception { + void chainedMethodWithBracketOnNewLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("arrayInitIndent", "2"); @@ -2722,7 +2720,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationSwitchExpression() throws Exception { + void indentationSwitchExpression() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2746,7 +2744,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationYieldStatement() throws Exception { + void indentationYieldStatement() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2762,7 +2760,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationSwitchExpressionCorrect() throws Exception { + void indentationSwitchExpressionCorrect() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -2773,7 +2771,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationSwitchExpressionDeclaration() throws Exception { + void indentationSwitchExpressionDeclaration() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("caseIndent", "4"); @@ -2795,7 +2793,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationSwitchExpressionDeclarationLeftCurlyNewLine() throws Exception { + void indentationSwitchExpressionDeclarationLeftCurlyNewLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2811,7 +2809,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationRecords() throws Exception { + void indentationRecords() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2828,7 +2826,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationRecordsAndCompactCtors() throws Exception { + void indentationRecordsAndCompactCtors() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2845,7 +2843,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationSwitchExpressionNewLine() throws Exception { + void indentationSwitchExpressionNewLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2860,7 +2858,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationMethodParenthesisOnNewLine() throws Exception { + void indentationMethodParenthesisOnNewLine() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2872,7 +2870,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationMethodParenthesisOnNewLine1() throws Exception { + void indentationMethodParenthesisOnNewLine1() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); final String[] expected = { @@ -2885,7 +2883,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationLineWrappedRecordDeclaration() throws Exception { + void indentationLineWrappedRecordDeclaration() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2924,7 +2922,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationAnnotationFieldDefinition() throws Exception { + void indentationAnnotationFieldDefinition() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); checkConfig.addProperty("basicOffset", "4"); @@ -2944,7 +2942,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationLongConcatenatedString() throws Exception { + void indentationLongConcatenatedString() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); @@ -2954,7 +2952,7 @@ public class IndentationCheckTest extends AbstractModuleTestSupport { } @Test - public void testIndentationLineBreakVariableDeclaration() throws Exception { + void indentationLineBreakVariableDeclaration() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(IndentationCheck.class); checkConfig.addProperty("tabWidth", "4"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AbstractJavadocCheckTest.java @@ -26,7 +26,7 @@ import static com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocChec import static com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck.MSG_JAVADOC_WRONG_SINGLETON_TAG; import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTypeCheck.MSG_TAG_FORMAT; import static com.puppycrawl.tools.checkstyle.checks.javadoc.SummaryJavadocCheck.MSG_SUMMARY_FIRST_SENTENCE; -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.assertj.core.api.Assertions.assertThatCode; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -35,6 +35,7 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; import java.io.File; +import java.nio.file.Files; import org.itsallcode.io.Capturable; import org.itsallcode.junit.sysextensions.SystemErrGuard; import org.itsallcode.junit.sysextensions.SystemErrGuard.SysErr; @@ -44,7 +45,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.io.TempDir; @ExtendWith(SystemErrGuard.class) -public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { +final class AbstractJavadocCheckTest extends AbstractModuleTestSupport { @TempDir public File temporaryFolder; @@ -63,12 +64,12 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { * @param systemErr wrapper for {@code System.err} */ @BeforeEach - public void setUp(@SysErr Capturable systemErr) { + void setUp(@SysErr Capturable systemErr) { systemErr.captureMuted(); } @Test - public void testJavadocTagsWithoutArgs() throws Exception { + void javadocTagsWithoutArgs() throws Exception { final String[] expected = { "16: " + getCheckMessage( @@ -109,7 +110,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testNumberFormatException() throws Exception { + void numberFormatException() throws Exception { final String[] expected = { "8: " + getCheckMessage( @@ -123,13 +124,13 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomTag() throws Exception { + void customTag() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbstractJavadocCustomTag.java"), expected); } @Test - public void testParsingErrors(@SysErr Capturable systemErr) throws Exception { + void parsingErrors(@SysErr Capturable systemErr) throws Exception { final String[] expected = { "9: " + getCheckMessage(MSG_JAVADOC_MISSED_HTML_CLOSE, 4, "unclosedTag"), "16: " + getCheckMessage(MSG_JAVADOC_WRONG_SINGLETON_TAG, 35, "img"), @@ -139,19 +140,19 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithMultipleChecksOne() throws Exception { + void withMultipleChecksOne() throws Exception { verifyWithInlineConfigParser( getPath("InputAbstractJavadocCorrectParagraphOne.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testWithMultipleChecksTwo() throws Exception { + void withMultipleChecksTwo() throws Exception { verifyWithInlineConfigParser( getPath("InputAbstractJavadocCorrectParagraphTwo.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testAntlrError(@SysErr Capturable systemErr) throws Exception { + void antlrError(@SysErr Capturable systemErr) throws Exception { final String[] expected = { "9: " + getCheckMessage( @@ -163,8 +164,8 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckReuseAfterParseErrorWithFollowingAntlrErrorInTwoFiles( - @SysErr Capturable systemErr) throws Exception { + void checkReuseAfterParseErrorWithFollowingAntlrErrorInTwoFiles(@SysErr Capturable systemErr) + throws Exception { final String[] expectedMessagesForFile1 = { "9: " + getCheckMessage(MSG_JAVADOC_MISSED_HTML_CLOSE, 4, "unclosedTag"), "16: " + getCheckMessage(MSG_JAVADOC_WRONG_SINGLETON_TAG, 35, "img"), @@ -184,7 +185,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testCheckReuseAfterParseErrorWithFollowingAntlrErrorInSingleFile() throws Exception { + void checkReuseAfterParseErrorWithFollowingAntlrErrorInSingleFile() throws Exception { final String[] expected = { "9: " + getCheckMessage(MSG_JAVADOC_MISSED_HTML_CLOSE, 4, "unclosedTag"), "16: " @@ -196,7 +197,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testCache() throws Exception { + void cache() throws Exception { final String[] expected = { "12: " + getCheckMessage(SummaryJavadocCheck.class, MSG_SUMMARY_FIRST_SENTENCE), }; @@ -207,7 +208,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPositionOne() throws Exception { + void positionOne() throws Exception { JavadocCatchCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbstractJavadocPositionOne.java"), expected); @@ -219,7 +220,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPositionTwo() throws Exception { + void positionTwo() throws Exception { JavadocCatchCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbstractJavadocPositionTwo.java"), expected); @@ -231,7 +232,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPositionThree() throws Exception { + void positionThree() throws Exception { JavadocCatchCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbstractJavadocPositionThree.java"), expected); @@ -243,7 +244,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPositionWithSinglelineCommentsOne() throws Exception { + void positionWithSinglelineCommentsOne() throws Exception { JavadocCatchCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -256,7 +257,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPositionWithSinglelineCommentsTwo() throws Exception { + void positionWithSinglelineCommentsTwo() throws Exception { JavadocCatchCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -269,7 +270,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPositionWithSinglelineCommentsThree() throws Exception { + void positionWithSinglelineCommentsThree() throws Exception { JavadocCatchCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -282,7 +283,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPositionOnlyComments() throws Exception { + void positionOnlyComments() throws Exception { JavadocCatchCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -293,7 +294,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokens() { + void tokens() { final int[] defaultJavadocTokens = {JavadocTokenTypes.JAVADOC}; final AbstractJavadocCheck check = new AbstractJavadocCheck() { @@ -329,7 +330,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokensFail() { + void tokensFail() { final int[] defaultJavadocTokens = { JavadocTokenTypes.JAVADOC, JavadocTokenTypes.AREA_HTML_TAG_NAME, @@ -351,11 +352,11 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } }; check.setJavadocTokens("RETURN_LITERAL"); - assertDoesNotThrow(check::init); + assertThatCode(check::init).doesNotThrowAnyException(); } @Test - public void testAcceptableTokensFail() throws Exception { + void acceptableTokensFail() throws Exception { final String path = getPath("InputAbstractJavadocTokensFail.java"); try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -374,16 +375,17 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testAcceptableTokensPass() throws Exception { + void acceptableTokensPass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbstractJavadocTokensPass.java"), expected); } @Test - public void testRequiredTokenIsNotInDefaultTokens() throws Exception { + void requiredTokenIsNotInDefaultTokens() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RequiredTokenIsNotInDefaultsJavadocCheck.class); - final String pathToEmptyFile = File.createTempFile("empty", ".java", temporaryFolder).getPath(); + final String pathToEmptyFile = + Files.createTempFile(temporaryFolder.toPath(), "empty", ".java").toFile().getPath(); try { execute(checkConfig, pathToEmptyFile); @@ -402,7 +404,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitLeaveTokenOne() throws Exception { + void visitLeaveTokenOne() throws Exception { JavadocVisitLeaveCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbstractJavadocLeaveTokenOne.java"), expected); @@ -415,7 +417,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitLeaveTokenTwo() throws Exception { + void visitLeaveTokenTwo() throws Exception { JavadocVisitLeaveCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbstractJavadocLeaveTokenTwo.java"), expected); @@ -428,7 +430,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitLeaveTokenThree() throws Exception { + void visitLeaveTokenThree() throws Exception { JavadocVisitLeaveCheck.clearCounter(); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbstractJavadocLeaveTokenThree.java"), expected); @@ -441,7 +443,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoWsBeforeDescriptionInJavadocTags() throws Exception { + void noWsBeforeDescriptionInJavadocTags() throws Exception { final String[] expected = { "18: " + getCheckMessage( @@ -491,7 +493,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongSingletonTagInJavadoc() throws Exception { + void wrongSingletonTagInJavadoc() throws Exception { final String[] expected = { "10: " + getCheckMessage(MSG_JAVADOC_WRONG_SINGLETON_TAG, 9, "embed"), "17: " + getCheckMessage(MSG_JAVADOC_WRONG_SINGLETON_TAG, 9, "keygen"), @@ -504,7 +506,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonTightHtmlTagIntolerantCheckOne() throws Exception { + void nonTightHtmlTagIntolerantCheckOne() throws Exception { final String[] expected = { "12: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), "19: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), @@ -518,7 +520,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonTightHtmlTagIntolerantCheckTwo() throws Exception { + void nonTightHtmlTagIntolerantCheckTwo() throws Exception { final String[] expected = { "12: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), "19: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), @@ -530,21 +532,21 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonTightHtmlTagIntolerantCheckReportingNoViolationOne() throws Exception { + void nonTightHtmlTagIntolerantCheckReportingNoViolationOne() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAbstractJavadocNonTightHtmlTagsNoViolationOne.java"), expected); } @Test - public void testNonTightHtmlTagIntolerantCheckReportingNoViolationTwo() throws Exception { + void nonTightHtmlTagIntolerantCheckReportingNoViolationTwo() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputAbstractJavadocNonTightHtmlTagsNoViolationTwo.java"), expected); } @Test - public void testNonTightHtmlTagIntolerantCheckVisitCountOne() throws Exception { + void nonTightHtmlTagIntolerantCheckVisitCountOne() throws Exception { final String[] expected = { "13: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), "20: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), @@ -560,7 +562,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonTightHtmlTagIntolerantCheckVisitCountTwo() throws Exception { + void nonTightHtmlTagIntolerantCheckVisitCountTwo() throws Exception { final String[] expected = { "13: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), "20: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), @@ -577,7 +579,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitCountForCheckAcceptingJavadocWithNonTightHtml() throws Exception { + void visitCountForCheckAcceptingJavadocWithNonTightHtml() throws Exception { final String[] expected = { "11:4: " + getCheckMessage(NonTightHtmlTagCheck.MSG_KEY, "BODY_TAG_START"), "12:4: " + getCheckMessage(NonTightHtmlTagCheck.MSG_KEY, "P_TAG_START"), @@ -619,7 +621,7 @@ public class AbstractJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitCountForCheckAcceptingJavadocWithNonTightHtml3() throws Exception { + void visitCountForCheckAcceptingJavadocWithNonTightHtml3() throws Exception { final String[] expected = { "29:8: " + getCheckMessage(NonTightHtmlTagCheck.MSG_KEY, "P_TAG_START"), "36: " + getCheckMessage(MSG_UNCLOSED_HTML_TAG, "p"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { +final class AtclauseOrderCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AtclauseOrderCheck checkObj = new AtclauseOrderCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default acceptable tokens are invalid") @@ -44,7 +44,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AtclauseOrderCheck checkObj = new AtclauseOrderCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default acceptable tokens are invalid") @@ -53,35 +53,35 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testCorrect1() throws Exception { + void correct1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAtclauseOrderCorrect1.java"), expected); } @Test - public void testCorrect2() throws Exception { + void correct2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAtclauseOrderCorrect2.java"), expected); } @Test - public void testCorrect3() throws Exception { + void correct3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAtclauseOrderCorrect3.java"), expected); } @Test - public void testCorrect4() throws Exception { + void correct4() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAtclauseOrderCorrect4.java"), expected); } @Test - public void testIncorrect1() throws Exception { + void incorrect1() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; @@ -105,7 +105,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrect2() throws Exception { + void incorrect2() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; @@ -129,7 +129,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrect3() throws Exception { + void incorrect3() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; @@ -147,7 +147,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrect4() throws Exception { + void incorrect4() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; @@ -172,14 +172,14 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrectCustom1() throws Exception { + void incorrectCustom1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAtclauseOrderIncorrectCustom1.java"), expected); } @Test - public void testIncorrectCustom2() throws Exception { + void incorrectCustom2() throws Exception { final String tagOrder = "[@since, @version, @param, @return, @throws, @exception," + " @deprecated, @see, @serial, @serialField, @serialData, @author]"; @@ -190,7 +190,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrectCustom3() throws Exception { + void incorrectCustom3() throws Exception { final String tagOrder = "[@since, @version, @param, @return, @throws, @exception," + " @deprecated, @see, @serial, @serialField, @serialData, @author]"; @@ -201,7 +201,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrectCustom4() throws Exception { + void incorrectCustom4() throws Exception { final String tagOrder = "[@since, @version, @param, @return, @throws, @exception," + " @deprecated, @see, @serial, @serialField, @serialData, @author]"; @@ -212,14 +212,14 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageInfo() throws Exception { + void packageInfo() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("package-info.java"), expected); } @Test - public void testAtclauseOrderRecords() throws Exception { + void atclauseOrderRecords() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception," + " @see, @since, @serial, @serialField, @serialData, @deprecated]"; @@ -238,7 +238,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodReturningArrayType() throws Exception { + void methodReturningArrayType() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; @@ -252,7 +252,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testAtclauseOrderLotsOfRecords1() throws Exception { + void atclauseOrderLotsOfRecords1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -260,7 +260,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testAtclauseOrderLotsOfRecords2() throws Exception { + void atclauseOrderLotsOfRecords2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -268,7 +268,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testAtclauseOrderLotsOfRecords3() throws Exception { + void atclauseOrderLotsOfRecords3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -276,7 +276,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testAtclauseOrderLotsOfRecords4() throws Exception { + void atclauseOrderLotsOfRecords4() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -284,7 +284,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testAtclause() throws Exception { + void atclause() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; @@ -317,7 +317,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testNewArrayDeclaratorStructure() throws Exception { + void newArrayDeclaratorStructure() throws Exception { final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see," + " @since, @serial, @serialField, @serialData, @deprecated]"; @@ -335,7 +335,7 @@ public class AtclauseOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrim() throws Exception { + void trim() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAtclauseOrder1.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class InvalidJavadocPositionCheckTest extends AbstractModuleTestSupport { +final class InvalidJavadocPositionCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class InvalidJavadocPositionCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final int[] expected = { TokenTypes.BLOCK_COMMENT_BEGIN, }; @@ -45,7 +45,7 @@ public class InvalidJavadocPositionCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final int[] expected = { TokenTypes.BLOCK_COMMENT_BEGIN, }; @@ -56,7 +56,7 @@ public class InvalidJavadocPositionCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "7:9: " + getCheckMessage(MSG_KEY), "10:1: " + getCheckMessage(MSG_KEY), @@ -89,7 +89,7 @@ public class InvalidJavadocPositionCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageInfo() throws Exception { + void packageInfo() throws Exception { final String[] expected = { "7:1: " + getCheckMessage(MSG_KEY), }; @@ -97,7 +97,7 @@ public class InvalidJavadocPositionCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageInfoComment() throws Exception { + void packageInfoComment() throws Exception { final String[] expected = { "7:1: " + getCheckMessage(MSG_KEY), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocBlockTagLocationCheckTest extends AbstractModuleTestSupport { +final class JavadocBlockTagLocationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class JavadocBlockTagLocationCheckTest extends AbstractModuleTestSupport } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavadocBlockTagLocationCheck checkObj = new JavadocBlockTagLocationCheck(); final int[] expected = { JavadocTokenTypes.TEXT, @@ -46,7 +46,7 @@ public class JavadocBlockTagLocationCheckTest extends AbstractModuleTestSupport } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocBlockTagLocationCorrect.java"), expected); @@ -61,7 +61,7 @@ public class JavadocBlockTagLocationCheckTest extends AbstractModuleTestSupport * @throws Exception if exception occurs during verification process. */ @Test - public void testMultilineCodeBlock() throws Exception { + void multilineCodeBlock() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -69,7 +69,7 @@ public class JavadocBlockTagLocationCheckTest extends AbstractModuleTestSupport } @Test - public void testIncorrect() throws Exception { + void incorrect() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "author"), "16: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "since"), @@ -83,7 +83,7 @@ public class JavadocBlockTagLocationCheckTest extends AbstractModuleTestSupport } @Test - public void testCustomTags() throws Exception { + void customTags() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "apiNote"), "14: " + getCheckMessage(MSG_BLOCK_TAG_LOCATION, "implNote"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { +final class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavadocContentLocationCheck checkObj = new JavadocContentLocationCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Acceptable tokens are invalid") @@ -45,7 +45,7 @@ public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetDefaultTokens() { + void getDefaultTokens() { final JavadocContentLocationCheck checkObj = new JavadocContentLocationCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default tokens are invalid") @@ -54,7 +54,7 @@ public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_SECOND_LINE), "21:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_SECOND_LINE), @@ -63,7 +63,7 @@ public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testFirstLine() throws Exception { + void firstLine() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), "21:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), @@ -72,7 +72,7 @@ public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackage() throws Exception { + void testPackage() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_JAVADOC_CONTENT_SECOND_LINE), }; @@ -80,7 +80,7 @@ public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterface() throws Exception { + void testInterface() throws Exception { final String[] expected = { "10:1: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), }; @@ -88,14 +88,14 @@ public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testOptionalSpacesAndAsterisks() throws Exception { + void optionalSpacesAndAsterisks() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocContentLocationTrailingSpace.java"), expected); } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), "21:5: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), @@ -105,7 +105,7 @@ public class JavadocContentLocationCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault2() throws Exception { + void default2() throws Exception { final String[] expected = { "9:1: " + getCheckMessage(MSG_JAVADOC_CONTENT_SECOND_LINE), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheckTest.java @@ -34,7 +34,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import org.junit.jupiter.api.Test; -public class JavadocMethodCheckTest extends AbstractModuleTestSupport { +final class JavadocMethodCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,7 +42,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavadocMethodCheck javadocMethodCheck = new JavadocMethodCheck(); final int[] actual = javadocMethodCheck.getAcceptableTokens(); @@ -61,19 +61,19 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void extendAnnotationTest() throws Exception { + void extendAnnotationTest() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethodExtendAnnotation.java"), expected); } @Test - public void allowedAnnotationsTest() throws Exception { + void allowedAnnotationsTest() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethodAllowedAnnotations.java"), expected); } @Test - public void testThrowsDetection() throws Exception { + void throwsDetection() throws Exception { final String[] expected = { "25:19: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "UnsupportedOperationException"), "37:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "UnsupportedOperationException"), @@ -94,7 +94,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testExtraThrows() throws Exception { + void extraThrows() throws Exception { final String[] expected = { "54:56: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalStateException"), "70:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"), @@ -107,7 +107,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreThrows() throws Exception { + void ignoreThrows() throws Exception { final String[] expected = { "40:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"), "43:23: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalStateException"), @@ -119,7 +119,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testTags() throws Exception { + void tags() throws Exception { final String[] expected = { "30:9: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unused"), "37: " + getCheckMessage(MSG_RETURN_EXPECTED), @@ -148,7 +148,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrictJavadoc() throws Exception { + void strictJavadoc() throws Exception { final String[] expected = { "77:29: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"), "82:22: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"), @@ -160,14 +160,14 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoJavadoc() throws Exception { + void noJavadoc() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethodPublicOnly1.java"), expected); } // pre 1.4 relaxed mode is roughly equivalent with check=protected @Test - public void testRelaxedJavadoc() throws Exception { + void relaxedJavadoc() throws Exception { final String[] expected = { "87:41: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"), "92:37: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "aA"), @@ -176,19 +176,19 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopeInnerInterfacesPublic() throws Exception { + void scopeInnerInterfacesPublic() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethodScopeInnerInterfaces.java"), expected); } @Test - public void testScopeAnonInnerPrivate() throws Exception { + void scopeAnonInnerPrivate() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethodScopeAnonInner.java"), expected); } @Test - public void testScopes() throws Exception { + void scopes() throws Exception { final String[] expected = { "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), "29: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), @@ -199,7 +199,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopes2() throws Exception { + void scopes2() throws Exception { final String[] expected = { "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), "29: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), @@ -209,7 +209,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludeScope() throws Exception { + void excludeScope() throws Exception { final String[] expected = { "27: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), "31: " + getCheckMessage(MSG_UNUSED_TAG_GENERAL), @@ -220,21 +220,21 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowMissingJavadocTags() throws Exception { + void allowMissingJavadocTags() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodMissingJavadocNoMissingTags.java"), expected); } @Test - public void testSurroundingAccessModifier() throws Exception { + void surroundingAccessModifier() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMethodSurroundingAccessModifier.java"), expected); } @Test - public void testDoAllowMissingJavadocTagsByDefault() throws Exception { + void doAllowMissingJavadocTagsByDefault() throws Exception { final String[] expected = { "23: " + getCheckMessage(MSG_RETURN_EXPECTED), "34:26: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "number"), @@ -247,13 +247,13 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testSetterGetter() throws Exception { + void setterGetter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethodSetterGetter.java"), expected); } @Test - public void testTypeParamsTags() throws Exception { + void typeParamsTags() throws Exception { final String[] expected = { "37:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), "40:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", ""), @@ -264,7 +264,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowUndocumentedParamsTags() throws Exception { + void allowUndocumentedParamsTags() throws Exception { final String[] expected = { "33:6: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unexpectedParam"), "34:6: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "unexpectedParam2"), @@ -279,25 +279,25 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void test11684081() throws Exception { + void test11684081() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethod_01.java"), expected); } @Test - public void test11684082() throws Exception { + void test11684082() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethod_02.java"), expected); } @Test - public void test11684083() throws Exception { + void test11684083() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethod_03.java"), expected); } @Test - public void testGenerics() throws Exception { + void generics() throws Exception { final String[] expected = { "29:34: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "RE"), "46:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", ""), @@ -308,13 +308,13 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void test1379666() throws Exception { + void test1379666() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethod_1379666.java"), expected); } @Test - public void testInheritDoc() throws Exception { + void inheritDoc() throws Exception { final String[] expected = { "18:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC), "23:5: " + getCheckMessage(MSG_INVALID_INHERIT_DOC), @@ -327,7 +327,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowToSkipOverridden() throws Exception { + void allowToSkipOverridden() throws Exception { final String[] expected = { "19:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"), "30:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"), @@ -336,19 +336,19 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testJava8ReceiverParameter() throws Exception { + void java8ReceiverParameter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethodReceiverParameter.java"), expected); } @Test - public void testJavadocInMethod() throws Exception { + void javadocInMethod() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethodJavadocInMethod.java"), expected); } @Test - public void testConstructor() throws Exception { + void constructor() throws Exception { final String[] expected = { "21:49: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"), "24:50: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "p1"), @@ -357,7 +357,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocMethodRecordsAndCompactCtors() throws Exception { + void javadocMethodRecordsAndCompactCtors() throws Exception { final String[] expected = { "29:27: " + getCheckMessage(MSG_EXPECTED_TAG, "@throws", "IllegalArgumentException"), "43:27: " @@ -375,7 +375,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final int[] expected = { TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.ENUM_DEF, TokenTypes.RECORD_DEF, }; @@ -385,7 +385,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokenToString() throws Exception { + void tokenToString() throws Exception { final Class tokenType = Class.forName( "com.puppycrawl.tools.checkstyle.checks.javadoc." + "JavadocMethodCheck$Token"); @@ -399,20 +399,20 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithoutLogErrors() throws Exception { + void withoutLogErrors() throws Exception { verifyWithInlineConfigParser( getPath("InputJavadocMethodLoadErrors.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testCompilationUnit() throws Exception { + void compilationUnit() throws Exception { verifyWithInlineConfigParser( getNonCompilablePath("InputJavadocMethodCompilationUnit.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testDefaultAccessModifier() throws Exception { + void defaultAccessModifier() throws Exception { final String[] expected = { "21:32: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "a"), "26:43: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "b"), @@ -421,7 +421,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testAccessModifierEnum() throws Exception { + void accessModifierEnum() throws Exception { final String[] expected = { "27:17: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", "i"), }; @@ -429,7 +429,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomMessages() throws Exception { + void customMessages() throws Exception { final String msgReturnExpectedCustom = "@return tag should be present and have description :)"; final String msgUnusedTagCustom = "Unused @param tag for 'unused' :)"; final String msgExpectedTagCustom = "Expected @param tag for 'a' :)"; @@ -443,7 +443,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void test1() throws Exception { + void test1() throws Exception { final String[] expected = { "23: " + getCheckMessage(MSG_RETURN_EXPECTED), }; @@ -451,7 +451,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void test2() throws Exception { + void test2() throws Exception { final String[] expected = { "15:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "<"), "19:13: " + getCheckMessage(MSG_EXPECTED_TAG, "@param", ""), @@ -460,7 +460,7 @@ public class JavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void test3() throws Exception { + void test3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocMethod3.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingLeadingAsteriskCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingLeadingAsteriskCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocMissingLeadingAsteriskCheckTest extends AbstractModuleTestSupport { +final class JavadocMissingLeadingAsteriskCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class JavadocMissingLeadingAsteriskCheckTest extends AbstractModuleTestSu } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavadocMissingLeadingAsteriskCheck checkObj = new JavadocMissingLeadingAsteriskCheck(); final int[] expected = { JavadocTokenTypes.NEWLINE, @@ -46,14 +46,14 @@ public class JavadocMissingLeadingAsteriskCheckTest extends AbstractModuleTestSu } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocMissingLeadingAsteriskCorrect.java"), expected); } @Test - public void testIncorrect() throws Exception { + void incorrect() throws Exception { final String[] expected = { "13: " + getCheckMessage(MSG_MISSING_ASTERISK), "18: " + getCheckMessage(MSG_MISSING_ASTERISK), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocMissingWhitespaceAfterAsteriskCheckTest extends AbstractModuleTestSupport { +final class JavadocMissingWhitespaceAfterAsteriskCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class JavadocMissingWhitespaceAfterAsteriskCheckTest extends AbstractModu } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavadocMissingWhitespaceAfterAsteriskCheck checkObj = new JavadocMissingWhitespaceAfterAsteriskCheck(); final int[] expected = { @@ -48,7 +48,7 @@ public class JavadocMissingWhitespaceAfterAsteriskCheckTest extends AbstractModu } @Test - public void testGetRequiredJavadocTokens() { + void getRequiredJavadocTokens() { final JavadocMissingWhitespaceAfterAsteriskCheck checkObj = new JavadocMissingWhitespaceAfterAsteriskCheck(); final int[] expected = { @@ -60,7 +60,7 @@ public class JavadocMissingWhitespaceAfterAsteriskCheckTest extends AbstractModu } @Test - public void testValid() throws Exception { + void valid() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -68,7 +68,7 @@ public class JavadocMissingWhitespaceAfterAsteriskCheckTest extends AbstractModu } @Test - public void testValidWithTabCharacter() throws Exception { + void validWithTabCharacter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -76,7 +76,7 @@ public class JavadocMissingWhitespaceAfterAsteriskCheckTest extends AbstractModu } @Test - public void testInvalid() throws Exception { + void invalid() throws Exception { final String[] expected = { "10:4: " + getCheckMessage(MSG_KEY), "16:7: " + getCheckMessage(MSG_KEY), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImplTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocNodeImplTest.java @@ -24,10 +24,10 @@ import static com.google.common.truth.Truth.assertWithMessage; import com.puppycrawl.tools.checkstyle.api.JavadocTokenTypes; import org.junit.jupiter.api.Test; -public class JavadocNodeImplTest { +final class JavadocNodeImplTest { @Test - public void testToString() { + void testToString() { final JavadocNodeImpl javadocNode = new JavadocNodeImpl(); javadocNode.setType(JavadocTokenTypes.CODE_LITERAL); javadocNode.setLineNumber(1); @@ -43,7 +43,7 @@ public class JavadocNodeImplTest { } @Test - public void testGetColumnNumber() { + void getColumnNumber() { final JavadocNodeImpl javadocNode = new JavadocNodeImpl(); javadocNode.setColumnNumber(1); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocPackageCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocPackageCheckTest.java @@ -23,15 +23,15 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck.MSG_LEGACY_PACKAGE_HTML; import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocPackageCheck.MSG_PACKAGE_INFO; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.FileText; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; -import java.util.Collections; import org.junit.jupiter.api.Test; -public class JavadocPackageCheckTest extends AbstractModuleTestSupport { +final class JavadocPackageCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissing() throws Exception { + void missing() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_PACKAGE_INFO), }; @@ -47,7 +47,7 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingWithAllowLegacy() throws Exception { + void missingWithAllowLegacy() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_PACKAGE_INFO), }; @@ -55,7 +55,7 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithMultipleFiles() throws Exception { + void withMultipleFiles() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_PACKAGE_INFO), }; @@ -66,7 +66,7 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testBoth() throws Exception { + void both() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_LEGACY_PACKAGE_HTML), }; @@ -75,7 +75,7 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtmlDisallowed() throws Exception { + void htmlDisallowed() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_PACKAGE_INFO), }; @@ -84,7 +84,7 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtmlAllowed() throws Exception { + void htmlAllowed() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("pkghtml" + File.separator + "InputJavadocPackageHtmlIgnored2.java"), @@ -93,7 +93,7 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotation() throws Exception { + void annotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("annotation" + File.separator + "package-info.java"), expected); @@ -104,10 +104,10 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { * invalid canonical path. */ @Test - public void testCheckstyleExceptionIfFailedToGetCanonicalPathToFile() { + void checkstyleExceptionIfFailedToGetCanonicalPathToFile() { final JavadocPackageCheck check = new JavadocPackageCheck(); final File fileWithInvalidPath = new File("\u0000\u0000\u0000"); - final FileText mockFileText = new FileText(fileWithInvalidPath, Collections.emptyList()); + final FileText mockFileText = new FileText(fileWithInvalidPath, ImmutableList.of()); final String expectedExceptionMessage = "Exception while getting canonical path to file " + fileWithInvalidPath.getPath(); try { @@ -121,13 +121,13 @@ public class JavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonJava() throws Exception { + void nonJava() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocPackageNotJava.txt"), expected); } @Test - public void testWithFileWithoutParent() throws Exception { + void withFileWithoutParent() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("annotation" + File.separator + "package-info.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocParagraphCheckTest extends AbstractModuleTestSupport { +final class JavadocParagraphCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,7 +38,7 @@ public class JavadocParagraphCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final JavadocParagraphCheck checkObj = new JavadocParagraphCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default required tokens are invalid") @@ -47,14 +47,14 @@ public class JavadocParagraphCheckTest extends AbstractModuleTestSupport { } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocParagraphCorrect.java"), expected); } @Test - public void testIncorrect() throws Exception { + void incorrect() throws Exception { final String[] expected = { "13: " + getCheckMessage(MSG_MISPLACED_TAG), "13: " + getCheckMessage(MSG_LINE_BEFORE), @@ -97,7 +97,7 @@ public class JavadocParagraphCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowNewlineParagraph() throws Exception { + void allowNewlineParagraph() throws Exception { final String[] expected = { "13: " + getCheckMessage(MSG_LINE_BEFORE), "14: " + getCheckMessage(MSG_LINE_BEFORE), @@ -123,7 +123,7 @@ public class JavadocParagraphCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocParagraph() throws Exception { + void javadocParagraph() throws Exception { final String[] expected = { "19: " + getCheckMessage(MSG_LINE_BEFORE), "30: " + getCheckMessage(MSG_MISPLACED_TAG), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckTest.java @@ -32,7 +32,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import org.junit.jupiter.api.Test; -public class JavadocStyleCheckTest extends AbstractModuleTestSupport { +final class JavadocStyleCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -40,7 +40,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavadocStyleCheck javadocStyleCheck = new JavadocStyleCheck(); final int[] actual = javadocStyleCheck.getAcceptableTokens(); @@ -63,7 +63,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleDefaultSettingsOne() throws Exception { + void javadocStyleDefaultSettingsOne() throws Exception { final String[] expected = { "24: " + getCheckMessage(MSG_NO_PERIOD), "50: " + getCheckMessage(MSG_NO_PERIOD), @@ -84,7 +84,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleDefaultSettingsTwo() throws Exception { + void javadocStyleDefaultSettingsTwo() throws Exception { final String[] expected = { "26:39: " + getCheckMessage(MSG_EXTRA_HTML, ""), "72:8: " + getCheckMessage(MSG_UNCLOSED_HTML, "
"), @@ -96,7 +96,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleDefaultSettingsThree() throws Exception { + void javadocStyleDefaultSettingsThree() throws Exception { final String[] expected = { "109: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -105,7 +105,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleDefaultSettingsFour() throws Exception { + void javadocStyleDefaultSettingsFour() throws Exception { final String[] expected = { "30:33: " + getCheckMessage(MSG_UNCLOSED_HTML, ""), "42: " + getCheckMessage(MSG_NO_PERIOD), @@ -121,7 +121,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleFirstSentenceOne() throws Exception { + void javadocStyleFirstSentenceOne() throws Exception { final String[] expected = { "24: " + getCheckMessage(MSG_NO_PERIOD), "50: " + getCheckMessage(MSG_NO_PERIOD), @@ -134,7 +134,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleFirstSentenceTwo() throws Exception { + void javadocStyleFirstSentenceTwo() throws Exception { final String[] expected = { "67: " + getCheckMessage(MSG_NO_PERIOD), "101: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -143,14 +143,14 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleFirstSentenceThree() throws Exception { + void javadocStyleFirstSentenceThree() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleFirstSentenceThree.java"), expected); } @Test - public void testJavadocStyleFirstSentenceFour() throws Exception { + void javadocStyleFirstSentenceFour() throws Exception { final String[] expected = { "40: " + getCheckMessage(MSG_NO_PERIOD), "51: " + getCheckMessage(MSG_NO_PERIOD), @@ -164,7 +164,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleFirstSentenceFormatOne() throws Exception { + void javadocStyleFirstSentenceFormatOne() throws Exception { final String[] expected = { "24: " + getCheckMessage(MSG_NO_PERIOD), "35: " + getCheckMessage(MSG_NO_PERIOD), @@ -179,7 +179,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleFirstSentenceFormatTwo() throws Exception { + void javadocStyleFirstSentenceFormatTwo() throws Exception { final String[] expected = { "74: " + getCheckMessage(MSG_NO_PERIOD), "108: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -188,7 +188,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleFirstSentenceFormatThree() throws Exception { + void javadocStyleFirstSentenceFormatThree() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -196,7 +196,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleFirstSentenceFormatFour() throws Exception { + void javadocStyleFirstSentenceFormatFour() throws Exception { final String[] expected = { "40: " + getCheckMessage(MSG_NO_PERIOD), "51: " + getCheckMessage(MSG_NO_PERIOD), @@ -211,7 +211,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtml1() throws Exception { + void html1() throws Exception { final String[] expected = { "59:11: " + getCheckMessage(MSG_UNCLOSED_HTML, ""), "62:7: " + getCheckMessage(MSG_EXTRA_HTML, ""), @@ -228,7 +228,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtml2() throws Exception { + void html2() throws Exception { final String[] expected = { "68:8: " + getCheckMessage(MSG_UNCLOSED_HTML, "
"), }; @@ -237,7 +237,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtml3() throws Exception { + void html3() throws Exception { final String[] expected = { "103:21: " + getCheckMessage(MSG_EXTRA_HTML, ""), }; @@ -246,7 +246,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtml4() throws Exception { + void html4() throws Exception { final String[] expected = { "29:33: " + getCheckMessage(MSG_UNCLOSED_HTML, ""), "47:11: " + getCheckMessage(MSG_UNCLOSED_HTML, ""), @@ -256,28 +256,28 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtmlComment() throws Exception { + void htmlComment() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleHtmlComment.java"), expected); } @Test - public void testOnInputWithNoJavadoc1() throws Exception { + void onInputWithNoJavadoc1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleNoJavadoc1.java"), expected); } @Test - public void testOnInputWithNoJavadoc2() throws Exception { + void onInputWithNoJavadoc2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleNoJavadoc2.java"), expected); } @Test - public void testScopePublic1() throws Exception { + void scopePublic1() throws Exception { final String[] expected = { "78: " + getCheckMessage(MSG_NO_PERIOD), "79:31: " + getCheckMessage(MSG_EXTRA_HTML, ""), @@ -288,7 +288,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopePublic2() throws Exception { + void scopePublic2() throws Exception { final String[] expected = { "83: " + getCheckMessage(MSG_EMPTY), "102: " + getCheckMessage(MSG_EMPTY), @@ -299,7 +299,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopePublic3() throws Exception { + void scopePublic3() throws Exception { final String[] expected = { "104:21: " + getCheckMessage(MSG_EXTRA_HTML, ""), }; @@ -308,7 +308,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopePublic4() throws Exception { + void scopePublic4() throws Exception { final String[] expected = { "51: " + getCheckMessage(MSG_NO_PERIOD), "56: " + getCheckMessage(MSG_NO_PERIOD), @@ -319,7 +319,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopeProtected1() throws Exception { + void scopeProtected1() throws Exception { final String[] expected = { "67: " + getCheckMessage(MSG_NO_PERIOD), "68:23: " + getCheckMessage(MSG_UNCLOSED_HTML, ""), @@ -332,7 +332,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopeProtected2() throws Exception { + void scopeProtected2() throws Exception { final String[] expected = { "83: " + getCheckMessage(MSG_EMPTY), "87: " + getCheckMessage(MSG_EMPTY), @@ -344,7 +344,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopeProtected3() throws Exception { + void scopeProtected3() throws Exception { final String[] expected = { "104:21: " + getCheckMessage(MSG_EXTRA_HTML, ""), }; @@ -353,7 +353,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopeProtected4() throws Exception { + void scopeProtected4() throws Exception { final String[] expected = { "51: " + getCheckMessage(MSG_NO_PERIOD), "56: " + getCheckMessage(MSG_NO_PERIOD), @@ -364,7 +364,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopePackage1() throws Exception { + void scopePackage1() throws Exception { final String[] expected = { "67: " + getCheckMessage(MSG_NO_PERIOD), "68:24: " + getCheckMessage(MSG_UNCLOSED_HTML, ""), @@ -379,7 +379,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopePackage2() throws Exception { + void scopePackage2() throws Exception { final String[] expected = { "83: " + getCheckMessage(MSG_EMPTY), "87: " + getCheckMessage(MSG_EMPTY), @@ -392,7 +392,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopePackage3() throws Exception { + void scopePackage3() throws Exception { final String[] expected = { "104:21: " + getCheckMessage(MSG_EXTRA_HTML, ""), }; @@ -401,7 +401,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopePackage4() throws Exception { + void scopePackage4() throws Exception { final String[] expected = { "51: " + getCheckMessage(MSG_NO_PERIOD), "56: " + getCheckMessage(MSG_NO_PERIOD), @@ -414,14 +414,14 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyJavadoc1() throws Exception { + void emptyJavadoc1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleEmptyJavadoc1.java"), expected); } @Test - public void testEmptyJavadoc2() throws Exception { + void emptyJavadoc2() throws Exception { final String[] expected = { "75: " + getCheckMessage(MSG_EMPTY), "79: " + getCheckMessage(MSG_EMPTY), @@ -434,21 +434,21 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyJavadoc3() throws Exception { + void emptyJavadoc3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleEmptyJavadoc3.java"), expected); } @Test - public void testEmptyJavadoc4() throws Exception { + void emptyJavadoc4() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleEmptyJavadoc4.java"), expected); } @Test - public void testExcludeScope1() throws Exception { + void excludeScope1() throws Exception { final String[] expected = { "24: " + getCheckMessage(MSG_NO_PERIOD), "50: " + getCheckMessage(MSG_NO_PERIOD), @@ -465,7 +465,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludeScope2() throws Exception { + void excludeScope2() throws Exception { final String[] expected = { "69:8: " + getCheckMessage(MSG_UNCLOSED_HTML, "
"), "75: " + getCheckMessage(MSG_NO_PERIOD), @@ -475,14 +475,14 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludeScope3() throws Exception { + void excludeScope3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleExcludeScope3.java"), expected); } @Test - public void testExcludeScope4() throws Exception { + void excludeScope4() throws Exception { final String[] expected = { "30:33: " + getCheckMessage(MSG_UNCLOSED_HTML, ""), "42: " + getCheckMessage(MSG_NO_PERIOD), @@ -495,7 +495,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void packageInfoInheritDoc() throws Exception { + void packageInfoInheritDoc() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -507,7 +507,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void packageInfoInvalid() throws Exception { + void packageInfoInvalid() throws Exception { final String[] expected = { "17: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -519,7 +519,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void packageInfoAnnotation() throws Exception { + void packageInfoAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -528,7 +528,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void packageInfoMissing() throws Exception { + void packageInfoMissing() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -536,7 +536,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void packageInfoMissingPeriod() throws Exception { + void packageInfoMissingPeriod() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -546,14 +546,14 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testNothing() throws Exception { + void nothing() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleNothing.java"), expected); } @Test - public void packageInfoValid() throws Exception { + void packageInfoValid() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -562,7 +562,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testRestrictedTokenSet1() throws Exception { + void restrictedTokenSet1() throws Exception { final String[] expected = { "74: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -571,21 +571,21 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testRestrictedTokenSet2() throws Exception { + void restrictedTokenSet2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleRestrictedTokenSet2.java"), expected); } @Test - public void testRestrictedTokenSet3() throws Exception { + void restrictedTokenSet3() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleRestrictedTokenSet3.java"), expected); } @Test - public void testRestrictedTokenSet4() throws Exception { + void restrictedTokenSet4() throws Exception { final String[] expected = { "53: " + getCheckMessage(MSG_NO_PERIOD), "86: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -594,7 +594,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleRecordsAndCompactCtors() throws Exception { + void javadocStyleRecordsAndCompactCtors() throws Exception { final String[] expected = { "24: " + getCheckMessage(MSG_NO_PERIOD), "45: " + getCheckMessage(MSG_NO_PERIOD), @@ -614,7 +614,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtmlTagToString() { + void htmlTagToString() { final HtmlTag tag = new HtmlTag("id", 3, 5, true, false, ""); assertWithMessage("Invalid toString result") .that(tag.toString()) @@ -624,14 +624,14 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testNeverEndingXmlCommentInsideJavadoc() throws Exception { + void neverEndingXmlCommentInsideJavadoc() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocStyleNeverEndingXmlComment.java"), expected); } @Test - public void testInterfaceMemberScopeIsPublic() throws Exception { + void interfaceMemberScopeIsPublic() throws Exception { final String[] expected = { "21: " + getCheckMessage(MSG_EMPTY), "25: " + getCheckMessage(MSG_EMPTY), }; @@ -641,7 +641,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnumCtorScopeIsPrivate() throws Exception { + void enumCtorScopeIsPrivate() throws Exception { final String[] expected = { "21: " + getCheckMessage(MSG_EMPTY), "25: " + getCheckMessage(MSG_EMPTY), @@ -652,7 +652,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testLowerCasePropertyForTag() throws Exception { + void lowerCasePropertyForTag() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -660,7 +660,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocTag() throws Exception { + void javadocTag() throws Exception { final String[] expected = { "11: " + getCheckMessage(MSG_NO_PERIOD), "15: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -669,7 +669,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocTag2() throws Exception { + void javadocTag2() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_NO_PERIOD), "18:16: " @@ -682,7 +682,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocTag3() throws Exception { + void javadocTag3() throws Exception { final String[] expected = { "21:4: " + getCheckMessage(MSG_EXTRA_HTML, ""), }; @@ -691,7 +691,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleCheck3() throws Exception { + void javadocStyleCheck3() throws Exception { final String[] expected = { "11: " + getCheckMessage(MSG_NO_PERIOD), }; @@ -700,7 +700,7 @@ public class JavadocStyleCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocStyleCheck4() throws Exception { + void javadocStyleCheck4() throws Exception { final String[] expected = { "12: " + getCheckMessage(MSG_NO_PERIOD), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTestSupport { +final class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTe } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final JavadocTagContinuationIndentationCheck checkObj = new JavadocTagContinuationIndentationCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; @@ -45,14 +45,14 @@ public class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTe } @Test - public void testFp() throws Exception { + void fp() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputJavadocTagContinuationIndentationGuavaFalsePositive.java"), expected); } @Test - public void testCheck() throws Exception { + void check() throws Exception { final String[] expected = { "55: " + getCheckMessage(MSG_KEY, 4), "117: " + getCheckMessage(MSG_KEY, 4), @@ -73,7 +73,7 @@ public class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTe } @Test - public void testCheckWithOffset3() throws Exception { + void checkWithOffset3() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_KEY, 3), "27: " + getCheckMessage(MSG_KEY, 3), }; @@ -82,7 +82,7 @@ public class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTe } @Test - public void testCheckWithDescription() throws Exception { + void checkWithDescription() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_KEY, 4), "17: " + getCheckMessage(MSG_KEY, 4), @@ -96,7 +96,7 @@ public class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTe } @Test - public void testBlockTag() throws Exception { + void blockTag() throws Exception { final String[] expected = { "21: " + getCheckMessage(MSG_KEY, 4), "32: " + getCheckMessage(MSG_KEY, 4), @@ -128,7 +128,7 @@ public class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTe } @Test - public void testContinuationIndentation() throws Exception { + void continuationIndentation() throws Exception { final String[] expected = { "23: " + getCheckMessage(MSG_KEY, 4), }; @@ -136,7 +136,7 @@ public class JavadocTagContinuationIndentationCheckTest extends AbstractModuleTe } @Test - public void testJavadocTagContinuationIndentationCheck1() throws Exception { + void javadocTagContinuationIndentationCheck1() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_KEY, 4), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfoTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagInfoTest.java @@ -26,14 +26,14 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import java.lang.reflect.Method; import org.junit.jupiter.api.Test; -public class JavadocTagInfoTest { +final class JavadocTagInfoTest { /* Additional test for jacoco, since valueOf() * is generated by javac and jacoco reports that * valueOf() is uncovered. */ @Test - public void testJavadocTagInfoValueOf() { + void javadocTagInfoValueOf() { final JavadocTagInfo tag = JavadocTagInfo.valueOf("AUTHOR"); assertWithMessage("Invalid valueOf result").that(tag).isEqualTo(JavadocTagInfo.AUTHOR); } @@ -43,7 +43,7 @@ public class JavadocTagInfoTest { * valueOf() is uncovered. */ @Test - public void testTypeValueOf() { + void typeValueOf() { final JavadocTagInfo.Type type = JavadocTagInfo.Type.valueOf("BLOCK"); assertWithMessage("Invalid valueOf result").that(type).isEqualTo(JavadocTagInfo.Type.BLOCK); } @@ -53,7 +53,7 @@ public class JavadocTagInfoTest { * values() is uncovered. */ @Test - public void testTypeValues() { + void typeValues() { final JavadocTagInfo.Type[] expected = { JavadocTagInfo.Type.BLOCK, JavadocTagInfo.Type.INLINE, }; @@ -62,7 +62,7 @@ public class JavadocTagInfoTest { } @Test - public void testAuthor() { + void author() { final DetailAstImpl ast = new DetailAstImpl(); final int[] validTypes = { @@ -86,7 +86,7 @@ public class JavadocTagInfoTest { } @Test - public void testOthers() throws ReflectiveOperationException { + void others() throws ReflectiveOperationException { final JavadocTagInfo[] tags = { JavadocTagInfo.CODE, JavadocTagInfo.DOC_ROOT, @@ -137,7 +137,7 @@ public class JavadocTagInfoTest { } @Test - public void testDeprecated() throws ReflectiveOperationException { + void deprecated() throws ReflectiveOperationException { final DetailAstImpl ast = new DetailAstImpl(); final DetailAstImpl astParent = new DetailAstImpl(); astParent.setType(TokenTypes.LITERAL_CATCH); @@ -176,7 +176,7 @@ public class JavadocTagInfoTest { } @Test - public void testSerial() throws ReflectiveOperationException { + void serial() throws ReflectiveOperationException { final DetailAstImpl ast = new DetailAstImpl(); final DetailAstImpl astParent = new DetailAstImpl(); astParent.setType(TokenTypes.LITERAL_CATCH); @@ -207,7 +207,7 @@ public class JavadocTagInfoTest { } @Test - public void testException() { + void exception() { final DetailAstImpl ast = new DetailAstImpl(); final int[] validTypes = { @@ -227,7 +227,7 @@ public class JavadocTagInfoTest { } @Test - public void testThrows() { + void testThrows() { final DetailAstImpl ast = new DetailAstImpl(); final int[] validTypes = { @@ -247,7 +247,7 @@ public class JavadocTagInfoTest { } @Test - public void testVersions() { + void versions() { final DetailAstImpl ast = new DetailAstImpl(); final int[] validTypes = { @@ -271,7 +271,7 @@ public class JavadocTagInfoTest { } @Test - public void testParam() { + void param() { final DetailAstImpl ast = new DetailAstImpl(); final int[] validTypes = { @@ -291,7 +291,7 @@ public class JavadocTagInfoTest { } @Test - public void testReturn() { + void testReturn() { final DetailAstImpl ast = new DetailAstImpl(); final DetailAstImpl astChild = new DetailAstImpl(); astChild.setType(TokenTypes.TYPE); @@ -322,7 +322,7 @@ public class JavadocTagInfoTest { } @Test - public void testSerialField() { + void serialField() { final DetailAstImpl ast = new DetailAstImpl(); final DetailAstImpl astChild = new DetailAstImpl(); astChild.setType(TokenTypes.TYPE); @@ -359,7 +359,7 @@ public class JavadocTagInfoTest { } @Test - public void testSerialData() { + void serialData() { final DetailAstImpl ast = new DetailAstImpl(); ast.setType(TokenTypes.METHOD_DEF); final DetailAstImpl astChild = new DetailAstImpl(); @@ -389,7 +389,7 @@ public class JavadocTagInfoTest { } @Test - public void testCoverage() { + void coverage() { assertWithMessage("Invalid type") .that(JavadocTagInfo.VERSION.getType()) .isEqualTo(JavadocTagInfo.Type.BLOCK); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagTest.java @@ -25,14 +25,14 @@ import static com.google.common.truth.Truth.assertWithMessage; import com.puppycrawl.tools.checkstyle.utils.JavadocUtil; import org.junit.jupiter.api.Test; -public class JavadocTagTest { +final class JavadocTagTest { /* Additional test for jacoco, since valueOf() * is generated by javac and jacoco reports that * valueOf() is uncovered. */ @Test - public void testJavadocTagTypeValueOf() { + void javadocTagTypeValueOf() { final JavadocUtil.JavadocTagType enumConst = JavadocUtil.JavadocTagType.valueOf("ALL"); assertWithMessage("Invalid enum valueOf result") .that(enumConst) @@ -44,7 +44,7 @@ public class JavadocTagTest { * values() is uncovered. */ @Test - public void testJavadocTagTypeValues() { + void javadocTagTypeValues() { final JavadocUtil.JavadocTagType[] enumConstants = JavadocUtil.JavadocTagType.values(); final JavadocUtil.JavadocTagType[] expected = { JavadocUtil.JavadocTagType.BLOCK, @@ -55,7 +55,7 @@ public class JavadocTagTest { } @Test - public void testToString() { + void testToString() { final JavadocTag javadocTag = new JavadocTag(0, 1, "author", "firstArg"); final String result = javadocTag.toString(); @@ -66,7 +66,7 @@ public class JavadocTagTest { } @Test - public void testJavadocTagReferenceImports() { + void javadocTagReferenceImports() { assertThat(new JavadocTag(0, 0, "see", null).canReferenceImports()).isTrue(); assertThat(new JavadocTag(0, 0, "link", null).canReferenceImports()).isTrue(); assertThat(new JavadocTag(0, 0, "value", null).canReferenceImports()).isTrue(); @@ -76,7 +76,7 @@ public class JavadocTagTest { } @Test - public void testJavadocTagReferenceImportsInvalid() { + void javadocTagReferenceImportsInvalid() { assertThat(new JavadocTag(0, 0, "author", null).canReferenceImports()).isFalse(); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocTypeCheckTest extends AbstractModuleTestSupport { +final class JavadocTypeCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,7 +38,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final JavadocTypeCheck javadocTypeCheck = new JavadocTypeCheck(); assertWithMessage("JavadocTypeCheck#getRequiredTokens should return empty array by default") .that(javadocTypeCheck.getRequiredTokens()) @@ -46,7 +46,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavadocTypeCheck javadocTypeCheck = new JavadocTypeCheck(); final int[] actual = javadocTypeCheck.getAcceptableTokens(); @@ -62,43 +62,43 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTags() throws Exception { + void tags() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeTags.java"), expected); } @Test - public void testInner() throws Exception { + void inner() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeInner.java"), expected); } @Test - public void testStrict() throws Exception { + void strict() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypePublicOnly.java"), expected); } @Test - public void testProtected() throws Exception { + void testProtected() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypePublicOnly1.java"), expected); } @Test - public void testPublic() throws Exception { + void testPublic() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeScopeInnerInterfaces.java"), expected); } @Test - public void testProtest() throws Exception { + void protest() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeScopeInnerInterfaces1.java"), expected); } @Test - public void testPkg() throws Exception { + void pkg() throws Exception { final String[] expected = { "53:5: " + getCheckMessage(MSG_MISSING_TAG, "@param "), }; @@ -106,13 +106,13 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testEclipse() throws Exception { + void eclipse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeScopeInnerClasses1.java"), expected); } @Test - public void testAuthorRequired() throws Exception { + void authorRequired() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), }; @@ -120,7 +120,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testAuthorRegularEx() throws Exception { + void authorRegularEx() throws Exception { final String[] expected = { "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), "67:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), @@ -130,7 +130,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testAuthorRegularExError() throws Exception { + void authorRegularExError() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"), "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), @@ -146,7 +146,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testVersionRequired() throws Exception { + void versionRequired() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"), }; @@ -154,7 +154,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testVersionRegularEx() throws Exception { + void versionRegularEx() throws Exception { final String[] expected = { "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"), "67:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"), @@ -164,7 +164,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testVersionRegularExError() throws Exception { + void versionRegularExError() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_TAG_FORMAT, "@version", "\\$Revision.*\\$"), "31:1: " + getCheckMessage(MSG_MISSING_TAG, "@version"), @@ -183,7 +183,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopes() throws Exception { + void scopes() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), "137:5: " + getCheckMessage(MSG_MISSING_TAG, "@param "), @@ -192,13 +192,13 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testLimitViolationsBySpecifyingTokens() throws Exception { + void limitViolationsBySpecifyingTokens() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeNoJavadocOnInterface.java"), expected); } @Test - public void testScopes2() throws Exception { + void scopes2() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), }; @@ -206,7 +206,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludeScope() throws Exception { + void excludeScope() throws Exception { final String[] expected = { "137:5: " + getCheckMessage(MSG_MISSING_TAG, "@param "), }; @@ -214,7 +214,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTypeParameters() throws Exception { + void typeParameters() throws Exception { final String[] expected = { "21:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), "25:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), @@ -226,7 +226,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowMissingTypeParameters() throws Exception { + void allowMissingTypeParameters() throws Exception { final String[] expected = { "21:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), "58:8: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), @@ -236,7 +236,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDontAllowUnusedParameterTag() throws Exception { + void dontAllowUnusedParameterTag() throws Exception { final String[] expected = { "20:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", "BAD"), "21:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), @@ -246,7 +246,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testBadTag() throws Exception { + void badTag() throws Exception { final String[] expected = { "19:4: " + getCheckMessage(MSG_UNKNOWN_TAG, "mytag"), }; @@ -254,33 +254,33 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testBadTagSuppress() throws Exception { + void badTagSuppress() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeBadTag_1.java"), expected); } @Test - public void testAllowedAnnotationsDefault() throws Exception { + void allowedAnnotationsDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeAllowedAnnotations.java"), expected); } @Test - public void testAllowedAnnotationsWithFullyQualifiedName() throws Exception { + void allowedAnnotationsWithFullyQualifiedName() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeAllowedAnnotations_1.java"), expected); } @Test - public void testAllowedAnnotationsAllowed() throws Exception { + void allowedAnnotationsAllowed() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocTypeAllowedAnnotations_2.java"), expected); } @Test - public void testAllowedAnnotationsNotAllowed() throws Exception { + void allowedAnnotationsNotAllowed() throws Exception { final String[] expected = { "38:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), @@ -289,7 +289,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocTypeRecords() throws Exception { + void javadocTypeRecords() throws Exception { final String[] expected = { "24:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), "33:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), @@ -301,7 +301,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocTypeRecordComponents() throws Exception { + void javadocTypeRecordComponents() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -310,7 +310,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocTypeRecordComponents2() throws Exception { + void javadocTypeRecordComponents2() throws Exception { final String[] expected = { "44:1: " + getCheckMessage(MSG_MISSING_TAG, "@param "), @@ -331,7 +331,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocTypeInterfaceMemberScopeIsPublic() throws Exception { + void javadocTypeInterfaceMemberScopeIsPublic() throws Exception { final String[] expected = { "19:5: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), @@ -342,7 +342,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = { "21:4: " + getCheckMessage(MSG_UNUSED_TAG, "@param", ""), }; @@ -350,13 +350,13 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testAuthorFormat() throws Exception { + void authorFormat() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocType1.java"), expected); } @Test - public void testAuthorFormat2() throws Exception { + void authorFormat2() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_MISSING_TAG, "@author"), }; @@ -364,7 +364,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocType() throws Exception { + void javadocType() throws Exception { final String[] expected = { "28:5: " + getCheckMessage(MSG_MISSING_TAG, "@param "), }; @@ -372,7 +372,7 @@ public class JavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocType2() throws Exception { + void javadocType2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocType4.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class JavadocVariableCheckTest extends AbstractModuleTestSupport { +final class JavadocVariableCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final JavadocVariableCheck javadocVariableCheck = new JavadocVariableCheck(); final int[] actual = javadocVariableCheck.getRequiredTokens(); final int[] expected = { @@ -45,7 +45,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavadocVariableCheck javadocVariableCheck = new JavadocVariableCheck(); final int[] actual = javadocVariableCheck.getAcceptableTokens(); @@ -57,7 +57,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "18:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "311:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -68,7 +68,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnother() throws Exception { + void another() throws Exception { final String[] expected = { "23:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "30:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -78,13 +78,13 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnother2() throws Exception { + void another2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavadocVariableInner2.java"), expected); } @Test - public void testAnother3() throws Exception { + void another3() throws Exception { final String[] expected = { "17:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "22:13: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -98,7 +98,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnother4() throws Exception { + void another4() throws Exception { final String[] expected = { "52:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -106,7 +106,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocVariableOnInnerClassFields() throws Exception { + void javadocVariableOnInnerClassFields() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -129,7 +129,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocVariableOnPublicInnerClassFields() throws Exception { + void javadocVariableOnPublicInnerClassFields() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -158,7 +158,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopes2() throws Exception { + void scopes2() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -169,7 +169,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludeScope() throws Exception { + void excludeScope() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "18:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -209,7 +209,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoredVariableNames() throws Exception { + void ignoredVariableNames() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -252,7 +252,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testDoNotIgnoreAnythingWhenIgnoreNamePatternIsEmpty() throws Exception { + void doNotIgnoreAnythingWhenIgnoreNamePatternIsEmpty() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -296,7 +296,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaLocalVariablesDoNotNeedJavadoc() throws Exception { + void lambdaLocalVariablesDoNotNeedJavadoc() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -305,7 +305,7 @@ public class JavadocVariableCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfaceMemberScopeIsPublic() throws Exception { + void interfaceMemberScopeIsPublic() throws Exception { final String[] expected = { "18:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import org.junit.jupiter.api.Test; -public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { +final class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,7 +38,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MissingJavadocMethodCheck missingJavadocMethodCheck = new MissingJavadocMethodCheck(); final int[] actual = missingJavadocMethodCheck.getAcceptableTokens(); @@ -53,7 +53,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MissingJavadocMethodCheck missingJavadocMethodCheck = new MissingJavadocMethodCheck(); final int[] actual = missingJavadocMethodCheck.getRequiredTokens(); final int[] expected = CommonUtil.EMPTY_INT_ARRAY; @@ -61,7 +61,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void extendAnnotationTest() throws Exception { + void extendAnnotationTest() throws Exception { final String[] expected = { "44:1: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -70,7 +70,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void newTest() throws Exception { + void newTest() throws Exception { final String[] expected = { "70:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -78,7 +78,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void allowedAnnotationsTest() throws Exception { + void allowedAnnotationsTest() throws Exception { final String[] expected = { "32:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -87,7 +87,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testTags() throws Exception { + void tags() throws Exception { final String[] expected = { "23:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "337:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -98,7 +98,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrictJavadoc() throws Exception { + void strictJavadoc() throws Exception { final String[] expected = { "24:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "30:13: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -117,14 +117,14 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoJavadoc() throws Exception { + void noJavadoc() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMissingJavadocMethodPublicOnly2.java"), expected); } // pre 1.4 relaxed mode is roughly equivalent with check=protected @Test - public void testRelaxedJavadoc() throws Exception { + void relaxedJavadoc() throws Exception { final String[] expected = { "65:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "69:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -135,7 +135,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopeInnerInterfacesPublic() throws Exception { + void scopeInnerInterfacesPublic() throws Exception { final String[] expected = { "52:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "53:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -145,7 +145,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfaceMemberScopeIsPublic() throws Exception { + void interfaceMemberScopeIsPublic() throws Exception { final String[] expected = { "22:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "30:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -155,7 +155,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnumCtorScopeIsPrivate() throws Exception { + void enumCtorScopeIsPrivate() throws Exception { final String[] expected = { "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -164,13 +164,13 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopeAnonInnerPrivate() throws Exception { + void scopeAnonInnerPrivate() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMissingJavadocMethodScopeAnonInner.java"), expected); } @Test - public void testScopeAnonInnerAnonInner() throws Exception { + void scopeAnonInnerAnonInner() throws Exception { final String[] expected = { "34:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "47:13: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -181,7 +181,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopes() throws Exception { + void scopes() throws Exception { final String[] expected = { "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -225,7 +225,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopes2() throws Exception { + void scopes2() throws Exception { final String[] expected = { "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -236,7 +236,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludeScope() throws Exception { + void excludeScope() throws Exception { final String[] expected = { "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "29:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -268,14 +268,14 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testDoAllowMissingJavadocTagsByDefault() throws Exception { + void doAllowMissingJavadocTagsByDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodMissingJavadocTags.java"), expected); } @Test - public void testSetterGetterOff() throws Exception { + void setterGetterOff() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -299,7 +299,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testSetterGetterOnCheck() throws Exception { + void setterGetterOnCheck() throws Exception { final String[] expected = { "30:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "35:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -320,26 +320,26 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void test11684081() throws Exception { + void test11684081() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMissingJavadocMethod_01.java"), expected); } @Test - public void test11684082() throws Exception { + void test11684082() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMissingJavadocMethod_02.java"), expected); } @Test - public void testSkipCertainMethods() throws Exception { + void skipCertainMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodIgnoreNameRegex.java"), expected); } @Test - public void testNotSkipAnythingWhenSkipRegexDoesNotMatch() throws Exception { + void notSkipAnythingWhenSkipRegexDoesNotMatch() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -350,21 +350,21 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowToSkipOverridden() throws Exception { + void allowToSkipOverridden() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodsNotSkipWritten.java"), expected); } @Test - public void testJava8ReceiverParameter() throws Exception { + void java8ReceiverParameter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodReceiverParameter.java"), expected); } @Test - public void testJavadocInMethod() throws Exception { + void javadocInMethod() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -376,7 +376,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testConstructor() throws Exception { + void constructor() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -384,14 +384,14 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotPublicInterfaceMethods() throws Exception { + void notPublicInterfaceMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocMethodInterfacePrivateMethod.java"), expected); } @Test - public void testPublicMethods() throws Exception { + void publicMethods() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "24:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -403,7 +403,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingJavadocMethodRecordsAndCompactCtors() throws Exception { + void missingJavadocMethodRecordsAndCompactCtors() throws Exception { final String[] expected = { "22:9: " + getCheckMessage(MSG_JAVADOC_MISSING), "27:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -417,7 +417,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingJavadocMethodRecordsAndCompactCtorsMinLineCount() throws Exception { + void missingJavadocMethodRecordsAndCompactCtorsMinLineCount() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -427,7 +427,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testMinLineCount() throws Exception { + void minLineCount() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -435,7 +435,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationField() throws Exception { + void annotationField() throws Exception { final String[] expected = { "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "27:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -446,7 +446,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testIsGetterMethod() throws Exception { + void isGetterMethod() throws Exception { final File testFile = new File(getPath("InputMissingJavadocMethodSetterGetter3.java")); final DetailAST notGetterMethod = CheckUtilTest.getNode(testFile, TokenTypes.METHOD_DEF); final DetailAST getterMethod = notGetterMethod.getNextSibling().getNextSibling(); @@ -460,7 +460,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testIsSetterMethod() throws Exception { + void isSetterMethod() throws Exception { final File testFile = new File(getPath("InputMissingJavadocMethodSetterGetter3.java")); final DetailAST firstClassMethod = CheckUtilTest.getNode(testFile, TokenTypes.METHOD_DEF); final DetailAST setterMethod = @@ -476,7 +476,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void testSetterGetterOn() throws Exception { + void setterGetterOn() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MissingJavadocMethodCheck.class, MSG_JAVADOC_MISSING), "24:5: " + getCheckMessage(MissingJavadocMethodCheck.class, MSG_JAVADOC_MISSING), @@ -486,7 +486,7 @@ public class MissingJavadocMethodCheckTest extends AbstractModuleTestSupport { } @Test - public void missingJavadoc() throws Exception { + void missingJavadoc() throws Exception { final String[] expected = { "13:5: " + getCheckMessage(MissingJavadocMethodCheck.class, MSG_JAVADOC_MISSING), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { +final class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,31 +35,31 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageJavadocPresent() throws Exception { + void packageJavadocPresent() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("package-info.java"), expected); } @Test - public void testPackageSingleLineJavadocPresent() throws Exception { + void packageSingleLineJavadocPresent() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("singleline/package-info.java"), expected); } @Test - public void testPackageJavadocPresentWithAnnotation() throws Exception { + void packageJavadocPresentWithAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("annotation/package-info.java"), expected); } @Test - public void testPackageJavadocPresentWithBlankLines() throws Exception { + void packageJavadocPresentWithBlankLines() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("blank/package-info.java"), expected); } @Test - public void testPackageJavadocMissing() throws Exception { + void packageJavadocMissing() throws Exception { final String[] expected = { "7:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -67,7 +67,7 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testBlockCommentInsteadOfJavadoc() throws Exception { + void blockCommentInsteadOfJavadoc() throws Exception { final String[] expected = { "10:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -75,7 +75,7 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testSinglelineCommentInsteadOfJavadoc() throws Exception { + void singlelineCommentInsteadOfJavadoc() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -83,7 +83,7 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testSinglelineCommentInsteadOfJavadoc2() throws Exception { + void singlelineCommentInsteadOfJavadoc2() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -91,7 +91,7 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageJavadocMissingWithAnnotation() throws Exception { + void packageJavadocMissingWithAnnotation() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -99,7 +99,7 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageJavadocMissingWithAnnotationAndBlockComment() throws Exception { + void packageJavadocMissingWithAnnotationAndBlockComment() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -108,7 +108,7 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageJavadocMissingDetachedJavadoc() throws Exception { + void packageJavadocMissingDetachedJavadoc() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -116,13 +116,13 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageJavadocPresentWithHeader() throws Exception { + void packageJavadocPresentWithHeader() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("header/package-info.java"), expected); } @Test - public void testPackageJavadocMissingWithBlankLines() throws Exception { + void packageJavadocMissingWithBlankLines() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_PKG_JAVADOC_MISSING), }; @@ -130,14 +130,14 @@ public class MissingJavadocPackageCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotPackageInfo() throws Exception { + void notPackageInfo() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyFilterWithInlineConfigParser( getPath("InputMissingJavadocPackageNotPackageInfo-package-info.java"), expected); } @Test - public void testTokensAreCorrect() { + void tokensAreCorrect() { final MissingJavadocPackageCheck check = new MissingJavadocPackageCheck(); final int[] expected = { TokenTypes.PACKAGE_DEF, --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { +final class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MissingJavadocTypeCheck missingJavadocTypeCheck = new MissingJavadocTypeCheck(); assertWithMessage( "MissingJavadocTypeCheck#getRequiredTokens should return empty array by default") @@ -44,7 +44,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MissingJavadocTypeCheck missingJavadocTypeCheck = new MissingJavadocTypeCheck(); final int[] actual = missingJavadocTypeCheck.getAcceptableTokens(); @@ -60,7 +60,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTagsOne() throws Exception { + void tagsOne() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "44:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -70,7 +70,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTagsTwo() throws Exception { + void tagsTwo() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -78,7 +78,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTagsThree() throws Exception { + void tagsThree() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -86,7 +86,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testTagsFour() throws Exception { + void tagsFour() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -94,7 +94,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testInner() throws Exception { + void inner() throws Exception { final String[] expected = { "19:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "26:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -104,7 +104,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testStrict() throws Exception { + void strict() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -115,7 +115,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testProtected() throws Exception { + void testProtected() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -123,7 +123,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testPublic() throws Exception { + void testPublic() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "44:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -133,7 +133,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testProtest() throws Exception { + void protest() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "35:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -145,7 +145,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testPkg() throws Exception { + void pkg() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "24:9: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -156,7 +156,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testEclipse() throws Exception { + void eclipse() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -165,7 +165,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopesOne() throws Exception { + void scopesOne() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -176,7 +176,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopesTwo() throws Exception { + void scopesTwo() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "15:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -190,7 +190,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testLimitViolationsBySpecifyingTokens() throws Exception { + void limitViolationsBySpecifyingTokens() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_JAVADOC_MISSING), }; @@ -199,7 +199,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testScopes2() throws Exception { + void scopes2() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "25:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -208,7 +208,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludeScope() throws Exception { + void excludeScope() throws Exception { final String[] expected = { "37:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "49:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -223,14 +223,14 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDontAllowUnusedParameterTag() throws Exception { + void dontAllowUnusedParameterTag() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocTypeUnusedParamInJavadocForClass.java"), expected); } @Test - public void testSkipAnnotationsDefault() throws Exception { + void skipAnnotationsDefault() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -241,7 +241,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testSkipAnnotationsWithFullyQualifiedName() throws Exception { + void skipAnnotationsWithFullyQualifiedName() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), "17:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -251,14 +251,14 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testSkipAnnotationsAllowed() throws Exception { + void skipAnnotationsAllowed() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMissingJavadocTypeSkipAnnotations3.java"), expected); } @Test - public void testSkipAnnotationsNotAllowed() throws Exception { + void skipAnnotationsNotAllowed() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -269,7 +269,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingJavadocTypeCheckRecords() throws Exception { + void missingJavadocTypeCheckRecords() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -285,7 +285,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfaceMemberScopeIsPublic() throws Exception { + void interfaceMemberScopeIsPublic() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -297,7 +297,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testQualifiedAnnotation1() throws Exception { + void qualifiedAnnotation1() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -308,7 +308,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testQualifiedAnnotation2() throws Exception { + void qualifiedAnnotation2() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "23:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -318,7 +318,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testQualifiedAnnotation3() throws Exception { + void qualifiedAnnotation3() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "22:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -328,7 +328,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testQualifiedAnnotation4() throws Exception { + void qualifiedAnnotation4() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "21:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -338,14 +338,14 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testQualifiedAnnotation5() throws Exception { + void qualifiedAnnotation5() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputMissingJavadocTypeQualifiedAnnotation5.java"), expected); } @Test - public void testMultipleQualifiedAnnotation() throws Exception { + void multipleQualifiedAnnotation() throws Exception { final String[] expected = { "29:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "38:5: " + getCheckMessage(MSG_JAVADOC_MISSING), @@ -355,7 +355,7 @@ public class MissingJavadocTypeCheckTest extends AbstractModuleTestSupport { } @Test - public void testQualifiedAnnotationWithParameters() throws Exception { + void qualifiedAnnotationWithParameters() throws Exception { final String[] expected = { "33:5: " + getCheckMessage(MSG_JAVADOC_MISSING), "37:5: " + getCheckMessage(MSG_JAVADOC_MISSING), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckTest.java @@ -31,7 +31,7 @@ import de.thetaphi.forbiddenapis.SuppressForbidden; import java.nio.charset.CodingErrorAction; import org.junit.jupiter.api.Test; -public class NonEmptyAtclauseDescriptionCheckTest extends AbstractModuleTestSupport { +final class NonEmptyAtclauseDescriptionCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class NonEmptyAtclauseDescriptionCheckTest extends AbstractModuleTestSupp } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final NonEmptyAtclauseDescriptionCheck checkObj = new NonEmptyAtclauseDescriptionCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default acceptable tokens are invalid") @@ -48,7 +48,7 @@ public class NonEmptyAtclauseDescriptionCheckTest extends AbstractModuleTestSupp } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final NonEmptyAtclauseDescriptionCheck checkObj = new NonEmptyAtclauseDescriptionCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default required tokens are invalid") @@ -57,7 +57,7 @@ public class NonEmptyAtclauseDescriptionCheckTest extends AbstractModuleTestSupp } @Test - public void testCheckOne() throws Exception { + void checkOne() throws Exception { final String[] expected = { // this is a case with description that is sequences of spaces "37: " + getCheckMessage(MSG_KEY), @@ -82,7 +82,7 @@ public class NonEmptyAtclauseDescriptionCheckTest extends AbstractModuleTestSupp } @Test - public void testCheckTwo() throws Exception { + void checkTwo() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_KEY), "17: " + getCheckMessage(MSG_KEY), @@ -107,7 +107,7 @@ public class NonEmptyAtclauseDescriptionCheckTest extends AbstractModuleTestSupp */ @SuppressForbidden @Test - public void testDecoderOnMalformedInput() throws Exception { + void decoderOnMalformedInput() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final DefaultConfiguration checkConfig = createModuleConfig(NonEmptyAtclauseDescriptionCheck.class); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/RequireEmptyLineBeforeBlockTagGroupCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/RequireEmptyLineBeforeBlockTagGroupCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class RequireEmptyLineBeforeBlockTagGroupCheckTest extends AbstractModuleTestSupport { +final class RequireEmptyLineBeforeBlockTagGroupCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class RequireEmptyLineBeforeBlockTagGroupCheckTest extends AbstractModule } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final RequireEmptyLineBeforeBlockTagGroupCheck checkObj = new RequireEmptyLineBeforeBlockTagGroupCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; @@ -46,7 +46,7 @@ public class RequireEmptyLineBeforeBlockTagGroupCheckTest extends AbstractModule } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { createModuleConfig(RequireEmptyLineBeforeBlockTagGroupCheck.class); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -55,7 +55,7 @@ public class RequireEmptyLineBeforeBlockTagGroupCheckTest extends AbstractModule } @Test - public void testIncorrect() throws Exception { + void incorrect() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_JAVADOC_TAG_LINE_BEFORE, "@since"), "20: " + getCheckMessage(MSG_JAVADOC_TAG_LINE_BEFORE, "@param"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class SingleLineJavadocCheckTest extends AbstractModuleTestSupport { +final class SingleLineJavadocCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class SingleLineJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testAcceptableTokens() { + void acceptableTokens() { final SingleLineJavadocCheck checkObj = new SingleLineJavadocCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default acceptable tokens are invalid") @@ -43,7 +43,7 @@ public class SingleLineJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final SingleLineJavadocCheck checkObj = new SingleLineJavadocCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default required tokens are invalid") @@ -52,7 +52,7 @@ public class SingleLineJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void simpleTest() throws Exception { + void simpleTest() throws Exception { final String[] expected = { "22: " + getCheckMessage(MSG_KEY), "38: " + getCheckMessage(MSG_KEY), @@ -64,7 +64,7 @@ public class SingleLineJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoredTags() throws Exception { + void ignoredTags() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_KEY), "44: " + getCheckMessage(MSG_KEY), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { +final class SummaryJavadocCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,7 +38,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final SummaryJavadocCheck checkObj = new SummaryJavadocCheck(); final int[] expected = {TokenTypes.BLOCK_COMMENT_BEGIN}; assertWithMessage("Default required tokens are invalid") @@ -47,14 +47,14 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testCorrect() throws Exception { + void correct() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSummaryJavadocCorrect.java"), expected); } @Test - public void testInlineCorrect() throws Exception { + void inlineCorrect() throws Exception { final String[] expected = { "112: " + getCheckMessage(MSG_SUMMARY_FIRST_SENTENCE), }; @@ -63,7 +63,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrect() throws Exception { + void incorrect() throws Exception { final String[] expected = { "24: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), "42: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -85,7 +85,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testInlineForbidden() throws Exception { + void inlineForbidden() throws Exception { final String[] expected = { "26: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), "31: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), @@ -103,7 +103,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPeriod() throws Exception { + void period() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_SUMMARY_FIRST_SENTENCE), "19: " + getCheckMessage(MSG_SUMMARY_FIRST_SENTENCE), @@ -114,14 +114,14 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoPeriod() throws Exception { + void noPeriod() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSummaryJavadocNoPeriod.java"), expected); } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = { "23: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), "41: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -142,7 +142,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testIncorrectUsageOfSummaryTag() throws Exception { + void incorrectUsageOfSummaryTag() throws Exception { final String[] expected = { "34: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), "41: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -159,7 +159,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testInlineDefaultConfiguration() throws Exception { + void inlineDefaultConfiguration() throws Exception { final String[] expected = { "22: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), "26: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), @@ -181,7 +181,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testInlineReturn() throws Exception { + void inlineReturn() throws Exception { final String[] expected = { "74: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), }; @@ -190,7 +190,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testInlineReturn2() throws Exception { + void inlineReturn2() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), }; @@ -199,7 +199,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testInlineReturnForbidden() throws Exception { + void inlineReturnForbidden() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_SUMMARY_JAVADOC), "21: " + getCheckMessage(MSG_SUMMARY_JAVADOC), @@ -211,7 +211,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPeriodAtEnd() throws Exception { + void periodAtEnd() throws Exception { final String[] expected = { "19: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), "26: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -224,7 +224,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testHtmlFormatSummary() throws Exception { + void htmlFormatSummary() throws Exception { final String[] expected = { "22: " + getCheckMessage(MSG_SUMMARY_MISSING_PERIOD), "36: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), @@ -235,7 +235,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageInfo() throws Exception { + void packageInfo() throws Exception { final String[] expected = { "10: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), }; @@ -244,7 +244,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageInfoWithAnnotation() throws Exception { + void packageInfoWithAnnotation() throws Exception { final String[] expected = { "10: " + getCheckMessage(MSG_SUMMARY_JAVADOC_MISSING), }; @@ -253,7 +253,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testForbidden() throws Exception { + void forbidden() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_SUMMARY_JAVADOC), }; @@ -263,14 +263,14 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyPeriod() throws Exception { + void emptyPeriod() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSummaryJavadocEmptyPeriod.java"), expected); } @Test - public void testForbidden3() throws Exception { + void forbidden3() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_SUMMARY_JAVADOC), }; @@ -280,7 +280,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testForbidden2() throws Exception { + void forbidden2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -288,14 +288,14 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testSummaryJavaDoc() throws Exception { + void summaryJavaDoc() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSummaryJavadoc1.java"), expected); } @Test - public void testSummaryJavaDoc2() throws Exception { + void summaryJavaDoc2() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_SUMMARY_JAVADOC), }; @@ -304,7 +304,7 @@ public class SummaryJavadocCheckTest extends AbstractModuleTestSupport { } @Test - public void testInheritDoc() throws Exception { + void inheritDoc() throws Exception { final String[] expected = { "14: " + getCheckMessage(MSG_SUMMARY_FIRST_SENTENCE), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckTest.java @@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck.MSG_MISSING_TAG; import static com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck.MSG_TAG_FORMAT; import static com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck.MSG_WRITE_TAG; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.Checker; @@ -31,14 +32,13 @@ import java.io.ByteArrayInputStream; import java.io.File; import java.io.InputStreamReader; import java.io.LineNumberReader; -import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.junit.jupiter.api.Test; /** Unit test for WriteTagCheck. */ -public class WriteTagCheckTest extends AbstractModuleTestSupport { +final class WriteTagCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -46,13 +46,13 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultSettings() throws Exception { + void defaultSettings() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputWriteTagDefault.java"), expected); } @Test - public void testTag() throws Exception { + void tag() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_WRITE_TAG, "@author", "Daniel Grenner"), }; @@ -60,7 +60,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingFormat() throws Exception { + void missingFormat() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_WRITE_TAG, "@author", "Daniel Grenner"), }; @@ -68,7 +68,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testTagIncomplete() throws Exception { + void tagIncomplete() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete", "This class needs more code..."), }; @@ -76,7 +76,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testDoubleTag() throws Exception { + void doubleTag() throws Exception { final String[] expected = { "18: " + getCheckMessage(MSG_WRITE_TAG, "@doubletag", "first text"), "19: " + getCheckMessage(MSG_WRITE_TAG, "@doubletag", "second text"), @@ -85,7 +85,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyTag() throws Exception { + void emptyTag() throws Exception { final String[] expected = { "19: " + getCheckMessage(MSG_WRITE_TAG, "@emptytag", ""), }; @@ -93,7 +93,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testMissingTag() throws Exception { + void missingTag() throws Exception { final String[] expected = { "20: " + getCheckMessage(MSG_MISSING_TAG, "@missingtag"), }; @@ -101,7 +101,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethod() throws Exception { + void method() throws Exception { final String[] expected = { "24: " + getCheckMessage(MSG_WRITE_TAG, "@todo", "Add a constructor comment"), "36: " + getCheckMessage(MSG_WRITE_TAG, "@todo", "Add a comment"), @@ -110,7 +110,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testSeverity() throws Exception { + void severity() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_WRITE_TAG, "@author", "Daniel Grenner"), }; @@ -118,19 +118,19 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreMissing() throws Exception { + void ignoreMissing() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputWriteTagIgnore.java"), expected); } @Test - public void testRegularEx() throws Exception { + void regularEx() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputWriteTagRegularExpression.java"), expected); } @Test - public void testRegularExError() throws Exception { + void regularExError() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_TAG_FORMAT, "@author", "ABC"), }; @@ -138,7 +138,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnumsAndAnnotations() throws Exception { + void enumsAndAnnotations() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_WRITE_TAG, "@incomplete", "This enum needs more code..."), "21: " @@ -152,7 +152,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoJavadocs() throws Exception { + void noJavadocs() throws Exception { final String[] expected = { "13: " + getCheckMessage(MSG_MISSING_TAG, "null"), }; @@ -160,7 +160,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { } @Test - public void testWriteTagRecordsAndCompactCtors() throws Exception { + void writeTagRecordsAndCompactCtors() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_MISSING_TAG, "@incomplete"), "19: " + getCheckMessage(MSG_TAG_FORMAT, "@incomplete", "\\S"), @@ -196,8 +196,7 @@ public class WriteTagCheckTest extends AbstractModuleTestSupport { // process each of the lines try (ByteArrayInputStream localStream = new ByteArrayInputStream(getStream().toByteArray()); - LineNumberReader lnr = - new LineNumberReader(new InputStreamReader(localStream, StandardCharsets.UTF_8))) { + LineNumberReader lnr = new LineNumberReader(new InputStreamReader(localStream, UTF_8))) { for (int i = 0; i < expected.length; i++) { final String expectedResult = messageFileName + ":" + expected[i]; final String actual = lnr.readLine(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/utils/BlockTagUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/utils/BlockTagUtilTest.java @@ -25,17 +25,17 @@ import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import java.util.List; import org.junit.jupiter.api.Test; -public class BlockTagUtilTest { +final class BlockTagUtilTest { @Test - public void testHasPrivateConstructor() throws Exception { + void hasPrivateConstructor() throws Exception { assertWithMessage("Constructor is not private") .that(TestUtil.isUtilsClassHasPrivateConstructor(BlockTagUtil.class)) .isTrue(); } @Test - public void testExtractBlockTags() { + void extractBlockTags() { final String[] text = { "/** @foo abc ", " * @bar def ", " @baz ghi ", " * @qux jkl", " */", }; @@ -57,7 +57,7 @@ public class BlockTagUtilTest { } @Test - public void testVersionStringFormat() { + void versionStringFormat() { final String[] text = { "/** ", " * @version 1.0", " */", }; @@ -68,7 +68,7 @@ public class BlockTagUtilTest { } @Test - public void testOddVersionString() { + void oddVersionString() { final String[] text = {"/**", " * Foo", " * @version 1.0 */"}; final List tags = BlockTagUtil.extractBlockTags(text); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/utils/InlineTagUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/utils/InlineTagUtilTest.java @@ -25,17 +25,17 @@ import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import java.util.List; import org.junit.jupiter.api.Test; -public class InlineTagUtilTest { +final class InlineTagUtilTest { @Test - public void testHasPrivateConstructor() throws Exception { + void hasPrivateConstructor() throws Exception { assertWithMessage("Constructor is not private") .that(TestUtil.isUtilsClassHasPrivateConstructor(InlineTagUtil.class)) .isTrue(); } @Test - public void testExtractInlineTags() { + void testExtractInlineTags() { final String[] text = { "/** @see elsewhere ", " * {@link List }, {@link List link text }", @@ -54,7 +54,7 @@ public class InlineTagUtilTest { } @Test - public void testMultiLineLinkTag() { + void multiLineLinkTag() { final String[] text = {"/**", " * {@link foo", " * bar baz}", " */"}; final List tags = InlineTagUtil.extractInlineTags(text); @@ -64,7 +64,7 @@ public class InlineTagUtilTest { } @Test - public void testCollapseWhitespace() { + void collapseWhitespace() { final String[] text = {"/**", " * {@code foo\t\t bar baz\t }", " */"}; final List tags = InlineTagUtil.extractInlineTags(text); @@ -74,7 +74,7 @@ public class InlineTagUtilTest { } @Test - public void extractInlineTags() { + void extractInlineTags() { final String[] source = { " {@link foo}", }; @@ -88,7 +88,7 @@ public class InlineTagUtilTest { } @Test - public void testBadInputExtractInlineTagsLineFeed() { + void badInputExtractInlineTagsLineFeed() { try { InlineTagUtil.extractInlineTags("abc\ndef"); assertWithMessage("IllegalArgumentException expected").fail(); @@ -98,7 +98,7 @@ public class InlineTagUtilTest { } @Test - public void testBadInputExtractInlineTagsCarriageReturn() { + void badInputExtractInlineTagsCarriageReturn() { try { InlineTagUtil.extractInlineTags("abc\rdef"); assertWithMessage("IllegalArgumentException expected").fail(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupport { +final class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupp } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "21:9: " + getCheckMessage(MSG_KEY, 4, 3), @@ -51,7 +51,7 @@ public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupp } @Test - public void testNoBitwise() throws Exception { + void noBitwise() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -59,7 +59,7 @@ public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupp } @Test - public void testNullPointerException() throws Exception { + void nullPointerException() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -67,7 +67,7 @@ public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupp } @Test - public void testWrongToken() { + void wrongToken() { final BooleanExpressionComplexityCheck booleanExpressionComplexityCheckObj = new BooleanExpressionComplexityCheck(); final DetailAstImpl ast = new DetailAstImpl(); @@ -83,7 +83,7 @@ public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupp } @Test - public void testSmall() throws Exception { + void small() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -91,7 +91,7 @@ public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupp } @Test - public void testBooleanExpressionComplexityRecordsAndCompactCtors() throws Exception { + void booleanExpressionComplexityRecordsAndCompactCtors() throws Exception { final int max = 3; @@ -108,7 +108,7 @@ public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupp } @Test - public void testLeaves() throws Exception { + void leaves() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -116,7 +116,7 @@ public class BooleanExpressionComplexityCheckTest extends AbstractModuleTestSupp } @Test - public void testRecordLeaves() throws Exception { + void recordLeaves() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckTest.java @@ -31,7 +31,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSupport { +final class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testTokens() { + void tokens() { final ClassDataAbstractionCouplingCheck check = new ClassDataAbstractionCouplingCheck(); assertWithMessage("Required tokens should not be null") .that(check.getRequiredTokens()) @@ -56,7 +56,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_KEY, 4, 0, "[AnotherInnerClass, HashMap, HashSet, int]"), @@ -68,7 +68,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testExcludedPackageDirectPackages() throws Exception { + void excludedPackageDirectPackages() throws Exception { final String[] expected = { "28:1: " + getCheckMessage(MSG_KEY, 2, 0, "[BasicHttpContext, TlsCiphers]"), }; @@ -78,7 +78,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testExcludedPackageCommonPackages() throws Exception { + void excludedPackageCommonPackages() throws Exception { final String[] expected = { "28:1: " + getCheckMessage(MSG_KEY, 2, 0, "[BasicHttpContext, TlsCiphers]"), "32:5: " + getCheckMessage(MSG_KEY, 2, 0, "[BasicClientTlsStrategy, CommandSupport]"), @@ -89,7 +89,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testExcludedPackageWithEndingDot() throws Exception { + void excludedPackageWithEndingDot() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(ClassDataAbstractionCouplingCheck.class); @@ -118,20 +118,20 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testExcludedPackageCommonPackagesAllIgnored() throws Exception { + void excludedPackageCommonPackagesAllIgnored() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassDataAbstractionCouplingExcludedPackagesAllIgnored.java"), expected); } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputClassDataAbstractionCoupling2.java"), expected); } @Test - public void testWrongToken() { + void wrongToken() { final ClassDataAbstractionCouplingCheck classDataAbstractionCouplingCheckObj = new ClassDataAbstractionCouplingCheck(); final DetailAstImpl ast = new DetailAstImpl(); @@ -147,7 +147,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testRegularExpression() throws Exception { + void regularExpression() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_KEY, 2, 0, "[AnotherInnerClass, int]"), @@ -158,7 +158,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testEmptyRegularExpression() throws Exception { + void emptyRegularExpression() throws Exception { final String[] expected = { "22:1: " + getCheckMessage(MSG_KEY, 4, 0, "[AnotherInnerClass, HashMap, HashSet, int]"), @@ -170,7 +170,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testClassDataAbstractionCouplingRecords() throws Exception { + void classDataAbstractionCouplingRecords() throws Exception { final int maxAbstraction = 1; final String[] expected = { @@ -186,7 +186,7 @@ public class ClassDataAbstractionCouplingCheckTest extends AbstractModuleTestSup } @Test - public void testNew() throws Exception { + void testNew() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheckTest.java @@ -36,7 +36,7 @@ import java.util.Map; import java.util.Optional; import org.junit.jupiter.api.Test; -public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { +final class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -44,7 +44,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "27:1: " + getCheckMessage(MSG_KEY, 3, 0), "59:1: " + getCheckMessage(MSG_KEY, 1, 0), @@ -54,7 +54,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludedPackagesDirectPackages() throws Exception { + void excludedPackagesDirectPackages() throws Exception { final String[] expected = { "29:1: " + getCheckMessage(MSG_KEY, 2, 0), }; @@ -64,7 +64,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludedPackagesCommonPackages() throws Exception { + void excludedPackagesCommonPackages() throws Exception { final String[] expected = { "28:1: " + getCheckMessage(MSG_KEY, 2, 0), "32:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -75,7 +75,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludedPackagesCommonPackagesWithEndingDot() throws Exception { + void excludedPackagesCommonPackagesWithEndingDot() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(ClassFanOutComplexityCheck.class); checkConfig.addProperty("max", "0"); @@ -103,14 +103,14 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testExcludedPackagesAllIgnored() throws Exception { + void excludedPackagesAllIgnored() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassFanOutComplexityExcludedPackagesAllIgnored.java"), expected); } @Test - public void test15() throws Exception { + void test15() throws Exception { final String[] expected = { "29:1: " + getCheckMessage(MSG_KEY, 1, 0), @@ -120,13 +120,13 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputClassFanOutComplexity2.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final ClassFanOutComplexityCheck classFanOutComplexityCheckObj = new ClassFanOutComplexityCheck(); final int[] actual = classFanOutComplexityCheckObj.getAcceptableTokens(); @@ -150,7 +150,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testRegularExpression() throws Exception { + void regularExpression() throws Exception { final String[] expected = { "44:1: " + getCheckMessage(MSG_KEY, 2, 0), "76:1: " + getCheckMessage(MSG_KEY, 1, 0), @@ -160,7 +160,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyRegularExpression() throws Exception { + void emptyRegularExpression() throws Exception { final String[] expected = { "44:1: " + getCheckMessage(MSG_KEY, 3, 0), "76:1: " + getCheckMessage(MSG_KEY, 1, 0), @@ -170,7 +170,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithMultiDimensionalArray() throws Exception { + void withMultiDimensionalArray() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -178,14 +178,14 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageName() throws Exception { + void packageName() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputClassFanOutComplexityPackageName.java"), expected); } @Test - public void testExtends() throws Exception { + void testExtends() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_KEY, 1, 0), }; @@ -193,7 +193,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testImplements() throws Exception { + void testImplements() throws Exception { final String[] expected = { "23:1: " + getCheckMessage(MSG_KEY, 1, 0), }; @@ -201,7 +201,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotation() throws Exception { + void annotation() throws Exception { final String[] expected = { "29:1: " + getCheckMessage(MSG_KEY, 2, 0), "45:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -215,7 +215,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testImplementsAndNestedCount() throws Exception { + void implementsAndNestedCount() throws Exception { final String[] expected = { "26:1: " + getCheckMessage(MSG_KEY, 3, 0), }; @@ -224,7 +224,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassFanOutComplexityRecords() throws Exception { + void classFanOutComplexityRecords() throws Exception { final String[] expected = { "32:1: " + getCheckMessage(MSG_KEY, 4, 2), "53:1: " + getCheckMessage(MSG_KEY, 4, 2), }; @@ -233,27 +233,27 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassFanOutComplexityIgnoreVar() throws Exception { + void classFanOutComplexityIgnoreVar() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputClassFanOutComplexityVar.java"), expected); } @Test - public void testClassFanOutComplexityRemoveIncorrectAnnotationToken() throws Exception { + void classFanOutComplexityRemoveIncorrectAnnotationToken() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassFanOutComplexityRemoveIncorrectAnnotationToken.java"), expected); } @Test - public void testClassFanOutComplexityRemoveIncorrectTypeParameter() throws Exception { + void classFanOutComplexityRemoveIncorrectTypeParameter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassFanOutComplexityRemoveIncorrectTypeParameter.java"), expected); } @Test - public void testClassFanOutComplexityMultiCatchBitwiseOr() throws Exception { + void classFanOutComplexityMultiCatchBitwiseOr() throws Exception { final String[] expected = { "27:1: " + getCheckMessage(MSG_KEY, 5, 4), }; @@ -263,7 +263,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testThrows() throws Exception { + void testThrows() throws Exception { final String[] expected = { "25:1: " + getCheckMessage(MSG_KEY, 2, 0), }; @@ -277,9 +277,9 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { * * @throws Exception when code tested throws exception */ - @Test @SuppressWarnings("unchecked") - public void testClearStateImportedClassPackages() throws Exception { + @Test + void clearStateImportedClassPackages() throws Exception { final ClassFanOutComplexityCheck check = new ClassFanOutComplexityCheck(); final DetailAST root = JavaParser.parseFile( @@ -293,7 +293,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - importAst.get(), + importAst.orElseThrow(), "importedClassPackages", importedClssPackage -> ((Map) importedClssPackage).isEmpty())) .isTrue(); @@ -306,7 +306,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws exception */ @Test - public void testClearStateClassContexts() throws Exception { + void clearStateClassContexts() throws Exception { final ClassFanOutComplexityCheck check = new ClassFanOutComplexityCheck(); final DetailAST root = JavaParser.parseFile( @@ -320,7 +320,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - classDef.get(), + classDef.orElseThrow(), "classesContexts", classContexts -> ((Collection) classContexts).size() == 1)) .isTrue(); @@ -333,7 +333,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { * @throws Exception when code tested throws exception */ @Test - public void testClearStatePackageName() throws Exception { + void clearStatePackageName() throws Exception { final ClassFanOutComplexityCheck check = new ClassFanOutComplexityCheck(); final DetailAST root = JavaParser.parseFile( @@ -347,7 +347,7 @@ public class ClassFanOutComplexityCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - packageDef.get(), + packageDef.orElseThrow(), "packageName", packageName -> ((String) packageName).isEmpty())) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { +final class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchBlockAsSingleDecisionPointSetToTrue() throws Exception { + void switchBlockAsSingleDecisionPointSetToTrue() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -45,7 +45,7 @@ public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchBlockAsSingleDecisionPointSetToFalse() throws Exception { + void switchBlockAsSingleDecisionPointSetToFalse() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, 5, 0), @@ -55,7 +55,7 @@ public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualsMaxComplexity() throws Exception { + void equalsMaxComplexity() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -63,7 +63,7 @@ public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "15:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -82,7 +82,7 @@ public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testCyclomaticComplexityRecords() throws Exception { + void cyclomaticComplexityRecords() throws Exception { final int max = 0; @@ -99,7 +99,7 @@ public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final CyclomaticComplexityCheck cyclomaticComplexityCheckObj = new CyclomaticComplexityCheck(); final int[] actual = cyclomaticComplexityCheckObj.getAcceptableTokens(); final int[] expected = { @@ -123,7 +123,7 @@ public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final CyclomaticComplexityCheck cyclomaticComplexityCheckObj = new CyclomaticComplexityCheck(); final int[] actual = cyclomaticComplexityCheckObj.getRequiredTokens(); final int[] expected = { @@ -137,14 +137,14 @@ public class CyclomaticComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testHighMax() throws Exception { + void highMax() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputCyclomaticComplexitySwitchBlocks4.java"), expected); } @Test - public void testDefaultMax() throws Exception { + void defaultMax() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, 12, 10), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckTest.java @@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test; /** Test case for the JavaNCSS-Check. */ // -@cs[AbbreviationAsWordInName] Test should be named as its main class. -public class JavaNCSSCheckTest extends AbstractModuleTestSupport { +final class JavaNCSSCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -40,7 +40,7 @@ public class JavaNCSSCheckTest extends AbstractModuleTestSupport { } @Test - public void test() throws Exception { + void test() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_FILE, 39, 2), @@ -62,7 +62,7 @@ public class JavaNCSSCheckTest extends AbstractModuleTestSupport { } @Test - public void testEqualToMax() throws Exception { + void equalToMax() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -70,13 +70,13 @@ public class JavaNCSSCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJavaNCSS3.java"), expected); } @Test - public void testRecordsAndCompactCtors() throws Exception { + void recordsAndCompactCtors() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_FILE, 89, 2), @@ -99,7 +99,7 @@ public class JavaNCSSCheckTest extends AbstractModuleTestSupport { } @Test - public void testForMutation() throws Exception { + void forMutation() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_CLASS, 84, 80), "16:5: " + getCheckMessage(MSG_CLASS, 83, 80), }; @@ -107,7 +107,7 @@ public class JavaNCSSCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordMax() throws Exception { + void recordMax() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_CLASS, 152, 80), "15:5: " + getCheckMessage(MSG_RECORD, 151, 150), @@ -117,7 +117,7 @@ public class JavaNCSSCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final JavaNCSSCheck javaNcssCheckObj = new JavaNCSSCheck(); final int[] actual = javaNcssCheckObj.getAcceptableTokens(); final int[] expected = { @@ -157,7 +157,7 @@ public class JavaNCSSCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final JavaNCSSCheck javaNcssCheckObj = new JavaNCSSCheck(); final int[] actual = javaNcssCheckObj.getRequiredTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckTest.java @@ -40,7 +40,7 @@ import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; // -@cs[AbbreviationAsWordInName] Can't change check name -public class NPathComplexityCheckTest extends AbstractModuleTestSupport { +final class NPathComplexityCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -48,7 +48,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testCalculation() throws Exception { + void calculation() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 2, 0), "17:17: " + getCheckMessage(MSG_KEY, 2, 0), @@ -70,7 +70,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testCalculation2() throws Exception { + void calculation2() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 5, 0), "18:5: " + getCheckMessage(MSG_KEY, 5, 0), @@ -92,7 +92,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testCalculation3() throws Exception { + void calculation3() throws Exception { final String[] expected = { "11:5: " + getCheckMessage(MSG_KEY, 64, 0), }; @@ -102,7 +102,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testIntegerOverflow() throws Exception { + void integerOverflow() throws Exception { final long largerThanMaxInt = 3_486_784_401L; @@ -113,9 +113,9 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { verifyWithInlineConfigParser(getPath("InputNPathComplexityOverflow.java"), expected); } - @Test @SuppressWarnings("unchecked") - public void testStatefulFieldsClearedOnBeginTree1() { + @Test + void statefulFieldsClearedOnBeginTree1() { final DetailAstImpl ast = new DetailAstImpl(); ast.setType(TokenTypes.LITERAL_ELSE); @@ -151,9 +151,9 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { .isTrue(); } - @Test @SuppressWarnings("unchecked") - public void testStatefulFieldsClearedOnBeginTree2() { + @Test + void statefulFieldsClearedOnBeginTree2() { final DetailAstImpl ast = new DetailAstImpl(); ast.setType(TokenTypes.LITERAL_RETURN); ast.setLineNo(5); @@ -173,7 +173,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testStatefulFieldsClearedOnBeginTree3() throws Exception { + void statefulFieldsClearedOnBeginTree3() throws Exception { final NPathComplexityCheck check = new NPathComplexityCheck(); final Optional question = TestUtil.findTokenInAstByPredicate( @@ -188,7 +188,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - question.get(), + question.orElseThrow(), "processingTokenEnd", processingTokenEnd -> { return TestUtil.getInternalState(processingTokenEnd, "endLineNo") == 0 @@ -198,13 +198,13 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNPathComplexityDefault2.java"), expected); } @Test - public void testNpathComplexityRecords() throws Exception { + void npathComplexityRecords() throws Exception { final int max = 1; final String[] expected = { @@ -219,7 +219,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testNpathComplexitySwitchExpression() throws Exception { + void npathComplexitySwitchExpression() throws Exception { final int max = 1; @@ -235,7 +235,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testBranchVisited() throws Exception { + void branchVisited() throws Exception { final String[] expected = { "13:3: " + getCheckMessage(MSG_KEY, 37, 20), @@ -245,7 +245,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testCount() throws Exception { + void count() throws Exception { final String[] expected = { "11:5: " + getCheckMessage(MSG_KEY, 30, 20), @@ -257,7 +257,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final NPathComplexityCheck npathComplexityCheckObj = new NPathComplexityCheck(); final int[] actual = npathComplexityCheckObj.getAcceptableTokens(); final int[] expected = { @@ -285,7 +285,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final NPathComplexityCheck npathComplexityCheckObj = new NPathComplexityCheck(); final int[] actual = npathComplexityCheckObj.getRequiredTokens(); final int[] expected = { @@ -313,7 +313,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultHooks() { + void defaultHooks() { final NPathComplexityCheck npathComplexityCheckObj = new NPathComplexityCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(new CommonToken(TokenTypes.INTERFACE_DEF, "interface")); @@ -341,7 +341,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { * @throws Exception if there is an error. */ @Test - public void testTokenEndIsAfterSameLineColumn() throws Exception { + void tokenEndIsAfterSameLineColumn() throws Exception { final NPathComplexityCheck check = new NPathComplexityCheck(); final Object tokenEnd = TestUtil.getInternalState(check, "processingTokenEnd"); final DetailAstImpl token = new DetailAstImpl(); @@ -354,7 +354,7 @@ public class NPathComplexityCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitTokenBeforeExpressionRange() { + void visitTokenBeforeExpressionRange() { // Create first ast final DetailAstImpl astIf = mockAST(TokenTypes.LITERAL_IF, "if", 2, 2); final DetailAstImpl astIfLeftParen = mockAST(TokenTypes.LPAREN, "(", 3, 3); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ClassMemberImpliedModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ClassMemberImpliedModifierCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSupport { +final class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSuppo } @Test - public void testMethodsOnClass() throws Exception { + void methodsOnClass() throws Exception { final String[] expected = { "51:9: " + getCheckMessage(MSG_KEY, "static"), "58:9: " + getCheckMessage(MSG_KEY, "static"), @@ -49,7 +49,7 @@ public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSuppo } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final ClassMemberImpliedModifierCheck check = new ClassMemberImpliedModifierCheck(); final int[] actual = check.getRequiredTokens(); final int[] expected = { @@ -59,7 +59,7 @@ public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSuppo } @Test - public void testMethodsOnClassNoImpliedStaticEnum() throws Exception { + void methodsOnClassNoImpliedStaticEnum() throws Exception { final String[] expected = { "59:9: " + getCheckMessage(MSG_KEY, "static"), "77:9: " + getCheckMessage(MSG_KEY, "static"), @@ -70,7 +70,7 @@ public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSuppo } @Test - public void testMethodsOnClassNoImpliedStaticInterface() throws Exception { + void methodsOnClassNoImpliedStaticInterface() throws Exception { final String[] expected = { "52:9: " + getCheckMessage(MSG_KEY, "static"), "63:5: " + getCheckMessage(MSG_KEY, "static"), @@ -81,14 +81,14 @@ public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSuppo } @Test - public void testMethodsOnClassNoViolationsChecked() throws Exception { + void methodsOnClassNoViolationsChecked() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputClassMemberImpliedModifierOnClassNoViolations.java"), expected); } @Test - public void testMethodsOnInterface() throws Exception { + void methodsOnInterface() throws Exception { final String[] expected = { "60:13: " + getCheckMessage(MSG_KEY, "static"), "67:13: " + getCheckMessage(MSG_KEY, "static"), @@ -102,7 +102,7 @@ public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSuppo } @Test - public void testClassMemberImpliedModifierRecords() throws Exception { + void classMemberImpliedModifierRecords() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY, "static"), "20:5: " + getCheckMessage(MSG_KEY, "static"), @@ -117,7 +117,7 @@ public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSuppo } @Test - public void testClassMemberImpliedModifierNoViolationRecords() throws Exception { + void classMemberImpliedModifierNoViolationRecords() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY, "static"), "20:5: " + getCheckMessage(MSG_KEY, "static"), @@ -129,7 +129,7 @@ public class ClassMemberImpliedModifierCheckTest extends AbstractModuleTestSuppo } @Test - public void testIllegalState() { + void illegalState() { final DetailAstImpl init = new DetailAstImpl(); init.setType(TokenTypes.STATIC_INIT); final DetailAstImpl objBlock = new DetailAstImpl(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestSupport { +final class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testMethodsOnInterfaceNoImpliedPublicAbstract() throws Exception { + void methodsOnInterfaceNoImpliedPublicAbstract() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY, "public"), "27:5: " + getCheckMessage(MSG_KEY, "public"), @@ -50,7 +50,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final InterfaceMemberImpliedModifierCheck check = new InterfaceMemberImpliedModifierCheck(); final int[] actual = check.getRequiredTokens(); final int[] expected = { @@ -64,7 +64,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testMethodsOnInterfaceNoImpliedAbstractAllowImpliedPublic() throws Exception { + void methodsOnInterfaceNoImpliedAbstractAllowImpliedPublic() throws Exception { final String[] expected = { "36:5: " + getCheckMessage(MSG_KEY, "abstract"), "38:5: " + getCheckMessage(MSG_KEY, "abstract"), @@ -74,7 +74,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testMethodsOnInterfaceNoImpliedPublicAllowImpliedAbstract() throws Exception { + void methodsOnInterfaceNoImpliedPublicAllowImpliedAbstract() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY, "public"), "27:5: " + getCheckMessage(MSG_KEY, "public"), @@ -86,21 +86,21 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testMethodsOnInterfaceAllowImpliedPublicAbstract() throws Exception { + void methodsOnInterfaceAllowImpliedPublicAbstract() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierMethodsOnInterface4.java"), expected); } @Test - public void testMethodsOnClassIgnored() throws Exception { + void methodsOnClassIgnored() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierMethodsOnClass.java"), expected); } @Test - public void testMethodsOnInterfaceNestedNoImpliedPublicAbstract() throws Exception { + void methodsOnInterfaceNestedNoImpliedPublicAbstract() throws Exception { final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY, "public"), "29:9: " + getCheckMessage(MSG_KEY, "public"), @@ -114,7 +114,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testMethodsOnClassNestedNoImpliedPublicAbstract() throws Exception { + void methodsOnClassNestedNoImpliedPublicAbstract() throws Exception { final String[] expected = { "23:9: " + getCheckMessage(MSG_KEY, "public"), "29:9: " + getCheckMessage(MSG_KEY, "public"), @@ -128,7 +128,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testFieldsOnInterfaceNoImpliedPublicStaticFinal() throws Exception { + void fieldsOnInterfaceNoImpliedPublicStaticFinal() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY, "final"), "22:5: " + getCheckMessage(MSG_KEY, "static"), @@ -148,7 +148,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testFieldsOnInterfaceNoImpliedPublicStaticAllowImpliedFinal() throws Exception { + void fieldsOnInterfaceNoImpliedPublicStaticAllowImpliedFinal() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY, "static"), "24:5: " + getCheckMessage(MSG_KEY, "static"), @@ -164,7 +164,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testFieldsOnInterfaceNoImpliedPublicFinalAllowImpliedStatic() throws Exception { + void fieldsOnInterfaceNoImpliedPublicFinalAllowImpliedStatic() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY, "final"), "24:5: " + getCheckMessage(MSG_KEY, "final"), @@ -180,7 +180,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testFieldsOnInterfaceNoImpliedStaticFinalAllowImpliedPublic() throws Exception { + void fieldsOnInterfaceNoImpliedStaticFinalAllowImpliedPublic() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY, "final"), "22:5: " + getCheckMessage(MSG_KEY, "static"), @@ -196,21 +196,21 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testFieldsOnInterfaceAllowImpliedPublicStaticFinal() throws Exception { + void fieldsOnInterfaceAllowImpliedPublicStaticFinal() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierFieldsOnInterface5.java"), expected); } @Test - public void testFieldsOnClassIgnored() throws Exception { + void fieldsOnClassIgnored() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierFieldsOnClass.java"), expected); } @Test - public void testNestedOnInterfaceNoImpliedPublicStatic() throws Exception { + void nestedOnInterfaceNoImpliedPublicStatic() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY, "static"), "24:5: " + getCheckMessage(MSG_KEY, "public"), @@ -230,7 +230,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testNestedOnInterfaceNoImpliedStaticAllowImpliedPublic() throws Exception { + void nestedOnInterfaceNoImpliedStaticAllowImpliedPublic() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_KEY, "static"), "27:5: " + getCheckMessage(MSG_KEY, "static"), @@ -244,7 +244,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testNestedOnInterfaceNoImpliedPublicAllowImpliedStatic() throws Exception { + void nestedOnInterfaceNoImpliedPublicAllowImpliedStatic() throws Exception { final String[] expected = { "24:5: " + getCheckMessage(MSG_KEY, "public"), "27:5: " + getCheckMessage(MSG_KEY, "public"), @@ -258,21 +258,21 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testNestedOnInterfaceAllowImpliedPublicStatic() throws Exception { + void nestedOnInterfaceAllowImpliedPublicStatic() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierNestedOnInterface4.java"), expected); } @Test - public void testNestedOnClassIgnored() throws Exception { + void nestedOnClassIgnored() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierNestedOnClass.java"), expected); } @Test - public void testNestedOnInterfaceNestedNoImpliedPublicStatic() throws Exception { + void nestedOnInterfaceNestedNoImpliedPublicStatic() throws Exception { final String[] expected = { "20:9: " + getCheckMessage(MSG_KEY, "public"), "20:9: " + getCheckMessage(MSG_KEY, "static"), @@ -286,7 +286,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testNestedOnClassNestedNoImpliedPublicStatic() throws Exception { + void nestedOnClassNestedNoImpliedPublicStatic() throws Exception { final String[] expected = { "20:9: " + getCheckMessage(MSG_KEY, "public"), "20:9: " + getCheckMessage(MSG_KEY, "static"), @@ -300,7 +300,7 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testPackageScopeInterface() throws Exception { + void packageScopeInterface() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY, "final"), "22:5: " + getCheckMessage(MSG_KEY, "static"), @@ -330,14 +330,14 @@ public class InterfaceMemberImpliedModifierCheckTest extends AbstractModuleTestS } @Test - public void testPrivateMethodsOnInterface() throws Exception { + void privateMethodsOnInterface() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputInterfaceMemberImpliedModifierPrivateMethods.java"), expected); } @Test - public void testIllegalState() { + void illegalState() { final DetailAstImpl init = new DetailAstImpl(); init.setType(TokenTypes.STATIC_INIT); final DetailAstImpl objBlock = new DetailAstImpl(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class ModifierOrderCheckTest extends AbstractModuleTestSupport { +final class ModifierOrderCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class ModifierOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final ModifierOrderCheck checkObj = new ModifierOrderCheck(); final int[] expected = {TokenTypes.MODIFIERS}; assertWithMessage("Default required tokens are invalid") @@ -45,7 +45,7 @@ public class ModifierOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "15:10: " + getCheckMessage(MSG_MODIFIER_ORDER, "final"), "19:12: " + getCheckMessage(MSG_MODIFIER_ORDER, "private"), @@ -59,13 +59,13 @@ public class ModifierOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultMethods() throws Exception { + void defaultMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputModifierOrderDefaultMethods.java"), expected); } @Test - public void testGetDefaultTokens() { + void getDefaultTokens() { final ModifierOrderCheck modifierOrderCheckObj = new ModifierOrderCheck(); final int[] actual = modifierOrderCheckObj.getDefaultTokens(); final int[] expected = {TokenTypes.MODIFIERS}; @@ -82,7 +82,7 @@ public class ModifierOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final ModifierOrderCheck modifierOrderCheckObj = new ModifierOrderCheck(); final int[] actual = modifierOrderCheckObj.getAcceptableTokens(); final int[] expected = {TokenTypes.MODIFIERS}; @@ -99,7 +99,7 @@ public class ModifierOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testSkipTypeAnnotations() throws Exception { + void skipTypeAnnotations() throws Exception { final String[] expected = { "110:13: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@MethodAnnotation"), }; @@ -107,7 +107,7 @@ public class ModifierOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationOnAnnotationDeclaration() throws Exception { + void annotationOnAnnotationDeclaration() throws Exception { final String[] expected = { "9:8: " + getCheckMessage(MSG_ANNOTATION_ORDER, "@InterfaceAnnotation"), }; @@ -115,7 +115,7 @@ public class ModifierOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testModifierOrderSealedAndNonSealed() throws Exception { + void modifierOrderSealedAndNonSealed() throws Exception { final String[] expected = { "10:8: " + getCheckMessage(MSG_MODIFIER_ORDER, "public"), "26:12: " + getCheckMessage(MSG_MODIFIER_ORDER, "private"), @@ -129,7 +129,7 @@ public class ModifierOrderCheckTest extends AbstractModuleTestSupport { } @Test - public void testModifierOrderSealedAndNonSealedNoViolation() throws Exception { + void modifierOrderSealedAndNonSealedNoViolation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputModifierOrderSealedAndNonSealedNoViolation.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class RedundantModifierCheckTest extends AbstractModuleTestSupport { +final class RedundantModifierCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassesInsideOfInterfaces() throws Exception { + void classesInsideOfInterfaces() throws Exception { final String[] expected = { "19:5: " + getCheckMessage(MSG_KEY, "static"), "25:5: " + getCheckMessage(MSG_KEY, "public"), @@ -49,7 +49,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "57:12: " + getCheckMessage(MSG_KEY, "static"), "60:9: " + getCheckMessage(MSG_KEY, "public"), @@ -70,14 +70,14 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testStaticMethodInInterface() throws Exception { + void staticMethodInInterface() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRedundantModifierStaticMethodInInterface.java"), expected); } @Test - public void testFinalInInterface() throws Exception { + void finalInInterface() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(MSG_KEY, "final"), }; @@ -85,7 +85,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnumConstructorIsImplicitlyPrivate() throws Exception { + void enumConstructorIsImplicitlyPrivate() throws Exception { final String[] expected = { "14:5: " + getCheckMessage(MSG_KEY, "private"), }; @@ -94,7 +94,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testInnerTypeInInterfaceIsImplicitlyStatic() throws Exception { + void innerTypeInInterfaceIsImplicitlyStatic() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, "static"), "16:5: " + getCheckMessage(MSG_KEY, "static"), }; @@ -103,7 +103,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotPublicClassConstructorHasNotPublicModifier() throws Exception { + void notPublicClassConstructorHasNotPublicModifier() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY, "public"), @@ -113,7 +113,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testNestedClassConsInPublicInterfaceHasValidPublicModifier() throws Exception { + void nestedClassConsInPublicInterfaceHasValidPublicModifier() throws Exception { final String[] expected = { "22:17: " + getCheckMessage(MSG_KEY, "public"), @@ -127,7 +127,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final RedundantModifierCheck redundantModifierCheckObj = new RedundantModifierCheck(); final int[] actual = redundantModifierCheckObj.getAcceptableTokens(); final int[] expected = { @@ -146,7 +146,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongTokenType() { + void wrongTokenType() { final RedundantModifierCheck obj = new RedundantModifierCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(TokenTypes.LITERAL_NULL, "null"); @@ -165,7 +165,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final RedundantModifierCheck redundantModifierCheckObj = new RedundantModifierCheck(); final int[] actual = redundantModifierCheckObj.getRequiredTokens(); final int[] expected = CommonUtil.EMPTY_INT_ARRAY; @@ -173,7 +173,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testNestedStaticEnum() throws Exception { + void nestedStaticEnum() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, "static"), "16:9: " + getCheckMessage(MSG_KEY, "static"), @@ -184,7 +184,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalInAnonymousClass() throws Exception { + void finalInAnonymousClass() throws Exception { final String[] expected = { "22:20: " + getCheckMessage(MSG_KEY, "final"), }; @@ -193,7 +193,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalInTryWithResource() throws Exception { + void finalInTryWithResource() throws Exception { final String[] expected = { "38:14: " + getCheckMessage(MSG_KEY, "final"), "43:14: " + getCheckMessage(MSG_KEY, "final"), @@ -204,7 +204,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testFinalInAbstractMethods() throws Exception { + void finalInAbstractMethods() throws Exception { final String[] expected = { "12:33: " + getCheckMessage(MSG_KEY, "final"), "16:49: " + getCheckMessage(MSG_KEY, "final"), @@ -217,7 +217,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnumMethods() throws Exception { + void enumMethods() throws Exception { final String[] expected = { "15:16: " + getCheckMessage(MSG_KEY, "final"), "30:16: " + getCheckMessage(MSG_KEY, "final"), }; @@ -226,7 +226,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnumStaticMethodsInPublicClass() throws Exception { + void enumStaticMethodsInPublicClass() throws Exception { final String[] expected = { "20:23: " + getCheckMessage(MSG_KEY, "final"), }; @@ -235,7 +235,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationOnEnumConstructor() throws Exception { + void annotationOnEnumConstructor() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY, "private"), }; @@ -244,7 +244,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testPrivateMethodInPrivateClass() throws Exception { + void privateMethodInPrivateClass() throws Exception { final String[] expected = { "13:17: " + getCheckMessage(MSG_KEY, "final"), }; @@ -253,7 +253,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResourcesBlock() throws Exception { + void tryWithResourcesBlock() throws Exception { final String[] expected = { "18:19: " + getCheckMessage(MSG_KEY, "final"), }; @@ -261,7 +261,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testNestedDef() throws Exception { + void nestedDef() throws Exception { final String[] expected = { "10:5: " + getCheckMessage(MSG_KEY, "public"), "11:5: " + getCheckMessage(MSG_KEY, "static"), @@ -291,7 +291,7 @@ public class RedundantModifierCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecords() throws Exception { + void records() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, "static"), "16:9: " + getCheckMessage(MSG_KEY, "final"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameCheckTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport { +final class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final int expectedCapitalCount = 4; final String[] expected = { @@ -51,7 +51,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeNamesForThreePermittedCapitalLetters() throws Exception { + void typeNamesForThreePermittedCapitalLetters() throws Exception { final int expectedCapitalCount = 4; final String[] expected = { @@ -65,7 +65,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeNamesForFourPermittedCapitalLetters() throws Exception { + void typeNamesForFourPermittedCapitalLetters() throws Exception { final int expectedCapitalCount = 5; final String[] expected = { @@ -76,7 +76,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeNamesForFivePermittedCapitalLetters() throws Exception { + void typeNamesForFivePermittedCapitalLetters() throws Exception { final int expectedCapitalCount = 6; final String[] expected = { "45:11: " + getWarningMessage("AbstractINNERRClass", expectedCapitalCount), @@ -87,7 +87,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNames() throws Exception { + void typeAndVariablesAndMethodNames() throws Exception { final int expectedCapitalCount = 6; final String[] expected = { @@ -102,7 +102,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNamesWithNoIgnores() throws Exception { + void typeAndVariablesAndMethodNamesWithNoIgnores() throws Exception { final int expectedCapitalCount = 6; final String[] expected = { @@ -122,7 +122,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNamesWithIgnores() throws Exception { + void typeAndVariablesAndMethodNamesWithIgnores() throws Exception { final int expectedCapitalCount = 6; final String[] expected = { @@ -138,7 +138,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNamesWithIgnoresFinal() throws Exception { + void typeAndVariablesAndMethodNamesWithIgnoresFinal() throws Exception { final int expectedCapitalCount = 5; final String[] expected = { @@ -155,7 +155,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNamesWithIgnoresStatic() throws Exception { + void typeAndVariablesAndMethodNamesWithIgnoresStatic() throws Exception { final int expectedCapitalCount = 5; final String[] expected = { @@ -172,7 +172,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNamesWithIgnoresStaticFinal() throws Exception { + void typeAndVariablesAndMethodNamesWithIgnoresStaticFinal() throws Exception { final int expectedCapitalCount = 5; final String[] expected = { @@ -190,7 +190,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNamesWithIgnoresNonStaticFinal() throws Exception { + void typeAndVariablesAndMethodNamesWithIgnoresNonStaticFinal() throws Exception { final int expectedCapitalCount = 5; final String[] expected = { @@ -219,7 +219,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNamesWithIgnoresFinalKeepStaticFinal() throws Exception { + void typeAndVariablesAndMethodNamesWithIgnoresFinalKeepStaticFinal() throws Exception { final int expectedCapitalCount = 5; final String[] expected = { @@ -242,8 +242,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeAndVariablesAndMethodNamesWithIgnoresStaticKeepStaticFinal() - throws Exception { + void typeAndVariablesAndMethodNamesWithIgnoresStaticKeepStaticFinal() throws Exception { final int expectedCapitalCount = 5; final String[] expected = { @@ -266,7 +265,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeNamesForThreePermittedCapitalLettersWithOverriddenMethod() throws Exception { + void typeNamesForThreePermittedCapitalLettersWithOverriddenMethod() throws Exception { final int expectedCapitalCount = 4; final String[] expected = { @@ -278,7 +277,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testOverriddenMethod() throws Exception { + void overriddenMethod() throws Exception { final int expectedCapitalCount = 4; final String[] expected = { @@ -293,7 +292,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testTypeNamesForZeroPermittedCapitalLetter() throws Exception { + void typeNamesForZeroPermittedCapitalLetter() throws Exception { final int expectedCapitalCount = 1; final String[] expected = { "20:16: " + getWarningMessage("NonAAAAbstractClassName6", expectedCapitalCount), @@ -329,7 +328,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testNullPointerException() throws Exception { + void nullPointerException() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -338,7 +337,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testAbbreviationAsWordInNameCheckEnhancedInstanceof() throws Exception { + void abbreviationAsWordInNameCheckEnhancedInstanceof() throws Exception { final int expectedCapitalCount = 4; @@ -355,8 +354,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testAbbreviationAsWordInNameCheckEnhancedInstanceofAllowXmlLength1() - throws Exception { + void abbreviationAsWordInNameCheckEnhancedInstanceofAllowXmlLength1() throws Exception { final int expectedCapitalCount = 2; @@ -375,7 +373,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testAbbreviationAsWordInNameCheckRecords() throws Exception { + void abbreviationAsWordInNameCheckRecords() throws Exception { final int expectedCapitalCount = 4; @@ -406,14 +404,14 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testReceiver() throws Exception { + void receiver() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAbbreviationAsWordInNameReceiver.java"), expected); } @Test - public void testInputAbbreviationAsWordInNameTypeSnakeStyle() throws Exception { + void inputAbbreviationAsWordInNameTypeSnakeStyle() throws Exception { final String[] expected = { "13:20: " + getWarningMessage("FLAG_IS_FIRST_RUN", 4), "16:17: " + getWarningMessage("HYBRID_LOCK_PATH", 4), @@ -431,7 +429,7 @@ public class AbbreviationAsWordInNameCheckTest extends AbstractModuleTestSupport } @Test - public void testAnnotation() throws Exception { + void annotation() throws Exception { final String[] expected = { "16:12: " + getWarningMessage("readMETHOD", 4), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class AbstractClassNameCheckTest extends AbstractModuleTestSupport { +final class AbstractClassNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class AbstractClassNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalAbstractClassName() throws Exception { + void illegalAbstractClassName() throws Exception { final String pattern = "^Abstract.+$"; @@ -50,7 +50,7 @@ public class AbstractClassNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomFormat() throws Exception { + void customFormat() throws Exception { final String[] expected = { "13:1: " @@ -68,7 +68,7 @@ public class AbstractClassNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalClassType() throws Exception { + void illegalClassType() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MSG_NO_ABSTRACT_CLASS_MODIFIER, "AbstractClassType"), @@ -79,7 +79,7 @@ public class AbstractClassNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllVariants() throws Exception { + void allVariants() throws Exception { final String pattern = "^Abstract.+$"; @@ -99,7 +99,7 @@ public class AbstractClassNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testFalsePositive() throws Exception { + void falsePositive() throws Exception { final String pattern = "^Abstract.+$"; final String[] expected = { "13:1: " @@ -118,7 +118,7 @@ public class AbstractClassNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AbstractClassNameCheck classNameCheckObj = new AbstractClassNameCheck(); final int[] actual = classNameCheckObj.getAcceptableTokens(); final int[] expected = { @@ -128,7 +128,7 @@ public class AbstractClassNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AbstractClassNameCheck classNameCheckObj = new AbstractClassNameCheck(); final int[] actual = classNameCheckObj.getRequiredTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AccessModifierOptionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/AccessModifierOptionTest.java @@ -23,10 +23,10 @@ import static com.google.common.truth.Truth.assertWithMessage; import org.junit.jupiter.api.Test; -public class AccessModifierOptionTest { +final class AccessModifierOptionTest { @Test - public void testDefaultCase() { + void defaultCase() { assertWithMessage("Case mismatch.") .that(AccessModifierOption.PUBLIC.name()) .isEqualTo("PUBLIC"); @@ -42,7 +42,7 @@ public class AccessModifierOptionTest { } @Test - public void testCase() { + void testCase() { assertWithMessage("Case mismatch.") .that(AccessModifierOption.PUBLIC.toString()) .isEqualTo("public"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class CatchParameterNameCheckTest extends AbstractModuleTestSupport { +final class CatchParameterNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class CatchParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testTokens() { + void tokens() { final CatchParameterNameCheck catchParameterNameCheck = new CatchParameterNameCheck(); final int[] expected = {TokenTypes.PARAMETER_DEF}; @@ -48,14 +48,14 @@ public class CatchParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultConfigurationOnCorrectFile() throws Exception { + void defaultConfigurationOnCorrectFile() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputCatchParameterNameSimple.java"), expected); } @Test - public void testDefaultConfigurationOnFileWithViolations() throws Exception { + void defaultConfigurationOnFileWithViolations() throws Exception { final String defaultFormat = "^(e|t|ex|[a-z][a-z][a-zA-Z]+)$"; final String[] expected = { @@ -73,7 +73,7 @@ public class CatchParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomFormatFromJavadoc() throws Exception { + void customFormatFromJavadoc() throws Exception { final String[] expected = { "13:28: " + getCheckMessage(MSG_INVALID_PATTERN, "e", "^[a-z][a-zA-Z0-9]+$"), @@ -84,7 +84,7 @@ public class CatchParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomFormatWithNoAnchors() throws Exception { + void customFormatWithNoAnchors() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class ClassTypeParameterNameCheckTest extends AbstractModuleTestSupport { +final class ClassTypeParameterNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class ClassTypeParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetClassRequiredTokens() { + void getClassRequiredTokens() { final ClassTypeParameterNameCheck checkObj = new ClassTypeParameterNameCheck(); final int[] expected = {TokenTypes.TYPE_PARAMETER}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class ClassTypeParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassDefault() throws Exception { + void classDefault() throws Exception { final String pattern = "^[A-Z]$"; @@ -56,7 +56,7 @@ public class ClassTypeParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassFooName() throws Exception { + void classFooName() throws Exception { final String pattern = "^foo$"; @@ -68,7 +68,7 @@ public class ClassTypeParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final ClassTypeParameterNameCheck typeParameterNameCheckObj = new ClassTypeParameterNameCheck(); final int[] actual = typeParameterNameCheckObj.getAcceptableTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class ConstantNameCheckTest extends AbstractModuleTestSupport { +final class ConstantNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class ConstantNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final ConstantNameCheck checkObj = new ConstantNameCheck(); final int[] expected = {TokenTypes.VARIABLE_DEF}; assertWithMessage("Default required tokens are invalid") @@ -46,7 +46,7 @@ public class ConstantNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalRegexp() throws Exception { + void illegalRegexp() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(ConstantNameCheck.class); checkConfig.addProperty("format", "\\"); try { @@ -64,7 +64,7 @@ public class ConstantNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -76,7 +76,7 @@ public class ConstantNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testAccessControlTuning() throws Exception { + void accessControlTuning() throws Exception { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -87,7 +87,7 @@ public class ConstantNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfaceAndAnnotation() throws Exception { + void interfaceAndAnnotation() throws Exception { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -99,13 +99,13 @@ public class ConstantNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault1() throws Exception { + void default1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputConstantName.java"), expected); } @Test - public void testIntoInterface() throws Exception { + void intoInterface() throws Exception { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -123,21 +123,21 @@ public class ConstantNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIntoInterfaceExcludePublic() throws Exception { + void intoInterfaceExcludePublic() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputConstantNameInterfaceIgnorePublic.java"), expected); } @Test - public void testStaticMethodInInterface() throws Exception { + void staticMethodInInterface() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputConstantNameStaticModifierInInterface.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final ConstantNameCheck constantNameCheckObj = new ConstantNameCheck(); final int[] actual = constantNameCheckObj.getAcceptableTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { +final class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final IllegalIdentifierNameCheck illegalIdentifierNameCheck = new IllegalIdentifierNameCheck(); final int[] expected = { TokenTypes.CLASS_DEF, @@ -59,7 +59,7 @@ public class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final IllegalIdentifierNameCheck illegalIdentifierNameCheck = new IllegalIdentifierNameCheck(); final int[] expected = CommonUtil.EMPTY_INT_ARRAY; @@ -69,7 +69,7 @@ public class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalIdentifierNameDefault() throws Exception { + void illegalIdentifierNameDefault() throws Exception { final String format = "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$"; @@ -92,7 +92,7 @@ public class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalIdentifierNameOpenTransitive() throws Exception { + void illegalIdentifierNameOpenTransitive() throws Exception { final String format = "(?i)^(?!(record|yield|var|permits|sealed|open|transitive)$).+$"; final String[] expected = { @@ -116,7 +116,7 @@ public class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalIdentifierNameParameterReceiver() throws Exception { + void illegalIdentifierNameParameterReceiver() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -125,7 +125,7 @@ public class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalIdentifierNameUnderscore() throws Exception { + void illegalIdentifierNameUnderscore() throws Exception { final String format = "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$"; final String[] expected = { @@ -136,7 +136,7 @@ public class IllegalIdentifierNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalIdentifierNameLambda() throws Exception { + void illegalIdentifierNameLambda() throws Exception { final String format = "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$"; final String[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class InterfaceTypeParameterNameCheckTest extends AbstractModuleTestSupport { +final class InterfaceTypeParameterNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class InterfaceTypeParameterNameCheckTest extends AbstractModuleTestSuppo } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final InterfaceTypeParameterNameCheck interfaceTypeParameterNameCheck = new InterfaceTypeParameterNameCheck(); final int[] expected = {TokenTypes.TYPE_PARAMETER}; @@ -45,7 +45,7 @@ public class InterfaceTypeParameterNameCheckTest extends AbstractModuleTestSuppo } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final InterfaceTypeParameterNameCheck checkObj = new InterfaceTypeParameterNameCheck(); final int[] expected = {TokenTypes.TYPE_PARAMETER}; assertWithMessage("Default required tokens are invalid") @@ -54,7 +54,7 @@ public class InterfaceTypeParameterNameCheckTest extends AbstractModuleTestSuppo } @Test - public void testInterfaceDefault() throws Exception { + void interfaceDefault() throws Exception { final String pattern = "^[A-Z]$"; @@ -65,7 +65,7 @@ public class InterfaceTypeParameterNameCheckTest extends AbstractModuleTestSuppo } @Test - public void testInterfaceFooName() throws Exception { + void interfaceFooName() throws Exception { final String pattern = "^foo$"; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class LambdaParameterNameCheckTest extends AbstractModuleTestSupport { +final class LambdaParameterNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class LambdaParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final int[] expected = { TokenTypes.LAMBDA, }; @@ -45,7 +45,7 @@ public class LambdaParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testAcceptableTokens() { + void acceptableTokens() { final int[] expected = { TokenTypes.LAMBDA, }; @@ -56,7 +56,7 @@ public class LambdaParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testParametersInLambda() throws Exception { + void parametersInLambda() throws Exception { final String pattern = "^(id)|([a-z][a-z0-9][a-zA-Z0-9]+)$"; @@ -71,7 +71,7 @@ public class LambdaParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaParameterNameSwitchExpression() throws Exception { + void lambdaParameterNameSwitchExpression() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class LocalFinalVariableNameCheckTest extends AbstractModuleTestSupport { +final class LocalFinalVariableNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class LocalFinalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final LocalFinalVariableNameCheck checkObj = new LocalFinalVariableNameCheck(); assertWithMessage( "LocalFinalVariableNameCheck#getRequiredTokens should return empty array " @@ -45,7 +45,7 @@ public class LocalFinalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -56,7 +56,7 @@ public class LocalFinalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testSet() throws Exception { + void set() throws Exception { final String pattern = "[A-Z]+"; @@ -67,13 +67,13 @@ public class LocalFinalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testInnerClass() throws Exception { + void innerClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLocalFinalVariableNameInnerClass.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final LocalFinalVariableNameCheck localFinalVariableNameCheckObj = new LocalFinalVariableNameCheck(); final int[] actual = localFinalVariableNameCheckObj.getAcceptableTokens(); @@ -84,7 +84,7 @@ public class LocalFinalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResources() throws Exception { + void tryWithResources() throws Exception { final String pattern = "[A-Z]+"; @@ -99,7 +99,7 @@ public class LocalFinalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResourcesJava9() throws Exception { + void tryWithResourcesJava9() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class LocalVariableNameCheckTest extends AbstractModuleTestSupport { +final class LocalVariableNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class LocalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final LocalVariableNameCheck localVariableNameCheck = new LocalVariableNameCheck(); final int[] expected = {TokenTypes.VARIABLE_DEF}; @@ -45,7 +45,7 @@ public class LocalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -59,13 +59,13 @@ public class LocalVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testInnerClass() throws Exception { + void innerClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLocalVariableNameInnerClass.java"), expected); } @Test - public void testLoopVariables() throws Exception { + void loopVariables() throws Exception { final String pattern = "^[a-z]{2,}[a-zA-Z0-9]*$"; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class MemberNameCheckTest extends AbstractModuleTestSupport { +final class MemberNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MemberNameCheck checkObj = new MemberNameCheck(); final int[] expected = {TokenTypes.VARIABLE_DEF}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpecified() throws Exception { + void specified() throws Exception { final String pattern = "^m[A-Z][a-zA-Z0-9]*$"; @@ -55,7 +55,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testInnerClass() throws Exception { + void innerClass() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -66,7 +66,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaults() throws Exception { + void defaults() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -80,7 +80,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testUnderlined() throws Exception { + void underlined() throws Exception { final String pattern = "^_[a-z]*$"; @@ -94,7 +94,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testPublicOnly() throws Exception { + void publicOnly() throws Exception { final String pattern = "^_[a-z]*$"; @@ -105,7 +105,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testProtectedOnly() throws Exception { + void protectedOnly() throws Exception { final String pattern = "^_[a-z]*$"; @@ -116,7 +116,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageOnly() throws Exception { + void packageOnly() throws Exception { final String pattern = "^_[a-z]*$"; @@ -127,7 +127,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testPrivateOnly() throws Exception { + void privateOnly() throws Exception { final String pattern = "^_[a-z]*$"; @@ -138,7 +138,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotPrivate() throws Exception { + void notPrivate() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -151,7 +151,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void memberNameExtended() throws Exception { + void memberNameExtended() throws Exception { final String pattern = "^[a-z][a-z0-9][a-zA-Z0-9]*$"; @@ -193,7 +193,7 @@ public class MemberNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MemberNameCheck memberNameCheckObj = new MemberNameCheck(); final int[] actual = memberNameCheckObj.getAcceptableTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MethodNameCheckTest extends AbstractModuleTestSupport { +final class MethodNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MethodNameCheck checkObj = new MethodNameCheck(); final int[] expected = {TokenTypes.METHOD_DEF}; assertWithMessage("Default required tokens are invalid") @@ -45,7 +45,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -56,7 +56,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodEqClass() throws Exception { + void methodEqClass() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -80,7 +80,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodEqClassAllow() throws Exception { + void methodEqClassAllow() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { @@ -98,7 +98,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testAccessTuning() throws Exception { + void accessTuning() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { @@ -114,7 +114,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testForNpe() throws Exception { + void forNpe() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -122,7 +122,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testOverriddenMethods() throws Exception { + void overriddenMethods() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -135,7 +135,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfacesExcludePublic() throws Exception { + void interfacesExcludePublic() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { @@ -148,7 +148,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfacesExcludePrivate() throws Exception { + void interfacesExcludePrivate() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { @@ -163,7 +163,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MethodNameCheck methodNameCheckObj = new MethodNameCheck(); final int[] actual = methodNameCheckObj.getAcceptableTokens(); final int[] expected = { @@ -173,7 +173,7 @@ public class MethodNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordInInterfaceBody() throws Exception { + void recordInInterfaceBody() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class MethodTypeParameterNameCheckTest extends AbstractModuleTestSupport { +final class MethodTypeParameterNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class MethodTypeParameterNameCheckTest extends AbstractModuleTestSupport } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MethodTypeParameterNameCheck methodTypeParameterNameCheck = new MethodTypeParameterNameCheck(); final int[] expected = {TokenTypes.TYPE_PARAMETER}; @@ -45,7 +45,7 @@ public class MethodTypeParameterNameCheckTest extends AbstractModuleTestSupport } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MethodTypeParameterNameCheck checkObj = new MethodTypeParameterNameCheck(); final int[] expected = {TokenTypes.TYPE_PARAMETER}; assertWithMessage("Default required tokens are invalid") @@ -54,7 +54,7 @@ public class MethodTypeParameterNameCheckTest extends AbstractModuleTestSupport } @Test - public void testMethodDefault() throws Exception { + void methodDefault() throws Exception { final String pattern = "^[A-Z]$"; @@ -69,7 +69,7 @@ public class MethodTypeParameterNameCheckTest extends AbstractModuleTestSupport } @Test - public void testMethodFooName() throws Exception { + void methodFooName() throws Exception { final String pattern = "^foo$"; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class PackageNameCheckTest extends AbstractModuleTestSupport { +final class PackageNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class PackageNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final PackageNameCheck checkObj = new PackageNameCheck(); final int[] expected = {TokenTypes.PACKAGE_DEF}; assertWithMessage("Default required tokens are invalid") @@ -44,7 +44,7 @@ public class PackageNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpecified() throws Exception { + void specified() throws Exception { final String pattern = "[A-Z]+"; @@ -57,13 +57,13 @@ public class PackageNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputPackageNameSimple.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final PackageNameCheck packageNameCheckObj = new PackageNameCheck(); final int[] actual = packageNameCheckObj.getAcceptableTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class ParameterNameCheckTest extends AbstractModuleTestSupport { +final class ParameterNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class ParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final ParameterNameCheck checkObj = new ParameterNameCheck(); final int[] expected = {TokenTypes.PARAMETER_DEF}; assertWithMessage("Default required tokens are invalid") @@ -45,13 +45,13 @@ public class ParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testCatch() throws Exception { + void testCatch() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParameterNameCatchOnly.java"), expected); } @Test - public void testSpecified() throws Exception { + void specified() throws Exception { final String pattern = "^a[A-Z][a-zA-Z0-9]*$"; @@ -64,7 +64,7 @@ public class ParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceInAccessModifierProperty() throws Exception { + void whitespaceInAccessModifierProperty() throws Exception { final String pattern = "^h$"; final String[] expected = { "14:69: " + getCheckMessage(MSG_INVALID_PATTERN, "parameter1", pattern), @@ -75,13 +75,13 @@ public class ParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParameterName.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final ParameterNameCheck parameterNameCheckObj = new ParameterNameCheck(); final int[] actual = parameterNameCheckObj.getAcceptableTokens(); final int[] expected = { @@ -91,7 +91,7 @@ public class ParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testSkipMethodsWithOverrideAnnotationTrue() throws Exception { + void skipMethodsWithOverrideAnnotationTrue() throws Exception { final String pattern = "^h$"; @@ -108,7 +108,7 @@ public class ParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testSkipMethodsWithOverrideAnnotationFalse() throws Exception { + void skipMethodsWithOverrideAnnotationFalse() throws Exception { final String pattern = "^h$"; @@ -126,7 +126,7 @@ public class ParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testPublicAccessModifier() throws Exception { + void publicAccessModifier() throws Exception { final String pattern = "^h$"; @@ -142,32 +142,32 @@ public class ParameterNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIsOverriddenNoNullPointerException() throws Exception { + void isOverriddenNoNullPointerException() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParameterNameOverrideAnnotationNoNPE.java"), expected); } @Test - public void testReceiverParameter() throws Exception { + void receiverParameter() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParameterNameReceiver.java"), expected); } @Test - public void testLambdaParameterNoViolationAtAll() throws Exception { + void lambdaParameterNoViolationAtAll() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParameterNameLambda.java"), expected); } @Test - public void testWhitespaceInConfig() throws Exception { + void whitespaceInConfig() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParameterNameWhitespaceInConfig.java"), expected); } @Test - public void testSetAccessModifiers() throws Exception { + void setAccessModifiers() throws Exception { final AccessModifierOption[] input = { AccessModifierOption.PACKAGE, }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PatternVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/PatternVariableNameCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class PatternVariableNameCheckTest extends AbstractModuleTestSupport { +final class PatternVariableNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class PatternVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final PatternVariableNameCheck patternVariableNameCheck = new PatternVariableNameCheck(); final int[] expected = {TokenTypes.PATTERN_VARIABLE_DEF}; @@ -44,7 +44,7 @@ public class PatternVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -65,7 +65,7 @@ public class PatternVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testPatternVariableNameNoSingleChar() throws Exception { + void patternVariableNameNoSingleChar() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]+$"; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordComponentNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordComponentNameCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class RecordComponentNameCheckTest extends AbstractModuleTestSupport { +final class RecordComponentNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class RecordComponentNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetClassRequiredTokens() { + void getClassRequiredTokens() { final RecordComponentNameCheck checkObj = new RecordComponentNameCheck(); final int[] expected = {TokenTypes.RECORD_COMPONENT_DEF}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class RecordComponentNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordDefault() throws Exception { + void recordDefault() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -58,7 +58,7 @@ public class RecordComponentNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassFooName() throws Exception { + void classFooName() throws Exception { final String pattern = "^[a-z0-9]+$"; @@ -73,7 +73,7 @@ public class RecordComponentNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final RecordComponentNameCheck typeParameterNameCheckObj = new RecordComponentNameCheck(); final int[] actual = typeParameterNameCheckObj.getAcceptableTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordTypeParameterNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordTypeParameterNameCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class RecordTypeParameterNameCheckTest extends AbstractModuleTestSupport { +final class RecordTypeParameterNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class RecordTypeParameterNameCheckTest extends AbstractModuleTestSupport } @Test - public void testGetClassRequiredTokens() { + void getClassRequiredTokens() { final RecordTypeParameterNameCheck checkObj = new RecordTypeParameterNameCheck(); final int[] expected = {TokenTypes.TYPE_PARAMETER}; assertWithMessage("Default required tokens are invalid") @@ -43,7 +43,7 @@ public class RecordTypeParameterNameCheckTest extends AbstractModuleTestSupport } @Test - public void testRecordDefault() throws Exception { + void recordDefault() throws Exception { final String pattern = "^[A-Z]$"; @@ -57,7 +57,7 @@ public class RecordTypeParameterNameCheckTest extends AbstractModuleTestSupport } @Test - public void testClassFooName() throws Exception { + void classFooName() throws Exception { final String pattern = "^foo$"; @@ -71,7 +71,7 @@ public class RecordTypeParameterNameCheckTest extends AbstractModuleTestSupport } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final RecordTypeParameterNameCheck typeParameterNameCheckObj = new RecordTypeParameterNameCheck(); final int[] actual = typeParameterNameCheckObj.getAcceptableTokens(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class StaticVariableNameCheckTest extends AbstractModuleTestSupport { +final class StaticVariableNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class StaticVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final StaticVariableNameCheck checkObj = new StaticVariableNameCheck(); final int[] expected = {TokenTypes.VARIABLE_DEF}; assertWithMessage("Default required tokens are invalid") @@ -44,7 +44,7 @@ public class StaticVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpecified() throws Exception { + void specified() throws Exception { final String pattern = "^s[A-Z][a-zA-Z0-9]*$"; @@ -55,19 +55,19 @@ public class StaticVariableNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testAccessTuning() throws Exception { + void accessTuning() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputStaticVariableName2.java"), expected); } @Test - public void testInterfaceOrAnnotationBlock() throws Exception { + void interfaceOrAnnotationBlock() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputStaticVariableName.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final StaticVariableNameCheck staticVariableNameCheckObj = new StaticVariableNameCheck(); final int[] actual = staticVariableNameCheckObj.getAcceptableTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.TypeNameCheck.DEFAUL import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class TypeNameCheckTest extends AbstractModuleTestSupport { +final class TypeNameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class TypeNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpecified() throws Exception { + void specified() throws Exception { final String[] expected = { "25:14: " + getCheckMessage(MSG_INVALID_PATTERN, "InputTypeName", "^inputHe"), }; @@ -41,7 +41,7 @@ public class TypeNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "15:7: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderClass2", DEFAULT_PATTERN), "17:22: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderInterface", DEFAULT_PATTERN), @@ -52,7 +52,7 @@ public class TypeNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassSpecific() throws Exception { + void classSpecific() throws Exception { final String[] expected = { "15:7: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderClass3", DEFAULT_PATTERN), }; @@ -60,7 +60,7 @@ public class TypeNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfaceSpecific() throws Exception { + void interfaceSpecific() throws Exception { final String[] expected = { "17:22: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderInterface", DEFAULT_PATTERN), }; @@ -68,7 +68,7 @@ public class TypeNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnumSpecific() throws Exception { + void enumSpecific() throws Exception { final String[] expected = { "19:17: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderEnum", DEFAULT_PATTERN), }; @@ -76,7 +76,7 @@ public class TypeNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationSpecific() throws Exception { + void annotationSpecific() throws Exception { final String[] expected = { "21:23: " + getCheckMessage(MSG_INVALID_PATTERN, "inputHeaderAnnotation", DEFAULT_PATTERN), }; @@ -84,7 +84,7 @@ public class TypeNameCheckTest extends AbstractModuleTestSupport { } @Test - public void testTypeNameRecords() throws Exception { + void typeNameRecords() throws Exception { final String[] expected = { "23:10: " + getCheckMessage(MSG_INVALID_PATTERN, "Third_Name", DEFAULT_PATTERN), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheckTest.java @@ -24,12 +24,13 @@ import static com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck.MSG_DUPL import static com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck.MSG_ILLEGAL_REGEXP; import static com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck.MSG_REQUIRED_REGEXP; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.List; import org.junit.jupiter.api.Test; -public class RegexpCheckTest extends AbstractModuleTestSupport { +final class RegexpCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +38,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final RegexpCheck regexpCheck = new RegexpCheck(); assertWithMessage("RegexpCheck#getAcceptableTokens should return empty array by default") .that(regexpCheck.getAcceptableTokens()) @@ -45,7 +46,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final RegexpCheck checkObj = new RegexpCheck(); assertWithMessage("RegexpCheck#getRequiredTokens should return empty array by default") .that(checkObj.getRequiredTokens()) @@ -53,13 +54,13 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testRequiredPass() throws Exception { + void requiredPass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSemantic.java"), expected); } @Test - public void testRequiredFail() throws Exception { + void requiredFail() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_REQUIRED_REGEXP, "This\\stext is not in the file"), }; @@ -67,25 +68,25 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpCheckDefault.java"), expected); } @Test - public void testRequiredNoDuplicatesPass() throws Exception { + void requiredNoDuplicatesPass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSemantic3.java"), expected); } @Test - public void testSetDuplicatesTrue() throws Exception { + void setDuplicatesTrue() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSemantic4.java"), expected); } @Test - public void testRequiredNoDuplicatesFail() throws Exception { + void requiredNoDuplicatesFail() throws Exception { final String[] expected = { "27: " + getCheckMessage(MSG_DUPLICATE_REGEXP, "Boolean x = new Boolean"), "32: " + getCheckMessage(MSG_DUPLICATE_REGEXP, "Boolean x = new Boolean"), @@ -94,19 +95,19 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalPass() throws Exception { + void illegalPass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSemantic6.java"), expected); } @Test - public void testStopEarly() throws Exception { + void stopEarly() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpCheckStopEarly.java"), expected); } @Test - public void testIllegalFailBelowErrorLimit() throws Exception { + void illegalFailBelowErrorLimit() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "^import"), "16: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "^import"), @@ -116,7 +117,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIllegalFailAboveErrorLimit() throws Exception { + void illegalFailAboveErrorLimit() throws Exception { final String error = "The error limit has been exceeded, " + "the check is aborting, there may be more unreported errors."; @@ -128,7 +129,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testMessagePropertyGood() throws Exception { + void messagePropertyGood() throws Exception { final String[] expected = { "78: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "Bad line :("), }; @@ -136,7 +137,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testMessagePropertyBad() throws Exception { + void messagePropertyBad() throws Exception { final String[] expected = { "78: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -144,7 +145,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testMessagePropertyBad2() throws Exception { + void messagePropertyBad2() throws Exception { final String[] expected = { "78: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -152,7 +153,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCaseTrue() throws Exception { + void ignoreCaseTrue() throws Exception { final String[] expected = { "78: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "(?i)SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), }; @@ -160,7 +161,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCaseFalse() throws Exception { + void ignoreCaseFalse() throws Exception { final String[] expectedTrue = { "78: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "(?i)SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), }; @@ -171,14 +172,14 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsCppStyle() throws Exception { + void ignoreCommentsCppStyle() throws Exception { // See if the comment is removed properly final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpTrailingComment.java"), expected); } @Test - public void testIgnoreCommentsFalseCppStyle() throws Exception { + void ignoreCommentsFalseCppStyle() throws Exception { // See if the comment is removed properly final String[] expected = { "16: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "don't\\suse trailing comments"), @@ -187,14 +188,14 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsBlockStyle() throws Exception { + void ignoreCommentsBlockStyle() throws Exception { // See if the comment is removed properly final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpTrailingComment3.java"), expected); } @Test - public void testIgnoreCommentsFalseBlockStyle() throws Exception { + void ignoreCommentsFalseBlockStyle() throws Exception { final String[] expected = { "31: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "c-style\\s1"), }; @@ -202,26 +203,26 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsMultipleBlockStyle() throws Exception { + void ignoreCommentsMultipleBlockStyle() throws Exception { // See if a second comment on the same line is removed properly final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpTrailingComment5.java"), expected); } @Test - public void testIgnoreCommentsMultiLine() throws Exception { + void ignoreCommentsMultiLine() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpTrailingComment6.java"), expected); } @Test - public void testIgnoreCommentsInlineStart() throws Exception { + void ignoreCommentsInlineStart() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpTrailingComment7.java"), expected); } @Test - public void testIgnoreCommentsInlineEnd() throws Exception { + void ignoreCommentsInlineEnd() throws Exception { final String[] expected = { "34: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "int z"), }; @@ -229,7 +230,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsInlineMiddle() throws Exception { + void ignoreCommentsInlineMiddle() throws Exception { final String[] expected = { "35: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "int y"), }; @@ -237,20 +238,20 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsNoSpaces() throws Exception { + void ignoreCommentsNoSpaces() throws Exception { // make sure the comment is not turned into spaces final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpTrailingComment10.java"), expected); } @Test - public void testOnFileStartingWithEmptyLine() throws Exception { + void onFileStartingWithEmptyLine() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpStartingWithEmptyLine.java"), expected); } @Test - public void testIgnoreCommentsCppStyleWithIllegalPatternFalse() throws Exception { + void ignoreCommentsCppStyleWithIllegalPatternFalse() throws Exception { // See if the comment is removed properly final String[] expected = { "1: " + getCheckMessage(MSG_REQUIRED_REGEXP, "don't use trailing comments"), @@ -259,18 +260,18 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testStateIsClearedOnBeginTreeErrorCount() throws Exception { + void stateIsClearedOnBeginTreeErrorCount() throws Exception { final String file1 = getPath("InputRegexpCheckB2.java"); final String file2 = getPath("InputRegexpCheckB1.java"); final List expectedFromFile1 = - List.of("12: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "^import")); + ImmutableList.of("12: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "^import")); final List expectedFromFile2 = - List.of("12: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "^import")); + ImmutableList.of("12: " + getCheckMessage(MSG_ILLEGAL_REGEXP, "^import")); verifyWithInlineConfigParser(file1, file2, expectedFromFile1, expectedFromFile2); } @Test - public void testStateIsClearedOnBeginTreeMatchCount() throws Exception { + void stateIsClearedOnBeginTreeMatchCount() throws Exception { final String file1 = getPath("InputRegexpCheckB3.java"); final String file2 = getPath("InputRegexpCheckB4.java"); final List expectedFirstInput = List.of(CommonUtil.EMPTY_STRING_ARRAY); @@ -279,7 +280,7 @@ public class RegexpCheckTest extends AbstractModuleTestSupport { } @Test - public void testOnFileStartingWithEmptyLine2() throws Exception { + void onFileStartingWithEmptyLine2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpCheckEmptyLine2.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckTest.java @@ -24,6 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.regexp.MultilineDetector.MS import static com.puppycrawl.tools.checkstyle.checks.regexp.MultilineDetector.MSG_REGEXP_EXCEEDED; import static com.puppycrawl.tools.checkstyle.checks.regexp.MultilineDetector.MSG_REGEXP_MINIMUM; import static com.puppycrawl.tools.checkstyle.checks.regexp.MultilineDetector.MSG_STACKOVERFLOW; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -36,7 +37,7 @@ import java.nio.file.Files; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { +final class RegexpMultilineCheckTest extends AbstractModuleTestSupport { @TempDir public File temporaryFolder; @@ -46,7 +47,7 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "78: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -54,7 +55,7 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testMessageProperty() throws Exception { + void messageProperty() throws Exception { final String[] expected = { "79: " + "Bad line :(", }; @@ -62,7 +63,7 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCaseTrue() throws Exception { + void ignoreCaseTrue() throws Exception { final String[] expected = { "79: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), }; @@ -70,13 +71,13 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCaseFalse() throws Exception { + void ignoreCaseFalse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpMultilineSemantic4.java"), expected); } @Test - public void testIllegalFailBelowErrorLimit() throws Exception { + void illegalFailBelowErrorLimit() throws Exception { final String[] expected = { "16: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "^import"), "17: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "^import"), @@ -86,7 +87,7 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testCarriageReturn() throws Exception { + void carriageReturn() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); checkConfig.addProperty("format", "\\r"); checkConfig.addProperty("maximum", "0"); @@ -95,16 +96,14 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { "3: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "\\r"), }; - final File file = File.createTempFile("junit", null, temporaryFolder); - Files.write( - file.toPath(), - "first line \r\n second line \n\r third line".getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), "first line \r\n second line \n\r third line".getBytes(UTF_8)); verify(checkConfig, file.getPath(), expected); } @Test - public void testMaximum() throws Exception { + void maximum() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); checkConfig.addProperty("format", "\\r"); checkConfig.addProperty("maximum", "1"); @@ -112,10 +111,8 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { "3: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "\\r"), }; - final File file = File.createTempFile("junit", null, temporaryFolder); - Files.write( - file.toPath(), - "first line \r\n second line \n\r third line".getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), "first line \r\n second line \n\r third line".getBytes(UTF_8)); verify(checkConfig, file.getPath(), expected); } @@ -126,16 +123,14 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { * @throws Exception some Exception */ @Test - public void testStateIsBeingReset() throws Exception { + void stateIsBeingReset() throws Exception { final TestLoggingReporter reporter = new TestLoggingReporter(); final DetectorOptions detectorOptions = DetectorOptions.newBuilder().reporter(reporter).format("\\r").maximum(1).build(); final MultilineDetector detector = new MultilineDetector(detectorOptions); - final File file = File.createTempFile("junit", null, temporaryFolder); - Files.write( - file.toPath(), - "first line \r\n second line \n\r third line".getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), "first line \r\n second line \n\r third line".getBytes(UTF_8)); detector.processLines(new FileText(file, StandardCharsets.UTF_8.name())); detector.processLines(new FileText(file, StandardCharsets.UTF_8.name())); @@ -145,13 +140,13 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpMultilineSemantic6.java"), expected); } @Test - public void testNullFormat() throws Exception { + void nullFormat() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_EMPTY), }; @@ -159,7 +154,7 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyFormat() throws Exception { + void emptyFormat() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_EMPTY), }; @@ -167,7 +162,7 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoStackOverflowError() throws Exception { + void noStackOverflowError() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); // http://madbean.com/2004/mb2004-20/ checkConfig.addProperty("format", "(x|y)*"); @@ -176,14 +171,14 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { "1: " + getCheckMessage(MSG_STACKOVERFLOW, "(x|y)*"), }; - final File file = File.createTempFile("junit", null, temporaryFolder); - Files.write(file.toPath(), makeLargeXyString().toString().getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), makeLargeXyString().toString().getBytes(UTF_8)); verify(checkConfig, file.getPath(), expected); } @Test - public void testMinimum() throws Exception { + void minimum() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); checkConfig.addProperty("format", "\\r"); checkConfig.addProperty("minimum", "5"); @@ -191,14 +186,14 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { "1: " + getCheckMessage(MSG_REGEXP_MINIMUM, "5", "\\r"), }; - final File file = File.createTempFile("junit", null, temporaryFolder); - Files.write(file.toPath(), "".getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), "".getBytes(UTF_8)); verify(checkConfig, file.getPath(), expected); } @Test - public void testMinimumWithCustomMessage() throws Exception { + void minimumWithCustomMessage() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpMultilineCheck.class); checkConfig.addProperty("format", "\\r"); checkConfig.addProperty("minimum", "5"); @@ -207,8 +202,8 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { "1: some message", }; - final File file = File.createTempFile("junit", null, temporaryFolder); - Files.write(file.toPath(), "".getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), "".getBytes(UTF_8)); verify(checkConfig, file.getPath(), expected); } @@ -221,13 +216,13 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testGoodLimit() throws Exception { + void goodLimit() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpMultilineSemantic9.java"), expected); } @Test - public void testMultilineSupport() throws Exception { + void multilineSupport() throws Exception { final String[] expected = { "22: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "(a)bc.*def"), }; @@ -235,7 +230,7 @@ public class RegexpMultilineCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultilineSupportNotGreedy() throws Exception { + void multilineSupportNotGreedy() throws Exception { final String[] expected = { "22: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "(a)bc.*?def"), "24: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "(a)bc.*?def"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheckTest.java @@ -24,17 +24,17 @@ import static com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameChec import static com.puppycrawl.tools.checkstyle.checks.regexp.RegexpOnFilenameCheck.MSG_MISMATCH; import static org.junit.jupiter.api.Assertions.assertThrows; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.FileText; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; -import java.util.Collections; import java.util.regex.Pattern; import org.junit.jupiter.api.Test; -public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { +final class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -42,14 +42,14 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultConfigurationOnValidInput() throws Exception { + void defaultConfigurationOnValidInput() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); verify( checkConfig, getPath("InputRegexpOnFilenameSemantic.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testDefaultProperties() throws Exception { + void defaultProperties() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); final String path = getPath("InputRegexpOnFilename Space.properties"); final String[] expected = { @@ -59,7 +59,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMatchFileMatches() throws Exception { + void matchFileMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "true"); checkConfig.addProperty("fileNamePattern", ".*\\.java"); @@ -71,7 +71,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMatchFileNotMatches() throws Exception { + void matchFileNotMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "true"); checkConfig.addProperty("fileNamePattern", "BAD.*"); @@ -80,7 +80,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotMatchFileMatches() throws Exception { + void notMatchFileMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "false"); checkConfig.addProperty("fileNamePattern", ".*\\.properties"); @@ -92,7 +92,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotMatchFileNotMatches() throws Exception { + void notMatchFileNotMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "false"); checkConfig.addProperty("fileNamePattern", ".*\\.java"); @@ -101,7 +101,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMatchFolderMatches() throws Exception { + void matchFolderMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "true"); checkConfig.addProperty("folderPattern", ".*[\\\\/]resources[\\\\/].*"); @@ -113,7 +113,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMatchFolderNotMatches() throws Exception { + void matchFolderNotMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "true"); checkConfig.addProperty("folderPattern", "BAD.*"); @@ -122,7 +122,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotMatchFolderMatches() throws Exception { + void notMatchFolderMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "false"); checkConfig.addProperty("folderPattern", ".*[\\\\/]gov[\\\\/].*"); @@ -134,7 +134,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotMatchFolderNotMatches() throws Exception { + void notMatchFolderNotMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "false"); checkConfig.addProperty("folderPattern", ".*[\\\\/]resources[\\\\/].*"); @@ -143,7 +143,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMatchFolderAndFileMatches() throws Exception { + void matchFolderAndFileMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "true"); checkConfig.addProperty("folderPattern", ".*[\\\\/]resources[\\\\/].*"); @@ -156,7 +156,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMatchFolderAndFileNotMatchesBoth() throws Exception { + void matchFolderAndFileNotMatchesBoth() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "true"); checkConfig.addProperty("folderPattern", "BAD.*"); @@ -166,7 +166,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMatchFolderAndFileNotMatchesFile() throws Exception { + void matchFolderAndFileNotMatchesFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "true"); checkConfig.addProperty("folderPattern", ".*[\\\\/]resources[\\\\/].*"); @@ -176,7 +176,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testMatchFolderAndFileNotMatchesFolder() throws Exception { + void matchFolderAndFileNotMatchesFolder() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "true"); checkConfig.addProperty("folderPattern", "BAD.*"); @@ -186,7 +186,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotMatchFolderAndFileMatches() throws Exception { + void notMatchFolderAndFileMatches() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "false"); checkConfig.addProperty("folderPattern", ".*[\\\\/]com[\\\\/].*"); @@ -199,7 +199,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotMatchFolderAndFileNotMatchesFolder() throws Exception { + void notMatchFolderAndFileNotMatchesFolder() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "false"); checkConfig.addProperty("folderPattern", ".*[\\\\/]javastrangefolder[\\\\/].*"); @@ -209,7 +209,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotMatchFolderAndFileNotMatchesFile() throws Exception { + void notMatchFolderAndFileNotMatchesFile() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("match", "false"); checkConfig.addProperty("folderPattern", ".*[\\\\/]govstrangefolder[\\\\/].*"); @@ -219,7 +219,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreExtension() throws Exception { + void ignoreExtension() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("fileNamePattern", ".*\\.java"); checkConfig.addProperty("ignoreFileNameExtensions", "true"); @@ -228,7 +228,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreExtensionNoExtension() throws Exception { + void ignoreExtensionNoExtension() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(RegexpOnFilenameCheck.class); checkConfig.addProperty("fileNamePattern", "\\."); checkConfig.addProperty("ignoreFileNameExtensions", "true"); @@ -236,7 +236,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testException() throws Exception { + void exception() throws Exception { // escape character needed for testing IOException from File.getCanonicalPath on all OSes final File file = new File(getPath("") + "\u0000" + File.separatorChar + "Test"); final RegexpOnFilenameCheck check = new RegexpOnFilenameCheck(); @@ -244,7 +244,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { final CheckstyleException ex = assertThrows( CheckstyleException.class, - () -> check.process(file, new FileText(file, Collections.emptyList())), + () -> check.process(file, new FileText(file, ImmutableList.of())), "CheckstyleException expected"); assertWithMessage("Invalid exception message") .that(ex) @@ -253,7 +253,7 @@ public class RegexpOnFilenameCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithFileWithoutParent() throws Exception { + void withFileWithoutParent() throws Exception { final DefaultConfiguration moduleConfig = createModuleConfig(RegexpOnFilenameCheck.class); final String path = getPath("package-info.java"); final File fileWithoutParent = new MockFile(path); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheckTest.java @@ -31,7 +31,7 @@ import java.io.File; import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; -public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { +final class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { private static final String[] EMPTY = {}; @@ -41,7 +41,7 @@ public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "77: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -49,7 +49,7 @@ public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { } @Test - public void testMessageProperty() throws Exception { + void messageProperty() throws Exception { final String[] expected = { "78: Bad line :(", }; @@ -57,7 +57,7 @@ public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCaseTrue() throws Exception { + void ignoreCaseTrue() throws Exception { final String[] expected = { "78: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), @@ -66,13 +66,13 @@ public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCaseFalse() throws Exception { + void ignoreCaseFalse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSinglelineSemantic4.java"), expected); } @Test - public void testMinimum() throws Exception { + void minimum() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_REGEXP_MINIMUM, "500", "\\r"), }; @@ -81,7 +81,7 @@ public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { } @Test - public void testSetMessage() throws Exception { + void setMessage() throws Exception { final String[] expected = { "1: someMessage", }; @@ -90,7 +90,7 @@ public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { } @Test - public void testMaximum() throws Exception { + void maximum() throws Exception { verifyWithInlineConfigParser(getPath("InputRegexpSinglelineSemantic7.java"), EMPTY); } @@ -100,7 +100,7 @@ public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { * @throws Exception some Exception */ @Test - public void testStateIsBeingReset() throws Exception { + void stateIsBeingReset() throws Exception { final String illegal = "System\\.(out)|(err)\\.print(ln)?\\("; final TestLoggingReporter reporter = new TestLoggingReporter(); final DetectorOptions detectorOptions = @@ -117,12 +117,12 @@ public class RegexpSinglelineCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { verifyWithInlineConfigParser(getPath("InputRegexpSinglelineSemantic9.java"), EMPTY); } @Test - public void testMessage() throws Exception { + void message() throws Exception { final String[] expected = { "17: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { +final class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final RegexpSinglelineJavaCheck regexpSinglelineJavaCheck = new RegexpSinglelineJavaCheck(); assertWithMessage("Default acceptable tokens are invalid") .that(regexpSinglelineJavaCheck.getAcceptableTokens()) @@ -43,7 +43,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final RegexpSinglelineJavaCheck checkObj = new RegexpSinglelineJavaCheck(); assertWithMessage("Default required tokens are invalid") .that(checkObj.getRequiredTokens()) @@ -51,7 +51,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIt() throws Exception { + void it() throws Exception { final String[] expected = { "77: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "System\\.(out)|(err)\\.print(ln)?\\("), }; @@ -59,7 +59,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testMessageProperty() throws Exception { + void messageProperty() throws Exception { final String[] expected = { "78: " + "Bad line :(", }; @@ -67,7 +67,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCaseTrue() throws Exception { + void ignoreCaseTrue() throws Exception { final String[] expected = { "78: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "SYSTEM\\.(OUT)|(ERR)\\.PRINT(LN)?\\("), }; @@ -75,13 +75,13 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCaseFalse() throws Exception { + void ignoreCaseFalse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSinglelineJavaSemantic4.java"), expected); } @Test - public void testIgnoreCommentsCppStyle() throws Exception { + void ignoreCommentsCppStyle() throws Exception { // See if the comment is removed properly final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -89,7 +89,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsFalseCppStyle() throws Exception { + void ignoreCommentsFalseCppStyle() throws Exception { // See if the comment is removed properly final String[] expected = { "16: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "don't\\suse trailing comments"), @@ -99,7 +99,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsBlockStyle() throws Exception { + void ignoreCommentsBlockStyle() throws Exception { // See if the comment is removed properly final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -107,7 +107,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsFalseBlockStyle() throws Exception { + void ignoreCommentsFalseBlockStyle() throws Exception { final String[] expected = { "31: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "c-style\\s1"), }; @@ -116,7 +116,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsMultipleBlockStyle() throws Exception { + void ignoreCommentsMultipleBlockStyle() throws Exception { // See if a second comment on the same line is removed properly final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -124,21 +124,21 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsMultiLine() throws Exception { + void ignoreCommentsMultiLine() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment6.java"), expected); } @Test - public void testIgnoreCommentsInlineStart() throws Exception { + void ignoreCommentsInlineStart() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputRegexpSinglelineJavaTrailingComment7.java"), expected); } @Test - public void testIgnoreCommentsInlineEnd() throws Exception { + void ignoreCommentsInlineEnd() throws Exception { final String[] expected = { "34: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "int z"), }; @@ -147,7 +147,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsInlineMiddle() throws Exception { + void ignoreCommentsInlineMiddle() throws Exception { final String[] expected = { "35: " + getCheckMessage(MSG_REGEXP_EXCEEDED, "int y"), }; @@ -156,7 +156,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreCommentsNoSpaces() throws Exception { + void ignoreCommentsNoSpaces() throws Exception { // make sure the comment is not turned into spaces final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -164,7 +164,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void test1371588() throws Exception { + void test1371588() throws Exception { // StackOverflowError with trailing space and ignoreComments final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -172,19 +172,19 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testExistingInDoc() throws Exception { + void existingInDoc() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSinglelineJavaSemantic5.java"), expected); } @Test - public void testExistingInCode() throws Exception { + void existingInCode() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSinglelineJavaSemantic6.java"), expected); } @Test - public void testMissing() throws Exception { + void missing() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_REGEXP_MINIMUM, 1, "This\\stext is not in the file"), }; @@ -192,7 +192,7 @@ public class RegexpSinglelineJavaCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputRegexpSinglelineJavaSemantic8.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; /** Unit test for AnonInnerLengthCheck. */ -public class AnonInnerLengthCheckTest extends AbstractModuleTestSupport { +final class AnonInnerLengthCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class AnonInnerLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final AnonInnerLengthCheck checkObj = new AnonInnerLengthCheck(); final int[] expected = {TokenTypes.LITERAL_NEW}; assertWithMessage("Default required tokens are invalid") @@ -44,7 +44,7 @@ public class AnonInnerLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final AnonInnerLengthCheck anonInnerLengthCheckObj = new AnonInnerLengthCheck(); final int[] actual = anonInnerLengthCheckObj.getAcceptableTokens(); final int[] expected = {TokenTypes.LITERAL_NEW}; @@ -53,7 +53,7 @@ public class AnonInnerLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "53:35: " + getCheckMessage(MSG_KEY, 21, 20), }; @@ -61,7 +61,7 @@ public class AnonInnerLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonDefault() throws Exception { + void nonDefault() throws Exception { final String[] expected = { "54:35: " + getCheckMessage(MSG_KEY, 21, 6), "79:35: " + getCheckMessage(MSG_KEY, 20, 6), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheckTest.java @@ -32,16 +32,16 @@ import java.util.Collection; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport { +final class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/executablestatementcount"; } - @Test @SuppressWarnings("unchecked") - public void testStatefulFieldsClearedOnBeginTree() { + @Test + void statefulFieldsClearedOnBeginTree() { final DetailAstImpl ast = new DetailAstImpl(); ast.setType(TokenTypes.STATIC_INIT); final ExecutableStatementCountCheck check = new ExecutableStatementCountCheck(); @@ -56,7 +56,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testMaxZero() throws Exception { + void maxZero() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 3, 0), @@ -76,7 +76,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testMethodDef() throws Exception { + void methodDef() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 3, 0), @@ -91,7 +91,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testCtorDef() throws Exception { + void ctorDef() throws Exception { final String[] expected = { "12:5: " + getCheckMessage(MSG_KEY, 2, 0), "22:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -101,7 +101,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testStaticInit() throws Exception { + void staticInit() throws Exception { final String[] expected = { "13:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -111,7 +111,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testInstanceInit() throws Exception { + void instanceInit() throws Exception { final String[] expected = { "13:5: " + getCheckMessage(MSG_KEY, 2, 0), @@ -122,7 +122,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testVisitTokenWithWrongTokenType() { + void visitTokenWithWrongTokenType() { final ExecutableStatementCountCheck checkObj = new ExecutableStatementCountCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(new CommonToken(TokenTypes.ENUM, "ENUM")); @@ -135,7 +135,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testLeaveTokenWithWrongTokenType() { + void leaveTokenWithWrongTokenType() { final ExecutableStatementCountCheck checkObj = new ExecutableStatementCountCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(new CommonToken(TokenTypes.ENUM, "ENUM")); @@ -148,7 +148,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testDefaultConfiguration() throws Exception { + void defaultConfiguration() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -156,7 +156,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testExecutableStatementCountRecords() throws Exception { + void executableStatementCountRecords() throws Exception { final int max = 1; @@ -174,7 +174,7 @@ public class ExecutableStatementCountCheckTest extends AbstractModuleTestSupport } @Test - public void testExecutableStatementCountLambdas() throws Exception { + void executableStatementCountLambdas() throws Exception { final int max = 1; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class FileLengthCheckTest extends AbstractModuleTestSupport { +final class FileLengthCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class FileLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testAlarm() throws Exception { + void alarm() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY, 228, 20), }; @@ -44,25 +44,25 @@ public class FileLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testAlarmDefault() throws Exception { + void alarmDefault() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFileLengthDefault.java"), expected); } @Test - public void testFileLengthEqualToMaxLength() throws Exception { + void fileLengthEqualToMaxLength() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFileLength2.java"), expected); } @Test - public void testOk() throws Exception { + void ok() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFileLength3.java"), expected); } @Test - public void testArgs() throws Exception { + void args() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(FileLengthCheck.class); try { checkConfig.addProperty("max", "abc"); @@ -79,14 +79,14 @@ public class FileLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoAlarmByExtension() throws Exception { + void noAlarmByExtension() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputFileLength4.java"), expected); } @Test - public void testExtensions() { + void extensions() { final FileLengthCheck check = new FileLengthCheck(); check.setFileExtensions("java"); assertWithMessage("extension should be the same") --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LambdaBodyLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LambdaBodyLengthCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class LambdaBodyLengthCheckTest extends AbstractModuleTestSupport { +final class LambdaBodyLengthCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class LambdaBodyLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final LambdaBodyLengthCheck checkObj = new LambdaBodyLengthCheck(); final int[] expected = {TokenTypes.LAMBDA}; assertWithMessage("Default required tokens are invalid") @@ -44,7 +44,7 @@ public class LambdaBodyLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final LambdaBodyLengthCheck lambdaBodyLengthCheckObj = new LambdaBodyLengthCheck(); final int[] actual = lambdaBodyLengthCheckObj.getAcceptableTokens(); final int[] expected = {TokenTypes.LAMBDA}; @@ -53,7 +53,7 @@ public class LambdaBodyLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "16:27: " + getCheckMessage(MSG_KEY, 12, 10), "28:27: " + getCheckMessage(MSG_KEY, 12, 10), @@ -66,14 +66,14 @@ public class LambdaBodyLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultSwitchExpressions() throws Exception { + void defaultSwitchExpressions() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputLambdaBodyLengthSwitchExps.java"), expected); } @Test - public void testMaxLimitIsDifferent() throws Exception { + void maxLimitIsDifferent() throws Exception { final String[] expected = { "16:27: " + getCheckMessage(MSG_KEY, 4, 3), "20:27: " + getCheckMessage(MSG_KEY, 4, 3), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java @@ -27,7 +27,7 @@ import de.thetaphi.forbiddenapis.SuppressForbidden; import java.nio.charset.CodingErrorAction; import org.junit.jupiter.api.Test; -public class LineLengthCheckTest extends AbstractModuleTestSupport { +final class LineLengthCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testSimple() throws Exception { + void simple() throws Exception { final String[] expected = { "22: " + getCheckMessage(MSG_KEY, 80, 81), "149: " + getCheckMessage(MSG_KEY, 80, 83), }; @@ -43,7 +43,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void shouldLogActualLineLength() throws Exception { + void shouldLogActualLineLength() throws Exception { final String[] expected = { "23: 80,81", "150: 80,83", }; @@ -51,7 +51,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void shouldNotLogLongImportStatements() throws Exception { + void shouldNotLogLongImportStatements() throws Exception { final String[] expected = { "18: " + getCheckMessage(MSG_KEY, 80, 100), }; @@ -59,7 +59,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void shouldNotLogLongPackageStatements() throws Exception { + void shouldNotLogLongPackageStatements() throws Exception { final String[] expected = { "17: " + getCheckMessage(MSG_KEY, 80, 100), }; @@ -68,7 +68,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void shouldNotLogLongLinks() throws Exception { + void shouldNotLogLongLinks() throws Exception { final String[] expected = { "13: " + getCheckMessage(MSG_KEY, 80, 111), }; @@ -76,7 +76,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void countUnicodePointsOnce() throws Exception { + void countUnicodePointsOnce() throws Exception { final String[] expected = { "15: " + getCheckMessage(MSG_KEY, 100, 149), "16: " + getCheckMessage(MSG_KEY, 100, 149), }; @@ -84,7 +84,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testLineLengthIgnoringPackageStatements() throws Exception { + void lineLengthIgnoringPackageStatements() throws Exception { final String[] expected = { "13: " + getCheckMessage(MSG_KEY, 75, 76), "22: " + getCheckMessage(MSG_KEY, 75, 86), @@ -97,7 +97,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testLineLengthIgnoringImportStatements() throws Exception { + void lineLengthIgnoringImportStatements() throws Exception { final String[] expected = { "12: " + getCheckMessage(MSG_KEY, 75, 79), "21: " + getCheckMessage(MSG_KEY, 75, 81), @@ -119,7 +119,7 @@ public class LineLengthCheckTest extends AbstractModuleTestSupport { */ @SuppressForbidden @Test - public void testUnmappableCharacters() throws Exception { + void unmappableCharacters() throws Exception { final String[] expected = { "4: " + getCheckMessage(MSG_KEY, 75, 238), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheckTest.java @@ -31,7 +31,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MethodCountCheckTest extends AbstractModuleTestSupport { +final class MethodCountCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MethodCountCheck checkObj = new MethodCountCheck(); final int[] expected = {TokenTypes.METHOD_DEF}; assertWithMessage("Default required tokens are invalid") @@ -48,7 +48,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MethodCountCheck methodCountCheckObj = new MethodCountCheck(); final int[] actual = methodCountCheckObj.getAcceptableTokens(); final int[] expected = { @@ -65,7 +65,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaults() throws Exception { + void defaults() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -73,7 +73,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testThreesOne() throws Exception { + void threesOne() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_PACKAGE_METHODS, 4, 3), @@ -87,7 +87,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testThreesTwo() throws Exception { + void threesTwo() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_PACKAGE_METHODS, 4, 3), @@ -103,7 +103,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testEnum() throws Exception { + void testEnum() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_PRIVATE_METHODS, 1, 0), @@ -114,7 +114,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithPackageModifier() throws Exception { + void withPackageModifier() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_MANY_METHODS, 5, 2), @@ -124,7 +124,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testOnInterfaceDefinitionWithField() throws Exception { + void onInterfaceDefinitionWithField() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -132,7 +132,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithInterfaceDefinitionInClass() throws Exception { + void withInterfaceDefinitionInClass() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_MANY_METHODS, 2, 1), @@ -142,7 +142,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testPartialTokens() throws Exception { + void partialTokens() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -150,7 +150,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testCountMethodToCorrectDefinition() throws Exception { + void countMethodToCorrectDefinition() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_MANY_METHODS, 2, 1), @@ -160,7 +160,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfaceMemberScopeIsPublic() throws Exception { + void interfaceMemberScopeIsPublic() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_PUBLIC_METHODS, 2, 1), @@ -172,7 +172,7 @@ public class MethodCountCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodCountRecords() throws Exception { + void methodCountRecords() throws Exception { final int max = 2; final String[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MethodLengthCheckTest extends AbstractModuleTestSupport { +final class MethodLengthCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class MethodLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MethodLengthCheck checkObj = new MethodLengthCheck(); assertWithMessage( "MethodLengthCheck#getRequiredTokens should return empty array " + "by default") @@ -44,7 +44,7 @@ public class MethodLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MethodLengthCheck methodLengthCheckObj = new MethodLengthCheck(); final int[] actual = methodLengthCheckObj.getAcceptableTokens(); final int[] expected = { @@ -55,13 +55,13 @@ public class MethodLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testItOne() throws Exception { + void itOne() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodLengthSimpleOne.java"), expected); } @Test - public void testItTwo() throws Exception { + void itTwo() throws Exception { final String[] expected = { "16:5: " + getCheckMessage(MSG_KEY, 20, 19, "longMethod"), }; @@ -69,13 +69,13 @@ public class MethodLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testCountEmptyIsFalse() throws Exception { + void countEmptyIsFalse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodLengthCountEmptyIsFalse.java"), expected); } @Test - public void testWithComments() throws Exception { + void withComments() throws Exception { final String[] expected = { "34:5: " + getCheckMessage(MSG_KEY, 8, 7, "visit"), }; @@ -83,7 +83,7 @@ public class MethodLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testCountEmpty() throws Exception { + void countEmpty() throws Exception { final int max = 2; final String[] expected = { "24:5: " + getCheckMessage(MSG_KEY, 3, max, "AA"), @@ -96,19 +96,19 @@ public class MethodLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testAbstractOne() throws Exception { + void abstractOne() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodLengthModifierOne.java"), expected); } @Test - public void testAbstractTwo() throws Exception { + void abstractTwo() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodLengthModifierTwo.java"), expected); } @Test - public void testTextBlocks() throws Exception { + void textBlocks() throws Exception { final int max = 2; final String[] expected = { @@ -123,7 +123,7 @@ public class MethodLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordsAndCompactCtors() throws Exception { + void recordsAndCompactCtors() throws Exception { final int max = 2; @@ -140,7 +140,7 @@ public class MethodLengthCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordsAndCompactCtorsCountEmpty() throws Exception { + void recordsAndCompactCtorsCountEmpty() throws Exception { final int max = 2; final String[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheckTest.java @@ -32,7 +32,7 @@ import java.io.File; import java.util.Optional; import org.junit.jupiter.api.Test; -public class OuterTypeNumberCheckTest extends AbstractModuleTestSupport { +final class OuterTypeNumberCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -40,7 +40,7 @@ public class OuterTypeNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final OuterTypeNumberCheck checkObj = new OuterTypeNumberCheck(); final int[] expected = { TokenTypes.CLASS_DEF, @@ -55,7 +55,7 @@ public class OuterTypeNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final OuterTypeNumberCheck outerTypeNumberObj = new OuterTypeNumberCheck(); final int[] actual = outerTypeNumberObj.getAcceptableTokens(); final int[] expected = { @@ -70,7 +70,7 @@ public class OuterTypeNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY, 3, 1), }; @@ -78,19 +78,19 @@ public class OuterTypeNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testMax30() throws Exception { + void max30() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOuterTypeNumberSimple1.java"), expected); } @Test - public void testWithInnerClass() throws Exception { + void withInnerClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOuterTypeNumberEmptyInner.java"), expected); } @Test - public void testWithRecords() throws Exception { + void withRecords() throws Exception { final int max = 1; @@ -109,7 +109,7 @@ public class OuterTypeNumberCheckTest extends AbstractModuleTestSupport { * @throws Exception if there is an error. */ @Test - public void testClearState() throws Exception { + void clearState() throws Exception { final OuterTypeNumberCheck check = new OuterTypeNumberCheck(); final DetailAST root = JavaParser.parseFile( @@ -123,14 +123,17 @@ public class OuterTypeNumberCheckTest extends AbstractModuleTestSupport { .that( TestUtil.isStatefulFieldClearedDuringBeginTree( check, - classDef.get(), + classDef.orElseThrow(), "currentDepth", currentDepth -> ((Number) currentDepth).intValue() == 0)) .isTrue(); assertWithMessage("State is not cleared on beginTree") .that( TestUtil.isStatefulFieldClearedDuringBeginTree( - check, classDef.get(), "outerNum", outerNum -> ((Number) outerNum).intValue() == 0)) + check, + classDef.orElseThrow(), + "outerNum", + outerNum -> ((Number) outerNum).intValue() == 0)) .isTrue(); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class ParameterNumberCheckTest extends AbstractModuleTestSupport { +final class ParameterNumberCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class ParameterNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final ParameterNumberCheck checkObj = new ParameterNumberCheck(); assertWithMessage( "ParameterNumberCheck#getRequiredTokens should return empty array " + "by default") @@ -44,7 +44,7 @@ public class ParameterNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final ParameterNumberCheck paramNumberCheckObj = new ParameterNumberCheck(); final int[] actual = paramNumberCheckObj.getAcceptableTokens(); final int[] expected = { @@ -55,7 +55,7 @@ public class ParameterNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "198:10: " + getCheckMessage(MSG_KEY, 7, 9), }; @@ -63,7 +63,7 @@ public class ParameterNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testNum() throws Exception { + void num() throws Exception { final String[] expected = { "75:9: " + getCheckMessage(MSG_KEY, 2, 3), "198:10: " + getCheckMessage(MSG_KEY, 2, 9), }; @@ -71,13 +71,13 @@ public class ParameterNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testMaxParam() throws Exception { + void maxParam() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParameterNumberSimple3.java"), expected); } @Test - public void shouldLogActualParameterNumber() throws Exception { + void shouldLogActualParameterNumber() throws Exception { final String[] expected = { "199:10: 7,9", }; @@ -85,7 +85,7 @@ public class ParameterNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreOverriddenMethods() throws Exception { + void ignoreOverriddenMethods() throws Exception { final String[] expected = { "15:10: " + getCheckMessage(MSG_KEY, 7, 8), "20:10: " + getCheckMessage(MSG_KEY, 7, 8), }; @@ -93,7 +93,7 @@ public class ParameterNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreOverriddenMethodsFalse() throws Exception { + void ignoreOverriddenMethodsFalse() throws Exception { final String[] expected = { "15:10: " + getCheckMessage(MSG_KEY, 7, 8), "20:10: " + getCheckMessage(MSG_KEY, 7, 8), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { +final class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final RecordComponentNumberCheck checkObj = new RecordComponentNumberCheck(); final int[] actual = checkObj.getRequiredTokens(); final int[] expected = { @@ -48,7 +48,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final RecordComponentNumberCheck checkObj = new RecordComponentNumberCheck(); final int[] actual = checkObj.getAcceptableTokens(); final int[] expected = { @@ -59,7 +59,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final int max = 8; @@ -77,7 +77,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentNumberTopLevel1() throws Exception { + void recordComponentNumberTopLevel1() throws Exception { final int max = 8; @@ -90,7 +90,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentNumberTopLevel2() throws Exception { + void recordComponentNumberTopLevel2() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -99,7 +99,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentNumberMax1() throws Exception { + void recordComponentNumberMax1() throws Exception { final int max = 1; @@ -125,7 +125,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentNumberMax20() throws Exception { + void recordComponentNumberMax20() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( @@ -133,7 +133,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { } @Test - public void testRecordComponentNumberPrivateModifier() throws Exception { + void recordComponentNumberPrivateModifier() throws Exception { final int max = 8; @@ -155,7 +155,7 @@ public class RecordComponentNumberCheckTest extends AbstractModuleTestSupport { * @throws Exception if an error occurs. */ @Test - public void testCloneInAccessModifiersProperty() throws Exception { + void cloneInAccessModifiersProperty() throws Exception { final AccessModifierOption[] input = { AccessModifierOption.PACKAGE, }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { +final class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,7 +38,7 @@ public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final EmptyForInitializerPadCheck checkObj = new EmptyForInitializerPadCheck(); final int[] expected = {TokenTypes.FOR_INIT}; assertWithMessage("Default required tokens are invalid") @@ -47,7 +47,7 @@ public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "51:15: " + getCheckMessage(MSG_PRECEDED, ";"), }; @@ -56,7 +56,7 @@ public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceOption() throws Exception { + void spaceOption() throws Exception { final String[] expected = { "54:14: " + getCheckMessage(MSG_NOT_PRECEDED, ";"), }; @@ -64,7 +64,7 @@ public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final EmptyForInitializerPadCheck emptyForInitializerPadCheckObj = new EmptyForInitializerPadCheck(); final int[] actual = emptyForInitializerPadCheckObj.getAcceptableTokens(); @@ -79,7 +79,7 @@ public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testPadOptionValueOf() { + void padOptionValueOf() { final PadOption option = PadOption.valueOf("NOSPACE"); assertWithMessage("Result of valueOf is invalid").that(option).isEqualTo(PadOption.NOSPACE); } @@ -89,13 +89,13 @@ public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { * valueOf() is uncovered. */ @Test - public void testWrapOptionValueOf() { + void wrapOptionValueOf() { final WrapOption option = WrapOption.valueOf("EOL"); assertWithMessage("Result of valueOf is invalid").that(option).isEqualTo(WrapOption.EOL); } @Test - public void testWithEmoji() throws Exception { + void withEmoji() throws Exception { final String[] expected = { "23:13: " + getCheckMessage(MSG_NOT_PRECEDED, ";"), "28:25: " + getCheckMessage(MSG_NOT_PRECEDED, ";"), @@ -104,7 +104,7 @@ public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(EmptyForInitializerPadCheck.class); checkConfig.addProperty("option", "invalid_option"); @@ -125,7 +125,7 @@ public class EmptyForInitializerPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = { "15:14: " + getCheckMessage(MSG_NOT_PRECEDED, ";"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForIteratorPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForIteratorPadCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { +final class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final EmptyForIteratorPadCheck checkObj = new EmptyForIteratorPadCheck(); final int[] expected = {TokenTypes.FOR_ITERATOR}; assertWithMessage("Default required tokens are invalid") @@ -46,7 +46,7 @@ public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "30:32: " + getCheckMessage(MSG_WS_FOLLOWED, ";"), "46:33: " + getCheckMessage(MSG_WS_FOLLOWED, ";"), @@ -56,7 +56,7 @@ public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceOption() throws Exception { + void spaceOption() throws Exception { final String[] expected = { "26:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), }; @@ -64,7 +64,7 @@ public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithEmoji() throws Exception { + void withEmoji() throws Exception { final String[] expected = { "24:40: " + getCheckMessage(MSG_WS_FOLLOWED, ";"), }; @@ -72,7 +72,7 @@ public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final EmptyForIteratorPadCheck emptyForIteratorPadCheckObj = new EmptyForIteratorPadCheck(); final int[] actual = emptyForIteratorPadCheckObj.getAcceptableTokens(); final int[] expected = { @@ -82,7 +82,7 @@ public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -100,7 +100,7 @@ public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = { "20:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), }; @@ -109,7 +109,7 @@ public class EmptyForIteratorPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testUppercaseOptionProperty() throws Exception { + void uppercaseOptionProperty() throws Exception { final String[] expected = { "20:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorCheckTest.java @@ -31,7 +31,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { +final class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final EmptyLineSeparatorCheck checkObj = new EmptyLineSeparatorCheck(); assertWithMessage( "EmptyLineSeparatorCheck#getRequiredTokens should return empty array " + "by default") @@ -48,7 +48,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), @@ -65,7 +65,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowNoEmptyLineBetweenFields() throws Exception { + void allowNoEmptyLineBetweenFields() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), @@ -81,7 +81,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testHeader() throws Exception { + void header() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), }; @@ -89,7 +89,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultipleEmptyLinesBetweenClassMembers() throws Exception { + void multipleEmptyLinesBetweenClassMembers() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_MULTIPLE_LINES, "package"), "17:1: " + getCheckMessage(MSG_MULTIPLE_LINES, "import"), @@ -104,20 +104,20 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testFormerArrayIndexOutOfBounds() throws Exception { + void formerArrayIndexOutOfBounds() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputEmptyLineSeparatorFormerException.java"), expected); } @Test - public void testAllowMultipleFieldInClass() throws Exception { + void allowMultipleFieldInClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorMultipleFieldsInClass.java"), expected); } @Test - public void testAllowMultipleImportSeparatedFromPackage() throws Exception { + void allowMultipleImportSeparatedFromPackage() throws Exception { final String[] expected = { "13:78: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), }; @@ -126,14 +126,14 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportSeparatedFromPackage() throws Exception { + void importSeparatedFromPackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorImportSeparatedFromPackage.java"), expected); } @Test - public void testStaticImport() throws Exception { + void staticImport() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), }; @@ -141,7 +141,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testBlockCommentNotSeparatedFromPackage() throws Exception { + void blockCommentNotSeparatedFromPackage() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "/*"), }; @@ -150,7 +150,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testSingleCommentNotSeparatedFromPackage() throws Exception { + void singleCommentNotSeparatedFromPackage() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "//"), }; @@ -159,7 +159,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassDefinitionNotSeparatedFromPackage() throws Exception { + void classDefinitionNotSeparatedFromPackage() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), }; @@ -168,7 +168,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommentAfterPackageWithImports() throws Exception { + void commentAfterPackageWithImports() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "//"), }; @@ -177,7 +177,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testJavadocCommentAfterPackageWithImports() throws Exception { + void javadocCommentAfterPackageWithImports() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); final String[] expected = { "2:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "/*"), @@ -187,7 +187,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testPackageImportsClassInSingleLine() throws Exception { + void packageImportsClassInSingleLine() throws Exception { final String[] expected = { "13:79: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), "13:101: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), @@ -197,7 +197,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineAfterPackageForPackageAst() throws Exception { + void emptyLineAfterPackageForPackageAst() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "/*"), }; @@ -206,14 +206,14 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineAfterPackageForImportAst() throws Exception { + void emptyLineAfterPackageForImportAst() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorEmptyLineAfterPackageForImportAst.java"), expected); } @Test - public void testClassDefinitionAndCommentNotSeparatedFromPackage() throws Exception { + void classDefinitionAndCommentNotSeparatedFromPackage() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "//"), "15:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), @@ -224,21 +224,21 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testBlockCommentSeparatedFromPackage() throws Exception { + void blockCommentSeparatedFromPackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorBlockCommentSeparatedFromPackage.java"), expected); } @Test - public void testSingleCommentSeparatedFromPackage() throws Exception { + void singleCommentSeparatedFromPackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorSingleCommentSeparatedFromPackage.java"), expected); } @Test - public void testEnumMembers() throws Exception { + void enumMembers() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_MULTIPLE_LINES, "VARIABLE_DEF"), "27:5: " + getCheckMessage(MSG_MULTIPLE_LINES, "VARIABLE_DEF"), @@ -251,7 +251,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testInterfaceFields() throws Exception { + void interfaceFields() throws Exception { final String[] expected = { "21:5: " + getCheckMessage(MSG_MULTIPLE_LINES, "VARIABLE_DEF"), "25:5: " + getCheckMessage(MSG_MULTIPLE_LINES, "VARIABLE_DEF"), @@ -263,7 +263,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final EmptyLineSeparatorCheck emptyLineSeparatorCheckObj = new EmptyLineSeparatorCheck(); final int[] actual = emptyLineSeparatorCheckObj.getAcceptableTokens(); final int[] expected = { @@ -285,7 +285,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testPrePreviousLineEmptiness() throws Exception { + void prePreviousLineEmptiness() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); checkConfig.addProperty("allowMultipleEmptyLines", "false"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -293,7 +293,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testPrePreviousLineIsEmpty() throws Exception { + void prePreviousLineIsEmpty() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(EmptyLineSeparatorCheck.class); checkConfig.addProperty("allowMultipleEmptyLines", "false"); final String[] expected = { @@ -303,7 +303,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testPreviousLineEmptiness() throws Exception { + void previousLineEmptiness() throws Exception { final String[] expected = { "21:30: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), "26:5: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), @@ -316,7 +316,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testDisAllowMultipleEmptyLinesInsideClassMembers() throws Exception { + void disAllowMultipleEmptyLinesInsideClassMembers() throws Exception { final String[] expected = { "18:11: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), "30:11: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), @@ -330,7 +330,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowMultipleEmptyLinesInsideClassMembers() throws Exception { + void allowMultipleEmptyLinesInsideClassMembers() throws Exception { final String[] expected = { "53:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), }; @@ -339,25 +339,25 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testImportsAndStaticImports() throws Exception { + void importsAndStaticImports() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputEmptyLineSeparatorImports.java"), expected); } @Test - public void testAllowPackageAnnotation() throws Exception { + void allowPackageAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("packageinfo/test1/package-info.java"), expected); } @Test - public void testAllowJavadocBeforePackage() throws Exception { + void allowJavadocBeforePackage() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("packageinfo/test2/package-info.java"), expected); } @Test - public void testDisAllowBlockCommentBeforePackage() throws Exception { + void disAllowBlockCommentBeforePackage() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), }; @@ -365,7 +365,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowSingleLineCommentPackage() throws Exception { + void allowSingleLineCommentPackage() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), }; @@ -373,7 +373,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonPackageInfoWithJavadocBeforePackage() throws Exception { + void nonPackageInfoWithJavadocBeforePackage() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), }; @@ -382,7 +382,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testClassOnly() throws Exception { + void classOnly() throws Exception { final String[] expected = { "51:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), }; @@ -391,7 +391,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testLineSeparationBeforeComments() throws Exception { + void lineSeparationBeforeComments() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "16:1: " + getCheckMessage(MSG_MULTIPLE_LINES, "//"), @@ -436,7 +436,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreEmptyLinesBeforeCommentsWhenItIsAllowed() throws Exception { + void ignoreEmptyLinesBeforeCommentsWhenItIsAllowed() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "239:5: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "INTERFACE_DEF"), @@ -445,14 +445,14 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoViolationsOnEmptyLinesBeforeComments() throws Exception { + void noViolationsOnEmptyLinesBeforeComments() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputEmptyLineSeparatorNoViolationOnEmptyLineBeforeComments.java"), expected); } @Test - public void testEmptyLineSeparatorRecordsAndCompactCtors() throws Exception { + void emptyLineSeparatorRecordsAndCompactCtors() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "18:5: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "RECORD_DEF"), @@ -476,7 +476,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineSeparatorRecordsAndCompactCtorsNoEmptyLines() throws Exception { + void emptyLineSeparatorRecordsAndCompactCtorsNoEmptyLines() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), @@ -490,7 +490,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineSeparatorMultipleSingleTypeVariables() throws Exception { + void emptyLineSeparatorMultipleSingleTypeVariables() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -499,7 +499,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineSeparatorEmptyLinesInsideClassMembersRecursive() throws Exception { + void emptyLineSeparatorEmptyLinesInsideClassMembersRecursive() throws Exception { final String[] expected = { "27:15: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), }; @@ -507,7 +507,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineSeparatorNewMethodDef() throws Exception { + void emptyLineSeparatorNewMethodDef() throws Exception { final String[] expected = { "29:34: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), "38:26: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), @@ -516,7 +516,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineSeparatorPostFixCornerCases() throws Exception { + void emptyLineSeparatorPostFixCornerCases() throws Exception { final String[] expected = { "18:19: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), "32:29: " + getCheckMessage(MSG_MULTIPLE_LINES_INSIDE), @@ -527,7 +527,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineSeparatorAnnotation() throws Exception { + void emptyLineSeparatorAnnotation() throws Exception { final String[] expected = { "18:22: " + getCheckMessage(MSG_MULTIPLE_LINES_AFTER, "}"), }; @@ -535,7 +535,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLineSeparatorWithEmoji() throws Exception { + void emptyLineSeparatorWithEmoji() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_MULTIPLE_LINES, "VARIABLE_DEF"), @@ -547,13 +547,13 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultipleLines() throws Exception { + void multipleLines() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputEmptyLineSeparatorMultipleLines.java"), expected); } @Test - public void testMultipleLines2() throws Exception { + void multipleLines2() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"), }; @@ -561,7 +561,7 @@ public class EmptyLineSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultipleLines3() throws Exception { + void multipleLines3() throws Exception { final String[] expected = { "24:5: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "VARIABLE_DEF"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterCheckTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacter import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import org.junit.jupiter.api.Test; -public class FileTabCharacterCheckTest extends AbstractModuleTestSupport { +final class FileTabCharacterCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class FileTabCharacterCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "22:25: " + getCheckMessage(MSG_FILE_CONTAINS_TAB), }; @@ -41,7 +41,7 @@ public class FileTabCharacterCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomMessage() throws Exception { + void customMessage() throws Exception { final String msgFileContainsTab = "File contains tab characters (this is the first instance) :)"; final String[] expected = { @@ -51,7 +51,7 @@ public class FileTabCharacterCheckTest extends AbstractModuleTestSupport { } @Test - public void testVerbose() throws Exception { + void verbose() throws Exception { final String[] expected = { "22:25: " + getCheckMessage(MSG_CONTAINS_TAB), "148:35: " + getCheckMessage(MSG_CONTAINS_TAB), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckTest.java @@ -40,7 +40,7 @@ import java.util.Optional; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { +final class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -48,7 +48,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final GenericWhitespaceCheck checkObj = new GenericWhitespaceCheck(); final int[] expected = { TokenTypes.GENERIC_START, TokenTypes.GENERIC_END, @@ -59,7 +59,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "22:14: " + getCheckMessage(MSG_WS_PRECEDED, "<"), "22:14: " + getCheckMessage(MSG_WS_FOLLOWED, "<"), @@ -102,7 +102,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testAtTheStartOfTheLine() throws Exception { + void atTheStartOfTheLine() throws Exception { final String[] expected = { "16:2: " + getCheckMessage(MSG_WS_PRECEDED, ">"), "18:2: " + getCheckMessage(MSG_WS_PRECEDED, "<"), @@ -111,7 +111,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testNestedGeneric() throws Exception { + void nestedGeneric() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "&"), }; @@ -119,25 +119,25 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testList() throws Exception { + void list() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputGenericWhitespaceList.java"), expected); } @Test - public void testInnerClass() throws Exception { + void innerClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputGenericWhitespaceInnerClass.java"), expected); } @Test - public void testMethodReferences() throws Exception { + void methodReferences() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputGenericWhitespaceMethodRef1.java"), expected); } @Test - public void testMethodReferences2() throws Exception { + void methodReferences2() throws Exception { final String[] expected = { "16:37: " + getCheckMessage(MSG_WS_FOLLOWED, ">"), }; @@ -145,13 +145,13 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testGenericEndsTheLine() throws Exception { + void genericEndsTheLine() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputGenericWhitespaceEndsTheLine.java"), expected); } @Test - public void testGenericWhitespaceWithEmoji() throws Exception { + void genericWhitespaceWithEmoji() throws Exception { final String[] expected = { "35:2: " + getCheckMessage(MSG_WS_PRECEDED, '>'), "40:35: " + getCheckMessage(MSG_WS_PRECEDED, '<'), @@ -163,7 +163,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testBeforeCtorInvocation() throws Exception { + void beforeCtorInvocation() throws Exception { final String[] expected = { "17:31: " + getCheckMessage(MSG_WS_FOLLOWED, '>'), "19:56: " + getCheckMessage(MSG_WS_FOLLOWED, '>'), @@ -187,7 +187,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testAfterNew() throws Exception { + void afterNew() throws Exception { final String[] expected = { "17:30: " + getCheckMessage(MSG_WS_FOLLOWED, '>'), "21:12: " + getCheckMessage(MSG_WS_FOLLOWED, '<'), @@ -213,7 +213,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testBeforeRecordHeader() throws Exception { + void beforeRecordHeader() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputGenericWhitespaceBeforeRecordHeader.java"), expected); @@ -226,7 +226,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { * @throws Exception if there is an error. */ @Test - public void testClearState() throws Exception { + void clearState() throws Exception { final GenericWhitespaceCheck check = new GenericWhitespaceCheck(); final FileText fileText = new FileText( @@ -240,12 +240,15 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { assertWithMessage("State is not cleared on beginTree") .that( TestUtil.isStatefulFieldClearedDuringBeginTree( - check, genericStart.get(), "depth", depth -> ((Number) depth).intValue() == 0)) + check, + genericStart.orElseThrow(), + "depth", + depth -> ((Number) depth).intValue() == 0)) .isTrue(); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final GenericWhitespaceCheck genericWhitespaceCheckObj = new GenericWhitespaceCheck(); final int[] actual = genericWhitespaceCheckObj.getAcceptableTokens(); final int[] expected = { @@ -255,7 +258,7 @@ public class GenericWhitespaceCheckTest extends AbstractModuleTestSupport { } @Test - public void testWrongTokenType() { + void wrongTokenType() { final GenericWhitespaceCheck genericWhitespaceCheckObj = new GenericWhitespaceCheck(); final DetailAstImpl ast = new DetailAstImpl(); ast.initialize(new CommonToken(TokenTypes.INTERFACE_DEF, "interface")); --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MethodParamPadCheckTest extends AbstractModuleTestSupport { +final class MethodParamPadCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,7 +38,7 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final MethodParamPadCheck checkObj = new MethodParamPadCheck(); assertWithMessage( "MethodParamPadCheck#getRequiredTokens should return empty array " + "by default") @@ -47,7 +47,7 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "21:32: " + getCheckMessage(MSG_WS_PRECEDED, "("), "23:15: " + getCheckMessage(MSG_WS_PRECEDED, "("), @@ -72,7 +72,7 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowLineBreaks() throws Exception { + void allowLineBreaks() throws Exception { final String[] expected = { "21:33: " + getCheckMessage(MSG_WS_PRECEDED, "("), "23:15: " + getCheckMessage(MSG_WS_PRECEDED, "("), @@ -88,7 +88,7 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceOption() throws Exception { + void spaceOption() throws Exception { final String[] expected = { "16:32: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "("), "18:14: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "("), @@ -117,7 +117,7 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodParamPadRecords() throws Exception { + void methodParamPadRecords() throws Exception { final String[] expected = { "19:16: " + getCheckMessage(MSG_WS_PRECEDED, "("), "20:34: " + getCheckMessage(MSG_WS_PRECEDED, "("), @@ -134,13 +134,13 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void test1322879() throws Exception { + void test1322879() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodParamPadWhitespaceAround.java"), expected); } @Test - public void testMethodParamPadCheckWithEmoji() throws Exception { + void methodParamPadCheckWithEmoji() throws Exception { final String[] expected = { "19:31: " + getCheckMessage(MSG_WS_PRECEDED, "("), "21:30: " + getCheckMessage(MSG_WS_PRECEDED, "("), @@ -156,7 +156,7 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final MethodParamPadCheck methodParamPadCheckObj = new MethodParamPadCheck(); final int[] actual = methodParamPadCheckObj.getAcceptableTokens(); final int[] expected = { @@ -172,7 +172,7 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -190,7 +190,7 @@ public class MethodParamPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = { "15:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "("), "26:27: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "("), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoLineWrapCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoLineWrapCheckTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NoLineWrapCheckTest extends AbstractModuleTestSupport { +final class NoLineWrapCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,13 +33,13 @@ public class NoLineWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testCaseWithoutLineWrapping() throws Exception { + void caseWithoutLineWrapping() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNoLineWrapGood.java"), expected); } @Test - public void testDefaultTokensLineWrapping() throws Exception { + void defaultTokensLineWrapping() throws Exception { final String[] expected = { "8:1: " + getCheckMessage(MSG_KEY, "package"), "13:1: " + getCheckMessage(MSG_KEY, "import"), @@ -49,7 +49,7 @@ public class NoLineWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testCustomTokensLineWrapping() throws Exception { + void customTokensLineWrapping() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY, "import"), "17:1: " + getCheckMessage(MSG_KEY, "import"), @@ -61,7 +61,7 @@ public class NoLineWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoLineWrapRecordsAndCompactCtors() throws Exception { + void noLineWrapRecordsAndCompactCtors() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(MSG_KEY, "CTOR_DEF"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.antlr.v4.runtime.CommonToken; import org.junit.jupiter.api.Test; -public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { +final class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "10:13: " + getCheckMessage(MSG_KEY, "."), "11:11: " + getCheckMessage(MSG_KEY, "."), @@ -61,13 +61,13 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testAssignment() throws Exception { + void assignment() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputNoWhitespaceAfterTestAssignment.java"), expected); } @Test - public void testDotAllowLineBreaks() throws Exception { + void dotAllowLineBreaks() throws Exception { final String[] expected = { "9:13: " + getCheckMessage(MSG_KEY, "."), "129:23: " + getCheckMessage(MSG_KEY, "."), @@ -78,7 +78,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testTypecast() throws Exception { + void typecast() throws Exception { final String[] expected = { "87:20: " + getCheckMessage(MSG_KEY, ")"), "89:13: " + getCheckMessage(MSG_KEY, ")"), @@ -88,7 +88,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayDeclarations() throws Exception { + void arrayDeclarations() throws Exception { final String[] expected = { "14:12: " + getCheckMessage(MSG_KEY, "Object"), "16:23: " + getCheckMessage(MSG_KEY, "someStuff3"), @@ -116,7 +116,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayDeclarations2() throws Exception { + void arrayDeclarations2() throws Exception { final String[] expected = { "20:31: " + getCheckMessage(MSG_KEY, "]"), "25:41: " + getCheckMessage(MSG_KEY, "create"), @@ -166,12 +166,12 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayDeclarations3() throws Exception { + void arrayDeclarations3() throws Exception { verifyWithInlineConfigParser(getPath("InputNoWhitespaceAfterArrayDeclarations3.java")); } @Test - public void testSynchronized() throws Exception { + void testSynchronized() throws Exception { final String[] expected = { "22:9: " + getCheckMessage(MSG_KEY, "synchronized"), }; @@ -179,12 +179,12 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testNpe() throws Exception { + void npe() throws Exception { verifyWithInlineConfigParser(getPath("InputNoWhitespaceAfterTestNpe.java")); } @Test - public void testMethodReference() throws Exception { + void methodReference() throws Exception { final String[] expected = { "17:41: " + getCheckMessage(MSG_KEY, "int"), "18:62: " + getCheckMessage(MSG_KEY, "String"), }; @@ -192,7 +192,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodReferenceAfter() throws Exception { + void methodReferenceAfter() throws Exception { final String[] expected = { "25:35: " + getCheckMessage(MSG_KEY, "::"), "26:64: " + getCheckMessage(MSG_KEY, "::"), }; @@ -201,7 +201,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayDeclarator() throws Exception { + void arrayDeclarator() throws Exception { final String[] expected = { "19:32: " + getCheckMessage(MSG_KEY, "Entry"), }; @@ -210,7 +210,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testVisitTokenSwitchReflection() { + void visitTokenSwitchReflection() { // unexpected parent for ARRAY_DECLARATOR token final DetailAstImpl astImport = mockAST(TokenTypes.IMPORT, "import"); final DetailAstImpl astArrayDeclarator = mockAST(TokenTypes.ARRAY_DECLARATOR, "["); @@ -230,7 +230,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllTokens() throws Exception { + void allTokens() throws Exception { final String[] expected = { "10:13: " + getCheckMessage(MSG_KEY, "."), "11:11: " + getCheckMessage(MSG_KEY, "."), @@ -259,14 +259,14 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayDeclarationsAndAnnotations() throws Exception { + void arrayDeclarationsAndAnnotations() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputNoWhitespaceAfterArrayDeclarationsAndAnno.java"), expected); } @Test - public void testArrayNewTypeStructure() throws Exception { + void arrayNewTypeStructure() throws Exception { final String[] expected = { "53:17: " + getCheckMessage(MSG_KEY, "ci"), "54:27: " + getCheckMessage(MSG_KEY, "int"), @@ -297,7 +297,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayNewGenericTypeArgument() throws Exception { + void arrayNewGenericTypeArgument() throws Exception { final String[] expected = { "59:15: " + getCheckMessage(MSG_KEY, "i"), @@ -323,7 +323,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoWhitespaceAfterWithEmoji() throws Exception { + void noWhitespaceAfterWithEmoji() throws Exception { final String[] expected = { "16:16: " + getCheckMessage(MSG_KEY, "String"), @@ -339,7 +339,7 @@ public class NoWhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoWhitespaceAfterSynchronized() throws Exception { + void noWhitespaceAfterSynchronized() throws Exception { final String[] expected = { "18:9: " + getCheckMessage(MSG_KEY, "synchronized"), }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCaseDefaultColonCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCaseDefaultColonCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class NoWhitespaceBeforeCaseDefaultColonCheckTest extends AbstractModuleTestSupport { +final class NoWhitespaceBeforeCaseDefaultColonCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class NoWhitespaceBeforeCaseDefaultColonCheckTest extends AbstractModuleT } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { createModuleConfig(NoWhitespaceBeforeCaseDefaultColonCheck.class); final String[] expected = { "15:20: " + getCheckMessage(MSG_KEY, ":"), @@ -56,7 +56,7 @@ public class NoWhitespaceBeforeCaseDefaultColonCheckTest extends AbstractModuleT } @Test - public void testDefaultNonCompilable() throws Exception { + void defaultNonCompilable() throws Exception { createModuleConfig(NoWhitespaceBeforeCaseDefaultColonCheck.class); final String[] expected = { "36:22: " + getCheckMessage(MSG_KEY, ":"), @@ -74,7 +74,7 @@ public class NoWhitespaceBeforeCaseDefaultColonCheckTest extends AbstractModuleT } @Test - public void testAcceptableTokenIsColon() { + void acceptableTokenIsColon() { final NoWhitespaceBeforeCaseDefaultColonCheck check = new NoWhitespaceBeforeCaseDefaultColonCheck(); assertWithMessage("Acceptable token should be colon") --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCheckTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { +final class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "34:15: " + getCheckMessage(MSG_KEY, "++"), "34:22: " + getCheckMessage(MSG_KEY, "--"), @@ -53,7 +53,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDot() throws Exception { + void dot() throws Exception { final String[] expected = { "9:13: " + getCheckMessage(MSG_KEY, "."), "10:5: " + getCheckMessage(MSG_KEY, "."), @@ -66,7 +66,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDotAllowLineBreaks() throws Exception { + void dotAllowLineBreaks() throws Exception { final String[] expected = { "9:13: " + getCheckMessage(MSG_KEY, "."), "133:18: " + getCheckMessage(MSG_KEY, "."), @@ -77,7 +77,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodReference() throws Exception { + void methodReference() throws Exception { final String[] expected = { "25:32: " + getCheckMessage(MSG_KEY, "::"), "26:61: " + getCheckMessage(MSG_KEY, "::"), }; @@ -85,7 +85,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testDotAtTheStartOfTheLine() throws Exception { + void dotAtTheStartOfTheLine() throws Exception { final String[] expected = { "10:1: " + getCheckMessage(MSG_KEY, "."), }; @@ -93,7 +93,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodRefAtTheStartOfTheLine() throws Exception { + void methodRefAtTheStartOfTheLine() throws Exception { final String[] expected = { "22:3: " + getCheckMessage(MSG_KEY, "::"), }; @@ -102,7 +102,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyForLoop() throws Exception { + void emptyForLoop() throws Exception { final String[] expected = { "20:24: " + getCheckMessage(MSG_KEY, ";"), "26:32: " + getCheckMessage(MSG_KEY, ";"), }; @@ -110,7 +110,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoWhitespaceBeforeTextBlocksWithTabIndent() throws Exception { + void noWhitespaceBeforeTextBlocksWithTabIndent() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -119,7 +119,7 @@ public class NoWhitespaceBeforeCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoWhitespaceBeforeWithEmoji() throws Exception { + void noWhitespaceBeforeWithEmoji() throws Exception { final String[] expected = { "13:15: " + getCheckMessage(MSG_KEY, ","), "14:17: " + getCheckMessage(MSG_KEY, ","), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/OperatorWrapCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/OperatorWrapCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class OperatorWrapCheckTest extends AbstractModuleTestSupport { +final class OperatorWrapCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "23:19: " + getCheckMessage(MSG_LINE_NEW, "+"), "24:15: " + getCheckMessage(MSG_LINE_NEW, "-"), @@ -48,7 +48,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testOpWrapEol() throws Exception { + void opWrapEol() throws Exception { final String[] expected = { "26:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "-"), "30:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "&&"), @@ -58,7 +58,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonDefOpsDefault() throws Exception { + void nonDefOpsDefault() throws Exception { final String[] expected = { "37:33: " + getCheckMessage(MSG_LINE_NEW, "::"), }; @@ -66,7 +66,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testNonDefOpsWrapEol() throws Exception { + void nonDefOpsWrapEol() throws Exception { final String[] expected = { "35:21: " + getCheckMessage(MSG_LINE_PREVIOUS, "::"), "40:21: " + getCheckMessage(MSG_LINE_PREVIOUS, "::"), @@ -75,7 +75,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testAssignEol() throws Exception { + void assignEol() throws Exception { final String[] expected = { "46:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "="), }; @@ -83,7 +83,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testEol() throws Exception { + void eol() throws Exception { final String[] expected = { "21:17: " + getCheckMessage(MSG_LINE_PREVIOUS, "="), "22:17: " + getCheckMessage(MSG_LINE_PREVIOUS, "*"), @@ -99,7 +99,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testNl() throws Exception { + void nl() throws Exception { final String[] expected = { "20:16: " + getCheckMessage(MSG_LINE_NEW, "="), "21:19: " + getCheckMessage(MSG_LINE_NEW, "*"), @@ -114,7 +114,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testArraysAssign() throws Exception { + void arraysAssign() throws Exception { final String[] expected = { "18:22: " + getCheckMessage(MSG_LINE_NEW, "="), "36:28: " + getCheckMessage(MSG_LINE_NEW, "="), @@ -124,7 +124,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testGuardedPattern() throws Exception { + void guardedPattern() throws Exception { final String[] expected = { "52:30: " + getCheckMessage(MSG_LINE_NEW, "&&"), "54:31: " + getCheckMessage(MSG_LINE_NEW, "&&"), @@ -142,13 +142,13 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResources() throws Exception { + void tryWithResources() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputOperatorWrapTryWithResources.java"), expected); } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -167,7 +167,7 @@ public class OperatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = { "18:21: " + getCheckMessage(MSG_LINE_PREVIOUS, ":"), "19:21: " + getCheckMessage(MSG_LINE_PREVIOUS, "?"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadCheckTest.java @@ -33,7 +33,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import com.puppycrawl.tools.checkstyle.utils.TokenUtil; import org.junit.jupiter.api.Test; -public class ParenPadCheckTest extends AbstractModuleTestSupport { +final class ParenPadCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,7 +41,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "65:11: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "65:37: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -57,7 +57,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpace() throws Exception { + void space() throws Exception { final String[] expected = { "36:19: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "36:23: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -99,7 +99,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefaultForIterator() throws Exception { + void defaultForIterator() throws Exception { final String[] expected = { "24:35: " + getCheckMessage(MSG_WS_PRECEDED, ")"), "27:36: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -113,7 +113,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceEmptyForIterator() throws Exception { + void spaceEmptyForIterator() throws Exception { final String[] expected = { "18:13: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "18:35: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -129,20 +129,20 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void test1322879() throws Exception { + void test1322879() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParenPadWithSpace.java"), expected); } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getPath("InputParenPadToCheckTrimFunctionInOptionProperty.java"), expected); } @Test - public void testNospaceWithComplexInput() throws Exception { + void nospaceWithComplexInput() throws Exception { final String[] expected = { "55:26: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "55:28: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -270,7 +270,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testConfigureTokens() throws Exception { + void configureTokens() throws Exception { final String[] expected = { "98:39: " + getCheckMessage(MSG_WS_PRECEDED, ")"), "121:22: " + getCheckMessage(MSG_WS_FOLLOWED, "("), @@ -303,7 +303,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -322,7 +322,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaAssignment() throws Exception { + void lambdaAssignment() throws Exception { final String[] expected = { "20:41: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "20:45: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -341,7 +341,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaAssignmentWithSpace() throws Exception { + void lambdaAssignmentWithSpace() throws Exception { final String[] expected = { "20:41: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "20:43: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -358,7 +358,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaCheckDisabled() throws Exception { + void lambdaCheckDisabled() throws Exception { final String[] expected = { "27:61: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "27:63: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -369,7 +369,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaCheckDisabledWithSpace() throws Exception { + void lambdaCheckDisabledWithSpace() throws Exception { final String[] expected = { "30:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "30:33: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -378,7 +378,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaCheckOnly() throws Exception { + void lambdaCheckOnly() throws Exception { final String[] expected = { "17:41: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "17:45: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -393,7 +393,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaCheckOnlyWithSpace() throws Exception { + void lambdaCheckOnlyWithSpace() throws Exception { final String[] expected = { "17:41: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "17:43: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -408,7 +408,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaCheckOnlyWithSpace1() throws Exception { + void lambdaCheckOnlyWithSpace1() throws Exception { final String[] expected = { "16:2: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), }; @@ -416,7 +416,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResources() throws Exception { + void tryWithResources() throws Exception { final String[] expected = { "20:37: " + getCheckMessage(MSG_WS_PRECEDED, ")"), "21:61: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -426,7 +426,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testTryWithResourcesAndSuppression() throws Exception { + void tryWithResourcesAndSuppression() throws Exception { final String[] expectedFiltered = CommonUtil.EMPTY_STRING_ARRAY; final String[] expectedUnfiltered = { "23:13: " + getCheckMessage(MSG_WS_FOLLOWED, "("), @@ -438,13 +438,13 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoStackoverflowError() throws Exception { + void noStackoverflowError() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithLimitedResources(getPath("InputParenPadNoStackoverflowError.java"), expected); } @Test - public void testParenPadCheckRecords() throws Exception { + void parenPadCheckRecords() throws Exception { final String[] expected = { "20:21: " + getCheckMessage(MSG_WS_FOLLOWED, "("), @@ -465,7 +465,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testParenPadCheckRecordsWithSpace() throws Exception { + void parenPadCheckRecordsWithSpace() throws Exception { final String[] expected = { "25:19: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -486,7 +486,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testParenPadCheckEmoji() throws Exception { + void parenPadCheckEmoji() throws Exception { final String[] expected = { "25:45: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -500,7 +500,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testParenPadForSynchronized() throws Exception { + void parenPadForSynchronized() throws Exception { final String[] expected = { "18:29: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -509,7 +509,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testParenPadForEnum() throws Exception { + void parenPadForEnum() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputParenPadForEnum.java"), expected); @@ -524,7 +524,7 @@ public class ParenPadCheckTest extends AbstractModuleTestSupport { * pass that check. */ @Test - public void testIsAcceptableToken() throws Exception { + void isAcceptableToken() throws Exception { final ParenPadCheck check = new ParenPadCheck(); final DetailAstImpl ast = new DetailAstImpl(); final String message = --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SeparatorWrapCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SeparatorWrapCheckTest.java @@ -29,7 +29,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { +final class SeparatorWrapCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -37,7 +37,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testDot() throws Exception { + void dot() throws Exception { final String[] expected = { "39:10: " + getCheckMessage(MSG_LINE_NEW, "."), }; @@ -45,7 +45,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testComma() throws Exception { + void comma() throws Exception { final String[] expected = { "47:17: " + getCheckMessage(MSG_LINE_PREVIOUS, ","), }; @@ -53,7 +53,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testMethodRef() throws Exception { + void methodRef() throws Exception { final String[] expected = { "25:56: " + getCheckMessage(MSG_LINE_NEW, "::"), }; @@ -61,7 +61,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetDefaultTokens() { + void getDefaultTokens() { final SeparatorWrapCheck separatorWrapCheckObj = new SeparatorWrapCheck(); final int[] actual = separatorWrapCheckObj.getDefaultTokens(); final int[] expected = { @@ -71,7 +71,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testInvalidOption() throws Exception { + void invalidOption() throws Exception { try { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -90,7 +90,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testEllipsis() throws Exception { + void ellipsis() throws Exception { final String[] expected = { "19:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "..."), }; @@ -98,7 +98,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayDeclarator() throws Exception { + void arrayDeclarator() throws Exception { final String[] expected = { "17:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "["), }; @@ -106,7 +106,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testWithEmoji() throws Exception { + void withEmoji() throws Exception { final String[] expected = { "13:39: " + getCheckMessage(MSG_LINE_NEW, '['), "16:57: " + getCheckMessage(MSG_LINE_NEW, '['), @@ -119,7 +119,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testTrimOptionProperty() throws Exception { + void trimOptionProperty() throws Exception { final String[] expected = { "18:44: " + getCheckMessage(MSG_LINE_NEW, "::"), }; @@ -127,7 +127,7 @@ public class SeparatorWrapCheckTest extends AbstractModuleTestSupport { } @Test - public void testCommaOnNewLine() throws Exception { + void commaOnNewLine() throws Exception { final String[] expected = { "16:10: " + getCheckMessage(MSG_LINE_NEW, ","), "21:26: " + getCheckMessage(MSG_LINE_NEW, ","), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SingleSpaceSeparatorCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SingleSpaceSeparatorCheckTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { +final class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -34,20 +34,20 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testNoSpaceErrors() throws Exception { + void noSpaceErrors() throws Exception { verifyWithInlineConfigParser( getPath("InputSingleSpaceSeparatorNoErrors.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testNoStackoverflowError() throws Exception { + void noStackoverflowError() throws Exception { verifyWithLimitedResources( getPath("InputSingleSpaceSeparatorNoStackoverflowError.java"), CommonUtil.EMPTY_STRING_ARRAY); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final SingleSpaceSeparatorCheck check = new SingleSpaceSeparatorCheck(); assertWithMessage("Invalid acceptable tokens") @@ -56,7 +56,7 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceErrors() throws Exception { + void spaceErrors() throws Exception { final String[] expected = { "8:10: " + getCheckMessage(MSG_KEY), "8:28: " + getCheckMessage(MSG_KEY), @@ -96,7 +96,7 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceErrorsAroundComments() throws Exception { + void spaceErrorsAroundComments() throws Exception { final String[] expected = { "12:11: " + getCheckMessage(MSG_KEY), "12:43: " + getCheckMessage(MSG_KEY), @@ -110,7 +110,7 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceErrorsInChildNodes() throws Exception { + void spaceErrorsInChildNodes() throws Exception { final String[] expected = { "12:16: " + getCheckMessage(MSG_KEY), }; @@ -119,7 +119,7 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testMinColumnNo() throws Exception { + void minColumnNo() throws Exception { final String[] expected = { "12:4: " + getCheckMessage(MSG_KEY), }; @@ -128,7 +128,7 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceInStartOfTheLine() throws Exception { + void whitespaceInStartOfTheLine() throws Exception { final String[] expected = { "12:7: " + getCheckMessage(MSG_KEY), }; @@ -137,7 +137,7 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceErrorsIfCommentsIgnored() throws Exception { + void spaceErrorsIfCommentsIgnored() throws Exception { final String[] expected = { "20:14: " + getCheckMessage(MSG_KEY), }; @@ -146,14 +146,14 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmpty() throws Exception { + void empty() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputSingleSpaceSeparatorEmpty.java"), expected); } @Test - public void testSpaceErrorsWithEmoji() throws Exception { + void spaceErrorsWithEmoji() throws Exception { final String[] expected = { "14:18: " + getCheckMessage(MSG_KEY), "16:17: " + getCheckMessage(MSG_KEY), @@ -173,7 +173,7 @@ public class SingleSpaceSeparatorCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpaceErrorsAroundCommentsWithEmoji() throws Exception { + void spaceErrorsAroundCommentsWithEmoji() throws Exception { final String[] expected = { "25:22: " + getCheckMessage(MSG_KEY), "25:26: " + getCheckMessage(MSG_KEY), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadCheckTest.java @@ -30,7 +30,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class TypecastParenPadCheckTest extends AbstractModuleTestSupport { +final class TypecastParenPadCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -38,7 +38,7 @@ public class TypecastParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "86:13: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "86:22: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -47,7 +47,7 @@ public class TypecastParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void testSpace() throws Exception { + void space() throws Exception { final String[] expected = { "84:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "84:27: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), @@ -63,13 +63,13 @@ public class TypecastParenPadCheckTest extends AbstractModuleTestSupport { } @Test - public void test1322879() throws Exception { + void test1322879() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputTypecastParenPadWhitespaceAround.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final TypecastParenPadCheck typecastParenPadCheckObj = new TypecastParenPadCheck(); final int[] actual = typecastParenPadCheckObj.getAcceptableTokens(); final int[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterCheckTest.java @@ -27,7 +27,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { +final class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -35,7 +35,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final WhitespaceAfterCheck checkObj = new WhitespaceAfterCheck(); assertWithMessage("WhitespaceAfterCheck#getRequiredTokens should return empty array by default") .that(checkObj.getRequiredTokens()) @@ -43,7 +43,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] expected = { "45:39: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), "74:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), @@ -52,7 +52,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testCast() throws Exception { + void cast() throws Exception { final String[] expected = { "91:20: " + getCheckMessage(MSG_WS_TYPECAST), }; @@ -60,7 +60,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testMultilineCast() throws Exception { + void multilineCast() throws Exception { final String[] expected = { "14:23: " + getCheckMessage(MSG_WS_TYPECAST), }; @@ -68,7 +68,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testSemi() throws Exception { + void semi() throws Exception { final String[] expected = { "57:22: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), "57:28: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), @@ -78,7 +78,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralWhile() throws Exception { + void literalWhile() throws Exception { final String[] expected = { "46:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), }; @@ -86,7 +86,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralIf() throws Exception { + void literalIf() throws Exception { final String[] expected = { "25:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "if"), }; @@ -94,7 +94,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralElse() throws Exception { + void literalElse() throws Exception { final String[] expected = { "34:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "else"), }; @@ -102,7 +102,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralFor() throws Exception { + void literalFor() throws Exception { final String[] expected = { "58:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "for"), }; @@ -110,7 +110,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralFinally() throws Exception { + void literalFinally() throws Exception { final String[] expected = { "14:13: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "finally"), "17:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "finally"), @@ -119,7 +119,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralReturn() throws Exception { + void literalReturn() throws Exception { final String[] expected = { "17:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "return"), "21:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "return"), @@ -130,7 +130,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralDo() throws Exception { + void literalDo() throws Exception { final String[] expected = { "70:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "do"), }; @@ -138,7 +138,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralYield() throws Exception { + void literalYield() throws Exception { final String[] expected = { "17:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "yield"), }; @@ -147,7 +147,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralSynchronized() throws Exception { + void literalSynchronized() throws Exception { final String[] expected = { "13:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "synchronized"), "31:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "synchronized"), @@ -157,7 +157,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testDoWhile() throws Exception { + void doWhile() throws Exception { final String[] expected = { "25:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), }; @@ -165,7 +165,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralTry() throws Exception { + void literalTry() throws Exception { final String[] expected = { "20:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "try"), "24:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "try"), @@ -174,7 +174,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralCatch() throws Exception { + void literalCatch() throws Exception { final String[] expected = { "14:14: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "catch"), }; @@ -182,7 +182,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralCase() throws Exception { + void literalCase() throws Exception { final String[] expected = { "15:13: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "case"), }; @@ -190,7 +190,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLiteralCase2() throws Exception { + void literalCase2() throws Exception { final String[] expected = { "13:13: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "case"), }; @@ -198,7 +198,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyForIterator() throws Exception { + void emptyForIterator() throws Exception { final String[] expected = { "18:30: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), "21:30: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), @@ -207,7 +207,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testTypeArgumentAndParameterCommas() throws Exception { + void typeArgumentAndParameterCommas() throws Exception { final String[] expected = { "20:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), "20:22: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), @@ -217,13 +217,13 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void test1322879() throws Exception { + void test1322879() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputWhitespaceAfterAround.java"), expected); } @Test - public void testCountUnicodeCorrectly() throws Exception { + void countUnicodeCorrectly() throws Exception { final String[] expected = { "14:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), }; @@ -232,7 +232,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testVarargs() throws Exception { + void varargs() throws Exception { final String[] expected = { "14:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "..."), "18:25: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "..."), @@ -244,7 +244,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchStatements() throws Exception { + void switchStatements() throws Exception { final String[] expected = { "18:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "switch"), "31:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "switch"), @@ -260,7 +260,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testLambdaExpressions() throws Exception { + void lambdaExpressions() throws Exception { final String[] expected = { "17:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "->"), "19:22: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "->"), @@ -271,7 +271,7 @@ public class WhitespaceAfterCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceAfterWithEmoji() throws Exception { + void whitespaceAfterWithEmoji() throws Exception { final String[] expected = { "13:48: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), "13:52: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundCheckTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { +final class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testGetRequiredTokens() { + void getRequiredTokens() { final WhitespaceAroundCheck checkObj = new WhitespaceAroundCheck(); assertWithMessage( "WhitespaceAroundCheck#getRequiredTokens should return empty array by default") @@ -45,7 +45,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testKeywordsAndOperators() throws Exception { + void keywordsAndOperators() throws Exception { final String[] expected = { "32:22: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), "32:22: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -93,7 +93,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testSimpleInput() throws Exception { + void simpleInput() throws Exception { final String[] expected = { "168:26: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), "169:26: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -106,7 +106,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testStartOfTheLine() throws Exception { + void startOfTheLine() throws Exception { final String[] expected = { "25:2: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), }; @@ -114,7 +114,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testBraces() throws Exception { + void braces() throws Exception { final String[] expected = { "53:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), "70:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "for"), @@ -133,7 +133,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testBracesInMethodsAndConstructors() throws Exception { + void bracesInMethodsAndConstructors() throws Exception { final String[] expected = { "53:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), "70:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "for"), @@ -146,7 +146,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testArrayInitialization() throws Exception { + void arrayInitialization() throws Exception { final String[] expected = { "21:39: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), "25:37: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), @@ -162,7 +162,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testGenericsTokensAreFlagged() throws Exception { + void genericsTokensAreFlagged() throws Exception { final String[] expected = { "27:16: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "&"), "27:16: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "&"), @@ -171,13 +171,13 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void test1322879And1649038() throws Exception { + void test1322879And1649038() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputWhitespaceAround1.java"), expected); } @Test - public void testAllowDoubleBraceInitialization() throws Exception { + void allowDoubleBraceInitialization() throws Exception { final String[] expected = { "31:33: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), "32:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), @@ -191,7 +191,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testIgnoreEnhancedForColon() throws Exception { + void ignoreEnhancedForColon() throws Exception { final String[] expected = { "39:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ":"), }; @@ -199,7 +199,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyTypes() throws Exception { + void emptyTypes() throws Exception { final String[] expected = { "45:94: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "45:95: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -213,7 +213,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testEmptyLoops() throws Exception { + void emptyLoops() throws Exception { final String[] expected = { "56:65: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "56:66: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -231,7 +231,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testSwitchWhitespaceAround() throws Exception { + void switchWhitespaceAround() throws Exception { final String[] expected = { "26:9: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "switch"), }; @@ -239,7 +239,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testDoWhileWhitespaceAround() throws Exception { + void doWhileWhitespaceAround() throws Exception { final String[] expected = { "29:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "while"), }; @@ -247,13 +247,13 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void allowEmptyMethods() throws Exception { + void allowEmptyMethods() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputWhitespaceAround3.java"), expected); } @Test - public void testGetAcceptableTokens() { + void getAcceptableTokens() { final WhitespaceAroundCheck whitespaceAroundCheckObj = new WhitespaceAroundCheck(); final int[] actual = whitespaceAroundCheckObj.getAcceptableTokens(); final int[] expected = { @@ -318,7 +318,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowEmptyTypesIsSetToFalseAndNonEmptyClasses() throws Exception { + void allowEmptyTypesIsSetToFalseAndNonEmptyClasses() throws Exception { final String[] expected = { "31:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), "35:32: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), @@ -341,7 +341,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowEmptyTypesIsSetToTrueAndNonEmptyClasses() throws Exception { + void allowEmptyTypesIsSetToTrueAndNonEmptyClasses() throws Exception { final String[] expected = { "30:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), "34:32: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), @@ -360,7 +360,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testNotAllowEmptyLambdaExpressionsByDefault() throws Exception { + void notAllowEmptyLambdaExpressionsByDefault() throws Exception { final String[] expected = { "27:27: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "27:28: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -374,7 +374,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testAllowEmptyLambdaExpressionsWithAllowEmptyLambdaParameter() throws Exception { + void allowEmptyLambdaExpressionsWithAllowEmptyLambdaParameter() throws Exception { final String[] expected = { "32:28: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "32:30: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -386,7 +386,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceAroundLambda() throws Exception { + void whitespaceAroundLambda() throws Exception { final String[] expected = { "28:48: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "->"), "28:48: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "->"), @@ -395,13 +395,13 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceAroundEmptyCatchBlock() throws Exception { + void whitespaceAroundEmptyCatchBlock() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputWhitespaceAroundCatch.java"), expected); } @Test - public void testWhitespaceAroundVarargs() throws Exception { + void whitespaceAroundVarargs() throws Exception { final String[] expected = { "19:29: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "..."), "20:37: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "..."), @@ -416,7 +416,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceAroundRecords() throws Exception { + void whitespaceAroundRecords() throws Exception { final String[] expected = { "26:23: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "26:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -445,7 +445,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceAroundAllowEmptyCompactCtors() throws Exception { + void whitespaceAroundAllowEmptyCompactCtors() throws Exception { final String[] expected = { "26:23: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "26:24: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -474,14 +474,14 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceAroundRecordsAllowEmptyTypes() throws Exception { + void whitespaceAroundRecordsAllowEmptyTypes() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputWhitespaceAroundRecordsAllowEmptyTypes.java"), expected); } @Test - public void testWhitespaceAroundAllTokens() throws Exception { + void whitespaceAroundAllTokens() throws Exception { final String[] expected = { "27:29: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "<"), "27:29: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "<"), @@ -497,7 +497,7 @@ public class WhitespaceAroundCheckTest extends AbstractModuleTestSupport { } @Test - public void testWhitespaceAroundAfterEmoji() throws Exception { + void whitespaceAroundAfterEmoji() throws Exception { final String[] expected = { "25:22: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "+"), "26:23: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "+"), --- a/src/test/java/com/puppycrawl/tools/checkstyle/filefilters/BeforeExecutionExclusionFileFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filefilters/BeforeExecutionExclusionFileFilterTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.util.regex.Pattern; import org.junit.jupiter.api.Test; -public class BeforeExecutionExclusionFileFilterTest extends AbstractModuleTestSupport { +final class BeforeExecutionExclusionFileFilterTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class BeforeExecutionExclusionFileFilterTest extends AbstractModuleTestSu } @Test - public void testAccept() { + void accept() { final String fileName = "BAD"; final BeforeExecutionExclusionFileFilter filter = createExclusionBeforeExecutionFileFilter(fileName); @@ -47,7 +47,7 @@ public class BeforeExecutionExclusionFileFilterTest extends AbstractModuleTestSu } @Test - public void testAcceptOnNullFile() { + void acceptOnNullFile() { final String fileName = null; final BeforeExecutionExclusionFileFilter filter = createExclusionBeforeExecutionFileFilter(fileName); @@ -56,7 +56,7 @@ public class BeforeExecutionExclusionFileFilterTest extends AbstractModuleTestSu } @Test - public void testReject() { + void reject() { final String fileName = "Test"; final BeforeExecutionExclusionFileFilter filter = createExclusionBeforeExecutionFileFilter(fileName); @@ -67,7 +67,7 @@ public class BeforeExecutionExclusionFileFilterTest extends AbstractModuleTestSu } @Test - public void testFileExclusion() throws Exception { + void fileExclusion() throws Exception { final String[] filteredViolations = CommonUtil.EMPTY_STRING_ARRAY; final String[] unfilteredViolations = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/CsvFilterElementTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/CsvFilterElementTest.java @@ -25,10 +25,10 @@ import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.Test; -public class CsvFilterElementTest { +final class CsvFilterElementTest { @Test - public void testDecideSingle() { + void decideSingle() { final IntFilterElement filter = new CsvFilterElement("0"); assertWithMessage("less than").that(filter.accept(-1)).isFalse(); assertWithMessage("equal").that(filter.accept(0)).isTrue(); @@ -36,7 +36,7 @@ public class CsvFilterElementTest { } @Test - public void testDecidePair() { + void decidePair() { final IntFilterElement filter = new CsvFilterElement("0, 2"); assertWithMessage("less than").that(filter.accept(-1)).isFalse(); assertWithMessage("equal 0").that(filter.accept(0)).isTrue(); @@ -45,7 +45,7 @@ public class CsvFilterElementTest { } @Test - public void testDecideRange() { + void decideRange() { final IntFilterElement filter = new CsvFilterElement("0-2"); assertWithMessage("less than").that(filter.accept(-1)).isFalse(); assertWithMessage("equal 0").that(filter.accept(0)).isTrue(); @@ -55,7 +55,7 @@ public class CsvFilterElementTest { } @Test - public void testDecideEmptyRange() { + void decideEmptyRange() { final IntFilterElement filter = new CsvFilterElement("2-0"); assertWithMessage("less than").that(filter.accept(-1)).isFalse(); assertWithMessage("equal 0").that(filter.accept(0)).isFalse(); @@ -65,7 +65,7 @@ public class CsvFilterElementTest { } @Test - public void testDecideRangePlusValue() { + void decideRangePlusValue() { final IntFilterElement filter = new CsvFilterElement("0-2, 10"); assertWithMessage("less than").that(filter.accept(-1)).isFalse(); assertWithMessage("equal 0").that(filter.accept(0)).isTrue(); @@ -76,13 +76,13 @@ public class CsvFilterElementTest { } @Test - public void testEmptyChain() { + void emptyChain() { final CsvFilterElement filter = new CsvFilterElement(""); assertWithMessage("0").that(filter.accept(0)).isFalse(); } @Test - public void testEqualsAndHashCode() { + void equalsAndHashCode() { final EqualsVerifierReport ev = EqualsVerifier.forClass(CsvFilterElement.class).usingGetClass().report(); assertWithMessage("Error: " + ev.getMessage()).that(ev.isSuccessful()).isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/IntMatchFilterElementTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/IntMatchFilterElementTest.java @@ -25,10 +25,10 @@ import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.Test; -public class IntMatchFilterElementTest { +final class IntMatchFilterElementTest { @Test - public void testDecide() { + void decide() { final IntFilterElement filter = new IntMatchFilterElement(0); assertWithMessage("less than").that(filter.accept(-1)).isFalse(); assertWithMessage("equal").that(filter.accept(0)).isTrue(); @@ -36,13 +36,13 @@ public class IntMatchFilterElementTest { } @Test - public void testEqualsAndHashCode() { + void equalsAndHashCode() { final EqualsVerifierReport ev = EqualsVerifier.forClass(IntMatchFilterElement.class).report(); assertWithMessage("Error: " + ev.getMessage()).that(ev.isSuccessful()).isTrue(); } @Test - public void testToString() { + void testToString() { final IntFilterElement filter = new IntMatchFilterElement(6); assertWithMessage("Invalid toString result") .that(filter.toString()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/IntRangeFilterElementTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/IntRangeFilterElementTest.java @@ -25,10 +25,10 @@ import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.Test; -public class IntRangeFilterElementTest { +final class IntRangeFilterElementTest { @Test - public void testDecide() { + void decide() { final IntFilterElement filter = new IntRangeFilterElement(0, 10); assertWithMessage("less than").that(filter.accept(-1)).isFalse(); assertWithMessage("in range").that(filter.accept(0)).isTrue(); @@ -38,7 +38,7 @@ public class IntRangeFilterElementTest { } @Test - public void testDecideSingle() { + void decideSingle() { final IntFilterElement filter = new IntRangeFilterElement(0, 0); assertWithMessage("less than").that(filter.accept(-1)).isFalse(); assertWithMessage("in range").that(filter.accept(0)).isTrue(); @@ -46,7 +46,7 @@ public class IntRangeFilterElementTest { } @Test - public void testDecideEmpty() { + void decideEmpty() { final IntFilterElement filter = new IntRangeFilterElement(10, 0); assertWithMessage("out").that(filter.accept(-1)).isFalse(); assertWithMessage("out").that(filter.accept(0)).isFalse(); @@ -56,7 +56,7 @@ public class IntRangeFilterElementTest { } @Test - public void testEqualsAndHashCode() { + void equalsAndHashCode() { final EqualsVerifierReport ev = EqualsVerifier.forClass(IntRangeFilterElement.class).usingGetClass().report(); assertWithMessage("Error: " + ev.getMessage()).that(ev.isSuccessful()).isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterTest.java @@ -28,12 +28,12 @@ import com.puppycrawl.tools.checkstyle.api.SeverityLevel; import com.puppycrawl.tools.checkstyle.api.Violation; import org.junit.jupiter.api.Test; -public class SeverityMatchFilterTest { +final class SeverityMatchFilterTest { private final SeverityMatchFilter filter = new SeverityMatchFilter(); @Test - public void testDefault() { + void testDefault() { final AuditEvent ev = new AuditEvent(this, "Test.java"); assertWithMessage("no message").that(filter.accept(ev)).isFalse(); final SeverityLevel errorLevel = SeverityLevel.ERROR; @@ -49,7 +49,7 @@ public class SeverityMatchFilterTest { } @Test - public void testSeverity() { + void severity() { filter.setSeverity(SeverityLevel.INFO); final AuditEvent ev = new AuditEvent(this, "Test.java"); // event with no message has severity level INFO @@ -67,7 +67,7 @@ public class SeverityMatchFilterTest { } @Test - public void testAcceptOnMatch() { + void acceptOnMatch() { filter.setSeverity(SeverityLevel.INFO); filter.setAcceptOnMatch(false); final AuditEvent ev = new AuditEvent(this, "Test.java"); @@ -86,7 +86,7 @@ public class SeverityMatchFilterTest { } @Test - public void testConfigure() throws CheckstyleException { + void configure() throws CheckstyleException { filter.configure(new DefaultConfiguration("test")); assertWithMessage("object exists").that(filter).isNotNull(); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressFilterElementTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressFilterElementTest.java @@ -30,23 +30,23 @@ import nl.jqno.equalsverifier.Warning; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class SuppressFilterElementTest { +final class SuppressFilterElementTest { private SuppressFilterElement filter; @BeforeEach - public void setUp() { + void setUp() { filter = new SuppressFilterElement("Test", "Test", null, null, null, null); } @Test - public void testDecideDefault() { + void decideDefault() { final AuditEvent ev = new AuditEvent(this, "Test.java"); assertWithMessage(ev.getFileName()).that(filter.accept(ev)).isTrue(); } @Test - public void testDecideViolation() { + void decideViolation() { final Violation violation = new Violation(1, 0, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", violation); // deny because there are matches on file and check names @@ -54,7 +54,7 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByMessage() { + void decideByMessage() { final Violation violation = new Violation(1, 0, "", "", null, null, getClass(), "Test"); final AuditEvent ev = new AuditEvent(this, "ATest.java", violation); final SuppressFilterElement filter1 = @@ -66,7 +66,7 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByLine() { + void decideByLine() { final Violation violation = new Violation(10, 10, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", violation); final SuppressFilterElement filter1 = @@ -82,7 +82,7 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByColumn() { + void decideByColumn() { final Violation violation = new Violation(10, 10, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", violation); final SuppressFilterElement filter1 = @@ -96,27 +96,27 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByFileNameAndModuleMatchingFileNameNull() { + void decideByFileNameAndModuleMatchingFileNameNull() { final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, null, message); assertWithMessage("Filter should accept valid event").that(filter.accept(ev)).isTrue(); } @Test - public void testDecideByFileNameAndModuleMatchingMessageNull() { + void decideByFileNameAndModuleMatchingMessageNull() { final AuditEvent ev = new AuditEvent(this, "ATest.java", null); assertWithMessage("Filter should accept valid event").that(filter.accept(ev)).isTrue(); } @Test - public void testDecideByFileNameAndModuleMatchingModuleNull() { + void decideByFileNameAndModuleMatchingModuleNull() { final Violation violation = new Violation(10, 10, "", "", null, "MyModule", getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", violation); assertWithMessage("Filter should not accept invalid event").that(filter.accept(ev)).isFalse(); } @Test - public void testDecideByFileNameAndModuleMatchingModuleEqual() { + void decideByFileNameAndModuleMatchingModuleEqual() { final Violation violation = new Violation(10, 10, "", "", null, "MyModule", getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", violation); final SuppressFilterElement myFilter = @@ -126,7 +126,7 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByFileNameAndModuleMatchingModuleNotEqual() { + void decideByFileNameAndModuleMatchingModuleNotEqual() { final Violation message = new Violation(10, 10, "", "", null, "TheirModule", getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", message); final SuppressFilterElement myFilter = @@ -136,14 +136,14 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByFileNameAndModuleMatchingRegExpNotMatch() { + void decideByFileNameAndModuleMatchingRegExpNotMatch() { final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, "T1est", message); assertWithMessage("Filter should accept valid event").that(filter.accept(ev)).isTrue(); } @Test - public void testDecideByFileNameAndModuleMatchingRegExpMatch() { + void decideByFileNameAndModuleMatchingRegExpMatch() { final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, "TestSUFFIX", message); final SuppressFilterElement myFilter = @@ -152,7 +152,7 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByFileNameAndModuleMatchingCheckRegExpNotMatch() { + void decideByFileNameAndModuleMatchingCheckRegExpNotMatch() { final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", message); final SuppressFilterElement myFilter = @@ -161,7 +161,7 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByFileNameAndModuleMatchingCheckRegExpMatch() { + void decideByFileNameAndModuleMatchingCheckRegExpMatch() { final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", message); final SuppressFilterElement myFilter = @@ -171,7 +171,7 @@ public class SuppressFilterElementTest { } @Test - public void testDecideByFileNameAndSourceNameCheckRegExpNotMatch() { + void decideByFileNameAndSourceNameCheckRegExpNotMatch() { final Violation message = new Violation(10, 10, "", "", null, null, getClass(), null); final AuditEvent ev = new AuditEvent(this, "ATest.java", message); final SuppressFilterElement myFilter = @@ -182,7 +182,7 @@ public class SuppressFilterElementTest { } @Test - public void testEquals() { + void testEquals() { // filterBased is used instead of filter field only to satisfy IntelliJ IDEA Inspection // Inspection "Arguments to assertEquals() in wrong order " final SuppressFilterElement filterBased = @@ -213,7 +213,7 @@ public class SuppressFilterElementTest { } @Test - public void testEqualsAndHashCode() { + void equalsAndHashCode() { final EqualsVerifierReport ev = EqualsVerifier.forClass(SuppressFilterElement.class) .usingGetClass() --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilterTest.java @@ -31,7 +31,7 @@ import com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class SuppressWarningsFilterTest extends AbstractModuleTestSupport { +final class SuppressWarningsFilterTest extends AbstractModuleTestSupport { private static final String[] ALL_MESSAGES = { "48:5: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), @@ -73,14 +73,14 @@ public class SuppressWarningsFilterTest extends AbstractModuleTestSupport { } @Test - public void testNone() throws Exception { + void none() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser( getPath("InputSuppressWarningsFilterWithoutFilter.java"), suppressed); } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] suppressed = { "56:17: " + getCheckMessage( @@ -102,7 +102,7 @@ public class SuppressWarningsFilterTest extends AbstractModuleTestSupport { } @Test - public void testSuppressById() throws Exception { + void suppressById() throws Exception { final String[] suppressedViolationMessages = { "49:17: " + getCheckMessage( --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilterTest.java @@ -22,6 +22,7 @@ package com.puppycrawl.tools.checkstyle.filters; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; import com.puppycrawl.tools.checkstyle.TreeWalker; @@ -37,13 +38,12 @@ import com.puppycrawl.tools.checkstyle.internal.utils.TestUtil; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.io.File; import java.util.Arrays; -import java.util.Collections; import java.util.List; import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.Test; -public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSupport { +final class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSupport { private static final String[] ALL_MESSAGES = { "46:17: " @@ -126,7 +126,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testNone() throws Exception { + void none() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; final String[] expected = { "36:17: " @@ -207,7 +207,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] suppressed = { "46:17: " + getCheckMessage( @@ -235,7 +235,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testCheckC() throws Exception { + void checkC() throws Exception { final String[] suppressed = { "46:17: " + getCheckMessage( @@ -249,7 +249,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testCheckCpp() throws Exception { + void checkCpp() throws Exception { final String[] suppressed = { "49:17: " + getCheckMessage( @@ -272,7 +272,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testUsingVariableMessage() throws Exception { + void usingVariableMessage() throws Exception { final String[] suppressed = { "102:23: " + getCheckMessage(IllegalCatchCheck.class, IllegalCatchCheck.MSG_KEY, "Throwable"), "109:11: " + getCheckMessage(IllegalCatchCheck.class, IllegalCatchCheck.MSG_KEY, "Exception"), @@ -282,7 +282,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testUsingNonMatchingVariableMessage() throws Exception { + void usingNonMatchingVariableMessage() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser( getPath("InputSuppressWithNearbyCommentFilterUsingNonMatchingVariableMessage.java"), @@ -290,7 +290,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testUsingVariableCheckOnNextLine() throws Exception { + void usingVariableCheckOnNextLine() throws Exception { final String[] suppressed = { "61:17: " + getCheckMessage( @@ -302,7 +302,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testUsingVariableCheckOnPreviousLine() throws Exception { + void usingVariableCheckOnPreviousLine() throws Exception { final String[] suppressed = { "65:17: " + getCheckMessage( @@ -314,7 +314,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testVariableCheckOnVariableNumberOfLines() throws Exception { + void variableCheckOnVariableNumberOfLines() throws Exception { final String[] suppressed = { "74:30: " + getCheckMessage( @@ -336,7 +336,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testEqualsAndHashCodeOfTagClass() { + void equalsAndHashCodeOfTagClass() { final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter(); final Object tag = getTagsAfterExecution(filter, "filename", "//SUPPRESS CHECKSTYLE ignore").get(0); @@ -356,7 +356,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testInvalidInfluenceFormat() throws Exception { + void invalidInfluenceFormat() throws Exception { final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class); final DefaultConfiguration filterConfig = createModuleConfig(SuppressWithNearbyCommentFilter.class); @@ -381,7 +381,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testInfluenceFormat() throws Exception { + void influenceFormat() throws Exception { final String[] suppressed = { "46:17: " + getCheckMessage( @@ -413,7 +413,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testInvalidCheckFormat() throws Exception { + void invalidCheckFormat() throws Exception { final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class); final DefaultConfiguration filterConfig = createModuleConfig(SuppressWithNearbyCommentFilter.class); @@ -437,12 +437,11 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testAcceptNullViolation() { + void acceptNullViolation() { final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter(); final FileContents contents = new FileContents( - new FileText( - new File("filename"), Collections.singletonList("//SUPPRESS CHECKSTYLE ignore"))); + new FileText(new File("filename"), ImmutableList.of("//SUPPRESS CHECKSTYLE ignore"))); contents.reportSingleLineComment(1, 0); final TreeWalkerAuditEvent auditEvent = new TreeWalkerAuditEvent(contents, null, null, null); assertWithMessage("Filter should accept null violation") @@ -451,7 +450,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testAcceptNullFileContents() { + void acceptNullFileContents() { final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter(); final FileContents contents = null; final TreeWalkerAuditEvent auditEvent = @@ -461,7 +460,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testToStringOfTagClass() { + void toStringOfTagClass() { final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter(); final Object tag = getTagsAfterExecution(filter, "filename", "//SUPPRESS CHECKSTYLE ignore").get(0); @@ -473,7 +472,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testToStringOfTagClassWithId() { + void toStringOfTagClassWithId() { final SuppressWithNearbyCommentFilter filter = new SuppressWithNearbyCommentFilter(); filter.setIdFormat(".*"); final Object tag = @@ -486,14 +485,14 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testUsingTagMessageRegexp() throws Exception { + void usingTagMessageRegexp() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser( getPath("InputSuppressWithNearbyCommentFilterUsingTagMessageRegexp.java"), suppressed); } @Test - public void testSuppressByCheck() throws Exception { + void suppressByCheck() throws Exception { final String[] suppressedViolationMessages = { "41:17: " + getCheckMessage( @@ -536,7 +535,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testSuppressById() throws Exception { + void suppressById() throws Exception { final String[] suppressedViolationMessages = { "41:17: " + getCheckMessage( @@ -579,7 +578,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testSuppressByCheckAndId() throws Exception { + void suppressByCheckAndId() throws Exception { final String[] suppressedViolationMessages = { "41:17: " + getCheckMessage( @@ -622,7 +621,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testSuppressByCheckAndNonMatchingId() throws Exception { + void suppressByCheckAndNonMatchingId() throws Exception { final String[] suppressedViolationMessages = CommonUtil.EMPTY_STRING_ARRAY; final String[] expectedViolationMessages = { "41:17: " @@ -655,7 +654,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void tesSuppressByIdAndMessage() throws Exception { + void tesSuppressByIdAndMessage() throws Exception { final String[] suppressedViolationMessages = { "55:17: " + getCheckMessage( @@ -692,7 +691,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void tesSuppressByCheckAndMessage() throws Exception { + void tesSuppressByCheckAndMessage() throws Exception { final String[] suppressedViolationMessages = { "55:17: " + getCheckMessage( @@ -729,7 +728,7 @@ public class SuppressWithNearbyCommentFilterTest extends AbstractModuleTestSuppo } @Test - public void testTagsAreClearedEachRun() { + void tagsAreClearedEachRun() { final SuppressWithNearbyCommentFilter suppressionCommentFilter = new SuppressWithNearbyCommentFilter(); final List tags1 = --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilterTest.java @@ -39,7 +39,7 @@ import java.io.IOException; import java.util.List; import org.junit.jupiter.api.Test; -public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport { +final class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport { private static final String REGEXP_SINGLELINE_CHECK_FORMAT = "this should not appear"; @@ -49,7 +49,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testDefaultConfig() throws Exception { + void defaultConfig() throws Exception { final int expectedLineLength = 90; final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -77,7 +77,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testNearbyTextPattern() throws Exception { + void nearbyTextPattern() throws Exception { final int expectedLineLength = 90; final String[] violationMessages = { @@ -108,7 +108,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testCheckPattern() throws Exception { + void checkPattern() throws Exception { final int expectedLineLength = 80; final String[] violationMessages = { @@ -130,7 +130,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testMessagePattern() throws Exception { + void messagePattern() throws Exception { final int expectedLineLength = 90; final String[] violationMessages = { @@ -152,7 +152,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testIdPattern() throws Exception { + void idPattern() throws Exception { final int expectedLineLength = 80; final String[] violationMessages = { @@ -174,7 +174,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testLineRangePositive3() throws Exception { + void lineRangePositive3() throws Exception { final int expectedLineLength = 92; final String[] violationMessages = { @@ -206,7 +206,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testLineRangeNegative2() throws Exception { + void lineRangeNegative2() throws Exception { final int expectedLineLength = 91; final String[] violationMessages = { @@ -237,7 +237,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testVariableCheckPatternAndLineRange() throws Exception { + void variableCheckPatternAndLineRange() throws Exception { final int expectedLineLength = 85; final String[] violationMessages = { @@ -265,7 +265,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testNearbyTextPatternAny() throws Exception { + void nearbyTextPatternAny() throws Exception { final int expectedLineLength = 76; final String[] violationMessages = { @@ -283,7 +283,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testNearbyTextPatternCompactVariableCheckPattern() throws Exception { + void nearbyTextPatternCompactVariableCheckPattern() throws Exception { final String[] violationMessages = { "26:13: " + getCheckMessage(MagicNumberCheck.class, MagicNumberCheck.MSG_KEY, "42"), "27:13: " + getCheckMessage(MagicNumberCheck.class, MagicNumberCheck.MSG_KEY, "43"), @@ -302,7 +302,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testNearbyTextPatternUrlLineLengthSuppression() throws Exception { + void nearbyTextPatternUrlLineLengthSuppression() throws Exception { final int expectedLineLength = 90; final String[] violationMessages = { @@ -323,7 +323,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testInvalidCheckPattern() throws Exception { + void invalidCheckPattern() throws Exception { final String[] violationAndSuppressedMessages = { "18: " + getLineLengthCheckMessage(80, 93), }; @@ -343,7 +343,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testInvalidIdPattern() throws Exception { + void invalidIdPattern() throws Exception { final String[] violationAndSuppressedMessages = { "18: " + getLineLengthCheckMessage(80, 93), }; @@ -363,7 +363,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testInvalidMessagePattern() throws Exception { + void invalidMessagePattern() throws Exception { final String[] violationAndSuppressedMessages = { "18: " + getLineLengthCheckMessage(80, 93), }; @@ -383,7 +383,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport } @Test - public void testInvalidLineRange() throws Exception { + void invalidLineRange() throws Exception { final String[] violationAndSuppressedMessages = { "18: " + getLineLengthCheckMessage(80, 93), }; @@ -410,7 +410,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport * {@link AbstractModuleTestSupport#verifyFilterWithInlineConfigParser}. */ @Test - public void testAcceptNullViolation() { + void acceptNullViolation() { final SuppressWithNearbyTextFilter filter = new SuppressWithNearbyTextFilter(); final AuditEvent auditEvent = new AuditEvent(this); assertWithMessage("Filter should accept audit event").that(filter.accept(auditEvent)).isTrue(); @@ -424,7 +424,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport * InlineConfigParser} does not allow to specify a non-existing file. */ @Test - public void testThrowsIllegalStateExceptionWhenFileNotFound() { + void throwsIllegalStateExceptionWhenFileNotFound() { final Violation message = new Violation( 1, @@ -470,7 +470,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport * @throws IOException if an error occurs while formatting the path to the input file. */ @Test - public void testFilterWithDirectory() throws IOException { + void filterWithDirectory() throws IOException { final SuppressWithNearbyTextFilter filter = new SuppressWithNearbyTextFilter(); final AuditEvent event = new AuditEvent( @@ -499,7 +499,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport * @throws IOException if an error occurs while formatting the path to the input file. */ @Test - public void testSuppressionsAreClearedEachRun() throws IOException { + void suppressionsAreClearedEachRun() throws IOException { final SuppressWithNearbyTextFilter filter = new SuppressWithNearbyTextFilter(); final List suppressions1 = @@ -522,7 +522,7 @@ public class SuppressWithNearbyTextFilterTest extends AbstractModuleTestSupport * @throws IOException if an error occurs while formatting the path to the input file. */ @Test - public void testCachedFileAbsolutePathHasChangedEachRun() throws IOException { + void cachedFileAbsolutePathHasChangedEachRun() throws IOException { final SuppressWithNearbyTextFilter filter = new SuppressWithNearbyTextFilter(); final String cachedFileAbsolutePath1 = --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilterTest.java @@ -46,7 +46,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.Test; -public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSupport { +final class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSupport { private static final String MSG_REGEXP_EXCEEDED = "regexp.exceeded"; @@ -56,7 +56,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testFilterWithDefaultConfig() throws Exception { + void filterWithDefaultConfig() throws Exception { final String[] suppressed = { "20:7: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB), "28:1: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB), @@ -75,7 +75,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testChangeOffAndOnFormat() throws Exception { + void changeOffAndOnFormat() throws Exception { final String[] suppressed = { "20:7: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB), "27:30: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB), @@ -95,7 +95,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressionCommentsInXmlFile() throws Exception { + void suppressionCommentsInXmlFile() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("offCommentFormat", "CS-OFF"); @@ -121,7 +121,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressionCommentsInPropertiesFile() throws Exception { + void suppressionCommentsInPropertiesFile() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("offCommentFormat", "# CHECKSTYLE:OFF"); @@ -147,7 +147,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressionCommentsInSqlFile() throws Exception { + void suppressionCommentsInSqlFile() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("offCommentFormat", "-- CHECKSTYLE OFF"); @@ -173,7 +173,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressionCommentsInJavaScriptFile() throws Exception { + void suppressionCommentsInJavaScriptFile() throws Exception { final String[] suppressed = { "22: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED, ".*\\s===.*"), }; @@ -190,7 +190,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testInvalidCheckFormat() throws Exception { + void invalidCheckFormat() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("checkFormat", "e[l"); @@ -225,7 +225,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testInvalidIdFormat() throws Exception { + void invalidIdFormat() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("idFormat", "e[l"); @@ -252,7 +252,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testInvalidMessageFormat() throws Exception { + void invalidMessageFormat() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("messageFormat", "e[l"); @@ -287,7 +287,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testInvalidMessageFormatInSqlFile() throws Exception { + void invalidMessageFormatInSqlFile() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("onCommentFormat", "CSON (\\w+)"); @@ -321,7 +321,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testAcceptNullViolation() { + void acceptNullViolation() { final SuppressWithPlainTextCommentFilter filter = new SuppressWithPlainTextCommentFilter(); final AuditEvent auditEvent = new AuditEvent(this); assertWithMessage("Filter should accept audit event").that(filter.accept(auditEvent)).isTrue(); @@ -334,7 +334,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu * the inner type {@code Suppression} here. */ @Test - public void testEqualsAndHashCodeOfSuppressionClass() throws ClassNotFoundException { + void equalsAndHashCodeOfSuppressionClass() throws ClassNotFoundException { final Class suppressionClass = TestUtil.getInnerClassType(SuppressWithPlainTextCommentFilter.class, "Suppression"); final EqualsVerifierReport ev = @@ -343,7 +343,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressByCheck() throws Exception { + void suppressByCheck() throws Exception { final String[] suppressedViolationMessages = { "36:1: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB), }; @@ -367,7 +367,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressByModuleId() throws Exception { + void suppressByModuleId() throws Exception { final String[] suppressedViolationMessages = { "33: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED, ".*[a-zA-Z][0-9].*"), @@ -398,7 +398,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressByCheckAndModuleId() throws Exception { + void suppressByCheckAndModuleId() throws Exception { final String[] suppressedViolationMessages = { "36:1: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB), }; @@ -424,7 +424,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressByCheckAndNonMatchingModuleId() throws Exception { + void suppressByCheckAndNonMatchingModuleId() throws Exception { final String[] suppressedViolationMessages = CommonUtil.EMPTY_STRING_ARRAY; final String[] expectedViolationMessages = { @@ -448,7 +448,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressByModuleIdWithNullModuleId() throws Exception { + void suppressByModuleIdWithNullModuleId() throws Exception { final String[] suppressedViolationMessages = { "33: " + getCheckMessage(RegexpSinglelineCheck.class, MSG_REGEXP_EXCEEDED, ".*[a-zA-Z][0-9].*"), @@ -479,7 +479,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testSuppressedByIdJavadocCheck() throws Exception { + void suppressedByIdJavadocCheck() throws Exception { final String[] suppressedViolationMessages = { "28: " + getCheckMessage(JavadocMethodCheck.class, MSG_RETURN_EXPECTED), "32:9: " + getCheckMessage(JavadocMethodCheck.class, MSG_UNUSED_TAG, "@param", "unused"), @@ -499,7 +499,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testAcceptThrowsIllegalStateExceptionAsFileNotFound() { + void acceptThrowsIllegalStateExceptionAsFileNotFound() { final Violation message = new Violation( 1, @@ -538,7 +538,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testFilterWithCustomMessageFormat() throws Exception { + void filterWithCustomMessageFormat() throws Exception { final String[] suppressed = { "34:1: " + getCheckMessage(FileTabCharacterCheck.class, MSG_CONTAINS_TAB), }; @@ -562,7 +562,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testFilterWithIdAndCustomMessageFormat() throws Exception { + void filterWithIdAndCustomMessageFormat() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("offCommentFormat", "CHECKSTYLE stop (\\w+) (\\w+)"); @@ -600,7 +600,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testFilterWithCheckAndCustomMessageFormat() throws Exception { + void filterWithCheckAndCustomMessageFormat() throws Exception { final DefaultConfiguration filterCfg = createModuleConfig(SuppressWithPlainTextCommentFilter.class); filterCfg.addProperty("offCommentFormat", "CHECKSTYLE stop (\\w+) (\\w+)"); @@ -638,7 +638,7 @@ public class SuppressWithPlainTextCommentFilterTest extends AbstractModuleTestSu } @Test - public void testFilterWithDirectory() throws IOException { + void filterWithDirectory() throws IOException { final SuppressWithPlainTextCommentFilter filter = new SuppressWithPlainTextCommentFilter(); final AuditEvent event = new AuditEvent( --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilterTest.java @@ -51,7 +51,7 @@ import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.Test; -public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { +final class SuppressionCommentFilterTest extends AbstractModuleTestSupport { private static final String[] ALL_MESSAGES = { "45:17: " @@ -96,7 +96,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testNone() throws Exception { + void none() throws Exception { final String[] messages = { "35:17: " + getCheckMessage( @@ -148,7 +148,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { // Suppress all checks between default comments @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] suppressed = { "48:17: " + getCheckMessage( @@ -164,7 +164,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testCheckC() throws Exception { + void checkC() throws Exception { final String[] suppressed = { "75:17: " + getCheckMessage( @@ -176,7 +176,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testCheckCpp() throws Exception { + void checkCpp() throws Exception { final String[] suppressed = { "48:17: " + getCheckMessage( @@ -188,7 +188,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { // Suppress all checks between CS_OFF and CS_ON @Test - public void testOffFormat() throws Exception { + void offFormat() throws Exception { final String[] suppressed = { "64:17: " + getCheckMessage( @@ -209,7 +209,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { // Test suppression of checks of only one type // Suppress only ConstantNameCheck between CS_OFF and CS_ON @Test - public void testOffFormatCheck() throws Exception { + void offFormatCheck() throws Exception { final String[] suppressed = { "71:30: " + getCheckMessage( @@ -219,7 +219,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testArgumentSuppression() throws Exception { + void argumentSuppression() throws Exception { final String[] suppressed = { "110:11: " + getCheckMessage(IllegalCatchCheck.class, IllegalCatchCheck.MSG_KEY, "Exception"), }; @@ -227,7 +227,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testExpansion() throws Exception { + void expansion() throws Exception { final String[] suppressed = { "54:17: " + getCheckMessage( @@ -243,7 +243,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testMessage() throws Exception { + void message() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser("InputSuppressionCommentFilter9.java", suppressed); } @@ -259,7 +259,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testEqualsAndHashCodeOfTagClass() { + void equalsAndHashCodeOfTagClass() { final Object tag = getTagsAfterExecutionOnDefaultFilter("//CHECKSTYLE:OFF").get(0); final EqualsVerifierReport ev = EqualsVerifier.forClass(tag.getClass()).usingGetClass().report(); @@ -267,7 +267,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testToStringOfTagClass() { + void toStringOfTagClass() { final Object tag = getTagsAfterExecutionOnDefaultFilter("//CHECKSTYLE:OFF").get(0); assertWithMessage("Invalid toString result") .that(tag.toString()) @@ -277,7 +277,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testToStringOfTagClassWithMessage() { + void toStringOfTagClassWithMessage() { final SuppressionCommentFilter filter = new SuppressionCommentFilter(); filter.setMessageFormat(".*"); final Object tag = getTagsAfterExecution(filter, "filename", "//CHECKSTYLE:ON").get(0); @@ -289,7 +289,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testCompareToOfTagClass() { + void compareToOfTagClass() { final List> tags1 = getTagsAfterExecutionOnDefaultFilter("//CHECKSTYLE:OFF", " //CHECKSTYLE:ON"); final Comparable tag1 = tags1.get(0); @@ -311,7 +311,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testInvalidCheckFormat() throws Exception { + void invalidCheckFormat() throws Exception { final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class); final DefaultConfiguration filterConfig = createModuleConfig(SuppressionCommentFilter.class); filterConfig.addProperty("checkFormat", "e[l"); @@ -332,7 +332,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testInvalidMessageFormat() throws Exception { + void invalidMessageFormat() throws Exception { final DefaultConfiguration treeWalkerConfig = createModuleConfig(TreeWalker.class); final DefaultConfiguration filterConfig = createModuleConfig(SuppressionCommentFilter.class); filterConfig.addProperty("messageFormat", "e[l"); @@ -353,7 +353,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testAcceptNullViolation() { + void acceptNullViolation() { final SuppressionCommentFilter filter = new SuppressionCommentFilter(); final FileContents contents = new FileContents( @@ -367,7 +367,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testAcceptNullFileContents() { + void acceptNullFileContents() { final SuppressionCommentFilter filter = new SuppressionCommentFilter(); final FileContents contents = null; final TreeWalkerAuditEvent auditEvent = @@ -377,7 +377,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testSuppressByCheck() throws Exception { + void suppressByCheck() throws Exception { final String[] suppressedViolation = { "42:17: " + getCheckMessage( @@ -414,7 +414,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testSuppressById() throws Exception { + void suppressById() throws Exception { final String[] suppressedViolation = { "42:17: " + getCheckMessage( @@ -451,7 +451,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testSuppressByCheckAndId() throws Exception { + void suppressByCheckAndId() throws Exception { final String[] suppressedViolation = { "42:17: " + getCheckMessage( @@ -488,7 +488,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testSuppressByIdAndMessage() throws Exception { + void suppressByIdAndMessage() throws Exception { final String[] suppressedViolation = { "54:17: " + getCheckMessage( @@ -522,7 +522,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testSuppressByCheckAndMessage() throws Exception { + void suppressByCheckAndMessage() throws Exception { final String[] suppressedViolation = { "54:17: " + getCheckMessage( @@ -556,7 +556,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testFindNearestMatchDontAllowSameColumn() { + void findNearestMatchDontAllowSameColumn() { final SuppressionCommentFilter suppressionCommentFilter = new SuppressionCommentFilter(); final FileContents contents = new FileContents( @@ -575,7 +575,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testTagsAreClearedEachRun() { + void tagsAreClearedEachRun() { final SuppressionCommentFilter suppressionCommentFilter = new SuppressionCommentFilter(); final List tags1 = getTagsAfterExecution(suppressionCommentFilter, "filename1", "//CHECKSTYLE:OFF", "line2"); @@ -615,7 +615,7 @@ public class SuppressionCommentFilterTest extends AbstractModuleTestSupport { } @Test - public void testCachingByFileContentsInstance() throws Exception { + void cachingByFileContentsInstance() throws Exception { final File file = new File(getPath("InputSuppressionCommentFilterSuppressById6.java")); final DetailAST rootAst = JavaParser.parseFile(file, JavaParser.Options.WITH_COMMENTS); --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionFilterTest.java @@ -36,10 +36,11 @@ import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.file.Files; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -public class SuppressionFilterTest extends AbstractModuleTestSupport { +final class SuppressionFilterTest extends AbstractModuleTestSupport { @TempDir public File temporaryFolder; @@ -49,7 +50,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testAccept() throws Exception { + void accept() throws Exception { final String fileName = getPath("InputSuppressionFilterNone.xml"); final boolean optional = false; final SuppressionFilter filter = createSuppressionFilter(fileName, optional); @@ -62,7 +63,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testAcceptFalse() throws Exception { + void acceptFalse() throws Exception { final String fileName = getPath("InputSuppressionFilterSuppress.xml"); final boolean optional = false; final SuppressionFilter filter = createSuppressionFilter(fileName, optional); @@ -77,7 +78,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testAcceptOnNullFile() throws CheckstyleException { + void acceptOnNullFile() throws CheckstyleException { final String fileName = null; final boolean optional = false; final SuppressionFilter filter = createSuppressionFilter(fileName, optional); @@ -89,7 +90,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testNonExistentSuppressionFileWithFalseOptional() { + void nonExistentSuppressionFileWithFalseOptional() { final String fileName = "non_existent_suppression_file.xml"; try { final boolean optional = false; @@ -103,7 +104,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testExistingInvalidSuppressionFileWithTrueOptional() throws IOException { + void existingInvalidSuppressionFileWithTrueOptional() throws IOException { final String fileName = getPath("InputSuppressionFilterInvalidFile.xml"); try { final boolean optional = true; @@ -118,7 +119,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testExistingSuppressionFileWithTrueOptional() throws Exception { + void existingSuppressionFileWithTrueOptional() throws Exception { final String fileName = getPath("InputSuppressionFilterNone.xml"); final boolean optional = true; final SuppressionFilter filter = createSuppressionFilter(fileName, optional); @@ -131,7 +132,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testNonExistentSuppressionFileWithTrueOptional() throws Exception { + void nonExistentSuppressionFileWithTrueOptional() throws Exception { final String fileName = "non_existent_suppression_file.xml"; final boolean optional = true; final SuppressionFilter filter = createSuppressionFilter(fileName, optional); @@ -144,7 +145,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testNonExistentSuppressionUrlWithTrueOptional() throws Exception { + void nonExistentSuppressionUrlWithTrueOptional() throws Exception { final String fileName = "https://checkstyle.org/non_existent_suppression.xml"; final boolean optional = true; final SuppressionFilter filter = createSuppressionFilter(fileName, optional); @@ -157,15 +158,16 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testUseCacheLocalFileExternalResourceContentDoesNotChange() throws Exception { + void useCacheLocalFileExternalResourceContentDoesNotChange() throws Exception { final DefaultConfiguration filterConfig = createModuleConfig(SuppressionFilter.class); filterConfig.addProperty("file", getPath("InputSuppressionFilterNone.xml")); final DefaultConfiguration checkerConfig = createRootConfig(filterConfig); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); checkerConfig.addProperty("cacheFile", cacheFile.getPath()); - final String filePath = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String filePath = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); execute(checkerConfig, filePath); // One more time to use cache. @@ -173,7 +175,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testUseCacheRemoteFileExternalResourceContentDoesNotChange() throws Exception { + void useCacheRemoteFileExternalResourceContentDoesNotChange() throws Exception { final String[] urlCandidates = { "https://checkstyle.org/files/suppressions_none.xml", "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/site/resources/" @@ -194,10 +196,11 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { firstFilterConfig.addProperty("file", urlForTest); final DefaultConfiguration firstCheckerConfig = createRootConfig(firstFilterConfig); - final File cacheFile = File.createTempFile("junit", null, temporaryFolder); + final File cacheFile = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); firstCheckerConfig.addProperty("cacheFile", cacheFile.getPath()); - final String pathToEmptyFile = File.createTempFile("file", ".java", temporaryFolder).getPath(); + final String pathToEmptyFile = + Files.createTempFile(temporaryFolder.toPath(), "file", ".java").toFile().getPath(); execute(firstCheckerConfig, pathToEmptyFile); @@ -262,7 +265,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testXpathSuppression() throws Exception { + void xpathSuppression() throws Exception { for (int test = 1; test <= 6; test++) { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { @@ -280,7 +283,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testSuppression2() throws Exception { + void suppression2() throws Exception { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { "19:29: " @@ -295,7 +298,7 @@ public class SuppressionFilterTest extends AbstractModuleTestSupport { } @Test - public void testSuppression3() throws Exception { + void suppression3() throws Exception { final String pattern = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { "19:29: " --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilterTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSinglelineCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class SuppressionSingleFilterTest extends AbstractModuleTestSupport { +final class SuppressionSingleFilterTest extends AbstractModuleTestSupport { private static final String FORMAT = "TODO$"; private static final String MESSAGE = @@ -39,7 +39,7 @@ public class SuppressionSingleFilterTest extends AbstractModuleTestSupport { } @Test - public void testDefault() throws Exception { + void testDefault() throws Exception { final String[] suppressed = { "25: " + MESSAGE, }; @@ -47,7 +47,7 @@ public class SuppressionSingleFilterTest extends AbstractModuleTestSupport { } @Test - public void testMatching() throws Exception { + void matching() throws Exception { final String[] suppressed = { "25: " + MESSAGE, }; @@ -55,31 +55,31 @@ public class SuppressionSingleFilterTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingLineNumber() throws Exception { + void nonMatchingLineNumber() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser(getPath("InputSuppressionSingleFilter4.java"), suppressed); } @Test - public void testNonMatchingColumnNumber() throws Exception { + void nonMatchingColumnNumber() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser(getPath("InputSuppressionSingleFilter5.java"), suppressed); } @Test - public void testNonMatchingFileRegexp() throws Exception { + void nonMatchingFileRegexp() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser(getPath("InputSuppressionSingleFilter6.java"), suppressed); } @Test - public void testNonMatchingModuleId() throws Exception { + void nonMatchingModuleId() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser(getPath("InputSuppressionSingleFilter7.java"), suppressed); } @Test - public void testMatchingModuleId() throws Exception { + void matchingModuleId() throws Exception { final String[] suppressed = { "25: " + MESSAGE, }; @@ -87,19 +87,19 @@ public class SuppressionSingleFilterTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingChecks() throws Exception { + void nonMatchingChecks() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser(getPath("InputSuppressionSingleFilter8.java"), suppressed); } @Test - public void testNotMatchingMessage() throws Exception { + void notMatchingMessage() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifySuppressedWithParser(getPath("InputSuppressionSingleFilter9.java"), suppressed); } @Test - public void testMatchMessage() throws Exception { + void matchMessage() throws Exception { final String[] suppressed = { "25: " + MESSAGE, }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathFilterTest.java @@ -23,19 +23,19 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck.MSG_KEY; import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextCheck; import com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; -import java.util.Collections; import java.util.Set; import nl.jqno.equalsverifier.EqualsVerifier; import nl.jqno.equalsverifier.EqualsVerifierReport; import nl.jqno.equalsverifier.Warning; import org.junit.jupiter.api.Test; -public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { +final class SuppressionXpathFilterTest extends AbstractModuleTestSupport { private static final String PATTERN = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @@ -49,7 +49,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testAcceptOne() throws Exception { + void acceptOne() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifyFilterWithInlineConfigParser( getPath("InputSuppressionXpathFilterAcceptOne.java"), @@ -58,7 +58,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testAcceptTwo() throws Exception { + void acceptTwo() throws Exception { final String[] expected = { "20:29: " + getCheckMessage( @@ -75,7 +75,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testAcceptOnNullFile() throws Exception { + void acceptOnNullFile() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifyFilterWithInlineConfigParser( getPath("InputSuppressionXpathFilterAcceptOnNullFile.java"), @@ -84,7 +84,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testNonExistentSuppressionFileWithFalseOptional() throws Exception { + void nonExistentSuppressionFileWithFalseOptional() throws Exception { final String fileName = getPath("non_existent_suppression_file.xml"); try { final boolean optional = false; @@ -98,7 +98,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testExistingInvalidSuppressionFileWithTrueOptional() throws Exception { + void existingInvalidSuppressionFileWithTrueOptional() throws Exception { final String fileName = getPath("InputSuppressionXpathFilterInvalidFile.xml"); try { final boolean optional = true; @@ -115,7 +115,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testExistingSuppressionFileWithTrueOptional() throws Exception { + void existingSuppressionFileWithTrueOptional() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifyFilterWithInlineConfigParser( getPath("InputSuppressionXpathFilterAcceptWithOptionalTrue.java"), @@ -124,7 +124,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testNonExistentSuppressionFileWithTrueOptional() throws Exception { + void nonExistentSuppressionFileWithTrueOptional() throws Exception { final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; verifyFilterWithInlineConfigParser( getPath("InputSuppressionXpathFilterNonExistentFileWithTrueOptional.java"), @@ -133,7 +133,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testReject() throws Exception { + void reject() throws Exception { final String[] suppressed = { "20:29: " + getCheckMessage(ConstantNameCheck.class, MSG_INVALID_PATTERN, "bad_name", PATTERN), @@ -145,7 +145,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testEqualsAndHashCode() { + void equalsAndHashCode() { final EqualsVerifierReport ev = EqualsVerifier.forClass(SuppressionXpathFilter.class) .usingGetClass() @@ -156,11 +156,11 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testExternalResource() throws Exception { + void externalResource() throws Exception { final boolean optional = false; final String fileName = getPath("InputSuppressionXpathFilterIdAndQuery.xml"); final SuppressionXpathFilter filter = createSuppressionXpathFilter(fileName, optional); - final Set expected = Collections.singleton(fileName); + final Set expected = ImmutableSet.of(fileName); final Set actual = filter.getExternalResourceLocations(); assertWithMessage("Invalid external resource").that(actual).isEqualTo(expected); } @@ -175,7 +175,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testFalseEncodeString() throws Exception { + void falseEncodeString() throws Exception { final String pattern = "[^a-zA-z0-9]*"; final String[] expected = { "17:24: " + getCheckMessage(IllegalTokenTextCheck.class, MSG_KEY, pattern), @@ -206,7 +206,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testFalseEncodeChar() throws Exception { + void falseEncodeChar() throws Exception { final String pattern = "[^a-zA-z0-9]*"; final String[] expected = { "17:14: " + getCheckMessage(IllegalTokenTextCheck.class, MSG_KEY, pattern), @@ -229,7 +229,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testXpathSuppression() throws Exception { + void xpathSuppression() throws Exception { for (int test = 1; test <= 4; test++) { final String[] expected = { @@ -248,7 +248,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testXpathSuppression2() throws Exception { + void xpathSuppression2() throws Exception { final String pattern = "[^a-zA-z0-9]*"; final String[] expected = { "18:14: " + getCheckMessage(IllegalTokenTextCheck.class, MSG_KEY, pattern), @@ -265,7 +265,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testXpathSuppression3() throws Exception { + void xpathSuppression3() throws Exception { final String pattern = "[^a-zA-z0-9]*"; final String[] expected = { "18:14: " + getCheckMessage(IllegalTokenTextCheck.class, MSG_KEY, pattern), @@ -282,7 +282,7 @@ public class SuppressionXpathFilterTest extends AbstractModuleTestSupport { } @Test - public void testXpathSuppression4() throws Exception { + void xpathSuppression4() throws Exception { final String[] suppressed = { "20:29: " + getCheckMessage(ConstantNameCheck.class, MSG_INVALID_PATTERN, "bad_name", PATTERN), --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilterTest.java @@ -41,7 +41,7 @@ import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; import org.junit.jupiter.api.Test; -public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport { +final class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -49,7 +49,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testMatching() throws Exception { + void matching() throws Exception { final String[] expected = { "19:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -65,7 +65,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNonMatchingTokenType() throws Exception { + void nonMatchingTokenType() throws Exception { final String[] expected = { "19:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -79,7 +79,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNonMatchingLineNumber() throws Exception { + void nonMatchingLineNumber() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), "21:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), @@ -96,7 +96,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNonMatchingColumnNumber() throws Exception { + void nonMatchingColumnNumber() throws Exception { final String[] expected = { "23:11: " + getCheckMessage( @@ -114,7 +114,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testComplexQuery() throws Exception { + void complexQuery() throws Exception { final String[] expected = { "27:21: " + getCheckMessage(MagicNumberCheck.class, MSG_KEY, "3.14"), "28:16: " + getCheckMessage(MagicNumberCheck.class, MSG_KEY, "123"), @@ -130,7 +130,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testIncorrectQuery() { + void incorrectQuery() { final String xpath = "1@#"; try { final Object test = @@ -145,7 +145,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNoQuery() throws Exception { + void noQuery() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -161,7 +161,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNullFileName() throws Exception { + void nullFileName() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -175,7 +175,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNonMatchingFileRegexp() throws Exception { + void nonMatchingFileRegexp() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -189,7 +189,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testInvalidFileRegexp() { + void invalidFileRegexp() { final SuppressionXpathSingleFilter filter = new SuppressionXpathSingleFilter(); try { filter.setFiles("e[l"); @@ -202,7 +202,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testInvalidCheckRegexp() { + void invalidCheckRegexp() { final SuppressionXpathSingleFilter filter = new SuppressionXpathSingleFilter(); try { filter.setChecks("e[l"); @@ -215,7 +215,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNullViolation() throws Exception { + void nullViolation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; final String[] suppressed = CommonUtil.EMPTY_STRING_ARRAY; @@ -226,7 +226,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNonMatchingModuleId() throws Exception { + void nonMatchingModuleId() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -240,7 +240,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testMatchingModuleId() throws Exception { + void matchingModuleId() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -256,7 +256,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNonMatchingChecks() throws Exception { + void nonMatchingChecks() throws Exception { final String[] expected = { "19:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -270,7 +270,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNonMatchingFileNameModuleIdAndCheck() throws Exception { + void nonMatchingFileNameModuleIdAndCheck() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -283,7 +283,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testNullModuleIdAndNonMatchingChecks() throws Exception { + void nullModuleIdAndNonMatchingChecks() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -296,7 +296,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testDecideByMessage() throws Exception { + void decideByMessage() throws Exception { final String[] expected = { "28:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), "30:21: " + getCheckMessage(MagicNumberCheck.class, MSG_KEY, "3.14"), @@ -315,7 +315,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testThrowException() throws Exception { + void throwException() throws Exception { final String xpath = "//CLASS_DEF[@text='InputSuppressionXpathSingleFilterComplexQuery']"; final SuppressionXpathSingleFilter filter = createSuppressionXpathSingleFilter( @@ -341,7 +341,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testAllNullConfiguration() throws Exception { + void allNullConfiguration() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -355,7 +355,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testDecideByIdAndExpression() throws Exception { + void decideByIdAndExpression() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -371,7 +371,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testDefaultFileProperty() throws Exception { + void defaultFileProperty() throws Exception { final String[] expected = { "20:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -387,7 +387,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testDecideByCheck() throws Exception { + void decideByCheck() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -403,7 +403,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport } @Test - public void testDecideById() throws Exception { + void decideById() throws Exception { final String[] expected = { "19:1: " + getCheckMessage(MissingJavadocTypeCheck.class, MSG_JAVADOC_MISSING), }; @@ -427,7 +427,7 @@ public class SuppressionXpathSingleFilterTest extends AbstractModuleTestSupport * @throws Exception when there is problem to load Input file */ @Test - public void testUpdateFilterSettingsInRunTime() throws Exception { + void updateFilterSettingsInRunTime() throws Exception { final File file = new File(getPath("InputSuppressionXpathSingleFilterComplexQuery.java")); final SuppressionXpathSingleFilter filter = new SuppressionXpathSingleFilter(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/SuppressionsLoaderTest.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; /** Tests SuppressionsLoader. */ -public class SuppressionsLoaderTest extends AbstractPathTestSupport { +final class SuppressionsLoaderTest extends AbstractPathTestSupport { @Override protected String getPackageLocation() { @@ -44,7 +44,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testNoSuppressions() throws Exception { + void noSuppressions() throws Exception { final FilterSet fc = SuppressionsLoader.loadSuppressions(getPath("InputSuppressionsLoaderNone.xml")); final FilterSet fc2 = new FilterSet(); @@ -54,7 +54,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testLoadFromUrl() throws Exception { + void loadFromUrl() throws Exception { final String[] urlCandidates = { "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/site/resources/" + "files/suppressions_none.xml", @@ -78,7 +78,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testLoadFromMalformedUrl() { + void loadFromMalformedUrl() { try { SuppressionsLoader.loadSuppressions("http"); assertWithMessage("exception expected").fail(); @@ -90,7 +90,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testLoadFromNonExistentUrl() { + void loadFromNonExistentUrl() { try { SuppressionsLoader.loadSuppressions("http://^%$^* %&% %^&"); assertWithMessage("exception expected").fail(); @@ -102,7 +102,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testMultipleSuppression() throws Exception { + void multipleSuppression() throws Exception { final FilterSet fc = SuppressionsLoader.loadSuppressions(getPath("InputSuppressionsLoaderMultiple.xml")); final FilterSet fc2 = new FilterSet(); @@ -128,7 +128,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testNoFile() throws IOException { + void noFile() throws IOException { final String fn = getPath("InputSuppressionsLoaderNoFile.xml"); try { SuppressionsLoader.loadSuppressions(fn); @@ -148,7 +148,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testNoCheck() throws IOException { + void noCheck() throws IOException { final String fn = getPath("InputSuppressionsLoaderNoCheck.xml"); try { SuppressionsLoader.loadSuppressions(fn); @@ -168,7 +168,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testBadInt() throws IOException { + void badInt() throws IOException { final String fn = getPath("InputSuppressionsLoaderBadInt.xml"); try { SuppressionsLoader.loadSuppressions(fn); @@ -219,7 +219,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testUnableToFindSuppressions() { + void unableToFindSuppressions() { final String sourceName = "InputSuppressionsLoaderNone.xml"; try { @@ -236,7 +236,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testUnableToReadSuppressions() { + void unableToReadSuppressions() { final String sourceName = "InputSuppressionsLoaderNone.xml"; try { @@ -253,7 +253,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testNoCheckNoId() throws IOException { + void noCheckNoId() throws IOException { final String fn = getPath("InputSuppressionsLoaderNoCheckAndId.xml"); try { SuppressionsLoader.loadSuppressions(fn); @@ -266,7 +266,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testNoCheckYesId() throws Exception { + void noCheckYesId() throws Exception { final String fn = getPath("InputSuppressionsLoaderId.xml"); final FilterSet set = SuppressionsLoader.loadSuppressions(fn); @@ -274,7 +274,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testInvalidFileFormat() throws IOException { + void invalidFileFormat() throws IOException { final String fn = getPath("InputSuppressionsLoaderInvalidFile.xml"); try { SuppressionsLoader.loadSuppressions(fn); @@ -287,7 +287,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testLoadFromClasspath() throws Exception { + void loadFromClasspath() throws Exception { final FilterSet fc = SuppressionsLoader.loadSuppressions(getPath("InputSuppressionsLoaderNone.xml")); final FilterSet fc2 = new FilterSet(); @@ -297,7 +297,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testSettingModuleId() throws Exception { + void settingModuleId() throws Exception { final FilterSet fc = SuppressionsLoader.loadSuppressions(getPath("InputSuppressionsLoaderWithId.xml")); final SuppressFilterElement suppressElement = @@ -308,7 +308,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testXpathSuppressions() throws Exception { + void xpathSuppressions() throws Exception { final String fn = getPath("InputSuppressionsLoaderXpathCorrect.xml"); final Set filterSet = SuppressionsLoader.loadXpathSuppressions(fn); @@ -325,7 +325,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testXpathInvalidFileFormat() throws IOException { + void xpathInvalidFileFormat() throws IOException { final String fn = getPath("InputSuppressionsLoaderXpathInvalidFile.xml"); try { SuppressionsLoader.loadXpathSuppressions(fn); @@ -341,7 +341,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testXpathNoCheckNoId() throws IOException { + void xpathNoCheckNoId() throws IOException { final String fn = getPath("InputSuppressionsLoaderXpathNoCheckAndId.xml"); try { SuppressionsLoader.loadXpathSuppressions(fn); @@ -357,7 +357,7 @@ public class SuppressionsLoaderTest extends AbstractPathTestSupport { } @Test - public void testXpathNoCheckYesId() throws Exception { + void xpathNoCheckYesId() throws Exception { final String fn = getPath("InputSuppressionsLoaderXpathId.xml"); final Set filterSet = SuppressionsLoader.loadXpathSuppressions(fn); --- a/src/test/java/com/puppycrawl/tools/checkstyle/filters/XpathFilterElementTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/filters/XpathFilterElementTest.java @@ -39,13 +39,13 @@ import nl.jqno.equalsverifier.EqualsVerifierReport; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class XpathFilterElementTest extends AbstractModuleTestSupport { +final class XpathFilterElementTest extends AbstractModuleTestSupport { private File file; private FileContents fileContents; @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { file = new File(getPath("InputXpathFilterElementSuppressByXpath.java")); fileContents = new FileContents(new FileText(file, StandardCharsets.UTF_8.name())); } @@ -56,7 +56,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testMatching() throws Exception { + void matching() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathFilterElementSuppressByXpath']]"; final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, xpath); @@ -65,7 +65,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingTokenType() throws Exception { + void nonMatchingTokenType() throws Exception { final String xpath = "//METHOD_DEF[./IDENT[@text='countTokens']]"; final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, xpath); @@ -74,7 +74,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingLineNumber() throws Exception { + void nonMatchingLineNumber() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathFilterElementSuppressByXpath']]"; final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, xpath); @@ -83,7 +83,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingColumnNumber() throws Exception { + void nonMatchingColumnNumber() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathFilterElementSuppressByXpath']]"; final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, xpath); @@ -92,7 +92,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testComplexQuery() throws Exception { + void complexQuery() throws Exception { final String xpath = "//VARIABLE_DEF[./IDENT[@text='pi'] and " + "../../IDENT[@text='countTokens']] " @@ -108,7 +108,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testInvalidCheckRegexp() { + void invalidCheckRegexp() { try { final Object test = new XpathFilterElement(".*", "e[l", ".*", "moduleId", "query"); assertWithMessage("Exception is expected but got " + test).fail(); @@ -120,7 +120,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testIncorrectQuery() { + void incorrectQuery() { final String xpath = "1@#"; try { final Object test = @@ -135,7 +135,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNoQuery() throws Exception { + void noQuery() throws Exception { final TreeWalkerAuditEvent event = getEvent(15, 8, TokenTypes.VARIABLE_DEF); final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, null); @@ -143,7 +143,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNullFileName() { + void nullFileName() { final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, null); final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, null, null, null); @@ -151,7 +151,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingFileRegexp() throws Exception { + void nonMatchingFileRegexp() throws Exception { final XpathFilterElement filter = new XpathFilterElement("NonMatchingRegexp", "Test", null, null, null); final TreeWalkerAuditEvent ev = getEvent(3, 0, TokenTypes.CLASS_DEF); @@ -159,7 +159,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingFilePattern() throws Exception { + void nonMatchingFilePattern() throws Exception { final Pattern pattern = Pattern.compile("NonMatchingRegexp"); final XpathFilterElement filter = new XpathFilterElement(pattern, null, null, null, null); final TreeWalkerAuditEvent ev = getEvent(3, 0, TokenTypes.CLASS_DEF); @@ -167,7 +167,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingCheckRegexp() throws Exception { + void nonMatchingCheckRegexp() throws Exception { final XpathFilterElement filter = new XpathFilterElement(null, "NonMatchingRegexp", null, null, null); final TreeWalkerAuditEvent ev = getEvent(3, 0, TokenTypes.CLASS_DEF); @@ -175,7 +175,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingCheckPattern() throws Exception { + void nonMatchingCheckPattern() throws Exception { final Pattern pattern = Pattern.compile("NonMatchingRegexp"); final XpathFilterElement filter = new XpathFilterElement(null, pattern, null, null, null); final TreeWalkerAuditEvent ev = getEvent(3, 0, TokenTypes.CLASS_DEF); @@ -183,7 +183,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNullViolation() { + void nullViolation() { final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, null); final TreeWalkerAuditEvent ev = new TreeWalkerAuditEvent(null, file.getName(), null, null); @@ -191,7 +191,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingModuleId() throws Exception { + void nonMatchingModuleId() throws Exception { final XpathFilterElement filter = new XpathFilterElement( "InputXpathFilterElementSuppressByXpath", "Test", null, "id19", null); @@ -207,7 +207,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testMatchingModuleId() throws Exception { + void matchingModuleId() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathFilterElementSuppressByXpath']]"; final XpathFilterElement filter = new XpathFilterElement( @@ -224,7 +224,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingChecks() throws Exception { + void nonMatchingChecks() throws Exception { final String xpath = "NON_MATCHING_QUERY"; final XpathFilterElement filter = new XpathFilterElement( @@ -241,7 +241,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNonMatchingFileNameModuleIdAndCheck() throws Exception { + void nonMatchingFileNameModuleIdAndCheck() throws Exception { final String xpath = "NON_MATCHING_QUERY"; final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", null, null, null, xpath); @@ -250,7 +250,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testNullModuleIdAndNonMatchingChecks() throws Exception { + void nullModuleIdAndNonMatchingChecks() throws Exception { final String xpath = "NON_MATCHING_QUERY"; final XpathFilterElement filter = new XpathFilterElement( @@ -260,7 +260,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testDecideByMessage() throws Exception { + void decideByMessage() throws Exception { final Violation message = new Violation(1, 0, TokenTypes.CLASS_DEF, "", "", null, null, null, getClass(), "Test"); final TreeWalkerAuditEvent ev = @@ -276,7 +276,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testThrowException() { + void throwException() { final String xpath = "//CLASS_DEF[@text='InputXpathFilterElementSuppressByXpath']"; final XpathFilterElement filter = new XpathFilterElement("InputXpathFilterElementSuppressByXpath", "Test", null, null, xpath); @@ -295,7 +295,7 @@ public class XpathFilterElementTest extends AbstractModuleTestSupport { } @Test - public void testEqualsAndHashCode() throws Exception { + void equalsAndHashCode() throws Exception { final XPathEvaluator xpathEvaluator = new XPathEvaluator(Configuration.newConfiguration()); final EqualsVerifierReport ev = EqualsVerifier.forClass(XpathFilterElement.class) --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/AstRegressionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/AstRegressionTest.java @@ -30,7 +30,7 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import org.junit.jupiter.api.Test; -public class AstRegressionTest extends AbstractTreeTestSupport { +final class AstRegressionTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -38,115 +38,115 @@ public class AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testClassAstTree1() throws Exception { + void classAstTree1() throws Exception { verifyAst( getPath("ExpectedRegressionJavaClass1Ast.txt"), getPath("InputRegressionJavaClass1.java")); } @Test - public void testClassAstTree2() throws Exception { + void classAstTree2() throws Exception { verifyAst( getPath("ExpectedRegressionJavaClass2Ast.txt"), getPath("InputRegressionJavaClass2.java")); } @Test - public void testJava8ClassAstTree1() throws Exception { + void java8ClassAstTree1() throws Exception { verifyAst( getPath("ExpectedRegressionJava8Class1Ast.txt"), getPath("InputRegressionJava8Class1.java")); } @Test - public void testJava8ClassAstTree2() throws Exception { + void java8ClassAstTree2() throws Exception { verifyAst( getPath("ExpectedRegressionJava8Class2Ast.txt"), getPath("InputRegressionJava8Class2.java")); } @Test - public void testJava9TryWithResourcesAstTree() throws Exception { + void java9TryWithResourcesAstTree() throws Exception { verifyAst( getPath("ExpectedJava9TryWithResources.txt"), getPath("/java9/InputJava9TryWithResources.java")); } @Test - public void testAdvanceJava9TryWithResourcesAstTree() throws Exception { + void advanceJava9TryWithResourcesAstTree() throws Exception { verifyAst( getPath("ExpectedAdvanceJava9TryWithResources.txt"), getPath("/java9/InputAdvanceJava9TryWithResources.java")); } @Test - public void testInputSemicolonBetweenImports() throws Exception { + void inputSemicolonBetweenImports() throws Exception { verifyAst( getPath("ExpectedSemicolonBetweenImportsAst.txt"), getNonCompilablePath("InputSemicolonBetweenImports.java")); } @Test - public void testInterfaceAstTree1() throws Exception { + void interfaceAstTree1() throws Exception { verifyAst( getPath("ExpectedRegressionJavaInterface1Ast.txt"), getPath("InputRegressionJavaInterface1.java")); } @Test - public void testInterfaceAstTree2() throws Exception { + void interfaceAstTree2() throws Exception { verifyAst( getPath("ExpectedRegressionJavaInterface2Ast.txt"), getPath("InputRegressionJavaInterface2.java")); } @Test - public void testJava8InterfaceAstTree1() throws Exception { + void java8InterfaceAstTree1() throws Exception { verifyAst( getPath("ExpectedRegressionJava8Interface1Ast.txt"), getPath("InputRegressionJava8Interface1.java")); } @Test - public void testEnumAstTree1() throws Exception { + void enumAstTree1() throws Exception { verifyAst( getPath("ExpectedRegressionJavaEnum1Ast.txt"), getPath("InputRegressionJavaEnum1.java")); } @Test - public void testEnumAstTree2() throws Exception { + void enumAstTree2() throws Exception { verifyAst( getPath("ExpectedRegressionJavaEnum2Ast.txt"), getPath("InputRegressionJavaEnum2.java")); } @Test - public void testAnnotationAstTree1() throws Exception { + void annotationAstTree1() throws Exception { verifyAst( getPath("ExpectedRegressionJavaAnnotation1Ast.txt"), getPath("InputRegressionJavaAnnotation1.java")); } @Test - public void testTypecast() throws Exception { + void typecast() throws Exception { verifyAst( getPath("ExpectedRegressionJavaTypecastAst.txt"), getPath("InputRegressionJavaTypecast.java")); } @Test - public void testJava14InstanceofWithPatternMatching() throws Exception { + void java14InstanceofWithPatternMatching() throws Exception { verifyAst( getPath("java14/ExpectedJava14InstanceofWithPatternMatchingAST.txt"), getNonCompilablePath("java14/InputJava14InstanceofWithPatternMatching.java")); } @Test - public void testCharLiteralSurrogatePair() throws Exception { + void charLiteralSurrogatePair() throws Exception { verifyAst( getPath("ExpectedCharLiteralSurrogatePair.txt"), getPath("InputCharLiteralSurrogatePair.java")); } @Test - public void testCustomAstTree() throws Exception { + void customAstTree() throws Exception { verifyAstRaw(getPath("ExpectedRegressionEmptyAst.txt"), "\t"); verifyAstRaw(getPath("ExpectedRegressionEmptyAst.txt"), "\r\n"); verifyAstRaw(getPath("ExpectedRegressionEmptyAst.txt"), "\n"); @@ -170,7 +170,7 @@ public class AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testNewlineCr() throws Exception { + void newlineCr() throws Exception { verifyAst( getPath("ExpectedNewlineCrAtEndOfFileAst.txt"), getPath("InputAstRegressionNewlineCrAtEndOfFile.java"), @@ -178,105 +178,105 @@ public class AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testJava14Records() throws Exception { + void java14Records() throws Exception { verifyAst( getPath("java14/ExpectedJava14Records.txt"), getNonCompilablePath("java14/InputJava14Records.java")); } @Test - public void testJava14RecordsTopLevel() throws Exception { + void java14RecordsTopLevel() throws Exception { verifyAst( getPath("java14/ExpectedJava14RecordsTopLevel.txt"), getNonCompilablePath("java14/InputJava14RecordsTopLevel.java")); } @Test - public void testJava14LocalRecordAnnotation() throws Exception { + void java14LocalRecordAnnotation() throws Exception { verifyAst( getPath("java14/ExpectedJava14LocalRecordAnnotation.txt"), getNonCompilablePath("java14/InputJava14LocalRecordAnnotation.java")); } @Test - public void testJava14TextBlocks() throws Exception { + void java14TextBlocks() throws Exception { verifyAst( getPath("java14/ExpectedJava14TextBlocks.txt"), getNonCompilablePath("java14/InputJava14TextBlocks.java")); } @Test - public void testJava14TextBlocksEscapes() throws Exception { + void java14TextBlocksEscapes() throws Exception { verifyAst( getPath("java14/ExpectedJava14TextBlocksEscapesAreOneChar.txt"), getNonCompilablePath("java14/InputJava14TextBlocksEscapesAreOneChar.java")); } @Test - public void testJava14SwitchExpression() throws Exception { + void java14SwitchExpression() throws Exception { verifyAst( getPath("java14/ExpectedJava14SwitchExpression.txt"), getNonCompilablePath("java14/InputJava14SwitchExpression.java")); } @Test - public void testInputJava14TextBlocksTabSize() throws Exception { + void inputJava14TextBlocksTabSize() throws Exception { verifyAst( getPath("java14/ExpectedJava14TextBlocksTabSize.txt"), getNonCompilablePath("java14/InputJava14TextBlocksTabSize.java")); } @Test - public void testInputEscapedS() throws Exception { + void inputEscapedS() throws Exception { verifyAst( getPath("java14/ExpectedJava14EscapedS.txt"), getNonCompilablePath("java14/InputJava14EscapedS.java")); } @Test - public void testInputSealedAndPermits() throws Exception { + void inputSealedAndPermits() throws Exception { verifyAst( getPath("java15/ExpectedAstRegressionSealedAndPermits.txt"), getNonCompilablePath("java15/InputAstRegressionSealedAndPermits.java")); } @Test - public void testInputTopLevelNonSealed() throws Exception { + void inputTopLevelNonSealed() throws Exception { verifyAst( getPath("java15/ExpectedTopLevelNonSealed.txt"), getNonCompilablePath("java15/InputTopLevelNonSealed.java")); } @Test - public void testPatternVariableWithModifiers() throws Exception { + void patternVariableWithModifiers() throws Exception { verifyAst( getPath("java16/ExpectedPatternVariableWithModifiers.txt"), getNonCompilablePath("java16/InputPatternVariableWithModifiers.java")); } @Test - public void testInputMethodDefArrayDeclarator() throws Exception { + void inputMethodDefArrayDeclarator() throws Exception { verifyAst( getPath("ExpectedAstRegressionMethodDefArrayDeclarator.txt"), getPath("InputAstRegressionMethodDefArrayDeclarator.java")); } @Test - public void testInputCstyleArrayDefinition() throws Exception { + void inputCstyleArrayDefinition() throws Exception { verifyAst( getPath("ExpectedAstRegressionCStyleArrayDefinition.txt"), getPath("InputAstRegressionCStyleArrayDefinition.java")); } @Test - public void testInputAnnotatedMethodVariableArityParam() throws Exception { + void inputAnnotatedMethodVariableArityParam() throws Exception { verifyAst( getPath("ExpectedAstRegressionAnnotatedMethodVariableArityParam.txt"), getPath("InputAstRegressionAnnotatedMethodVariableArityParam.java")); } @Test - public void testInputManyAlternativesInMultiCatch() throws Exception { + void inputManyAlternativesInMultiCatch() throws Exception { verifyAst( getPath("ExpectedAstRegressionManyAlternativesInMultiCatch.txt"), getPath("InputAstRegressionManyAlternativesInMultiCatch.java")); --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/CrAwareLexerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/CrAwareLexerTest.java @@ -25,10 +25,10 @@ import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; import org.junit.jupiter.api.Test; -public class CrAwareLexerTest { +final class CrAwareLexerTest { @Test - public void testConsumeCarriageReturnZeroCharPositionInLine() { + void consumeCarriageReturnZeroCharPositionInLine() { final String text = "\r"; final CharStream charStream = CharStreams.fromString(text); final CrAwareLexerSimulator lexer = new CrAwareLexerSimulator(null, null, null, null); @@ -40,7 +40,7 @@ public class CrAwareLexerTest { } @Test - public void testConsumeCarriageReturnNewline() { + void consumeCarriageReturnNewline() { final String text = "\r"; final CharStream charStream = CharStreams.fromString(text); final CrAwareLexerSimulator lexer = new CrAwareLexerSimulator(null, null, null, null); @@ -52,7 +52,7 @@ public class CrAwareLexerTest { } @Test - public void testConsumeWindowsNewlineZeroCharPositionInLine() { + void consumeWindowsNewlineZeroCharPositionInLine() { final String text = "\r\n"; final CharStream charStream = CharStreams.fromString(text); final CrAwareLexerSimulator lexer = new CrAwareLexerSimulator(null, null, null, null); @@ -65,7 +65,7 @@ public class CrAwareLexerTest { } @Test - public void testConsumeWindowsNewline() { + void consumeWindowsNewline() { final String text = "\r\n"; final CharStream charStream = CharStreams.fromString(text); final CrAwareLexerSimulator lexer = new CrAwareLexerSimulator(null, null, null, null); --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/EmbeddedNullCharTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/EmbeddedNullCharTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests that embedded nulls in string literals does not halt parsing. */ -public class EmbeddedNullCharTest extends AbstractModuleTestSupport { +final class EmbeddedNullCharTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class EmbeddedNullCharTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputEmbeddedNullChar.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/GeneratedJava14LexerTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/GeneratedJava14LexerTest.java @@ -20,21 +20,21 @@ package com.puppycrawl.tools.checkstyle.grammar; import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MSG_INVALID_PATTERN; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import java.nio.charset.Charset; -import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; /** Tests GeneratedJava14Lexer. */ -public class GeneratedJava14LexerTest extends AbstractModuleTestSupport { +final class GeneratedJava14LexerTest extends AbstractModuleTestSupport { /** Is {@code true} if current default encoding is UTF-8. */ private static final boolean IS_UTF8 = - Charset.forName(System.getProperty("file.encoding")).equals(StandardCharsets.UTF_8); + Charset.forName(System.getProperty("file.encoding")).equals(UTF_8); @Override protected String getPackageLocation() { @@ -42,7 +42,7 @@ public class GeneratedJava14LexerTest extends AbstractModuleTestSupport { } @Test - public void testUnexpectedChar() throws Exception { + void unexpectedChar() throws Exception { // Encoding problems will occur if default encoding is not UTF-8 Assumptions.assumeTrue(IS_UTF8, "Problems with encoding may occur"); @@ -59,7 +59,7 @@ public class GeneratedJava14LexerTest extends AbstractModuleTestSupport { } @Test - public void testSemicolonBetweenImports() throws Exception { + void semicolonBetweenImports() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser( getNonCompilablePath("InputSemicolonBetweenImports.java"), expected); --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/GeneratedJavaTokenTypesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/GeneratedJavaTokenTypesTest.java @@ -20,16 +20,16 @@ package com.puppycrawl.tools.checkstyle.grammar; import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.Collections.lastIndexOfSubList; +import static java.util.stream.Collectors.toUnmodifiableList; import com.puppycrawl.tools.checkstyle.grammar.java.JavaLanguageLexer; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; -import java.util.stream.Collectors; import org.antlr.v4.runtime.VocabularyImpl; import org.junit.jupiter.api.Test; @@ -40,7 +40,7 @@ import org.junit.jupiter.api.Test; * @noinspectionreason ClassIndependentOfModule - architecture of test modules requires this * structure */ -public class GeneratedJavaTokenTypesTest { +final class GeneratedJavaTokenTypesTest { /** * The following tokens are not declared in the lexer's 'tokens' block, they will always appear @@ -69,7 +69,7 @@ public class GeneratedJavaTokenTypesTest { *

Issue: #505 */ @Test - public void testTokenNumbering() { + void tokenNumbering() { final String message = "A token's number has changed. Please open" + " 'GeneratedJavaTokenTypesTest' and confirm which token is at fault.\n" @@ -332,17 +332,15 @@ public class GeneratedJavaTokenTypesTest { * unused tokens and cause Collections#lastIndexOfSubList to return a -1 and fail the test. */ @Test - public void testTokenHasBeenAddedToTokensBlockInLexerGrammar() { + void tokenHasBeenAddedToTokensBlockInLexerGrammar() { final VocabularyImpl vocabulary = (VocabularyImpl) JavaLanguageLexer.VOCABULARY; final String[] nullableSymbolicNames = vocabulary.getSymbolicNames(); final List allTokenNames = - Arrays.stream(nullableSymbolicNames) - .filter(Objects::nonNull) - .collect(Collectors.toUnmodifiableList()); + Arrays.stream(nullableSymbolicNames).filter(Objects::nonNull).collect(toUnmodifiableList()); // Get the starting index of the sublist of tokens, or -1 if sublist // is not present. - final int lastIndexOfSublist = Collections.lastIndexOfSubList(allTokenNames, INTERNAL_TOKENS); + final int lastIndexOfSublist = lastIndexOfSubList(allTokenNames, INTERNAL_TOKENS); final int expectedNumberOfUsedTokens = allTokenNames.size() - INTERNAL_TOKENS.size(); final String message = "New tokens must be added to the 'tokens' block in the" + " lexer grammar."; --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/HexFloatsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/HexFloatsTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests hex floats and doubles can be parsed. */ -public class HexFloatsTest extends AbstractModuleTestSupport { +final class HexFloatsTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class HexFloatsTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputHexFloat.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java14RecordsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java14RecordsTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class Java14RecordsTest extends AbstractModuleTestSupport { +final class Java14RecordsTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,7 +31,7 @@ public class Java14RecordsTest extends AbstractModuleTestSupport { } @Test - public void testJava14Records() throws Exception { + void java14Records() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getNonCompilablePath("InputJava14Records.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7DiamondTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7DiamondTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests Java 7 diamond can be parsed. */ -public class Java7DiamondTest extends AbstractModuleTestSupport { +final class Java7DiamondTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class Java7DiamondTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJava7Diamond.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7MultiCatchTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7MultiCatchTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests Java 7 multi-catch can be parsed. */ -public class Java7MultiCatchTest extends AbstractModuleTestSupport { +final class Java7MultiCatchTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class Java7MultiCatchTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJava7MultiCatch.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7NumericalLiteralsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7NumericalLiteralsTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests Java 7 numerical literals can be parsed. */ -public class Java7NumericalLiteralsTest extends AbstractModuleTestSupport { +final class Java7NumericalLiteralsTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class Java7NumericalLiteralsTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJava7NumericalLiterals.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7StringSwitchTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7StringSwitchTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests Java 7 String in switch can be parsed. */ -public class Java7StringSwitchTest extends AbstractModuleTestSupport { +final class Java7StringSwitchTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class Java7StringSwitchTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJava7StringSwitch.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7TryWithResourcesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java7TryWithResourcesTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests Java 7 try-with-resources can be parsed. */ -public class Java7TryWithResourcesTest extends AbstractModuleTestSupport { +final class Java7TryWithResourcesTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class Java7TryWithResourcesTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJava7TryWithResources.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java9TryWithResourcesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/Java9TryWithResourcesTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests Java 9 try-with-resources can be parsed. */ -public class Java9TryWithResourcesTest extends AbstractModuleTestSupport { +final class Java9TryWithResourcesTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class Java9TryWithResourcesTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputJava9TryWithResources.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/LineCommentAtTheEndOfFileTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/LineCommentAtTheEndOfFileTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Checks that file can be parsed, when it ends on line-comment but without new-line. */ -public class LineCommentAtTheEndOfFileTest extends AbstractModuleTestSupport { +final class LineCommentAtTheEndOfFileTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class LineCommentAtTheEndOfFileTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLineCommentAtTheEndOfFile.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/MultiDimensionalArraysInGenericsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/MultiDimensionalArraysInGenericsTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MultiDimensionalArraysInGenericsTest extends AbstractModuleTestSupport { +final class MultiDimensionalArraysInGenericsTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,7 +31,7 @@ public class MultiDimensionalArraysInGenericsTest extends AbstractModuleTestSupp } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMultiDimensionalArraysInGenerics.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/UnicodeEscapeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/UnicodeEscapeTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests that extended unicode escapes can be parsed. */ -public class UnicodeEscapeTest extends AbstractModuleTestSupport { +final class UnicodeEscapeTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class UnicodeEscapeTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputUnicodeEscape.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/VarargTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/VarargTest.java @@ -24,7 +24,7 @@ import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; /** Tests varargs can be parsed. */ -public class VarargTest extends AbstractModuleTestSupport { +final class VarargTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class VarargTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputVararg.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/antlr4/Antlr4AstRegressionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/antlr4/Antlr4AstRegressionTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractTreeTestSupport; import com.puppycrawl.tools.checkstyle.JavaParser; import org.junit.jupiter.api.Test; -public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { +final class Antlr4AstRegressionTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -31,229 +31,229 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testPackage() throws Exception { + void testPackage() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionPackage.txt"), getPath("InputAntlr4AstRegressionPackage.java")); } @Test - public void testSimple() throws Exception { + void simple() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionSimple.txt"), getPath("InputAntlr4AstRegressionSimple.java")); } @Test - public void testAnno() throws Exception { + void anno() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionSimpleWithAnno.txt"), getPath("InputAntlr4AstRegressionSimpleWithAnno.java")); } @Test - public void testImports() throws Exception { + void imports() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionImports.txt"), getPath("InputAntlr4AstRegressionImports.java")); } @Test - public void testConstructorCall() throws Exception { + void constructorCall() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionConstructorCall.txt"), getPath("InputAntlr4AstRegressionConstructorCall.java")); } @Test - public void testMethodCall() throws Exception { + void methodCall() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionMethodCall.txt"), getPath("InputAntlr4AstRegressionMethodCall.java")); } @Test - public void testRegressionJavaClass1() throws Exception { + void regressionJavaClass1() throws Exception { verifyAst( getPath("ExpectedRegressionJavaClass1Ast.txt"), getPath("InputRegressionJavaClass1.java")); } @Test - public void testRegressionAnnotationLocation() throws Exception { + void regressionAnnotationLocation() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionAnnotationLocation.txt"), getPath("InputAntlr4AstRegressionAnnotationLocation.java")); } @Test - public void testRegressionKeywordsAndOperators() throws Exception { + void regressionKeywordsAndOperators() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionKeywordsAndOperators.txt"), getPath("InputAntlr4AstRegressionKeywordsAndOperators.java")); } @Test - public void testRegressionDiamondOperators() throws Exception { + void regressionDiamondOperators() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionKeywordsAndOperators.txt"), getPath("InputAntlr4AstRegressionKeywordsAndOperators.java")); } @Test - public void testSingleLineBlocks() throws Exception { + void singleLineBlocks() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionSingleLineBlocks.txt"), getPath("InputAntlr4AstRegressionSingleLineBlocks.java")); } @Test - public void testExpressionList() throws Exception { + void expressionList() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionExpressionList.txt"), getPath("InputAntlr4AstRegressionExpressionList.java")); } @Test - public void testNewTypeTree() throws Exception { + void newTypeTree() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionNewTypeTree.txt"), getPath("InputAntlr4AstRegressionNewTypeTree.java")); } @Test - public void testFallThroughDefault() throws Exception { + void fallThroughDefault() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionFallThroughDefault.txt"), getPath("InputAntlr4AstRegressionFallThroughDefault.java")); } @Test - public void testPackageAnnotation() throws Exception { + void packageAnnotation() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionPackageAnnotation.txt"), getPath("package-info.java")); } @Test - public void testAnnotationOnSameLine1() throws Exception { + void annotationOnSameLine1() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionAnnotationOnSameLine.txt"), getPath("InputAntlr4AstRegressionAnnotationOnSameLine.java")); } @Test - public void testAnnotationOnSameLine2() throws Exception { + void annotationOnSameLine2() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionAnnotationOnSameLine2.txt"), getPath("InputAntlr4AstRegressionAnnotationOnSameLine2.java")); } @Test - public void testSuppressWarnings() throws Exception { + void suppressWarnings() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionSuppressWarnings.txt"), getPath("InputAntlr4AstRegressionSuppressWarnings.java")); } @Test - public void testBadOverride() throws Exception { + void badOverride() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionBadOverride.txt"), getPath("InputAntlr4AstRegressionBadOverride.java")); } @Test - public void testTrickySwitch() throws Exception { + void trickySwitch() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionTrickySwitch.txt"), getPath("InputAntlr4AstRegressionTrickySwitch.java")); } @Test - public void testExplicitInitialization() throws Exception { + void explicitInitialization() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionExplicitInitialization.txt"), getPath("InputAntlr4AstRegressionExplicitInitialization.java")); } @Test - public void testTypeParams() throws Exception { + void typeParams() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionTypeParams.txt"), getPath("InputAntlr4AstRegressionTypeParams.java")); } @Test - public void testForLoops() throws Exception { + void forLoops() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionForLoops.txt"), getPath("InputAntlr4AstRegressionForLoops.java")); } @Test - public void testIllegalCatch() throws Exception { + void illegalCatch() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionIllegalCatch.txt"), getPath("InputAntlr4AstRegressionIllegalCatch.java")); } @Test - public void testNestedTypeParametersAndArrayDeclarators() throws Exception { + void nestedTypeParametersAndArrayDeclarators() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionNestedTypeParametersAndArrayDeclarators.txt"), getPath("InputAntlr4AstRegressionNestedTypeParametersAndArrayDeclarators.java")); } @Test - public void testNewLineAtEndOfFileCr() throws Exception { + void newLineAtEndOfFileCr() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionNewLineAtEndOfFileCr.txt"), getPath("InputAntlr4AstRegressionNewLineAtEndOfFileCr.java")); } @Test - public void testWeirdCtor() throws Exception { + void weirdCtor() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionWeirdCtor.txt"), getPath("InputAntlr4AstRegressionWeirdCtor.java")); } @Test - public void testAnnotationOnQualifiedTypes() throws Exception { + void annotationOnQualifiedTypes() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionAnnotationOnQualifiedTypes.txt"), getPath("InputAntlr4AstRegressionAnnotationOnQualifiedTypes.java")); } @Test - public void testAnnotationOnArrays() throws Exception { + void annotationOnArrays() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionAnnotationOnArrays.txt"), getPath("InputAntlr4AstRegressionAnnotationOnArrays.java")); } @Test - public void testMethodRefs() throws Exception { + void methodRefs() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionMethodRefs.txt"), getPath("InputAntlr4AstRegressionMethodRefs.java")); } @Test - public void testEmbeddedBlockComments() throws Exception { + void embeddedBlockComments() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionEmbeddedBlockComments.txt"), getPath("InputAntlr4AstRegressionEmbeddedBlockComments.java")); } @Test - public void testJava16LocalEnumAndInterface() throws Exception { + void java16LocalEnumAndInterface() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionJava16LocalEnumAndInterface.txt"), getNonCompilablePath("InputAntlr4AstRegressionJava16LocalEnumAndInterface.java")); } @Test - public void testTrickySwitchWithComments() throws Exception { + void trickySwitchWithComments() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionTrickySwitchWithComments.txt"), getPath("InputAntlr4AstRegressionTrickySwitchWithComments.java"), @@ -261,7 +261,7 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testCassandraInputWithComments() throws Exception { + void cassandraInputWithComments() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionCassandraInputWithComments.txt"), getPath("InputAntlr4AstRegressionCassandraInputWithComments.java"), @@ -269,7 +269,7 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testCommentsOnAnnotationsAndEnums() throws Exception { + void commentsOnAnnotationsAndEnums() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionCommentsOnAnnotationsAndEnums.txt"), getPath("InputAntlr4AstRegressionCommentsOnAnnotationsAndEnums.java"), @@ -277,7 +277,7 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testUncommon() throws Exception { + void uncommon() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionUncommon.txt"), getNonCompilablePath("InputAntlr4AstRegressionUncommon.java"), @@ -285,7 +285,7 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testUncommon2() throws Exception { + void uncommon2() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionUncommon2.txt"), getNonCompilablePath("InputAntlr4AstRegressionUncommon2.java"), @@ -293,7 +293,7 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testTrickyYield() throws Exception { + void trickyYield() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionTrickyYield.txt"), getPath("InputAntlr4AstRegressionTrickyYield.java"), @@ -301,7 +301,7 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testSingleCommaInArrayInit() throws Exception { + void singleCommaInArrayInit() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionSingleCommaInArrayInit.txt"), getPath("InputAntlr4AstRegressionSingleCommaInArrayInit.java"), @@ -309,7 +309,7 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testUncommon3() throws Exception { + void uncommon3() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionUncommon3.txt"), getNonCompilablePath("InputAntlr4AstRegressionUncommon3.java"), @@ -317,7 +317,7 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testUncommon4() throws Exception { + void uncommon4() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionUncommon4.txt"), getPath("InputAntlr4AstRegressionUncommon4.java"), @@ -325,14 +325,14 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testQualifiedConstructorParameter() throws Exception { + void qualifiedConstructorParameter() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionQualifiedConstructorParameter.txt"), getNonCompilablePath("InputAntlr4AstRegressionQualifiedConstructorParameter.java")); } @Test - public void testJava15FinalLocalRecord() throws Exception { + void java15FinalLocalRecord() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionJava15FinalLocalRecord.txt"), getNonCompilablePath("InputAntlr4AstRegressionJava15FinalLocalRecord.java"), @@ -340,28 +340,28 @@ public class Antlr4AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testUnusualAnnotation() throws Exception { + void unusualAnnotation() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionUnusualAnnotation.txt"), getPath("InputAntlr4AstRegressionUnusualAnnotation.java")); } @Test - public void testLambda() throws Exception { + void lambda() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionLambda.txt"), getPath("InputAntlr4AstRegressionLambda.java")); } @Test - public void testExpressions() throws Exception { + void expressions() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionExpressions.txt"), getPath("InputAntlr4AstRegressionExpressions.java")); } @Test - public void testInterfaceMemberAlternativePrecedence() throws Exception { + void interfaceMemberAlternativePrecedence() throws Exception { verifyAst( getPath("ExpectedAntlr4AstRegressionInterfaceRecordDef.txt"), getNonCompilablePath("InputAntlr4AstRegressionInterfaceRecordDef.java")); --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/antlr4/Java17AstRegressionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/antlr4/Java17AstRegressionTest.java @@ -22,7 +22,7 @@ package com.puppycrawl.tools.checkstyle.grammar.antlr4; import com.puppycrawl.tools.checkstyle.AbstractTreeTestSupport; import org.junit.jupiter.api.Test; -public class Java17AstRegressionTest extends AbstractTreeTestSupport { +final class Java17AstRegressionTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -30,49 +30,49 @@ public class Java17AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testPatternsInSwitch() throws Exception { + void patternsInSwitch() throws Exception { verifyAst( getNonCompilablePath("ExpectedAntlr4AstRegressionPatternsInSwitch.txt"), getNonCompilablePath("InputAntlr4AstRegressionPatternsInSwitch.java")); } @Test - public void testPatternsInIfStatement() throws Exception { + void patternsInIfStatement() throws Exception { verifyAst( getNonCompilablePath("ExpectedAntlr4AstRegressionPatternsInIfStatement.txt"), getNonCompilablePath("InputAntlr4AstRegressionPatternsInIfStatement.java")); } @Test - public void testPatternsInWhile() throws Exception { + void patternsInWhile() throws Exception { verifyAst( getNonCompilablePath("ExpectedAntlr4AstRegressionPatternsInWhile.txt"), getNonCompilablePath("InputAntlr4AstRegressionPatternsInWhile.java")); } @Test - public void testPatternsInTernary() throws Exception { + void patternsInTernary() throws Exception { verifyAst( getNonCompilablePath("ExpectedAntlr4AstRegressionPatternsInTernary.txt"), getNonCompilablePath("InputAntlr4AstRegressionPatternsInTernary.java")); } @Test - public void testPatternsInFor() throws Exception { + void patternsInFor() throws Exception { verifyAst( getNonCompilablePath("ExpectedAntlr4AstRegressionPatternsInFor.txt"), getNonCompilablePath("InputAntlr4AstRegressionPatternsInFor.java")); } @Test - public void testPatternMatchingInSwitch() throws Exception { + void patternMatchingInSwitch() throws Exception { verifyAst( getNonCompilablePath("ExpectedAntlr4AstRegressionPatternMatchingInSwitch.txt"), getNonCompilablePath("InputAntlr4AstRegressionPatternMatchingInSwitch.java")); } @Test - public void testCaseDefault() throws Exception { + void caseDefault() throws Exception { verifyAst( getNonCompilablePath("ExpectedAntlr4AstRegressionCaseDefault.txt"), getNonCompilablePath("InputAntlr4AstRegressionCaseDefault.java")); --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/comments/AllBlockCommentsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/comments/AllBlockCommentsTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle.grammar.comments; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -27,13 +28,12 @@ import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil; -import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; import org.junit.jupiter.api.Test; -public class AllBlockCommentsTest extends AbstractModuleTestSupport { +final class AllBlockCommentsTest extends AbstractModuleTestSupport { private static final Set ALL_COMMENTS = new LinkedHashSet<>(); @@ -45,10 +45,10 @@ public class AllBlockCommentsTest extends AbstractModuleTestSupport { } @Test - public void testAllBlockComments() throws Exception { + void allBlockComments() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(BlockCommentListenerCheck.class); final String path = getPath("InputFullOfBlockComments.java"); - lineSeparator = CheckUtil.getLineSeparatorForFile(path, StandardCharsets.UTF_8); + lineSeparator = CheckUtil.getLineSeparatorForFile(path, UTF_8); execute(checkConfig, path); assertWithMessage("All comments should be empty").that(ALL_COMMENTS).isEmpty(); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/comments/AllSinglelineCommentsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/comments/AllSinglelineCommentsTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle.grammar.comments; import static com.google.common.truth.Truth.assertWithMessage; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -27,12 +28,11 @@ import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil; -import java.nio.charset.StandardCharsets; import java.util.LinkedHashSet; import java.util.Set; import org.junit.jupiter.api.Test; -public class AllSinglelineCommentsTest extends AbstractModuleTestSupport { +final class AllSinglelineCommentsTest extends AbstractModuleTestSupport { private static final Set ALL_COMMENTS = new LinkedHashSet<>(); @@ -44,11 +44,11 @@ public class AllSinglelineCommentsTest extends AbstractModuleTestSupport { } @Test - public void testAllSinglelineComments() throws Exception { + void allSinglelineComments() throws Exception { final DefaultConfiguration checkConfig = createModuleConfig(SinglelineCommentListenerCheck.class); final String path = getPath("InputFullOfSinglelineComments.java"); - lineSeparator = CheckUtil.getLineSeparatorForFile(path, StandardCharsets.UTF_8); + lineSeparator = CheckUtil.getLineSeparatorForFile(path, UTF_8); execute(checkConfig, path); assertWithMessage("All comments should be empty").that(ALL_COMMENTS).isEmpty(); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/comments/CommentsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/comments/CommentsTest.java @@ -26,7 +26,7 @@ import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.api.Comment; import org.junit.jupiter.api.Test; -public class CommentsTest extends AbstractTreeTestSupport { +final class CommentsTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -34,7 +34,7 @@ public class CommentsTest extends AbstractTreeTestSupport { } @Test - public void testCompareExpectedTreeWithInput1() throws Exception { + void compareExpectedTreeWithInput1() throws Exception { verifyAst( getPath("InputComments1Ast.txt"), getPath("InputComments1.java"), @@ -42,7 +42,7 @@ public class CommentsTest extends AbstractTreeTestSupport { } @Test - public void testCompareExpectedTreeWithInput2() throws Exception { + void compareExpectedTreeWithInput2() throws Exception { verifyAst( getPath("InputComments2Ast.txt"), getPath("InputComments2.java"), @@ -50,7 +50,7 @@ public class CommentsTest extends AbstractTreeTestSupport { } @Test - public void testToString() { + void testToString() { final Comment comment = new Comment(new String[] {"value"}, 1, 2, 3); assertWithMessage("Invalid toString result") .that(comment.toString()) @@ -59,7 +59,7 @@ public class CommentsTest extends AbstractTreeTestSupport { } @Test - public void testGetCommentMeasures() { + void getCommentMeasures() { final String[] commentText = { "/**", " * Creates new instance.", @@ -84,7 +84,7 @@ public class CommentsTest extends AbstractTreeTestSupport { } @Test - public void testIntersects() { + void intersects() { final String[] commentText = { "// compute a single number for start and end", "// to simplify conditional logic" }; --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java19/Java19AstRegressionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java19/Java19AstRegressionTest.java @@ -22,7 +22,7 @@ package com.puppycrawl.tools.checkstyle.grammar.java19; import com.puppycrawl.tools.checkstyle.AbstractTreeTestSupport; import org.junit.jupiter.api.Test; -public class Java19AstRegressionTest extends AbstractTreeTestSupport { +final class Java19AstRegressionTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -30,84 +30,84 @@ public class Java19AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testPatternsInSwitch() throws Exception { + void patternsInSwitch() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19PatternsInSwitchLabels.txt"), getNonCompilablePath("InputJava19PatternsInSwitchLabels.java")); } @Test - public void testPatternsInNullSwitch1() throws Exception { + void patternsInNullSwitch1() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19PatternsInNullSwitch1.txt"), getNonCompilablePath("InputJava19PatternsInNullSwitch1.java")); } @Test - public void testPatternsInNullSwitch2() throws Exception { + void patternsInNullSwitch2() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19PatternsInNullSwitch2.txt"), getNonCompilablePath("InputJava19PatternsInNullSwitch2.java")); } @Test - public void testAnnotationsOnBinding() throws Exception { + void annotationsOnBinding() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19PatternsAnnotationsOnBinding.txt"), getNonCompilablePath("InputJava19PatternsAnnotationsOnBinding.java")); } @Test - public void testTrickyWhenUsage() throws Exception { + void trickyWhenUsage() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19PatternsTrickyWhenUsage.txt"), getNonCompilablePath("InputJava19PatternsTrickyWhenUsage.java")); } @Test - public void testLotsOfOperators() throws Exception { + void lotsOfOperators() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19BindingsWithLotsOfOperators.txt"), getNonCompilablePath("InputJava19BindingsWithLotsOfOperators.java")); } @Test - public void testRecordPatternsWithNestedDecomposition() throws Exception { + void recordPatternsWithNestedDecomposition() throws Exception { verifyAst( getPath("ExpectedRecordPatternsPreviewNestedDecomposition.txt"), getNonCompilablePath("InputRecordPatternsPreviewNestedDecomposition.java")); } @Test - public void testRecordPatternsPreview() throws Exception { + void recordPatternsPreview() throws Exception { verifyAst( getPath("ExpectedRecordPatternsPreview.txt"), getNonCompilablePath("InputRecordPatternsPreview.java")); } @Test - public void testGenericRecordDecomposition() throws Exception { + void genericRecordDecomposition() throws Exception { verifyAst( getNonCompilablePath("ExpectedGenericRecordDeconstructionPattern.txt"), getNonCompilablePath("InputGenericRecordDeconstructionPattern.java")); } @Test - public void testGuardsWithExtraParenthesis() throws Exception { + void guardsWithExtraParenthesis() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19GuardsWithExtraParenthesis.txt"), getNonCompilablePath("InputJava19GuardsWithExtraParenthesis.java")); } @Test - public void testBindingWithModifiers() throws Exception { + void bindingWithModifiers() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19BindingWithModifiers.txt"), getNonCompilablePath("InputJava19BindingWithModifiers.java")); } @Test - public void test() throws Exception { + void test() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava19RecordDecompositionWithConditionInLoops.txt"), getNonCompilablePath("InputJava19RecordDecompositionWithConditionInLoops.java")); --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java20/Java20AstRegressionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java20/Java20AstRegressionTest.java @@ -22,7 +22,7 @@ package com.puppycrawl.tools.checkstyle.grammar.java20; import com.puppycrawl.tools.checkstyle.AbstractTreeTestSupport; import org.junit.jupiter.api.Test; -public class Java20AstRegressionTest extends AbstractTreeTestSupport { +final class Java20AstRegressionTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -30,14 +30,14 @@ public class Java20AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testRecordDecompositionEnhancedForLoop() throws Exception { + void recordDecompositionEnhancedForLoop() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava20RecordDecompositionEnhancedForLoop.txt"), getNonCompilablePath("InputJava20RecordDecompositionEnhancedForLoop.java")); } @Test - public void testRecordDecompositionEnhancedForLoopTricky() throws Exception { + void recordDecompositionEnhancedForLoopTricky() throws Exception { verifyAst( getNonCompilablePath("ExpectedJava20RecordDecompositionEnhancedForLoopTricky.txt"), getNonCompilablePath("InputJava20RecordDecompositionEnhancedForLoopTricky.java")); --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java21/Java21AstRegressionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java21/Java21AstRegressionTest.java @@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import java.io.File; import org.junit.jupiter.api.Test; -public class Java21AstRegressionTest extends AbstractTreeTestSupport { +final class Java21AstRegressionTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -36,7 +36,7 @@ public class Java21AstRegressionTest extends AbstractTreeTestSupport { } @Test - public void testBasicStringTemplate() throws Exception { + void basicStringTemplate() throws Exception { verifyAst( getNonCompilablePath("ExpectedStringTemplateBasic.txt"), getNonCompilablePath("InputStringTemplateBasic.java")); @@ -48,28 +48,28 @@ public class Java21AstRegressionTest extends AbstractTreeTestSupport { * vs. four spaces. */ @Test - public void testBasicStringTemplateWithTabs() throws Exception { + void basicStringTemplateWithTabs() throws Exception { verifyAst( getNonCompilablePath("ExpectedStringTemplateBasicWithTabs.txt"), getNonCompilablePath("InputStringTemplateBasicWithTabs.java")); } @Test - public void testUnnamedVariableBasic() throws Exception { + void unnamedVariableBasic() throws Exception { verifyAst( getNonCompilablePath("ExpectedUnnamedVariableBasic.txt"), getNonCompilablePath("InputUnnamedVariableBasic.java")); } @Test - public void testUnnamedVariableSwitch() throws Exception { + void unnamedVariableSwitch() throws Exception { verifyAst( getNonCompilablePath("ExpectedUnnamedVariableSwitch.txt"), getNonCompilablePath("InputUnnamedVariableSwitch.java")); } @Test - public void testTextBlockConsecutiveEscapes() throws Exception { + void textBlockConsecutiveEscapes() throws Exception { verifyAst( getNonCompilablePath("ExpectedTextBlockConsecutiveEscapes.txt"), getNonCompilablePath("InputTextBlockConsecutiveEscapes.java")); @@ -83,7 +83,7 @@ public class Java21AstRegressionTest extends AbstractTreeTestSupport { * @throws Exception if an error occurs */ @Test - public void testTextBlockParsingFail() throws Exception { + void textBlockParsingFail() throws Exception { final File file = new File(getNonCompilablePath("InputTextBlockParsingFail.java.fail")); final Throwable throwable = --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class AnnotationTest extends AbstractModuleTestSupport { +final class AnnotationTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,73 +31,73 @@ public class AnnotationTest extends AbstractModuleTestSupport { } @Test - public void testSimpleTypeAnnotation() throws Exception { + void simpleTypeAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations1.java"), expected); } @Test - public void testAnnotationOnClass() throws Exception { + void annotationOnClass() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations2.java"), expected); } @Test - public void testClassCastTypeAnnotation() throws Exception { + void classCastTypeAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations3.java"), expected); } @Test - public void testMethodParametersTypeAnnotation() throws Exception { + void methodParametersTypeAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations4.java"), expected); } @Test - public void testAnnotationInThrows() throws Exception { + void annotationInThrows() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations5.java"), expected); } @Test - public void testAnnotationInGeneric() throws Exception { + void annotationInGeneric() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations6.java"), expected); } @Test - public void testAnnotationOnConstructorCall() throws Exception { + void annotationOnConstructorCall() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations7.java"), expected); } @Test - public void testAnnotationNestedCall() throws Exception { + void annotationNestedCall() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations8.java"), expected); } @Test - public void testAnnotationOnWildcards() throws Exception { + void annotationOnWildcards() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations9.java"), expected); } @Test - public void testAnnotationInCatchParameters() throws Exception { + void annotationInCatchParameters() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations10.java"), expected); } @Test - public void testAnnotationInTypeParameters() throws Exception { + void annotationInTypeParameters() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations11.java"), expected); } @Test - public void testAnnotationOnVarargs() throws Exception { + void annotationOnVarargs() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotations12.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationsOnArrayTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/AnnotationsOnArrayTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class AnnotationsOnArrayTest extends AbstractModuleTestSupport { +final class AnnotationsOnArrayTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,7 +31,7 @@ public class AnnotationsOnArrayTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputAnnotationsOnArray.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/DefaultMethodsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/DefaultMethodsTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class DefaultMethodsTest extends AbstractModuleTestSupport { +final class DefaultMethodsTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,13 +31,13 @@ public class DefaultMethodsTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputDefaultMethods.java"), expected); } @Test - public void testSwitch() throws Exception { + void testSwitch() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputDefaultMethods2.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/LambdaTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/LambdaTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class LambdaTest extends AbstractModuleTestSupport { +final class LambdaTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,109 +31,109 @@ public class LambdaTest extends AbstractModuleTestSupport { } @Test - public void testLambdaInVariableInitialization() throws Exception { + void lambdaInVariableInitialization() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda1.java"), expected); } @Test - public void testWithoutArgsOneLineLambdaBody() throws Exception { + void withoutArgsOneLineLambdaBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda2.java"), expected); } @Test - public void testWithoutArgsFullLambdaBody() throws Exception { + void withoutArgsFullLambdaBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda3.java"), expected); } @Test - public void testWithOneArgWithOneLineBody() throws Exception { + void withOneArgWithOneLineBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda4.java"), expected); } @Test - public void testWithOneArgWithFullBody() throws Exception { + void withOneArgWithFullBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda5.java"), expected); } @Test - public void testWithOneArgWithoutTypeOneLineBody() throws Exception { + void withOneArgWithoutTypeOneLineBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda6.java"), expected); } @Test - public void testWithOneArgWithoutTypeFullBody() throws Exception { + void withOneArgWithoutTypeFullBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda7.java"), expected); } @Test - public void testWithFewArgsWithoutTypeOneLineBody() throws Exception { + void withFewArgsWithoutTypeOneLineBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda8.java"), expected); } @Test - public void testWithFewArgsWithoutTypeFullBody() throws Exception { + void withFewArgsWithoutTypeFullBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda9.java"), expected); } @Test - public void testWithOneArgWithoutParenthesesWithoutTypeOneLineBody() throws Exception { + void withOneArgWithoutParenthesesWithoutTypeOneLineBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda10.java"), expected); } @Test - public void testWithOneArgWithoutParenthesesWithoutTypeFullBody() throws Exception { + void withOneArgWithoutParenthesesWithoutTypeFullBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda11.java"), expected); } @Test - public void testWithFewArgWithTypeOneLine() throws Exception { + void withFewArgWithTypeOneLine() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda12.java"), expected); } @Test - public void testWithFewArgWithTypeFullBody() throws Exception { + void withFewArgWithTypeFullBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda13.java"), expected); } @Test - public void testWithMultilineBody() throws Exception { + void withMultilineBody() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda14.java"), expected); } @Test - public void testCasesFromSpec() throws Exception { + void casesFromSpec() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda15.java"), expected); } @Test - public void testWithTypecast() throws Exception { + void withTypecast() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda16.java"), expected); } @Test - public void testInAssignment() throws Exception { + void inAssignment() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda17.java"), expected); } @Test - public void testInTernary() throws Exception { + void inTernary() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputLambda18.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/MethodReferencesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/MethodReferencesTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class MethodReferencesTest extends AbstractModuleTestSupport { +final class MethodReferencesTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,43 +31,43 @@ public class MethodReferencesTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodReferences.java"), expected); } @Test - public void testFromSpec() throws Exception { + void fromSpec() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodReferences2.java"), expected); } @Test - public void testGenericInPostfixExpressionBeforeReference() throws Exception { + void genericInPostfixExpressionBeforeReference() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodReferences3.java"), expected); } @Test - public void testArrayAfterGeneric() throws Exception { + void arrayAfterGeneric() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodReferences4.java"), expected); } @Test - public void testFromHibernate() throws Exception { + void fromHibernate() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodReferences5.java"), expected); } @Test - public void testFromSpring() throws Exception { + void fromSpring() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodReferences6.java"), expected); } @Test - public void testMethodReferences7() throws Exception { + void methodReferences7() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputMethodReferences7.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/ReceiverParameterTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/ReceiverParameterTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class ReceiverParameterTest extends AbstractModuleTestSupport { +final class ReceiverParameterTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,7 +31,7 @@ public class ReceiverParameterTest extends AbstractModuleTestSupport { } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputReceiverParameter.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/TypeUseAnnotationsOnQualifiedTypesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/java8/TypeUseAnnotationsOnQualifiedTypesTest.java @@ -23,7 +23,7 @@ import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class TypeUseAnnotationsOnQualifiedTypesTest extends AbstractModuleTestSupport { +final class TypeUseAnnotationsOnQualifiedTypesTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -31,7 +31,7 @@ public class TypeUseAnnotationsOnQualifiedTypesTest extends AbstractModuleTestSu } @Test - public void testCanParse() throws Exception { + void canParse() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputTypeUseAnnotationsOnQualifiedTypes.java"), expected); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/javadoc/GeneratedJavadocTokenTypesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/javadoc/GeneratedJavadocTokenTypesTest.java @@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test; * @noinspectionreason ClassIndependentOfModule - architecture of test modules requires this * structure */ -public class GeneratedJavadocTokenTypesTest { +final class GeneratedJavadocTokenTypesTest { private static final String MSG = "Ensure that token numbers generated for the elements" @@ -50,7 +50,7 @@ public class GeneratedJavadocTokenTypesTest { * @see "https://github.com/checkstyle/checkstyle/issues/5186" */ @Test - public void testTokenNumbers() { + void tokenNumbers() { assertWithMessage(MSG).that(JavadocParser.LEADING_ASTERISK).isEqualTo(1); assertWithMessage(MSG).that(JavadocParser.HTML_COMMENT_START).isEqualTo(2); assertWithMessage(MSG).that(JavadocParser.DEPRECATED_CDATA_DO_NOT_USE).isEqualTo(3); @@ -180,7 +180,7 @@ public class GeneratedJavadocTokenTypesTest { * @see "https://github.com/checkstyle/checkstyle/issues/5186" */ @Test - public void testRuleNumbers() { + void ruleNumbers() { assertWithMessage(MSG).that(JavadocParser.RULE_javadoc).isEqualTo(0); assertWithMessage(MSG).that(JavadocParser.RULE_htmlElement).isEqualTo(1); assertWithMessage(MSG).that(JavadocParser.RULE_htmlElementStart).isEqualTo(2); --- a/src/test/java/com/puppycrawl/tools/checkstyle/grammar/javadoc/JavadocParseTreeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/grammar/javadoc/JavadocParseTreeTest.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; * @noinspection ClassOnlyUsedInOnePackage * @noinspectionreason ClassOnlyUsedInOnePackage - class is internal tool, and only used in testing */ -public class JavadocParseTreeTest extends AbstractTreeTestSupport { +final class JavadocParseTreeTest extends AbstractTreeTestSupport { @Override protected String getPackageLocation() { @@ -46,402 +46,402 @@ public class JavadocParseTreeTest extends AbstractTreeTestSupport { } @Test - public void oneSimpleHtmlTag() throws Exception { + void oneSimpleHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedOneSimpleHtmlTagAst.txt"), getHtmlPath("InputOneSimpleHtmlTag.javadoc")); } @Test - public void textBeforeJavadocTags() throws Exception { + void textBeforeJavadocTags() throws Exception { verifyJavadocTree( getDocPath("expectedTextBeforeJavadocTagsAst.txt"), getDocPath("InputTextBeforeJavadocTags.javadoc")); } @Test - public void customJavadocTags() throws Exception { + void customJavadocTags() throws Exception { verifyJavadocTree( getDocPath("expectedCustomJavadocTagsAst.txt"), getDocPath("InputCustomJavadocTags.javadoc")); } @Test - public void javadocTagDescriptionWithInlineTags() throws Exception { + void javadocTagDescriptionWithInlineTags() throws Exception { verifyJavadocTree( getDocPath("expectedJavadocTagDescriptionWithInlineTagsAst.txt"), getDocPath("InputJavadocTagDescriptionWithInlineTags.javadoc")); } @Test - public void leadingAsterisks() throws Exception { + void leadingAsterisks() throws Exception { verifyJavadocTree( getPath("expectedLeadingAsterisksAst.txt"), getPath("InputLeadingAsterisks.javadoc")); } @Test - public void authorWithMailto() throws Exception { + void authorWithMailto() throws Exception { verifyJavadocTree( getDocPath("expectedAuthorWithMailtoAst.txt"), getDocPath("InputAuthorWithMailto.javadoc")); } @Test - public void htmlTagsInParagraph() throws Exception { + void htmlTagsInParagraph() throws Exception { verifyJavadocTree( getHtmlPath("expectedHtmlTagsInParagraphAst.txt"), getHtmlPath("InputHtmlTagsInParagraph.javadoc")); } @Test - public void linkInlineTags() throws Exception { + void linkInlineTags() throws Exception { verifyJavadocTree( getDocPath("expectedLinkInlineTagsAst.txt"), getDocPath("InputLinkInlineTags.javadoc")); } @Test - public void seeReferenceWithFewNestedClasses() throws Exception { + void seeReferenceWithFewNestedClasses() throws Exception { verifyJavadocTree( getDocPath("expectedSeeReferenceWithFewNestedClassesAst.txt"), getDocPath("InputSeeReferenceWithFewNestedClasses.javadoc")); } @Test - public void paramWithGeneric() throws Exception { + void paramWithGeneric() throws Exception { verifyJavadocTree( getDocPath("expectedParamWithGenericAst.txt"), getDocPath("InputParamWithGeneric.javadoc")); } @Test - public void serial() throws Exception { + void serial() throws Exception { verifyJavadocTree(getDocPath("expectedSerialAst.txt"), getDocPath("InputSerial.javadoc")); } @Test - public void since() throws Exception { + void since() throws Exception { verifyJavadocTree(getDocPath("expectedSinceAst.txt"), getDocPath("InputSince.javadoc")); } @Test - public void unclosedAndClosedParagraphs() throws Exception { + void unclosedAndClosedParagraphs() throws Exception { verifyJavadocTree( getHtmlPath("expectedUnclosedAndClosedParagraphsAst.txt"), getHtmlPath("InputUnclosedAndClosedParagraphs.javadoc")); } @Test - public void listWithUnclosedItemInUnclosedParagraph() throws Exception { + void listWithUnclosedItemInUnclosedParagraph() throws Exception { verifyJavadocTree( getHtmlPath("expectedListWithUnclosedItemInUnclosedParagraphAst.txt"), getHtmlPath("InputListWithUnclosedItemInUnclosedParagraph.javadoc")); } @Test - public void unclosedParagraphFollowedByJavadocTag() throws Exception { + void unclosedParagraphFollowedByJavadocTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedUnclosedParagraphFollowedByJavadocTagAst.txt"), getHtmlPath("InputUnclosedParagraphFollowedByJavadocTag.javadoc")); } @Test - public void allJavadocInlineTags() throws Exception { + void allJavadocInlineTags() throws Exception { verifyJavadocTree( getDocPath("expectedAllJavadocInlineTagsAst.txt"), getDocPath("InputAllJavadocInlineTags.javadoc")); } @Test - public void docRootInheritDoc() throws Exception { + void docRootInheritDoc() throws Exception { verifyJavadocTree( getDocPath("expectedDocRootInheritDocAst.txt"), getDocPath("InputDocRootInheritDoc.javadoc")); } @Test - public void fewWhiteSpacesAsSeparator() throws Exception { + void fewWhiteSpacesAsSeparator() throws Exception { verifyJavadocTree( getDocPath("expectedFewWhiteSpacesAsSeparatorAst.txt"), getDocPath("InputFewWhiteSpacesAsSeparator.javadoc")); } @Test - public void mixedCaseOfHtmlTags() throws Exception { + void mixedCaseOfHtmlTags() throws Exception { verifyJavadocTree( getHtmlPath("expectedMixedCaseOfHtmlTagsAst.txt"), getHtmlPath("InputMixedCaseOfHtmlTags.javadoc")); } @Test - public void htmlComments() throws Exception { + void htmlComments() throws Exception { verifyJavadocTree(getHtmlPath("expectedCommentsAst.txt"), getHtmlPath("InputComments.javadoc")); } @Test - public void negativeNumberInAttribute() throws Exception { + void negativeNumberInAttribute() throws Exception { verifyJavadocTree( getHtmlPath("expectedNegativeNumberInAttributeAst.txt"), getHtmlPath("InputNegativeNumberInAttribute.javadoc")); } @Test - public void dollarInLink() throws Exception { + void dollarInLink() throws Exception { verifyJavadocTree( getDocPath("expectedDollarInLinkAst.txt"), getDocPath("InputDollarInLink.javadoc")); } @Test - public void dotCharacterInCustomTags() throws Exception { + void dotCharacterInCustomTags() throws Exception { verifyJavadocTree( getDocPath("expectedCustomTagWithDotAst.txt"), getDocPath("InputCustomTagWithDot.javadoc")); } @Test - public void testLinkToPackage() throws Exception { + void linkToPackage() throws Exception { verifyJavadocTree( getDocPath("expectedLinkToPackageAst.txt"), getDocPath("InputLinkToPackage.javadoc")); } @Test - public void testLeadingAsterisksExtended() throws Exception { + void leadingAsterisksExtended() throws Exception { verifyJavadocTree( getPath("expectedLeadingAsterisksExtendedAst.txt"), getPath("InputLeadingAsterisksExtended.javadoc")); } @Test - public void testInlineCustomJavadocTag() throws Exception { + void inlineCustomJavadocTag() throws Exception { verifyJavadocTree( getDocPath("expectedInlineCustomJavadocTagAst.txt"), getDocPath("InputInlineCustomJavadocTag.javadoc")); } @Test - public void testAttributeValueWithoutQuotes() throws Exception { + void attributeValueWithoutQuotes() throws Exception { verifyJavadocTree( getHtmlPath("expectedAttributeValueWithoutQuotesAst.txt"), getHtmlPath("InputAttributeValueWithoutQuotes.javadoc")); } @Test - public void testClosedOtherTag() throws Exception { + void closedOtherTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedClosedOtherTagAst.txt"), getHtmlPath("InputClosedOtherTag.javadoc")); } @Test - public void testAllStandardJavadocTags() throws Exception { + void allStandardJavadocTags() throws Exception { verifyJavadocTree( getDocPath("expectedAllStandardJavadocTagsAst.txt"), getDocPath("InputAllStandardJavadocTags.javadoc")); } @Test - public void testAsteriskInJavadocInlineTag() throws Exception { + void asteriskInJavadocInlineTag() throws Exception { verifyJavadocTree( getDocPath("expectedAsteriskInJavadocInlineTagAst.txt"), getDocPath("InputAsteriskInJavadocInlineTag.javadoc")); } @Test - public void testAsteriskInLiteral() throws Exception { + void asteriskInLiteral() throws Exception { verifyJavadocTree( getDocPath("expectedAsteriskInLiteralAst.txt"), getDocPath("InputAsteriskInLiteral.javadoc")); } @Test - public void testInnerBracesInCodeTag() throws Exception { + void innerBracesInCodeTag() throws Exception { verifyJavadocTree( getDocPath("expectedInnerBracesInCodeTagAst.txt"), getDocPath("InputInnerBracesInCodeTag.javadoc")); } @Test - public void testNewlineAndAsteriskInParameters() throws Exception { + void newlineAndAsteriskInParameters() throws Exception { verifyJavadocTree( getDocPath("expectedNewlineAndAsteriskInParametersAst.txt"), getDocPath("InputNewlineAndAsteriskInParameters.javadoc")); } @Test - public void testTwoLinkTagsInRow() throws Exception { + void twoLinkTagsInRow() throws Exception { verifyJavadocTree( getDocPath("expectedTwoLinkTagsInRowAst.txt"), getDocPath("InputTwoLinkTagsInRow.javadoc")); } @Test - public void testJavadocWithCrAsNewline() throws Exception { + void javadocWithCrAsNewline() throws Exception { verifyJavadocTree( getPath("expectedJavadocWithCrAsNewlineAst.txt"), getPath("InputJavadocWithCrAsNewline.javadoc")); } @Test - public void testNestingWithSingletonElement() throws Exception { + void nestingWithSingletonElement() throws Exception { verifyJavadocTree( getHtmlPath("expectedNestingWithSingletonElementAst.txt"), getHtmlPath("InputNestingWithSingletonElement.javadoc")); } @Test - public void testVoidElements() throws Exception { + void voidElements() throws Exception { verifyJavadocTree( getHtmlPath("expectedVoidElementsAst.txt"), getHtmlPath("InputVoidElements.javadoc")); } @Test - public void testHtmlVoidElementEmbed() throws Exception { + void htmlVoidElementEmbed() throws Exception { verifyJavadocTree( getHtmlPath("expectedHtmlVoidElementEmbedAst.txt"), getHtmlPath("InputHtmlVoidElementEmbed.javadoc")); } @Test - public void testSpaceBeforeDescriptionInBlockJavadocTags() throws Exception { + void spaceBeforeDescriptionInBlockJavadocTags() throws Exception { verifyJavadocTree( getDocPath("expectedSpaceBeforeDescriptionInBlockJavadocTagsAst.txt"), getDocPath("InputSpaceBeforeDescriptionInBlockJavadocTags.javadoc")); } @Test - public void testEmptyDescriptionBeforeTags() throws Exception { + void emptyDescriptionBeforeTags() throws Exception { verifyJavadocTree( getDocPath("expectedEmptyDescriptionBeforeTags.txt"), getDocPath("InputEmptyDescriptionBeforeTags.javadoc")); } @Test - public void testSpaceBeforeDescriptionInInlineTags() throws Exception { + void spaceBeforeDescriptionInInlineTags() throws Exception { verifyJavadocTree( getDocPath("expectedSpaceBeforeArgsInInlineTagsAst.txt"), getDocPath("InputSpaceBeforeArgsInInlineTags.javadoc")); } @Test - public void testHtmlVoidElementKeygen() throws Exception { + void htmlVoidElementKeygen() throws Exception { verifyJavadocTree( getHtmlPath("expectedHtmlVoidElementKeygenAst.txt"), getHtmlPath("InputHtmlVoidElementKeygen.javadoc")); } @Test - public void testHtmlVoidElementSource() throws Exception { + void htmlVoidElementSource() throws Exception { verifyJavadocTree( getHtmlPath("expectedHtmlVoidElementSourceAst.txt"), getHtmlPath("InputHtmlVoidElementSource.javadoc")); } @Test - public void testHtmlVoidElementTrack() throws Exception { + void htmlVoidElementTrack() throws Exception { verifyJavadocTree( getHtmlPath("expectedHtmlVoidElementTrackAst.txt"), getHtmlPath("InputHtmlVoidElementTrack.javadoc")); } @Test - public void testHtmlVoidElementWbr() throws Exception { + void htmlVoidElementWbr() throws Exception { verifyJavadocTree( getHtmlPath("expectedHtmlVoidElementWbrAst.txt"), getHtmlPath("InputHtmlVoidElementWbr.javadoc")); } @Test - public void testOptgroupHtmlTag() throws Exception { + void optgroupHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedOptgroupHtmlTagAst.txt"), getHtmlPath("InputOptgroupHtmlTag.javadoc")); } @Test - public void testNonTightOptgroupHtmlTag() throws Exception { + void nonTightOptgroupHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedNonTightOptgroupHtmlTagAst.txt"), getHtmlPath("InputNonTightOptgroupHtmlTag.javadoc")); } @Test - public void testRbHtmlTag() throws Exception { + void rbHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedRbHtmlTagAst.txt"), getHtmlPath("InputRbHtmlTag.javadoc")); } @Test - public void testNonTightRbHtmlTag() throws Exception { + void nonTightRbHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedNonTightRbHtmlTagAst.txt"), getHtmlPath("InputNonTightRbHtmlTag.javadoc")); } @Test - public void testRtHtmlTag() throws Exception { + void rtHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedRtHtmlTagAst.txt"), getHtmlPath("InputRtHtmlTag.javadoc")); } @Test - public void testNonTightRtHtmlTag() throws Exception { + void nonTightRtHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedNonTightRtHtmlTagAst.txt"), getHtmlPath("InputNonTightRtHtmlTag.javadoc")); } @Test - public void testRtcHtmlTag() throws Exception { + void rtcHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedRtcHtmlTagAst.txt"), getHtmlPath("InputRtcHtmlTag.javadoc")); } @Test - public void testNonTightRtcHtmlTag() throws Exception { + void nonTightRtcHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedNonTightRtcHtmlTagAst.txt"), getHtmlPath("InputNonTightRtcHtmlTag.javadoc")); } @Test - public void testRpHtmlTag() throws Exception { + void rpHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedRpHtmlTagAst.txt"), getHtmlPath("InputRpHtmlTag.javadoc")); } @Test - public void testNonTightRpHtmlTag() throws Exception { + void nonTightRpHtmlTag() throws Exception { verifyJavadocTree( getHtmlPath("expectedNonTightRpHtmlTagAst.txt"), getHtmlPath("InputNonTightRpHtmlTag.javadoc")); } @Test - public void testLeadingAsteriskAfterSeeTag() throws Exception { + void leadingAsteriskAfterSeeTag() throws Exception { verifyJavadocTree( getDocPath("expectedLeadingAsteriskAfterSeeTagAst.txt"), getDocPath("InputLeadingAsteriskAfterSeeTag.javadoc")); } @Test - public void testUppercaseInPackageName() throws Exception { + void uppercaseInPackageName() throws Exception { verifyJavadocTree( getDocPath("expectedUppercaseInPackageNameAst.txt"), getDocPath("InputUppercaseInPackageName.javadoc")); } @Test - public void testParagraph() throws Exception { + void paragraph() throws Exception { verifyJavadocTree( getHtmlPath("expectedParagraphAst.txt"), getHtmlPath("InputParagraph.javadoc")); } @Test - public void testCdata() throws Exception { + void cdata() throws Exception { verifyJavadocTree(getHtmlPath("expectedCdataAst.txt"), getHtmlPath("InputCdata.javadoc")); } @Test - public void testCrAsNewlineMultiline() throws Exception { + void crAsNewlineMultiline() throws Exception { verifyJavadocTree( getPath("expectedCrAsNewlineMultiline.txt"), getPath("InputCrAsNewlineMultiline.javadoc")); } @Test - public void testDosLineEndingAsNewlineMultiline() throws Exception { + void dosLineEndingAsNewlineMultiline() throws Exception { verifyJavadocTree( getPath("expectedDosLineEndingAsNewlineMultiline.txt"), getPath("InputDosLineEndingAsNewlineMultiline.javadoc")); --- a/src/test/java/com/puppycrawl/tools/checkstyle/gui/BaseCellEditorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/gui/BaseCellEditorTest.java @@ -25,10 +25,10 @@ import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import org.junit.jupiter.api.Test; -class BaseCellEditorTest { +final class BaseCellEditorTest { @Test - public void testToString() { + void testToString() { final BaseCellEditor cellEditor = new BaseCellEditor(); @@ -36,7 +36,7 @@ class BaseCellEditorTest { } @Test - public void testStopCellEditing() { + void stopCellEditing() { final BaseCellEditor cellEditor = new BaseCellEditor(); @@ -44,7 +44,7 @@ class BaseCellEditorTest { } @Test - public void testFireEditingStoppedAndCanceled() { + void fireEditingStoppedAndCanceled() { final BaseCellEditor cellEditor = new BaseCellEditor(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/gui/CodeSelectorPresentationTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/gui/CodeSelectorPresentationTest.java @@ -32,7 +32,7 @@ import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class CodeSelectorPresentationTest extends AbstractPathTestSupport { +final class CodeSelectorPresentationTest extends AbstractPathTestSupport { private MainFrameModel model; @@ -41,7 +41,7 @@ public class CodeSelectorPresentationTest extends AbstractPathTestSupport { private ImmutableList linesToPosition; @BeforeEach - public void loadFile() throws Exception { + void loadFile() throws Exception { model = new MainFrameModel(); model.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); model.openFile(new File(getPath("InputCodeSelectorPresentation.java"))); @@ -73,7 +73,7 @@ public class CodeSelectorPresentationTest extends AbstractPathTestSupport { } @Test - public void testDetailASTSelection() { + void detailASTSelection() { final CodeSelectorPresentation selector = new CodeSelectorPresentation(tree, linesToPosition); selector.findSelectionPositions(); assertWithMessage("Invalid selection start").that(selector.getSelectionStart()).isEqualTo(94); @@ -81,7 +81,7 @@ public class CodeSelectorPresentationTest extends AbstractPathTestSupport { } @Test - public void testDetailASTLeafSelection() { + void detailASTLeafSelection() { final DetailAST leaf = tree.getLastChild().getFirstChild(); final CodeSelectorPresentation selector = new CodeSelectorPresentation(leaf, linesToPosition); selector.findSelectionPositions(); @@ -90,7 +90,7 @@ public class CodeSelectorPresentationTest extends AbstractPathTestSupport { } @Test - public void testDetailASTNoSelection() { + void detailASTNoSelection() { final DetailAST leaf = tree.getFirstChild(); final CodeSelectorPresentation selector = new CodeSelectorPresentation(leaf, linesToPosition); selector.findSelectionPositions(); @@ -99,7 +99,7 @@ public class CodeSelectorPresentationTest extends AbstractPathTestSupport { } @Test - public void testDetailNodeSelection() { + void detailNodeSelection() { final DetailNode javadoc = (DetailNode) model @@ -113,7 +113,7 @@ public class CodeSelectorPresentationTest extends AbstractPathTestSupport { } @Test - public void testDetailNodeLeafSelection() { + void detailNodeLeafSelection() { final DetailNode javadoc = (DetailNode) model --- a/src/test/java/com/puppycrawl/tools/checkstyle/gui/MainFrameModelTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/gui/MainFrameModelTest.java @@ -33,7 +33,7 @@ import java.util.Locale; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class MainFrameModelTest extends AbstractModuleTestSupport { +final class MainFrameModelTest extends AbstractModuleTestSupport { private static final String FILE_NAME_TEST_DATA = "InputMainFrameModel.java"; private static final String FILE_NAME_NON_EXISTENT = "non-existent.file"; @@ -49,13 +49,13 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @BeforeEach - public void prepareTestData() throws IOException { + void prepareTestData() throws IOException { model = new MainFrameModel(); testData = new File(getPath(FILE_NAME_TEST_DATA)); } @Test - public void testParseModeEnum() { + void parseModeEnum() { for (final ParseMode parseMode : ParseMode.values()) { switch (parseMode) { case PLAIN_JAVA: @@ -80,7 +80,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testOpenFileWithParseModePlainJava() throws Exception { + void openFileWithParseModePlainJava() throws Exception { // Default parse mode: Plain Java model.openFile(testData); verifyCorrectTestDataInFrameModel(); @@ -90,7 +90,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testOpenFileWithParseModeJavaWithComments() throws Exception { + void openFileWithParseModeJavaWithComments() throws Exception { model.setParseMode(ParseMode.JAVA_WITH_COMMENTS); model.openFile(testData); @@ -98,7 +98,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testOpenFileWithParseModeJavaWithJavadocAndComments() throws Exception { + void openFileWithParseModeJavaWithJavadocAndComments() throws Exception { model.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); model.openFile(testData); @@ -106,7 +106,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testOpenFileNullParameter() throws Exception { + void openFileNullParameter() throws Exception { model.openFile(testData); model.openFile(null); @@ -116,7 +116,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testOpenFileNullParameter2() throws Exception { + void openFileNullParameter2() throws Exception { model.openFile(null); assertWithMessage("Test is null").that(model.getText()).isNull(); @@ -128,7 +128,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testOpenFileNonExistentFile() throws IOException { + void openFileNonExistentFile() throws IOException { final File nonExistentFile = new File(getPath(FILE_NAME_NON_EXISTENT)); try { @@ -147,7 +147,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testOpenFileNonCompilableFile() throws IOException { + void openFileNonCompilableFile() throws IOException { final File nonCompilableFile = new File(getNonCompilablePath(FILE_NAME_NON_COMPILABLE)); try { @@ -196,7 +196,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testShouldAcceptDirectory() { + void shouldAcceptDirectory() { final File directory = mock(); when(directory.isDirectory()).thenReturn(true); assertWithMessage("MainFrame should accept directory") @@ -205,7 +205,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testShouldAcceptFile() throws IOException { + void shouldAcceptFile() throws IOException { final File javaFile = new File(getPath(FILE_NAME_TEST_DATA)); assertWithMessage("MainFrame should accept java file") .that(MainFrameModel.shouldAcceptFile(javaFile)) @@ -213,7 +213,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testShouldNotAcceptNonJavaFile() { + void shouldNotAcceptNonJavaFile() { final File nonJavaFile = mock(); when(nonJavaFile.isDirectory()).thenReturn(false); when(nonJavaFile.getName()).thenReturn(FILE_NAME_NON_JAVA); @@ -223,7 +223,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testShouldNotAcceptNonExistentFile() throws IOException { + void shouldNotAcceptNonExistentFile() throws IOException { final File nonExistentFile = new File(getPath(FILE_NAME_NON_EXISTENT)); assertWithMessage("MainFrame should not accept non-existent file") .that(MainFrameModel.shouldAcceptFile(nonExistentFile)) @@ -231,7 +231,7 @@ public class MainFrameModelTest extends AbstractModuleTestSupport { } @Test - public void testOpenFileForUnknownParseMode() throws IOException { + void openFileForUnknownParseMode() throws IOException { final File javaFile = new File(getPath(FILE_NAME_TEST_DATA)); final ParseMode mock = mock(); model.setParseMode(mock); --- a/src/test/java/com/puppycrawl/tools/checkstyle/gui/MainFrameTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/gui/MainFrameTest.java @@ -46,7 +46,7 @@ import org.junit.jupiter.api.Test; import org.mockito.MockedConstruction; import org.mockito.MockedStatic; -public class MainFrameTest extends AbstractGuiTestSupport { +final class MainFrameTest extends AbstractGuiTestSupport { private static final String TEST_FILE_NAME = "InputMainFrame.java"; private static final String NON_EXISTENT_FILE_NAME = "non-existent.file"; @@ -59,17 +59,17 @@ public class MainFrameTest extends AbstractGuiTestSupport { } @BeforeEach - public void prepare() { + void prepare() { mainFrame = new MainFrame(); } @AfterEach - public void tearDown() { + void tearDown() { Arrays.stream(mainFrame.getOwnedWindows()).forEach(Window::dispose); } @Test - public void testOpenFile() throws IOException { + void openFile() throws IOException { mainFrame.openFile(new File(getPath(TEST_FILE_NAME))); assertWithMessage("Unexpected frame title") .that(mainFrame.getTitle()) @@ -83,7 +83,7 @@ public class MainFrameTest extends AbstractGuiTestSupport { * @throws IOException if I/O exception occurs while forming the path. */ @Test - public void testOpenNonExistentFile() throws IOException { + void openNonExistentFile() throws IOException { final File file = new File(getPath(NON_EXISTENT_FILE_NAME)); try (MockedStatic optionPane = mockStatic(JOptionPane.class)) { mainFrame.openFile(file); @@ -99,7 +99,7 @@ public class MainFrameTest extends AbstractGuiTestSupport { } @Test - public void testChangeMode() { + void changeMode() { final JComboBox modesCombobox = findComponentByName(mainFrame, "modesCombobox"); modesCombobox.setSelectedIndex(MainFrameModel.ParseMode.JAVA_WITH_COMMENTS.ordinal()); @@ -117,7 +117,7 @@ public class MainFrameTest extends AbstractGuiTestSupport { * @throws IOException if I/O exception occurs while forming the path. */ @Test - public void testOpenFileButton() throws IOException { + void openFileButton() throws IOException { final JButton openFileButton = findComponentByName(mainFrame, "openFileButton"); final File testFile = new File(getPath(TEST_FILE_NAME)); try (MockedConstruction mocked = @@ -139,7 +139,7 @@ public class MainFrameTest extends AbstractGuiTestSupport { * JFileChooser} is mocked to obtain an instance of {@code JavaFileFilter} class. */ @Test - public void testFileFilter() { + void fileFilter() { final JButton openFileButton = findComponentByName(mainFrame, "openFileButton"); try (MockedConstruction mocked = mockConstruction( @@ -162,7 +162,7 @@ public class MainFrameTest extends AbstractGuiTestSupport { } @Test - public void testExpandButton() { + void expandButton() { final JButton expandButton = findComponentByName(mainFrame, "expandButton"); final JTextArea xpathTextArea = findComponentByName(mainFrame, "xpathTextArea"); expandButton.doClick(); @@ -176,7 +176,7 @@ public class MainFrameTest extends AbstractGuiTestSupport { } @Test - public void testFindNodeButton() throws IOException { + void findNodeButton() throws IOException { mainFrame.openFile(new File(getPath(TEST_FILE_NAME))); final JButton findNodeButton = findComponentByName(mainFrame, "findNodeButton"); final JTextArea xpathTextArea = findComponentByName(mainFrame, "xpathTextArea"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/gui/MainTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/gui/MainTest.java @@ -28,7 +28,7 @@ import javax.swing.SwingUtilities; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -public class MainTest extends AbstractGuiTestSupport { +final class MainTest extends AbstractGuiTestSupport { @Override protected String getPackageLocation() { @@ -43,7 +43,7 @@ public class MainTest extends AbstractGuiTestSupport { */ @ParameterizedTest @ValueSource(strings = {";", "InputMain.java"}) - public void testMain(String argList) throws Exception { + void main(String argList) throws Exception { final String[] args = argList.split(";"); for (int i = 0; i < args.length; i++) { args[i] = getPath(args[i]); --- a/src/test/java/com/puppycrawl/tools/checkstyle/gui/ParseTreeTableModelTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/gui/ParseTreeTableModelTest.java @@ -38,7 +38,7 @@ import java.io.File; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class ParseTreeTableModelTest extends AbstractPathTestSupport { +final class ParseTreeTableModelTest extends AbstractPathTestSupport { private DetailAST classDef; @@ -48,7 +48,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @BeforeEach - public void loadTree() throws Exception { + void loadTree() throws Exception { classDef = JavaParser.parseFile( new File(getPath("InputParseTreeTablePresentation.java")), @@ -57,13 +57,13 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testChildCount() { + void childCount() { final int childCount = new ParseTreeTableModel(null).getChildCount(classDef); assertWithMessage("Invalid child count").that(childCount).isEqualTo(5); } @Test - public void testChild() { + void child() { final Object child = new ParseTreeTableModel(null).getChild(classDef, 1); assertWithMessage("Invalid child type").that(child).isInstanceOf(DetailAST.class); final int type = ((DetailAST) child).getType(); @@ -71,7 +71,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testCommentChildCount() { + void commentChildCount() { final DetailAST commentContentNode = classDef.findFirstToken(BLOCK_COMMENT_BEGIN).findFirstToken(COMMENT_CONTENT); final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); @@ -81,7 +81,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testChildCountInJavaAndJavadocMode() { + void childCountInJavaAndJavadocMode() { final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); final int childCount = parseTree.getChildCount(classDef); @@ -89,7 +89,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testChildInJavaAndJavadocMode() { + void childInJavaAndJavadocMode() { final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); final Object child = parseTree.getChild(classDef, 1); @@ -99,7 +99,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testCommentChildCountInJavaAndJavadocMode() { + void commentChildCountInJavaAndJavadocMode() { final DetailAST commentContentNode = classDef.findFirstToken(BLOCK_COMMENT_BEGIN).findFirstToken(COMMENT_CONTENT); final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); @@ -109,7 +109,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testCommentChildInJavaAndJavadocMode() { + void commentChildInJavaAndJavadocMode() { final DetailAST commentContentNode = classDef.findFirstToken(BLOCK_COMMENT_BEGIN).findFirstToken(COMMENT_CONTENT); final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); @@ -119,7 +119,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testJavadocCommentChildCount() { + void javadocCommentChildCount() { final DetailAST commentContentNode = classDef.findFirstToken(BLOCK_COMMENT_BEGIN).findFirstToken(COMMENT_CONTENT); final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); @@ -131,7 +131,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testJavadocCommentChild() { + void javadocCommentChild() { final DetailAST commentContentNode = classDef.findFirstToken(BLOCK_COMMENT_BEGIN).findFirstToken(COMMENT_CONTENT); final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); @@ -149,7 +149,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testJavadocChildCount() { + void javadocChildCount() { final DetailAST commentContentNode = classDef.findFirstToken(BLOCK_COMMENT_BEGIN).findFirstToken(COMMENT_CONTENT); final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); @@ -163,7 +163,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testJavadocChild() { + void javadocChild() { final DetailAST commentContentNode = classDef.findFirstToken(BLOCK_COMMENT_BEGIN).findFirstToken(COMMENT_CONTENT); final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); @@ -179,7 +179,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testGetIndexOfChild() { + void getIndexOfChild() { DetailAST child = classDef.findFirstToken(MODIFIERS); assertWithMessage("Child must not be null").that(child).isNotNull(); final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); @@ -195,7 +195,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testGetValueAt() { + void getValueAt() { final DetailAST classIdentNode = classDef.findFirstToken(IDENT); assertWithMessage("Expected a non-null identifier classDef here") .that(classIdentNode) @@ -223,7 +223,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testGetValueAtDetailNode() { + void getValueAtDetailNode() { final DetailAST commentContentNode = classDef.findFirstToken(BLOCK_COMMENT_BEGIN).findFirstToken(COMMENT_CONTENT); assertWithMessage("Comment classDef cannot be null").that(commentContentNode).isNotNull(); @@ -258,7 +258,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testColumnMethods() { + void columnMethods() { final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); assertWithMessage("Invalid type") .that(parseTree.getColumnClass(0)) @@ -279,7 +279,7 @@ public class ParseTreeTableModelTest extends AbstractPathTestSupport { } @Test - public void testColumnNames() { + void columnNames() { final ParseTreeTableModel parseTree = new ParseTreeTableModel(null); assertWithMessage("Invalid column count").that(parseTree.getColumnCount()).isEqualTo(5); assertWithMessage("Invalid column name").that(parseTree.getColumnName(0)).isEqualTo("Tree"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/gui/ParseTreeTablePresentationTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/gui/ParseTreeTablePresentationTest.java @@ -34,7 +34,7 @@ import java.io.File; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { +final class ParseTreeTablePresentationTest extends AbstractPathTestSupport { private DetailAST tree; @@ -44,7 +44,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @BeforeEach - public void loadTree() throws Exception { + void loadTree() throws Exception { tree = JavaParser.parseFile( new File(getPath("InputParseTreeTablePresentation.java")), @@ -54,7 +54,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testRoot() throws Exception { + void root() throws Exception { final DetailAST root = JavaParser.parseFile( new File(getPath("InputParseTreeTablePresentation.java")), @@ -63,13 +63,13 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testChildCount() { + void childCount() { final int childCount = new ParseTreeTablePresentation(null).getChildCount(tree); assertWithMessage("Invalid child count").that(childCount).isEqualTo(5); } @Test - public void testChildCountInJavaAndJavadocMode() { + void childCountInJavaAndJavadocMode() { final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); final int childCount = parseTree.getChildCount(tree); @@ -77,7 +77,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testChild() { + void child() { final Object child = new ParseTreeTablePresentation(null).getChild(tree, 1); assertWithMessage("Invalid child type").that(child).isInstanceOf(DetailAST.class); final int type = ((DetailAST) child).getType(); @@ -87,7 +87,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testChildInJavaAndJavadocMode() { + void childInJavaAndJavadocMode() { final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); final Object child = parseTree.getChild(tree, 1); @@ -99,7 +99,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testCommentChildCount() { + void commentChildCount() { final DetailAST commentContentNode = tree.getFirstChild().getNextSibling().getFirstChild(); final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); parseTree.setParseMode(ParseMode.JAVA_WITH_COMMENTS); @@ -108,7 +108,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testCommentChildCountInJavaAndJavadocMode() { + void commentChildCountInJavaAndJavadocMode() { final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); final DetailAST commentContentNode = @@ -123,7 +123,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testCommentChildInJavaAndJavadocMode() { + void commentChildInJavaAndJavadocMode() { final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); final DetailAST commentContentNode = @@ -138,7 +138,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testJavadocCommentChildCount() { + void javadocCommentChildCount() { final DetailAST commentContentNode = tree.getFirstChild().getNextSibling().getFirstChild(); final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); final int commentChildCount = parseTree.getChildCount(commentContentNode); @@ -149,7 +149,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testJavadocCommentChild() { + void javadocCommentChild() { final DetailAST commentContentNode = tree.getFirstChild().getNextSibling().getFirstChild(); final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); @@ -167,7 +167,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testJavadocChildCount() { + void javadocChildCount() { final DetailAST commentContentNode = tree.getFirstChild().getNextSibling().getFirstChild(); final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); @@ -180,7 +180,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testJavadocChild() { + void javadocChild() { final DetailAST commentContentNode = tree.getFirstChild().getNextSibling().getFirstChild(); final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); parseTree.setParseMode(ParseMode.JAVA_WITH_JAVADOC_AND_COMMENTS); @@ -195,7 +195,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testGetIndexOfChild() { + void getIndexOfChild() { DetailAST ithChild = tree.getFirstChild(); assertWithMessage("Child must not be null").that(ithChild).isNotNull(); final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); @@ -225,7 +225,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { * */ @Test - public void testGetValueAt() { + void getValueAt() { final DetailAST node = tree.getFirstChild().getNextSibling().getNextSibling().getNextSibling(); assertWithMessage("Expected a non-null identifier node here").that(node).isNotNull(); @@ -253,7 +253,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testGetValueAtDetailNode() { + void getValueAtDetailNode() { final DetailAST commentContentNode = tree.getFirstChild().getNextSibling().getFirstChild(); assertWithMessage("Comment node cannot be null").that(commentContentNode).isNotNull(); final int nodeType = commentContentNode.getType(); @@ -292,7 +292,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testColumnMethods() { + void columnMethods() { final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); assertWithMessage("Invalid type") .that(parseTree.getColumnClass(0)) @@ -313,7 +313,7 @@ public class ParseTreeTablePresentationTest extends AbstractPathTestSupport { } @Test - public void testColumnNames() { + void columnNames() { final ParseTreeTablePresentation parseTree = new ParseTreeTablePresentation(null); assertWithMessage("Invalid column count").that(parseTree.getColumnCount()).isEqualTo(5); assertWithMessage("Invalid column name").that(parseTree.getColumnName(0)).isEqualTo("Tree"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/gui/TreeTableTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/gui/TreeTableTest.java @@ -35,7 +35,7 @@ import javax.swing.tree.TreePath; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class TreeTableTest extends AbstractGuiTestSupport { +final class TreeTableTest extends AbstractGuiTestSupport { private static final String TEST_FILE_NAME = "InputTreeTable.java"; @@ -47,7 +47,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @BeforeEach - public void prepare() throws Exception { + void prepare() throws Exception { final MainFrameModel model = new MainFrameModel(); model.openFile(new File(getPath(TEST_FILE_NAME))); treeTable = new TreeTable(model.getParseTreeTableModel()); @@ -58,7 +58,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testExpandOnMouseDoubleClick() { + void expandOnMouseDoubleClick() { final MouseEvent mouseDoubleClickEvent = new MouseEvent(treeTable, MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, 2, false); assertWithMessage("The tree should be initially expanded") @@ -75,7 +75,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testNothingChangedOnMouseSingleClick() { + void nothingChangedOnMouseSingleClick() { final MouseEvent mouseSingleClickEvent = new MouseEvent(treeTable, MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, 1, false); assertWithMessage("The tree should be initially expanded") @@ -88,7 +88,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testExpandOnEnterKey() { + void expandOnEnterKey() { final ActionEvent expandCollapseActionEvent = new ActionEvent(treeTable, ActionEvent.ACTION_PERFORMED, "expand/collapse"); final ActionListener actionForEnter = @@ -107,7 +107,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testFindNodesAllClassDefs() throws IOException { + void findNodesAllClassDefs() throws IOException { final MainFrame mainFrame = new MainFrame(); mainFrame.openFile(new File(getPath("InputTreeTableXpathAreaPanel.java"))); final JButton findNodeButton = findComponentByName(mainFrame, "findNodeButton"); @@ -128,7 +128,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testFindNodesIdent() throws IOException { + void findNodesIdent() throws IOException { final MainFrame mainFrame = new MainFrame(); mainFrame.openFile(new File(getPath("InputTreeTableXpathAreaPanel.java"))); final JButton findNodeButton = findComponentByName(mainFrame, "findNodeButton"); @@ -163,7 +163,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testFindNodesMissingElements() throws IOException { + void findNodesMissingElements() throws IOException { final MainFrame mainFrame = new MainFrame(); mainFrame.openFile(new File(getPath("InputTreeTableXpathAreaPanel.java"))); final JButton findNodeButton = findComponentByName(mainFrame, "findNodeButton"); @@ -179,7 +179,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testFindNodesUnexpectedTokenAtStart() throws IOException { + void findNodesUnexpectedTokenAtStart() throws IOException { final MainFrame mainFrame = new MainFrame(); mainFrame.openFile(new File(getPath("InputTreeTableXpathAreaPanel.java"))); final JButton findNodeButton = findComponentByName(mainFrame, "findNodeButton"); @@ -195,7 +195,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testFindNodesInvalidCharacterInExpression() throws IOException { + void findNodesInvalidCharacterInExpression() throws IOException { final MainFrame mainFrame = new MainFrame(); mainFrame.openFile(new File(getPath("InputTreeTableXpathAreaPanel.java"))); final JButton findNodeButton = findComponentByName(mainFrame, "findNodeButton"); @@ -211,7 +211,7 @@ public class TreeTableTest extends AbstractGuiTestSupport { } @Test - public void testTreeModelAdapterMethods() throws IOException { + void treeModelAdapterMethods() throws IOException { final MainFrame mainFrame = new MainFrame(); mainFrame.openFile(new File(getPath("InputTreeTableXpathAreaPanel.java"))); --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/AllChecksTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/AllChecksTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle.internal; import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.stream.Collectors.toUnmodifiableSet; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DefaultConfiguration; @@ -53,11 +54,10 @@ import java.util.Map.Entry; import java.util.Properties; import java.util.Set; import java.util.TreeMap; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.junit.jupiter.api.Test; -public class AllChecksTest extends AbstractModuleTestSupport { +final class AllChecksTest extends AbstractModuleTestSupport { private static final Locale[] ALL_LOCALES = { Locale.CHINESE, @@ -85,20 +85,20 @@ public class AllChecksTest extends AbstractModuleTestSupport { Stream.of( // we use GenericWhitespace for this behavior "GENERIC_START", "GENERIC_END") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "AbbreviationAsWordInName", Stream.of( // enum values should be uppercase, we use EnumValueNameCheck instead "ENUM_CONSTANT_DEF") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "FinalLocalVariable", Stream.of( // we prefer all parameters be effectively final as to not damage readability // we use ParameterAssignmentCheck to enforce this "PARAMETER_DEF") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); // we have no need to block these specific tokens CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "IllegalToken", @@ -280,7 +280,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { "TEXT_BLOCK_LITERAL_END", "LITERAL_YIELD", "SWITCH_RULE") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); // we have no need to block specific token text CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "IllegalTokenText", @@ -295,7 +295,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { "CHAR_LITERAL", "TEXT_BLOCK_CONTENT", "STRING_TEMPLATE_CONTENT") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); // we do not use this check as it is deprecated CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "WriteTag", @@ -306,7 +306,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { "ANNOTATION_FIELD_DEF", "RECORD_DEF", "COMPACT_CTOR_DEF") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); // state of the configuration when test was made until reason found in // https://github.com/checkstyle/checkstyle/issues/3730 CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( @@ -320,7 +320,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { "VARIABLE_DEF", "RECORD_DEF", "COMPACT_CTOR_DEF") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "NoLineWrap", Stream.of( @@ -335,33 +335,33 @@ public class AllChecksTest extends AbstractModuleTestSupport { "ENUM_DEF", "INTERFACE_DEF", "RECORD_DEF") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "NoWhitespaceAfter", Stream.of( // whitespace after is preferred "TYPECAST", "LITERAL_SYNCHRONIZED") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "SeparatorWrap", Stream.of( // needs context to decide what type of parentheses should be separated or not // which this check does not provide "LPAREN", "RPAREN") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "NeedBraces", Stream.of( // we prefer no braces here as it looks unusual even though they help avoid sharing // scope of variables "LITERAL_DEFAULT", "LITERAL_CASE") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "FinalParameters", Stream.of( // we prefer these to be effectively final as to not damage readability "FOR_EACH_CLAUSE", "LITERAL_CATCH") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); CHECKSTYLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "WhitespaceAround", Stream.of( @@ -372,7 +372,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { "WILDCARD_TYPE", "GENERIC_END", "GENERIC_START") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); // google GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( @@ -381,13 +381,13 @@ public class AllChecksTest extends AbstractModuleTestSupport { // state of the configuration when test was made until reason found in // https://github.com/checkstyle/checkstyle/issues/3730 "ANNOTATION_DEF", "ANNOTATION_FIELD_DEF", "ENUM_CONSTANT_DEF", "PACKAGE_DEF") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "AbbreviationAsWordInName", Stream.of( // enum values should be uppercase "ENUM_CONSTANT_DEF") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "NoLineWrap", Stream.of( @@ -400,7 +400,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { "INTERFACE_DEF", "RECORD_DEF", "COMPACT_CTOR_DEF") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "SeparatorWrap", Stream.of( @@ -417,13 +417,13 @@ public class AllChecksTest extends AbstractModuleTestSupport { // which this check does not provide "LPAREN", "RPAREN") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "NeedBraces", Stream.of( // google doesn't require or prevent braces on these "LAMBDA", "LITERAL_DEFAULT", "LITERAL_CASE") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "EmptyBlock", Stream.of( @@ -442,7 +442,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { "LITERAL_SYNCHRONIZED", "LITERAL_WHILE", "STATIC_INIT") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "WhitespaceAround", Stream.of( @@ -454,7 +454,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { "GENERIC_START", "GENERIC_END", "WILDCARD_TYPE") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "IllegalTokenText", Stream.of( @@ -470,7 +470,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { // until #14291 "TEXT_BLOCK_CONTENT", "STRING_TEMPLATE_CONTENT") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "OperatorWrap", Stream.of( @@ -491,7 +491,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { // COLON token ignored in check config, explained in // https://github.com/checkstyle/checkstyle/issues/4122 "COLON") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); GOOGLE_TOKENS_IN_CONFIG_TO_IGNORE.put( "NoWhitespaceBefore", Stream.of( @@ -501,7 +501,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { // whitespace is necessary between a type annotation and ellipsis // according '4.6.2 Horizontal whitespace point 9' "ELLIPSIS") - .collect(Collectors.toUnmodifiableSet())); + .collect(toUnmodifiableSet())); INTERNAL_MODULES = Definitions.INTERNAL_MODULES.stream() .map( @@ -509,7 +509,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { final String[] packageTokens = moduleName.split("\\."); return packageTokens[packageTokens.length - 1]; }) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } @Override @@ -518,7 +518,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllModulesWithDefaultConfiguration() throws Exception { + void allModulesWithDefaultConfiguration() throws Exception { final String inputFilePath = getPath("InputAllChecksDefaultConfig.java"); final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; @@ -538,7 +538,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testDefaultTokensAreSubsetOfAcceptableTokens() throws Exception { + void defaultTokensAreSubsetOfAcceptableTokens() throws Exception { for (Class check : CheckUtil.getCheckstyleChecks()) { if (AbstractCheck.class.isAssignableFrom(check)) { final AbstractCheck testedCheck = @@ -555,7 +555,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testRequiredTokensAreSubsetOfAcceptableTokens() throws Exception { + void requiredTokensAreSubsetOfAcceptableTokens() throws Exception { for (Class check : CheckUtil.getCheckstyleChecks()) { if (AbstractCheck.class.isAssignableFrom(check)) { final AbstractCheck testedCheck = @@ -572,7 +572,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testRequiredTokensAreSubsetOfDefaultTokens() throws Exception { + void requiredTokensAreSubsetOfDefaultTokens() throws Exception { for (Class check : CheckUtil.getCheckstyleChecks()) { if (AbstractCheck.class.isAssignableFrom(check)) { final AbstractCheck testedCheck = @@ -589,7 +589,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllModulesHaveMultiThreadAnnotation() throws Exception { + void allModulesHaveMultiThreadAnnotation() throws Exception { for (Class module : CheckUtil.getCheckstyleModules()) { if (ModuleReflectionUtil.isRootModule(module) || ModuleReflectionUtil.isFilterModule(module) @@ -609,7 +609,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllModulesAreReferencedInConfigFile() throws Exception { + void allModulesAreReferencedInConfigFile() throws Exception { final Set modulesReferencedInConfig = CheckUtil.getConfigCheckStyleModules(); final Set moduleNames = CheckUtil.getSimpleNames(CheckUtil.getCheckstyleModules()); @@ -626,7 +626,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllCheckTokensAreReferencedInCheckstyleConfigFile() throws Exception { + void allCheckTokensAreReferencedInCheckstyleConfigFile() throws Exception { final Configuration configuration = ConfigurationUtil.loadConfiguration("config/checkstyle-checks.xml"); @@ -635,7 +635,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllCheckTokensAreReferencedInGoogleConfigFile() throws Exception { + void allCheckTokensAreReferencedInGoogleConfigFile() throws Exception { final Configuration configuration = ConfigurationUtil.loadConfiguration("src/main/resources/google_checks.xml"); @@ -733,7 +733,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllCheckstyleModulesHaveXdocDocumentation() throws Exception { + void allCheckstyleModulesHaveXdocDocumentation() throws Exception { final Set checkstyleModulesNames = CheckUtil.getSimpleNames(CheckUtil.getCheckstyleModules()); final Set modulesNamesWhichHaveXdocs = XdocUtil.getModulesNamesWhichHaveXdoc(); @@ -755,7 +755,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllCheckstyleModulesInCheckstyleConfig() throws Exception { + void allCheckstyleModulesInCheckstyleConfig() throws Exception { final Set configChecks = CheckUtil.getConfigCheckStyleModules(); final Set moduleNames = CheckUtil.getSimpleNames(CheckUtil.getCheckstyleModules()); moduleNames.removeAll(INTERNAL_MODULES); @@ -767,7 +767,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllCheckstyleChecksHaveMessage() throws Exception { + void allCheckstyleChecksHaveMessage() throws Exception { for (Class module : CheckUtil.getCheckstyleChecks()) { final String name = module.getSimpleName(); final Set messages = CheckUtil.getCheckMessages(module, false); @@ -786,7 +786,7 @@ public class AllChecksTest extends AbstractModuleTestSupport { } @Test - public void testAllCheckstyleMessages() throws Exception { + void allCheckstyleMessages() throws Exception { final Map> usedMessages = new TreeMap<>(); // test validity of messages from modules --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/AllTestsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/AllTestsTest.java @@ -25,7 +25,6 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -42,14 +41,14 @@ import org.junit.jupiter.api.Test; * @noinspectionreason ClassIndependentOfModule - architecture of test modules requires this * structure */ -public class AllTestsTest { +final class AllTestsTest { @Test - public void testAllInputsHaveTest() throws Exception { + void allInputsHaveTest() throws Exception { final Map> allTests = new HashMap<>(); walk( - Paths.get("src/test/java"), + Path.of("src/test/java"), filePath -> { grabAllTests(allTests, filePath.toFile()); }); @@ -57,23 +56,23 @@ public class AllTestsTest { assertWithMessage("found tests").that(allTests.keySet()).isNotEmpty(); walk( - Paths.get("src/test/resources/com/puppycrawl"), + Path.of("src/test/resources/com/puppycrawl"), filePath -> { verifyInputFile(allTests, filePath.toFile()); }); walk( - Paths.get("src/test/resources-noncompilable/com/puppycrawl"), + Path.of("src/test/resources-noncompilable/com/puppycrawl"), filePath -> { verifyInputFile(allTests, filePath.toFile()); }); } @Test - public void testAllTestsHaveProductionCode() throws Exception { + void allTestsHaveProductionCode() throws Exception { final Map> allTests = new HashMap<>(); walk( - Paths.get("src/main/java"), + Path.of("src/main/java"), filePath -> { grabAllFiles(allTests, filePath.toFile()); }); @@ -81,7 +80,7 @@ public class AllTestsTest { assertWithMessage("found tests").that(allTests.keySet()).isNotEmpty(); walk( - Paths.get("src/test/java"), + Path.of("src/test/java"), filePath -> { verifyHasProductionFile(allTests, filePath.toFile()); }); --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitSuperClassTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitSuperClassTest.java @@ -41,7 +41,7 @@ import java.util.Optional; import java.util.Set; import org.junit.jupiter.api.Test; -public class ArchUnitSuperClassTest { +final class ArchUnitSuperClassTest { /** * Classes not abiding to {@link #testChecksShouldHaveAllowedAbstractClassAsSuperclass()} rule. @@ -90,7 +90,7 @@ public class ArchUnitSuperClassTest { * AbstractJavadocCheck} as their super class. */ @Test - public void testChecksShouldHaveAllowedAbstractClassAsSuperclass() { + void checksShouldHaveAllowedAbstractClassAsSuperclass() { final JavaClasses checksPackage = new ClassFileImporter() .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS) @@ -134,7 +134,7 @@ public class ArchUnitSuperClassTest { public void check(JavaClass item, ConditionEvents events) { final Optional superclassOptional = item.getSuperclass(); if (superclassOptional.isPresent()) { - final JavaClass superclass = superclassOptional.get().toErasure(); + final JavaClass superclass = superclassOptional.orElseThrow().toErasure(); if (!superclass.isEquivalentTo(expectedSuperclass)) { final String format = "<%s> is subclass of <%s> instead of <%s>"; final String message = --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/ArchUnitTest.java @@ -32,7 +32,7 @@ import com.tngtech.archunit.lang.EvaluationResult; import java.util.List; import org.junit.jupiter.api.Test; -public class ArchUnitTest { +final class ArchUnitTest { /** * Suppression list containing violations from {@code classShouldNotDependOnUtilPackages} @@ -92,7 +92,7 @@ public class ArchUnitTest { * we need to make checkstyle's Check on this. */ @Test - public void nonProtectedCheckMethodsTest() { + void nonProtectedCheckMethodsTest() { // This list contains methods which have been overridden and are set to ignore in this test. final String[] methodsWithOverrideAnnotation = { "processFiltered", @@ -129,7 +129,7 @@ public class ArchUnitTest { * Therefore classes in api should not depend on them. */ @Test - public void testClassesInApiDoNotDependOnClassesInUtil() { + void classesInApiDoNotDependOnClassesInUtil() { final JavaClasses apiPackage = new ClassFileImporter() .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS) --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/CliOptionsXdocsSyncTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/CliOptionsXdocsSyncTest.java @@ -20,11 +20,11 @@ package com.puppycrawl.tools.checkstyle.internal; import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.stream.Collectors.toUnmodifiableSet; import com.puppycrawl.tools.checkstyle.internal.utils.XmlUtil; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -32,7 +32,6 @@ import java.util.Map; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -40,10 +39,10 @@ import org.w3c.dom.NodeList; import picocli.CommandLine; import picocli.CommandLine.Model.OptionSpec; -public class CliOptionsXdocsSyncTest { +final class CliOptionsXdocsSyncTest { @Test - public void validateCliDocSections() throws Exception { + void validateCliDocSections() throws Exception { final Map cmdDesc = new HashMap<>(); final NodeList sections = getSectionsFromXdoc("src/xdocs/cmdline.xml.vm"); @@ -85,7 +84,7 @@ public class CliOptionsXdocsSyncTest { } @Test - public void validateCliUsageSection() throws Exception { + void validateCliUsageSection() throws Exception { final NodeList sections = getSectionsFromXdoc("src/xdocs/cmdline.xml.vm"); final Node usageSource = XmlUtil.getFirstChildElement(sections.item(2)); final String usageText = XmlUtil.getFirstChildElement(usageSource).getTextContent(); @@ -99,12 +98,12 @@ public class CliOptionsXdocsSyncTest { final Set shortParamsMain = commandLine.getCommandSpec().options().stream() .map(OptionSpec::shortestName) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); final Set longParamsMain = commandLine.getCommandSpec().options().stream() .map(OptionSpec::longestName) .filter(names -> names.length() != 2) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); assertWithMessage("Short parameters in Main.java and cmdline" + ".xml.vm should match") .that(shortParamsMain) @@ -125,7 +124,7 @@ public class CliOptionsXdocsSyncTest { } private static NodeList getSectionsFromXdoc(String xdocPath) throws Exception { - final Path path = Paths.get(xdocPath); + final Path path = Path.of(xdocPath); final String input = Files.readString(path); final Document document = XmlUtil.getRawXml(path.getFileName().toString(), input, input); return document.getElementsByTagName("section"); @@ -138,7 +137,7 @@ public class CliOptionsXdocsSyncTest { result = XmlUtil.getChildrenElements(node).stream() .map(Node::getTextContent) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } return result; } --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/CommitValidationTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/CommitValidationTest.java @@ -20,16 +20,17 @@ package com.puppycrawl.tools.checkstyle.internal; import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.Collections.emptyIterator; +import static java.util.stream.Collectors.toUnmodifiableList; +import com.google.common.collect.ImmutableList; import java.io.IOException; -import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Spliterator; import java.util.Spliterators; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.StreamSupport; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; @@ -59,10 +60,10 @@ import org.junit.jupiter.api.Test; * *

Filtered commit list is checked if their messages has proper structure. */ -public class CommitValidationTest { +final class CommitValidationTest { private static final List USERS_EXCLUDED_FROM_VALIDATION = - Collections.singletonList("dependabot[bot]"); + ImmutableList.of("dependabot[bot]"); private static final String ISSUE_COMMIT_MESSAGE_REGEX_PATTERN = "^Issue #\\d+: .*$"; private static final String PR_COMMIT_MESSAGE_REGEX_PATTERN = "^Pull #\\d+: .*$"; @@ -97,14 +98,14 @@ public class CommitValidationTest { CommitsResolutionMode.BY_LAST_COMMIT_AUTHOR; @Test - public void testHasCommits() throws Exception { + void hasCommits() throws Exception { final List lastCommits = getCommitsToCheck(); assertWithMessage("must have at least one commit to validate").that(lastCommits).isNotEmpty(); } @Test - public void testCommitMessage() { + void commitMessage() { assertWithMessage("should not accept commit message with periods on end") .that(validateCommitMessage("minor: Test. Test.")) .isEqualTo(3); @@ -146,7 +147,7 @@ public class CommitValidationTest { } @Test - public void testReleaseCommitMessage() { + void releaseCommitMessage() { assertWithMessage("should accept release commit message for preparing release") .that( validateCommitMessage("[maven-release-plugin] " + "prepare release checkstyle-10.8.0")) @@ -161,7 +162,7 @@ public class CommitValidationTest { } @Test - public void testRevertCommitMessage() { + void revertCommitMessage() { assertWithMessage("should accept proper revert commit message") .that( validateCommitMessage( @@ -179,7 +180,7 @@ public class CommitValidationTest { } @Test - public void testSupplementalPrefix() { + void supplementalPrefix() { assertWithMessage("should accept commit message with supplemental prefix") .that(0) .isEqualTo( @@ -209,7 +210,7 @@ public class CommitValidationTest { } @Test - public void testCommitMessageHasProperStructure() throws Exception { + void commitMessageHasProperStructure() throws Exception { final List lastCommits = getCommitsToCheck(); for (RevCommit commit : filterValidCommits(lastCommits)) { final String commitMessage = commit.getFullMessage(); @@ -295,7 +296,7 @@ public class CommitValidationTest { second = git.log().add(secondParent).call().iterator(); } else { first = git.log().call().iterator(); - second = Collections.emptyIterator(); + second = emptyIterator(); } revCommitIteratorPair = @@ -317,7 +318,7 @@ public class CommitValidationTest { Spliterators.spliteratorUnknownSize(previousCommitsIterator, Spliterator.ORDERED); return StreamSupport.stream(spliterator, false) .limit(PREVIOUS_COMMITS_TO_CHECK_COUNT) - .collect(Collectors.toUnmodifiableList()); + .collect(toUnmodifiableList()); } private static List getCommitsByLastCommitAuthor( @@ -384,8 +385,8 @@ public class CommitValidationTest { private final Iterator second; private RevCommitsPair() { - first = Collections.emptyIterator(); - second = Collections.emptyIterator(); + first = emptyIterator(); + second = emptyIterator(); } private RevCommitsPair(Iterator first, Iterator second) { --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/ImmutabilityTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/ImmutabilityTest.java @@ -25,7 +25,10 @@ import static com.tngtech.archunit.lang.conditions.ArchPredicates.are; import static com.tngtech.archunit.lang.conditions.ArchPredicates.have; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes; import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.fields; +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.toUnmodifiableMap; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.FileStatefulCheck; import com.puppycrawl.tools.checkstyle.GlobalStatefulCheck; import com.puppycrawl.tools.checkstyle.StatelessCheck; @@ -51,11 +54,9 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.function.Function; -import java.util.stream.Collectors; import org.junit.jupiter.api.Test; -public class ImmutabilityTest { +final class ImmutabilityTest { /** Immutable types canonical names. */ private static final Set IMMUTABLE_TYPES = @@ -99,7 +100,7 @@ public class ImmutabilityTest { /** List of fields not following {@link #testUtilClassesImmutability()} rule. */ private static final Set SUPPRESSED_FIELDS_IN_UTIL_CLASSES = - Set.of( + ImmutableSet.of( "com.puppycrawl.tools.checkstyle.utils.TokenUtil.TOKEN_IDS", "com.puppycrawl.tools.checkstyle.utils.XpathUtil.TOKEN_TYPES_WITH_TEXT_ATTRIBUTE"); @@ -164,7 +165,7 @@ public class ImmutabilityTest { /** List of classes not following {@link #testClassesWithMutableFieldsShouldBeStateful()} rule. */ private static final Set SUPPRESSED_CLASSES_FOR_STATEFUL_CHECK_RULE = - Set.of("com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck"); + ImmutableSet.of("com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck"); private static final JavaClasses CHECKSTYLE_CHECKS = new ClassFileImporter() @@ -191,13 +192,11 @@ public class ImmutabilityTest { /** Map of module full name to module details. */ private static final Map MODULE_DETAILS_MAP = XmlMetaReader.readAllModulesIncludingThirdPartyIfAny().stream() - .collect( - Collectors.toUnmodifiableMap( - ModuleDetails::getFullQualifiedName, Function.identity())); + .collect(toUnmodifiableMap(ModuleDetails::getFullQualifiedName, identity())); /** Test to ensure that fields in util classes are immutable. */ @Test - public void testUtilClassesImmutability() { + void utilClassesImmutability() { final JavaClasses utilClasses = new ClassFileImporter() .withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS) @@ -225,7 +224,7 @@ public class ImmutabilityTest { /** Test to ensure modules annotated with {@link StatelessCheck} contain immutable fields. */ @Test - public void testFieldsInStatelessChecksShouldBeImmutable() { + void fieldsInStatelessChecksShouldBeImmutable() { final DescribedPredicate moduleProperties = new ModulePropertyPredicate(); final ArchCondition beSuppressedField = @@ -247,7 +246,7 @@ public class ImmutabilityTest { /** Test to ensure classes with immutable fields are annotated with {@link StatelessCheck}. */ @Test - public void testClassesWithImmutableFieldsShouldBeStateless() { + void classesWithImmutableFieldsShouldBeStateless() { final ArchCondition beSuppressedClass = new SuppressionArchCondition<>( SUPPRESSED_CLASSES_FOR_STATELESS_CHECK_RULE, "be suppressed"); @@ -269,7 +268,7 @@ public class ImmutabilityTest { * {@link GlobalStatefulCheck}. */ @Test - public void testClassesWithMutableFieldsShouldBeStateful() { + void classesWithMutableFieldsShouldBeStateful() { final ArchCondition beSuppressedClass = new SuppressionArchCondition<>(SUPPRESSED_CLASSES_FOR_STATEFUL_CHECK_RULE, "be suppressed"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsJavaDocsTest.java @@ -54,7 +54,6 @@ import java.io.File; import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -68,7 +67,7 @@ import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -public class XdocsJavaDocsTest extends AbstractModuleTestSupport { +final class XdocsJavaDocsTest extends AbstractModuleTestSupport { private static final Map> FULLY_QUALIFIED_CLASS_NAMES = ImmutableMap.>builder() .put("int", int.class) @@ -115,7 +114,7 @@ public class XdocsJavaDocsTest extends AbstractModuleTestSupport { } @BeforeEach - public void setUp() throws Exception { + void setUp() throws Exception { final DefaultConfiguration checkConfig = new DefaultConfiguration(JavaDocCapture.class.getName()); checker = createChecker(checkConfig); @@ -129,7 +128,7 @@ public class XdocsJavaDocsTest extends AbstractModuleTestSupport { * method */ @Test - public void testAllCheckSectionJavaDocs() throws Exception { + void allCheckSectionJavaDocs() throws Exception { final ModuleFactory moduleFactory = TestUtil.getPackageObjectFactory(); for (Path path : XdocUtil.getXdocsConfigFilePaths(XdocUtil.getXdocsFilePaths())) { @@ -532,7 +531,7 @@ public class XdocsJavaDocsTest extends AbstractModuleTestSupport { value = currentXdocPath .getParent() - .resolve(Paths.get(value)) + .resolve(Path.of(value)) .normalize() .toString() .replaceAll("src[\\\\/]xdocs[\\\\/]", "") --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsMobileWrapperTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsMobileWrapperTest.java @@ -21,6 +21,7 @@ package com.puppycrawl.tools.checkstyle.internal; import static com.google.common.truth.Truth.assertWithMessage; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.internal.utils.XdocUtil; import com.puppycrawl.tools.checkstyle.internal.utils.XmlUtil; import java.io.File; @@ -32,12 +33,12 @@ import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; -public class XdocsMobileWrapperTest { +final class XdocsMobileWrapperTest { - private static final Set NODES_TO_WRAP = Set.of("pre", "table", "svg", "img"); + private static final Set NODES_TO_WRAP = ImmutableSet.of("pre", "table", "svg", "img"); @Test - public void testAllCheckSectionMobileWrapper() throws Exception { + void allCheckSectionMobileWrapper() throws Exception { for (Path path : XdocUtil.getXdocsFilePaths()) { final File file = path.toFile(); final String fileName = file.getName(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java @@ -21,6 +21,10 @@ package com.puppycrawl.tools.checkstyle.internal; import static com.google.common.truth.Truth.assertWithMessage; import static java.lang.Integer.parseInt; +import static java.util.Collections.unmodifiableSet; +import static java.util.regex.Pattern.DOTALL; +import static java.util.stream.Collectors.joining; +import static java.util.stream.Collectors.toUnmodifiableSet; import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.ConfigurationLoader; @@ -50,12 +54,10 @@ import java.lang.reflect.ParameterizedType; import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java.util.Collection; -import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -69,7 +71,6 @@ import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import org.apache.commons.beanutils.PropertyUtils; @@ -85,10 +86,10 @@ import org.xml.sax.InputSource; * following commands have to be executed: - mvn clean compile - Required for next command - mvn * plexus-component-metadata:generate-metadata - Required to find custom macros and parser */ -public class XdocsPagesTest { - private static final Path SITE_PATH = Paths.get("src/site/site.xml"); +final class XdocsPagesTest { + private static final Path SITE_PATH = Path.of("src/site/site.xml"); - private static final Path AVAILABLE_CHECKS_PATH = Paths.get("src/xdocs/checks.xml"); + private static final Path AVAILABLE_CHECKS_PATH = Path.of("src/xdocs/checks.xml"); private static final String LINK_TEMPLATE = "(?s).*([\\r\\n\\s])*%1$s([\\r\\n\\s])*.*"; @@ -151,7 +152,7 @@ public class XdocsPagesTest { "CustomImportOrder.customImportOrderRules"); private static final Set SUN_MODULES = - Collections.unmodifiableSet(CheckUtil.getConfigSunStyleModules()); + unmodifiableSet(CheckUtil.getConfigSunStyleModules()); // ignore the not yet properly covered modules while testing newly added ones // add proper sections to the coverage report and integration tests // and then remove this list eventually @@ -221,7 +222,7 @@ public class XdocsPagesTest { "WhitespaceAround"); private static final Set GOOGLE_MODULES = - Collections.unmodifiableSet(CheckUtil.getConfigGoogleStyleModules()); + unmodifiableSet(CheckUtil.getConfigGoogleStyleModules()); /** * Generate xdoc content from templates before validation. This method will be removed once summaries = readSummaries(); for (Path path : XdocUtil.getXdocsConfigFilePaths(XdocUtil.getXdocsFilePaths())) { @@ -331,7 +332,7 @@ public class XdocsPagesTest { } @Test - public void testCategoryIndexPageTableInSyncWithAllChecksPageTable() throws Exception { + void categoryIndexPageTableInSyncWithAllChecksPageTable() throws Exception { final Map summaries = readSummaries(); for (Path path : XdocUtil.getXdocsConfigFilePaths(XdocUtil.getXdocsFilePaths())) { final String fileName = path.getFileName().toString(); @@ -384,7 +385,7 @@ public class XdocsPagesTest { } @Test - public void testAllSubSections() throws Exception { + void allSubSections() throws Exception { for (Path path : XdocUtil.getXdocsFilePaths()) { final String input = Files.readString(path); final String fileName = path.getFileName().toString(); @@ -441,7 +442,7 @@ public class XdocsPagesTest { } @Test - public void testAllXmlExamples() throws Exception { + void allXmlExamples() throws Exception { for (Path path : XdocUtil.getXdocsFilePaths()) { final String input = Files.readString(path); final String fileName = path.getFileName().toString(); @@ -564,7 +565,7 @@ public class XdocsPagesTest { } @Test - public void testAllCheckSections() throws Exception { + void allCheckSections() throws Exception { final ModuleFactory moduleFactory = TestUtil.getPackageObjectFactory(); for (Path path : XdocUtil.getXdocsConfigFilePaths(XdocUtil.getXdocsFilePaths())) { @@ -624,10 +625,10 @@ public class XdocsPagesTest { * method */ @Test - public void testAllCheckSectionsEx() throws Exception { + void allCheckSectionsEx() throws Exception { final ModuleFactory moduleFactory = TestUtil.getPackageObjectFactory(); - final Path path = Paths.get(XdocUtil.DIRECTORY_PATH + "/config.xml"); + final Path path = Path.of(XdocUtil.DIRECTORY_PATH + "/config.xml"); final String fileName = path.getFileName().toString(); final String input = Files.readString(path); @@ -1081,7 +1082,7 @@ public class XdocsPagesTest { Optional.ofNullable(field) .map(nonNullField -> nonNullField.getAnnotation(XdocsPropertyType.class)) .map(propertyType -> propertyType.value().getDescription()) - .orElse(fieldClass.getSimpleName()); + .orElseGet(fieldClass::getSimpleName); final String expectedValue = getModulePropertyExpectedValue(sectionName, propertyName, field, fieldClass, instance); @@ -1364,7 +1365,7 @@ public class XdocsPagesTest { final Object[] array = (Object[]) value; valuesStream = Arrays.stream(array); } - result = valuesStream.map(String.class::cast).sorted().collect(Collectors.joining(", ")); + result = valuesStream.map(String.class::cast).sorted().collect(joining(", ")); } if (result.isEmpty()) { @@ -1393,8 +1394,7 @@ public class XdocsPagesTest { } else { stream = Arrays.stream((int[]) value); } - String result = - stream.mapToObj(TokenUtil::getTokenName).sorted().collect(Collectors.joining(", ")); + String result = stream.mapToObj(TokenUtil::getTokenName).sorted().collect(joining(", ")); if (result.isEmpty()) { result = "{}"; } @@ -1470,7 +1470,7 @@ public class XdocsPagesTest { result = XmlUtil.getChildrenElements(node).stream() .map(Node::getTextContent) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } return result; } @@ -1684,7 +1684,7 @@ public class XdocsPagesTest { } @Test - public void testAllStyleRules() throws Exception { + void allStyleRules() throws Exception { for (Path path : XdocUtil.getXdocsStyleFilePaths(XdocUtil.getXdocsFilePaths())) { final String fileName = path.getFileName().toString(); final String styleName = fileName.substring(0, fileName.lastIndexOf('_')); @@ -1989,7 +1989,7 @@ public class XdocsPagesTest { } @Test - public void testAllExampleMacrosHaveParagraphWithIdBeforeThem() throws Exception { + void allExampleMacrosHaveParagraphWithIdBeforeThem() throws Exception { for (Path path : XdocUtil.getXdocsTemplatesFilePaths()) { final String fileName = path.getFileName().toString(); final String input = Files.readString(path); --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsUrlTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsUrlTest.java @@ -20,6 +20,7 @@ package com.puppycrawl.tools.checkstyle.internal; import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.stream.Collectors.toUnmodifiableSet; import com.puppycrawl.tools.checkstyle.api.AbstractCheck; import com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck; @@ -28,21 +29,19 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.junit.jupiter.api.Test; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; -public class XdocsUrlTest { +final class XdocsUrlTest { private static final String PACKAGE_NAME = "src/main/java/com/puppycrawl/tools/checkstyle/checks"; @@ -62,7 +61,7 @@ public class XdocsUrlTest { private static final String SUPPRESS_WARNINGS_HOLDER = "SuppressWarningsHolder"; - private static final Path AVAILABLE_CHECKS_PATH = Paths.get("src/xdocs/checks.xml"); + private static final Path AVAILABLE_CHECKS_PATH = Path.of("src/xdocs/checks.xml"); private static Map> getXdocsMap() throws IOException { final Map> checksNamesMap = new HashMap<>(); @@ -74,7 +73,7 @@ public class XdocsUrlTest { return AbstractCheck.class.isAssignableFrom(clazz) || AbstractFileSetCheck.class.isAssignableFrom(clazz); }) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); for (Class check : treeWalkerOrFileSetCheckSet) { final String checkName = check.getSimpleName(); if (!TREE_WORKER.equals(checkName)) { @@ -96,7 +95,7 @@ public class XdocsUrlTest { } @Test - public void testXdocsUrl() throws Exception { + void xdocsUrl() throws Exception { final SAXParserFactory parserFactory = SAXParserFactory.newInstance(); final SAXParser parser = parserFactory.newSAXParser(); final DummyHandler checkHandler = new DummyHandler(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/XpathRegressionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/XpathRegressionTest.java @@ -20,7 +20,12 @@ package com.puppycrawl.tools.checkstyle.internal; import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.function.Function.identity; +import static java.util.stream.Collectors.toCollection; +import static java.util.stream.Collectors.toUnmodifiableMap; +import static java.util.stream.Collectors.toUnmodifiableSet; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.Definitions; import com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocCheck; @@ -33,23 +38,20 @@ import java.io.IOException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashSet; import java.util.Locale; import java.util.Map; import java.util.Set; -import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class XpathRegressionTest extends AbstractModuleTestSupport { +final class XpathRegressionTest extends AbstractModuleTestSupport { // Checks that not compatible with SuppressionXpathFilter public static final Set INCOMPATIBLE_CHECK_NAMES = - Set.of( + ImmutableSet.of( "NoCodeInFile (reason is that AST is not generated for a file not containing code)", "Regexp (reason is at #7759)", "RegexpSinglelineJava (reason is at #7759)"); @@ -79,7 +81,7 @@ public class XpathRegressionTest extends AbstractModuleTestSupport { // Older regex-based checks that are under INCOMPATIBLE_JAVADOC_CHECK_NAMES // but not subclasses of AbstractJavadocCheck. private static final Set> REGEXP_JAVADOC_CHECKS = - Set.of( + ImmutableSet.of( JavadocStyleCheck.class, JavadocMethodCheck.class, JavadocTypeCheck.class, @@ -110,7 +112,7 @@ public class XpathRegressionTest extends AbstractModuleTestSupport { "VisibilityModifier"); // Modules that will never have xpath support ever because they not report violations - private static final Set NO_VIOLATION_MODULES = Set.of("SuppressWarningsHolder"); + private static final Set NO_VIOLATION_MODULES = ImmutableSet.of("SuppressWarningsHolder"); private static final Set SIMPLE_CHECK_NAMES = getSimpleCheckNames(); private static final Map ALLOWED_DIRECTORY_AND_CHECKS = @@ -131,9 +133,7 @@ public class XpathRegressionTest extends AbstractModuleTestSupport { private static Map getAllowedDirectoryAndChecks() { return SIMPLE_CHECK_NAMES.stream() - .collect( - Collectors.toUnmodifiableMap( - id -> id.toLowerCase(Locale.ENGLISH), Function.identity())); + .collect(toUnmodifiableMap(id -> id.toLowerCase(Locale.ENGLISH), identity())); } private static Set getInternalModules() { @@ -143,13 +143,13 @@ public class XpathRegressionTest extends AbstractModuleTestSupport { final String[] packageTokens = moduleName.split("\\."); return packageTokens[packageTokens.length - 1]; }) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } @BeforeEach - public void setUp() throws Exception { - javaDir = Paths.get("src/it/java/" + getPackageLocation()); - inputDir = Paths.get(getPath("")); + void setUp() throws Exception { + javaDir = Path.of("src/it/java/" + getPackageLocation()); + inputDir = Path.of(getPath("")); } @Override @@ -163,12 +163,12 @@ public class XpathRegressionTest extends AbstractModuleTestSupport { } @Test - public void validateIncompatibleJavadocCheckNames() throws IOException { + void validateIncompatibleJavadocCheckNames() throws IOException { // subclasses of AbstractJavadocCheck final Set> abstractJavadocCheckNames = CheckUtil.getCheckstyleChecks().stream() .filter(AbstractJavadocCheck.class::isAssignableFrom) - .collect(Collectors.toCollection(HashSet::new)); + .collect(toCollection(HashSet::new)); // add the extra checks abstractJavadocCheckNames.addAll(REGEXP_JAVADOC_CHECKS); final Set abstractJavadocCheckSimpleNames = @@ -182,7 +182,7 @@ public class XpathRegressionTest extends AbstractModuleTestSupport { } @Test - public void validateIntegrationTestClassNames() throws Exception { + void validateIntegrationTestClassNames() throws Exception { final Set compatibleChecks = new HashSet<>(); final Pattern pattern = Pattern.compile("^XpathRegression(.+)Test\\.java$"); try (DirectoryStream javaPaths = Files.newDirectoryStream(javaDir)) { @@ -226,7 +226,7 @@ public class XpathRegressionTest extends AbstractModuleTestSupport { final Set allChecks = new HashSet<>(SIMPLE_CHECK_NAMES); allChecks.removeAll(INCOMPATIBLE_JAVADOC_CHECK_NAMES); allChecks.removeAll(INCOMPATIBLE_CHECK_NAMES); - allChecks.removeAll(Set.of("Regexp", "RegexpSinglelineJava", "NoCodeInFile")); + allChecks.removeAll(ImmutableSet.of("Regexp", "RegexpSinglelineJava", "NoCodeInFile")); allChecks.removeAll(MISSING_CHECK_NAMES); allChecks.removeAll(NO_VIOLATION_MODULES); allChecks.removeAll(compatibleChecks); @@ -241,7 +241,7 @@ public class XpathRegressionTest extends AbstractModuleTestSupport { } @Test - public void validateInputFiles() throws Exception { + void validateInputFiles() throws Exception { try (DirectoryStream dirs = Files.newDirectoryStream(inputDir)) { for (Path dir : dirs) { // input directory must be named in lower case --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/testmodules/CheckstyleAntTaskLogStub.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/testmodules/CheckstyleAntTaskLogStub.java @@ -19,9 +19,10 @@ package com.puppycrawl.tools.checkstyle.internal.testmodules; +import static java.util.Collections.unmodifiableList; + import com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public final class CheckstyleAntTaskLogStub extends CheckstyleAntTask { @@ -39,6 +40,6 @@ public final class CheckstyleAntTaskLogStub extends CheckstyleAntTask { } public List getLoggedMessages() { - return Collections.unmodifiableList(loggedMessages); + return unmodifiableList(loggedMessages); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/testmodules/CheckstyleAntTaskStub.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/testmodules/CheckstyleAntTaskStub.java @@ -19,16 +19,16 @@ package com.puppycrawl.tools.checkstyle.internal.testmodules; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.ant.CheckstyleAntTask; import java.io.File; -import java.util.Collections; import java.util.List; public class CheckstyleAntTaskStub extends CheckstyleAntTask { @Override protected List scanFileSets() { - return Collections.singletonList(new MockFile()); + return ImmutableList.of(new MockFile()); } private static final class MockFile extends File { --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/testmodules/TestRootModuleChecker.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/testmodules/TestRootModuleChecker.java @@ -19,13 +19,14 @@ package com.puppycrawl.tools.checkstyle.internal.testmodules; +import static java.util.Collections.unmodifiableList; + import com.puppycrawl.tools.checkstyle.api.AuditListener; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; import com.puppycrawl.tools.checkstyle.api.Configuration; import com.puppycrawl.tools.checkstyle.api.RootModule; import java.io.File; import java.util.ArrayList; -import java.util.Collections; import java.util.List; public class TestRootModuleChecker implements RootModule { @@ -85,7 +86,7 @@ public class TestRootModuleChecker implements RootModule { } public static List getFilesToCheck() { - return Collections.unmodifiableList(filesToCheck); + return unmodifiableList(filesToCheck); } public static Configuration getConfig() { --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/CheckUtil.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/CheckUtil.java @@ -19,6 +19,9 @@ package com.puppycrawl.tools.checkstyle.internal.utils; +import static java.util.stream.Collectors.toCollection; +import static java.util.stream.Collectors.toUnmodifiableSet; + import com.google.common.reflect.ClassPath; import com.puppycrawl.tools.checkstyle.api.FileText; import com.puppycrawl.tools.checkstyle.checks.coding.AbstractSuperCheck; @@ -41,7 +44,6 @@ import java.util.HashSet; import java.util.Locale; import java.util.Properties; import java.util.Set; -import java.util.stream.Collectors; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; @@ -86,7 +88,7 @@ public final class CheckUtil { return name; }) - .collect(Collectors.toCollection(HashSet::new)); + .collect(toCollection(HashSet::new)); } /** @@ -145,7 +147,7 @@ public final class CheckUtil { final String packageName = "com.puppycrawl.tools.checkstyle"; return getCheckstyleModulesRecursive(packageName, loader).stream() .filter(ModuleReflectionUtil::isCheckstyleTreeWalkerCheck) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } /** @@ -176,7 +178,7 @@ public final class CheckUtil { .map(ClassPath.ClassInfo::load) .filter(ModuleReflectionUtil::isCheckstyleModule) .filter(CheckUtil::isFromAllowedPackages) - .collect(Collectors.toUnmodifiableSet()); + .collect(toUnmodifiableSet()); } /** --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocGenerator.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocGenerator.java @@ -19,11 +19,12 @@ package com.puppycrawl.tools.checkstyle.internal.utils; +import static java.nio.charset.StandardCharsets.UTF_8; + import com.puppycrawl.tools.checkstyle.site.XdocsTemplateParser; import com.puppycrawl.tools.checkstyle.site.XdocsTemplateSinkFactory; import java.io.File; import java.io.Reader; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; @@ -52,17 +53,16 @@ public final class XdocGenerator { final String pathToFile = path.toString(); final File inputFile = new File(pathToFile); final File outputFile = new File(pathToFile.replace(".template", "")); - final File tempFile = File.createTempFile(outputFile.getName(), ""); + final File tempFile = Files.createTempFile(outputFile.getName(), "").toFile(); tempFile.deleteOnExit(); final XdocsTemplateSinkFactory sinkFactory = (XdocsTemplateSinkFactory) plexus.lookup(SinkFactory.ROLE, XDOCS_TEMPLATE_HINT); final Sink sink = sinkFactory.createSink( - tempFile.getParentFile(), tempFile.getName(), String.valueOf(StandardCharsets.UTF_8)); + tempFile.getParentFile(), tempFile.getName(), String.valueOf(UTF_8)); final XdocsTemplateParser parser = (XdocsTemplateParser) plexus.lookup(Parser.ROLE, XDOCS_TEMPLATE_HINT); - try (Reader reader = - ReaderFactory.newReader(inputFile, String.valueOf(StandardCharsets.UTF_8))) { + try (Reader reader = ReaderFactory.newReader(inputFile, String.valueOf(UTF_8))) { parser.parse(reader, sink); } finally { sink.close(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocUtil.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/internal/utils/XdocUtil.java @@ -19,13 +19,13 @@ package com.puppycrawl.tools.checkstyle.internal.utils; +import static java.util.stream.Collectors.toUnmodifiableSet; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.HashSet; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -55,7 +55,7 @@ public final class XdocUtil { * @throws IOException if an I/O error occurs. */ public static Set getXdocsFilePaths() throws IOException { - final Path directory = Paths.get(DIRECTORY_PATH); + final Path directory = Path.of(DIRECTORY_PATH); try (Stream stream = Files.find( directory, @@ -64,7 +64,7 @@ public final class XdocUtil { return attr.isRegularFile() && (path.toString().endsWith(".xml") || path.toString().endsWith(".xml.vm")); })) { - return stream.collect(Collectors.toUnmodifiableSet()); + return stream.collect(toUnmodifiableSet()); } } @@ -77,7 +77,7 @@ public final class XdocUtil { * @throws IOException if an I/O error occurs. */ public static Set getXdocsTemplatesFilePaths() throws IOException { - final Path directory = Paths.get(DIRECTORY_PATH); + final Path directory = Path.of(DIRECTORY_PATH); try (Stream stream = Files.find( directory, @@ -85,7 +85,7 @@ public final class XdocUtil { (path, attr) -> { return attr.isRegularFile() && path.toString().endsWith(".xml.template"); })) { - return stream.collect(Collectors.toUnmodifiableSet()); + return stream.collect(toUnmodifiableSet()); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/meta/JavadocMetadataScraperTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/meta/JavadocMetadataScraperTest.java @@ -31,7 +31,7 @@ import java.util.Map; import java.util.Map.Entry; import org.junit.jupiter.api.Test; -public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { +final class JavadocMetadataScraperTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testAtclauseOrderCheck() throws Exception { + void atclauseOrderCheck() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperAtclauseOrderCheck.java"), @@ -50,7 +50,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationUseStyleCheck() throws Exception { + void annotationUseStyleCheck() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperAnnotationUseStyleCheck.java"), @@ -61,7 +61,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testBeforeExecutionExclusionFileFilter() throws Exception { + void beforeExecutionExclusionFileFilter() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperBeforeExecutionExclusionFileFilter.java"), @@ -74,7 +74,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testNoCodeInFileCheck() throws Exception { + void noCodeInFileCheck() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperNoCodeInFileCheck.java"), @@ -85,7 +85,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testPropertyMisplacedDefaultValueCheck() { + void propertyMisplacedDefaultValueCheck() { JavadocMetadataScraper.resetModuleDetailsStore(); final CheckstyleException exc = assertThrows( @@ -101,7 +101,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testPropertyMisplacedTypeCheck() { + void propertyMisplacedTypeCheck() { JavadocMetadataScraper.resetModuleDetailsStore(); final CheckstyleException exc = assertThrows( @@ -118,7 +118,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testPropertyMissingDefaultValueCheck() { + void propertyMissingDefaultValueCheck() { JavadocMetadataScraper.resetModuleDetailsStore(); final CheckstyleException exc = assertThrows( @@ -135,7 +135,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testPropertyMissingTypeCheck() { + void propertyMissingTypeCheck() { JavadocMetadataScraper.resetModuleDetailsStore(); final CheckstyleException exc = assertThrows( @@ -151,7 +151,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testPropertyWithNoCodeTagCheck() throws Exception { + void propertyWithNoCodeTagCheck() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperPropertyWithNoCodeTagCheck.java"), @@ -163,7 +163,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testRightCurlyCheck() throws Exception { + void rightCurlyCheck() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperRightCurlyCheck.java"), CommonUtil.EMPTY_STRING_ARRAY); @@ -173,7 +173,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testSummaryJavadocCheck() throws Exception { + void summaryJavadocCheck() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperSummaryJavadocCheck.java"), @@ -184,7 +184,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testSuppressWarningsFilter() throws Exception { + void suppressWarningsFilter() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperSuppressWarningsFilter.java"), @@ -195,7 +195,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testWriteTagCheck() throws Exception { + void writeTagCheck() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); verifyWithInlineConfigParser( getPath("InputJavadocMetadataScraperWriteTagCheck.java"), CommonUtil.EMPTY_STRING_ARRAY); @@ -205,7 +205,7 @@ public class JavadocMetadataScraperTest extends AbstractModuleTestSupport { } @Test - public void testEmptyDescription() throws Exception { + void emptyDescription() throws Exception { JavadocMetadataScraper.resetModuleDetailsStore(); final String[] expected = { --- a/src/test/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/meta/MetadataGeneratorUtilTest.java @@ -21,18 +21,18 @@ package com.puppycrawl.tools.checkstyle.meta; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.meta.JavadocMetadataScraper.MSG_DESC_MISSING; +import static java.util.stream.Collectors.toCollection; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.internal.utils.CheckUtil; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; import java.util.stream.Stream; import org.itsallcode.io.Capturable; import org.itsallcode.junit.sysextensions.SystemOutGuard; @@ -40,10 +40,10 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @ExtendWith(SystemOutGuard.class) -public final class MetadataGeneratorUtilTest extends AbstractModuleTestSupport { +final class MetadataGeneratorUtilTest extends AbstractModuleTestSupport { private final Set modulesContainingNoMetadataFile = - Set.of( + ImmutableSet.of( "Checker", "TreeWalker", "JavadocMetadataScraper", @@ -67,7 +67,7 @@ public final class MetadataGeneratorUtilTest extends AbstractModuleTestSupport { * System.out} for error messages */ @Test - public void testMetadataFilesGenerationAllFiles(@SystemOutGuard.SysOut Capturable systemOut) + void metadataFilesGenerationAllFiles(@SystemOutGuard.SysOut Capturable systemOut) throws Exception { systemOut.captureMuted(); @@ -107,7 +107,7 @@ public final class MetadataGeneratorUtilTest extends AbstractModuleTestSupport { final Set metaFiles; try (Stream fileStream = Files.walk( - Paths.get( + Path.of( System.getProperty("user.dir") + "/src/main/resources/com/puppycrawl" + "/tools/checkstyle/meta"))) { @@ -117,12 +117,12 @@ public final class MetadataGeneratorUtilTest extends AbstractModuleTestSupport { .filter(path -> !path.toString().endsWith(".properties")) .map(MetadataGeneratorUtilTest::getMetaFileName) .sorted() - .collect(Collectors.toCollection(LinkedHashSet::new)); + .collect(toCollection(LinkedHashSet::new)); } final Set checkstyleModules = CheckUtil.getSimpleNames(CheckUtil.getCheckstyleModules()).stream() .sorted() - .collect(Collectors.toCollection(LinkedHashSet::new)); + .collect(toCollection(LinkedHashSet::new)); checkstyleModules.removeAll(modulesContainingNoMetadataFile); assertWithMessage( "Number of generated metadata files dont match with " + "number of checkstyle module") --- a/src/test/java/com/puppycrawl/tools/checkstyle/meta/XmlMetaReaderTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/meta/XmlMetaReaderTest.java @@ -24,12 +24,12 @@ import static com.google.common.truth.Truth.assertThat; import com.puppycrawl.tools.checkstyle.AbstractPathTestSupport; import java.io.InputStream; import java.nio.file.Files; -import java.nio.file.Paths; +import java.nio.file.Path; import java.util.List; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; -public class XmlMetaReaderTest extends AbstractPathTestSupport { +final class XmlMetaReaderTest extends AbstractPathTestSupport { @Override protected String getPackageLocation() { @@ -37,12 +37,12 @@ public class XmlMetaReaderTest extends AbstractPathTestSupport { } @Test - public void test() { + void test() { assertThat(XmlMetaReader.readAllModulesIncludingThirdPartyIfAny()).hasSize(200); } @Test - public void testDuplicatePackage() { + void duplicatePackage() { assertThat( XmlMetaReader.readAllModulesIncludingThirdPartyIfAny( "com.puppycrawl.tools.checkstyle.meta")) @@ -50,14 +50,14 @@ public class XmlMetaReaderTest extends AbstractPathTestSupport { } @Test - public void testBadPackage() { + void badPackage() { assertThat(XmlMetaReader.readAllModulesIncludingThirdPartyIfAny("DOES.NOT.EXIST")).hasSize(200); } @Test - public void testReadXmlMetaCheckWithProperties() throws Exception { + void readXmlMetaCheckWithProperties() throws Exception { final String path = getPath("InputXmlMetaReaderCheckWithProps.xml"); - try (InputStream is = Files.newInputStream(Paths.get(path))) { + try (InputStream is = Files.newInputStream(Path.of(path))) { final ModuleDetails result = XmlMetaReader.read(is, ModuleType.CHECK); checkModuleProps( result, @@ -87,9 +87,9 @@ public class XmlMetaReaderTest extends AbstractPathTestSupport { } @Test - public void testReadXmlMetaCheckNoProperties() throws Exception { + void readXmlMetaCheckNoProperties() throws Exception { final String path = getPath("InputXmlMetaReaderCheckNoProps.xml"); - try (InputStream is = Files.newInputStream(Paths.get(path))) { + try (InputStream is = Files.newInputStream(Path.of(path))) { final ModuleDetails result = XmlMetaReader.read(is, ModuleType.CHECK); checkModuleProps( result, @@ -107,9 +107,9 @@ public class XmlMetaReaderTest extends AbstractPathTestSupport { } @Test - public void testReadXmlMetaFilter() throws Exception { + void readXmlMetaFilter() throws Exception { final String path = getPath("InputXmlMetaReaderFilter.xml"); - try (InputStream is = Files.newInputStream(Paths.get(path))) { + try (InputStream is = Files.newInputStream(Path.of(path))) { final ModuleDetails result = XmlMetaReader.read(is, ModuleType.FILTER); checkModuleProps( result, @@ -133,9 +133,9 @@ public class XmlMetaReaderTest extends AbstractPathTestSupport { } @Test - public void testReadXmlMetaFileFilter() throws Exception { + void readXmlMetaFileFilter() throws Exception { final String path = getPath("InputXmlMetaReaderFileFilter.xml"); - try (InputStream is = Files.newInputStream(Paths.get(path))) { + try (InputStream is = Files.newInputStream(Path.of(path))) { final ModuleDetails result = XmlMetaReader.read(is, ModuleType.FILEFILTER); checkModuleProps( result, @@ -158,7 +158,7 @@ public class XmlMetaReaderTest extends AbstractPathTestSupport { } @Test - public void testReadXmlMetaModuleTypeNull() throws Exception { + void readXmlMetaModuleTypeNull() throws Exception { try (InputStream is = IOUtils.toInputStream("", "UTF-8")) { assertThat(XmlMetaReader.read(is, null)).isNull(); } --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/AnnotationUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/AnnotationUtilTest.java @@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.checks.annotation.SuppressWarningsCheck.MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED; import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.DetailAST; @@ -31,7 +32,7 @@ import com.puppycrawl.tools.checkstyle.checks.annotation.SuppressWarningsCheck; import java.util.Set; import org.junit.jupiter.api.Test; -public class AnnotationUtilTest extends AbstractModuleTestSupport { +final class AnnotationUtilTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +40,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testIsProperUtilsClass() { + void isProperUtilsClass() { try { isUtilsClassHasPrivateConstructor(AnnotationUtil.class); assertWithMessage("Exception is expected").fail(); @@ -53,7 +54,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationNull() { + void containsAnnotationNull() { try { AnnotationUtil.containsAnnotation(null); assertWithMessage("IllegalArgumentException is expected").fail(); @@ -65,7 +66,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationNull2() { + void containsAnnotationNull2() { try { AnnotationUtil.containsAnnotation(null, ""); assertWithMessage("IllegalArgumentException is expected").fail(); @@ -77,7 +78,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationFalse() { + void containsAnnotationFalse() { final DetailAstImpl ast = new DetailAstImpl(); ast.setType(1); assertWithMessage("AnnotationUtil should not contain " + ast) @@ -86,7 +87,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationFalse2() { + void containsAnnotationFalse2() { final DetailAstImpl ast = new DetailAstImpl(); ast.setType(1); final DetailAstImpl ast2 = new DetailAstImpl(); @@ -98,7 +99,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationTrue() { + void containsAnnotationTrue() { final DetailAstImpl ast = new DetailAstImpl(); ast.setType(1); final DetailAstImpl ast2 = new DetailAstImpl(); @@ -113,7 +114,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationHolderNull() { + void annotationHolderNull() { try { AnnotationUtil.getAnnotationHolder(null); assertWithMessage("IllegalArgumentException is expected").fail(); @@ -125,7 +126,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationNull() { + void annotationNull() { try { AnnotationUtil.getAnnotation(null, null); assertWithMessage("IllegalArgumentException is expected").fail(); @@ -137,7 +138,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationNull2() { + void annotationNull2() { try { AnnotationUtil.getAnnotation(new DetailAstImpl(), null); assertWithMessage("IllegalArgumentException is expected").fail(); @@ -149,7 +150,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testAnnotationEmpty() { + void annotationEmpty() { try { AnnotationUtil.getAnnotation(new DetailAstImpl(), ""); assertWithMessage("IllegalArgumentException is expected").fail(); @@ -161,7 +162,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationWithNull() { + void containsAnnotationWithNull() { try { AnnotationUtil.getAnnotation(null, ""); assertWithMessage("IllegalArgumentException is expected").fail(); @@ -173,9 +174,9 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationListWithNullAst() { + void containsAnnotationListWithNullAst() { try { - AnnotationUtil.containsAnnotation(null, Set.of("Override")); + AnnotationUtil.containsAnnotation(null, ImmutableSet.of("Override")); assertWithMessage("IllegalArgumentException is expected").fail(); } catch (IllegalArgumentException ex) { assertWithMessage("Invalid exception message") @@ -185,7 +186,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationListWithNullList() { + void containsAnnotationListWithNullList() { final DetailAST ast = new DetailAstImpl(); final Set annotations = null; try { @@ -199,26 +200,26 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationListWithEmptyList() { + void containsAnnotationListWithEmptyList() { final DetailAST ast = new DetailAstImpl(); - final Set annotations = Set.of(); + final Set annotations = ImmutableSet.of(); final boolean result = AnnotationUtil.containsAnnotation(ast, annotations); assertWithMessage("An empty set should lead to a false result").that(result).isFalse(); } @Test - public void testContainsAnnotationListWithNoAnnotationNode() { + void containsAnnotationListWithNoAnnotationNode() { final DetailAstImpl ast = new DetailAstImpl(); final DetailAstImpl modifiersAst = new DetailAstImpl(); modifiersAst.setType(TokenTypes.MODIFIERS); ast.addChild(modifiersAst); - final Set annotations = Set.of("Override"); + final Set annotations = ImmutableSet.of("Override"); final boolean result = AnnotationUtil.containsAnnotation(ast, annotations); assertWithMessage("An empty ast should lead to a false result").that(result).isFalse(); } @Test - public void testContainsAnnotationListWithNoMatchingAnnotation() { + void containsAnnotationListWithNoMatchingAnnotation() { final DetailAstImpl ast = new DetailAstImpl(); final DetailAstImpl modifiersAst = create( @@ -227,13 +228,13 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { TokenTypes.ANNOTATION, create(TokenTypes.DOT, create(TokenTypes.IDENT, "Override")))); ast.addChild(modifiersAst); - final Set annotations = Set.of("Deprecated"); + final Set annotations = ImmutableSet.of("Deprecated"); final boolean result = AnnotationUtil.containsAnnotation(ast, annotations); assertWithMessage("No matching annotation found").that(result).isFalse(); } @Test - public void testContainsAnnotation() { + void containsAnnotation() { final DetailAstImpl astForTest = new DetailAstImpl(); astForTest.setType(TokenTypes.PACKAGE_DEF); final DetailAstImpl child = new DetailAstImpl(); @@ -258,7 +259,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationWithStringFalse() { + void containsAnnotationWithStringFalse() { final DetailAstImpl astForTest = new DetailAstImpl(); astForTest.setType(TokenTypes.PACKAGE_DEF); final DetailAstImpl child = new DetailAstImpl(); @@ -283,7 +284,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testContainsAnnotationWithComment() { + void containsAnnotationWithComment() { final DetailAstImpl astForTest = new DetailAstImpl(); astForTest.setType(TokenTypes.PACKAGE_DEF); final DetailAstImpl child = new DetailAstImpl(); @@ -311,7 +312,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testCompactNoUnchecked() throws Exception { + void compactNoUnchecked() throws Exception { final String[] expected = { "16:20: " @@ -335,7 +336,7 @@ public class AnnotationUtilTest extends AbstractModuleTestSupport { } @Test - public void testValuePairAnnotation() throws Exception { + void valuePairAnnotation() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/BlockCommentPositionTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/BlockCommentPositionTest.java @@ -19,6 +19,7 @@ package com.puppycrawl.tools.checkstyle.utils; +import static com.google.common.base.Preconditions.checkState; import static com.google.common.truth.Truth.assertWithMessage; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; @@ -32,17 +33,17 @@ import java.util.List; import java.util.function.Function; import org.junit.jupiter.api.Test; -public class BlockCommentPositionTest extends AbstractModuleTestSupport { +final class BlockCommentPositionTest extends AbstractModuleTestSupport { @Test - public void testPrivateConstr() throws Exception { + void privateConstr() throws Exception { assertWithMessage("Constructor is not private") .that(TestUtil.isUtilsClassHasPrivateConstructor(BlockCommentPosition.class)) .isTrue(); } @Test - public void testJavaDocsRecognition() throws Exception { + void javaDocsRecognition() throws Exception { final List metadataList = Arrays.asList( new BlockCommentPositionTestMetadata( @@ -88,7 +89,7 @@ public class BlockCommentPositionTest extends AbstractModuleTestSupport { } @Test - public void testJavaDocsRecognitionNonCompilable() throws Exception { + void javaDocsRecognitionNonCompilable() throws Exception { final List metadataList = Arrays.asList( new BlockCommentPositionTestMetadata( @@ -113,9 +114,7 @@ public class BlockCommentPositionTest extends AbstractModuleTestSupport { DetailAST node = detailAST; while (node != null) { if (node.getType() == TokenTypes.BLOCK_COMMENT_BEGIN && JavadocUtil.isJavadocComment(node)) { - if (!assertion.apply(node)) { - throw new IllegalStateException("Position of comment is defined correctly"); - } + checkState(assertion.apply(node), "Position of comment is defined correctly"); matchFound++; } matchFound += getJavadocsCount(node.getFirstChild(), assertion); --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/ChainedPropertyUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/ChainedPropertyUtilTest.java @@ -33,7 +33,7 @@ import java.nio.file.Files; import java.util.Properties; import org.junit.jupiter.api.Test; -public class ChainedPropertyUtilTest extends AbstractModuleTestSupport { +final class ChainedPropertyUtilTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -41,14 +41,14 @@ public class ChainedPropertyUtilTest extends AbstractModuleTestSupport { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private.") .that(isUtilsClassHasPrivateConstructor(ChainedPropertyUtil.class)) .isTrue(); } @Test - public void testPropertyChaining() throws Exception { + void propertyChaining() throws Exception { final File propertiesFile = new File(getPath("InputChainedPropertyUtil.properties")); final Properties properties = loadProperties(propertiesFile); final Properties resolvedProperties = ChainedPropertyUtil.getResolvedProperties(properties); @@ -72,7 +72,7 @@ public class ChainedPropertyUtilTest extends AbstractModuleTestSupport { } @Test - public void testPropertyChainingPropertyNotFound() throws Exception { + void propertyChainingPropertyNotFound() throws Exception { final File propertiesFile = new File(getPath("InputChainedPropertyUtilUndefinedProperty.properties")); final Properties properties = loadProperties(propertiesFile); @@ -87,7 +87,7 @@ public class ChainedPropertyUtilTest extends AbstractModuleTestSupport { } @Test - public void testPropertyChainingRecursiveUnresolvable() throws Exception { + void propertyChainingRecursiveUnresolvable() throws Exception { final File propertiesFile = new File(getPath("InputChainedPropertyUtilRecursiveUnresolvable.properties")); final Properties properties = loadProperties(propertiesFile); --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/CheckUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/CheckUtilTest.java @@ -55,20 +55,20 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(CheckUtil.class)) .isTrue(); } @Test - public void testParseDoubleWithIncorrectToken() { + void parseDoubleWithIncorrectToken() { final double parsedDouble = CheckUtil.parseDouble("1_02", TokenTypes.ASSIGN); assertWithMessage("Invalid parse result").that(parsedDouble).isEqualTo(Double.NaN); } @Test - public void testEquals() { + void testEquals() { final DetailAstImpl litStatic = new DetailAstImpl(); litStatic.setType(TokenTypes.LITERAL_STATIC); @@ -112,7 +112,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testGetAccessModifierFromModifiersTokenWrongTokenType() { + void getAccessModifierFromModifiersTokenWrongTokenType() { final DetailAstImpl modifiers = new DetailAstImpl(); modifiers.setType(TokenTypes.METHOD_DEF); @@ -129,7 +129,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testGetTypeParameterNames() throws Exception { + void getTypeParameterNames() throws Exception { final DetailAST parameterizedClassNode = getNodeFromFile(TokenTypes.CLASS_DEF); final List expected = Arrays.asList("V", "C"); final List actual = CheckUtil.getTypeParameterNames(parameterizedClassNode); @@ -138,7 +138,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testGetTypeParameters() throws Exception { + void getTypeParameters() throws Exception { final DetailAST parameterizedClassNode = getNodeFromFile(TokenTypes.CLASS_DEF); final DetailAST firstTypeParameter = getNode(parameterizedClassNode, TokenTypes.TYPE_PARAMETER); final List expected = @@ -149,7 +149,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testIsEqualsMethod() throws Exception { + void isEqualsMethod() throws Exception { final DetailAST equalsMethodNode = getNodeFromFile(TokenTypes.METHOD_DEF); final DetailAST someOtherMethod = equalsMethodNode.getNextSibling(); @@ -162,7 +162,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testIsNonVoidMethod() throws Exception { + void isNonVoidMethod() throws Exception { final DetailAST nonVoidMethod = getNodeFromFile(TokenTypes.METHOD_DEF); final DetailAST voidMethod = nonVoidMethod.getNextSibling(); @@ -175,7 +175,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testGetAccessModifierFromModifiersToken() throws Exception { + void getAccessModifierFromModifiersToken() throws Exception { final DetailAST interfaceDef = getNodeFromFile(TokenTypes.INTERFACE_DEF); final AccessModifierOption modifierInterface = CheckUtil.getAccessModifierFromModifiersToken( @@ -214,7 +214,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testGetFirstNode() throws Exception { + void getFirstNode() throws Exception { final DetailAST classDef = getNodeFromFile(TokenTypes.CLASS_DEF); final DetailAST firstChild = classDef.getFirstChild().getFirstChild(); @@ -223,7 +223,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testGetFirstNode1() { + void getFirstNode1() { final DetailAstImpl child = new DetailAstImpl(); child.setLineNo(5); child.setColumnNo(6); @@ -239,7 +239,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testGetFirstNode2() { + void getFirstNode2() { final DetailAstImpl child = new DetailAstImpl(); child.setLineNo(6); child.setColumnNo(5); @@ -255,7 +255,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testParseDoubleFloatingPointValues() { + void parseDoubleFloatingPointValues() { assertWithMessage("Invalid parse result") .that(CheckUtil.parseDouble("-0.05f", TokenTypes.NUM_FLOAT)) .isEqualTo(-0.05); @@ -277,7 +277,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testParseDoubleIntegerValues() { + void parseDoubleIntegerValues() { assertWithMessage("Invalid parse result") .that(CheckUtil.parseDouble("0L", TokenTypes.NUM_LONG)) .isEqualTo(0.0); @@ -314,7 +314,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testParseClassNames() { + void parseClassNames() { final Set actual = CheckUtil.parseClassNames("I.am.class.name.with.dot.in.the.end.", "ClassOnly", "my.Class"); final Set expected = new HashSet<>(); @@ -326,7 +326,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testEqualsAvoidNullCheck() throws Exception { + void equalsAvoidNullCheck() throws Exception { final String[] expected = { "14:28: " + getCheckMessage(EqualsAvoidNullCheck.class, MSG_EQUALS_AVOID_NULL), @@ -336,7 +336,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testMultipleVariableDeclarationsCheck() throws Exception { + void multipleVariableDeclarationsCheck() throws Exception { final String[] expected = { "11:5: " + getCheckMessage(MultipleVariableDeclarationsCheck.class, MSG_MULTIPLE), "14:5: " + getCheckMessage(MultipleVariableDeclarationsCheck.class, MSG_MULTIPLE), @@ -345,7 +345,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testNestedIfDepth() throws Exception { + void nestedIfDepth() throws Exception { final String[] expected = { "26:17: " + getCheckMessage(NestedIfDepthCheck.class, MSG_KEY, 2, 1), "52:17: " + getCheckMessage(NestedIfDepthCheck.class, MSG_KEY, 2, 1), @@ -354,13 +354,13 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testJavaDocMethod() throws Exception { + void javaDocMethod() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("InputCheckUtil4.java"), expected); } @Test - public void testJavaDocMethod2() throws Exception { + void javaDocMethod2() throws Exception { final String[] expected = { "14:25: " + getCheckMessage(JavadocMethodCheck.class, MSG_EXPECTED_TAG, "@param", "i"), }; @@ -368,7 +368,7 @@ public class CheckUtilTest extends AbstractModuleTestSupport { } @Test - public void testJavadoc() throws Exception { + void javadoc() throws Exception { final String[] expected = { "25:39: " + getCheckMessage(JavadocMethodCheck.class, MSG_EXPECTED_TAG, "@param", "i"), }; @@ -402,6 +402,6 @@ public class CheckUtilTest extends AbstractModuleTestSupport { .that(node.isPresent()) .isTrue(); - return node.get(); + return node.orElseThrow(); } } --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/CodePointUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/CodePointUtilTest.java @@ -24,10 +24,10 @@ import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsCla import org.junit.jupiter.api.Test; -public class CodePointUtilTest { +final class CodePointUtilTest { @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(CodePointUtil.class)) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/CommonUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/CommonUtilTest.java @@ -22,6 +22,8 @@ package com.puppycrawl.tools.checkstyle.utils; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor; +import static java.nio.charset.StandardCharsets.UTF_8; +import static java.util.regex.Pattern.MULTILINE; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.CALLS_REAL_METHODS; import static org.mockito.Mockito.mock; @@ -40,7 +42,6 @@ import java.lang.reflect.Constructor; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.util.Dictionary; import java.util.Properties; import java.util.regex.Pattern; @@ -48,7 +49,7 @@ import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; -public class CommonUtilTest extends AbstractPathTestSupport { +final class CommonUtilTest extends AbstractPathTestSupport { /** After appending to path produces equivalent, but denormalized path. */ private static final String PATH_DENORMALIZER = "/levelDown/.././"; @@ -59,7 +60,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(CommonUtil.class)) .isTrue(); @@ -67,7 +68,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { /** Test CommonUtil.countCharInString. */ @Test - public void testLengthExpandedTabs() { + void lengthExpandedTabs() { final String s1 = "\t"; assertWithMessage("Invalid expanded tabs length") .that(CommonUtil.lengthExpandedTabs(s1, s1.length(), 8)) @@ -103,7 +104,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testCreatePattern() { + void createPattern() { assertWithMessage("invalid pattern") .that(CommonUtil.createPattern("Test").pattern()) .isEqualTo("Test"); @@ -113,7 +114,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testBadRegex() { + void badRegex() { final IllegalArgumentException ex = assertThrows( IllegalArgumentException.class, @@ -127,12 +128,12 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testBadRegex2() { + void badRegex2() { final IllegalArgumentException ex = assertThrows( IllegalArgumentException.class, () -> { - CommonUtil.createPattern("[", Pattern.MULTILINE); + CommonUtil.createPattern("[", MULTILINE); }); assertWithMessage("Invalid exception message") .that(ex) @@ -141,7 +142,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testFileExtensions() { + void fileExtensions() { final String[] fileExtensions = {"java"}; final File pdfFile = new File("file.pdf"); assertWithMessage("Invalid file extension") @@ -174,42 +175,42 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testHasWhitespaceBefore() { + void hasWhitespaceBefore() { assertWithMessage("Invalid result").that(CommonUtil.hasWhitespaceBefore(0, "a")).isTrue(); assertWithMessage("Invalid result").that(CommonUtil.hasWhitespaceBefore(4, " a")).isTrue(); assertWithMessage("Invalid result").that(CommonUtil.hasWhitespaceBefore(5, " a")).isFalse(); } @Test - public void testBaseClassNameForCanonicalName() { + void baseClassNameForCanonicalName() { assertWithMessage("Invalid base class name") .that(CommonUtil.baseClassName("java.util.List")) .isEqualTo("List"); } @Test - public void testBaseClassNameForSimpleName() { + void baseClassNameForSimpleName() { assertWithMessage("Invalid base class name") .that(CommonUtil.baseClassName("Set")) .isEqualTo("Set"); } @Test - public void testRelativeNormalizedPath() { + void relativeNormalizedPath() { final String relativePath = CommonUtil.relativizePath("/home", "/home/test"); assertWithMessage("Invalid relative path").that(relativePath).isEqualTo("test"); } @Test - public void testRelativeNormalizedPathWithNullBaseDirectory() { + void relativeNormalizedPathWithNullBaseDirectory() { final String relativePath = CommonUtil.relativizePath(null, "/tmp"); assertWithMessage("Invalid relative path").that(relativePath).isEqualTo("/tmp"); } @Test - public void testRelativeNormalizedPathWithDenormalizedBaseDirectory() throws IOException { + void relativeNormalizedPathWithDenormalizedBaseDirectory() throws IOException { final String sampleAbsolutePath = new File("src/main/java").getCanonicalPath(); final String absoluteFilePath = sampleAbsolutePath + "/SampleFile.java"; final String basePath = sampleAbsolutePath + PATH_DENORMALIZER; @@ -220,19 +221,19 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testPattern() { + void pattern() { final boolean result = CommonUtil.isPatternValid("someValidPattern"); assertWithMessage("Should return true when pattern is valid").that(result).isTrue(); } @Test - public void testInvalidPattern() { + void invalidPattern() { final boolean result = CommonUtil.isPatternValid("some[invalidPattern"); assertWithMessage("Should return false when pattern is invalid").that(result).isFalse(); } @Test - public void testGetExistingConstructor() throws NoSuchMethodException { + void getExistingConstructor() throws NoSuchMethodException { final Constructor constructor = CommonUtil.getConstructor(String.class, String.class); assertWithMessage("Invalid constructor") @@ -241,7 +242,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testGetNonExistentConstructor() { + void getNonExistentConstructor() { final IllegalStateException ex = assertThrows( IllegalStateException.class, @@ -255,7 +256,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testInvokeConstructor() throws NoSuchMethodException { + void invokeConstructor() throws NoSuchMethodException { final Constructor constructor = String.class.getConstructor(String.class); final String constructedString = CommonUtil.invokeConstructor(constructor, "string"); @@ -265,7 +266,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { @SuppressWarnings("rawtypes") @Test - public void testInvokeConstructorThatFails() throws NoSuchMethodException { + void invokeConstructorThatFails() throws NoSuchMethodException { final Constructor constructor = Dictionary.class.getConstructor(); final IllegalStateException ex = assertThrows( @@ -280,7 +281,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testClose() { + void close() { final TestCloseable closeable = new TestCloseable(); CommonUtil.close(null); @@ -290,7 +291,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testCloseWithException() { + void closeWithException() { final IllegalStateException ex = assertThrows( IllegalStateException.class, @@ -307,7 +308,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testFillTemplateWithStringsByRegexp() { + void fillTemplateWithStringsByRegexp() { assertWithMessage("invalid result") .that( CommonUtil.fillTemplateWithStringsByRegexp( @@ -328,7 +329,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testGetFileNameWithoutExtension() { + void getFileNameWithoutExtension() { assertWithMessage("invalid result") .that(CommonUtil.getFileNameWithoutExtension("filename")) .isEqualTo("filename"); @@ -341,7 +342,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testGetFileExtension() { + void getFileExtension() { assertWithMessage("Invalid extension") .that(CommonUtil.getFileExtension("filename")) .isEqualTo(""); @@ -354,133 +355,133 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testIsIdentifier() { + void isIdentifier() { assertWithMessage("Should return true when valid identifier is passed") .that(CommonUtil.isIdentifier("aValidIdentifier")) .isTrue(); } @Test - public void testIsIdentifierEmptyString() { + void isIdentifierEmptyString() { assertWithMessage("Should return false when empty string is passed") .that(CommonUtil.isIdentifier("")) .isFalse(); } @Test - public void testIsIdentifierInvalidFirstSymbol() { + void isIdentifierInvalidFirstSymbol() { assertWithMessage("Should return false when invalid identifier is passed") .that(CommonUtil.isIdentifier("1InvalidIdentifier")) .isFalse(); } @Test - public void testIsIdentifierInvalidSymbols() { + void isIdentifierInvalidSymbols() { assertWithMessage("Should return false when invalid identifier is passed") .that(CommonUtil.isIdentifier("invalid#Identifier")) .isFalse(); } @Test - public void testIsName() { + void isName() { assertWithMessage("Should return true when valid name is passed") .that(CommonUtil.isName("a.valid.Nam3")) .isTrue(); } @Test - public void testIsNameEmptyString() { + void isNameEmptyString() { assertWithMessage("Should return false when empty string is passed") .that(CommonUtil.isName("")) .isFalse(); } @Test - public void testIsNameInvalidFirstSymbol() { + void isNameInvalidFirstSymbol() { assertWithMessage("Should return false when invalid name is passed") .that(CommonUtil.isName("1.invalid.name")) .isFalse(); } @Test - public void testIsNameEmptyPart() { + void isNameEmptyPart() { assertWithMessage("Should return false when name has empty part") .that(CommonUtil.isName("invalid..name")) .isFalse(); } @Test - public void testIsNameEmptyLastPart() { + void isNameEmptyLastPart() { assertWithMessage("Should return false when name has empty part") .that(CommonUtil.isName("invalid.name.")) .isFalse(); } @Test - public void testIsNameInvalidSymbol() { + void isNameInvalidSymbol() { assertWithMessage("Should return false when invalid name is passed") .that(CommonUtil.isName("invalid.name#42")) .isFalse(); } @Test - public void testIsBlank() { + void isBlank() { assertWithMessage("Should return false when string is not empty") .that(CommonUtil.isBlank("string")) .isFalse(); } @Test - public void testIsBlankAheadWhitespace() { + void isBlankAheadWhitespace() { assertWithMessage("Should return false when string is not empty") .that(CommonUtil.isBlank(" string")) .isFalse(); } @Test - public void testIsBlankBehindWhitespace() { + void isBlankBehindWhitespace() { assertWithMessage("Should return false when string is not empty") .that(CommonUtil.isBlank("string ")) .isFalse(); } @Test - public void testIsBlankWithWhitespacesAround() { + void isBlankWithWhitespacesAround() { assertWithMessage("Should return false when string is not empty") .that(CommonUtil.isBlank(" string ")) .isFalse(); } @Test - public void testIsBlankWhitespaceInside() { + void isBlankWhitespaceInside() { assertWithMessage("Should return false when string is not empty") .that(CommonUtil.isBlank("str ing")) .isFalse(); } @Test - public void testIsBlankNullString() { + void isBlankNullString() { assertWithMessage("Should return true when string is null") .that(CommonUtil.isBlank(null)) .isTrue(); } @Test - public void testIsBlankWithEmptyString() { + void isBlankWithEmptyString() { assertWithMessage("Should return true when string is empty") .that(CommonUtil.isBlank("")) .isTrue(); } @Test - public void testIsBlankWithWhitespacesOnly() { + void isBlankWithWhitespacesOnly() { assertWithMessage("Should return true when string contains only spaces") .that(CommonUtil.isBlank(" ")) .isTrue(); } @Test - public void testGetUriByFilenameFindsAbsoluteResourceOnClasspath() throws Exception { + void getUriByFilenameFindsAbsoluteResourceOnClasspath() throws Exception { final String filename = "/" + getPackageLocation() + "/InputCommonUtilTest_empty_checks.xml"; final URI uri = CommonUtil.getUriByFilename(filename); @@ -491,7 +492,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testGetUriByFilenameFindsRelativeResourceOnClasspath() throws Exception { + void getUriByFilenameFindsRelativeResourceOnClasspath() throws Exception { final String filename = getPackageLocation() + "/InputCommonUtilTest_empty_checks.xml"; final URI uri = CommonUtil.getUriByFilename(filename); @@ -507,7 +508,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { * interpreted relative to the current package "com/puppycrawl/tools/checkstyle/utils/" */ @Test - public void testGetUriByFilenameFindsResourceRelativeToRootClasspath() throws Exception { + void getUriByFilenameFindsResourceRelativeToRootClasspath() throws Exception { final String filename = getPackageLocation() + "/InputCommonUtilTest_resource.txt"; final URI uri = CommonUtil.getUriByFilename(filename); assertWithMessage("URI is null for: " + filename).that(uri).isNotNull(); @@ -518,12 +519,12 @@ public class CommonUtilTest extends AbstractPathTestSupport { assertWithMessage("URI is relative to package " + uriRelativeToPackage) .that(uri.toString()) .doesNotContain(uriRelativeToPackage); - final String content = IOUtils.toString(uri.toURL(), StandardCharsets.UTF_8); + final String content = IOUtils.toString(uri.toURL(), UTF_8); assertWithMessage("Content mismatches for: " + uri).that(content).startsWith("good"); } @Test - public void testGetUriByFilenameClasspathPrefixLoadConfig() throws Exception { + void getUriByFilenameClasspathPrefixLoadConfig() throws Exception { final String filename = CommonUtil.CLASSPATH_URL_PROTOCOL + getPackageLocation() @@ -537,7 +538,7 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testGetUriByFilenameFindsRelativeResourceOnClasspathPrefix() throws Exception { + void getUriByFilenameFindsRelativeResourceOnClasspathPrefix() throws Exception { final String filename = CommonUtil.CLASSPATH_URL_PROTOCOL + getPackageLocation() @@ -551,14 +552,14 @@ public class CommonUtilTest extends AbstractPathTestSupport { } @Test - public void testIsCodePointWhitespace() { + void isCodePointWhitespace() { final int[] codePoints = " 123".codePoints().toArray(); assertThat(CommonUtil.isCodePointWhitespace(codePoints, 0)).isTrue(); assertThat(CommonUtil.isCodePointWhitespace(codePoints, 1)).isFalse(); } @Test - public void testLoadSuppressionsUriSyntaxException() throws Exception { + void loadSuppressionsUriSyntaxException() throws Exception { final URL configUrl = mock(); when(configUrl.toURI()).thenThrow(URISyntaxException.class); try (MockedStatic utilities = mockStatic(CommonUtil.class, CALLS_REAL_METHODS)) { --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/FilterUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/FilterUtilTest.java @@ -23,30 +23,31 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor; import java.io.File; +import java.nio.file.Files; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -public class FilterUtilTest { +final class FilterUtilTest { @TempDir public File temporaryFolder; @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(FilterUtil.class)) .isTrue(); } @Test - public void testExistingFile() throws Exception { - final File file = File.createTempFile("junit", null, temporaryFolder); + void existingFile() throws Exception { + final File file = Files.createTempFile(temporaryFolder.toPath(), "junit", null).toFile(); assertWithMessage("Suppression file exists") .that(FilterUtil.isFileExists(file.getPath())) .isTrue(); } @Test - public void testNonExistentFile() { + void nonExistentFile() { assertWithMessage("Suppression file does not exist") .that(FilterUtil.isFileExists("non-existent.xml")) .isFalse(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/JavadocUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/JavadocUtilTest.java @@ -35,10 +35,10 @@ import com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocTags; import java.util.List; import org.junit.jupiter.api.Test; -public class JavadocUtilTest { +final class JavadocUtilTest { @Test - public void testTags() { + void tags() { final String[] text = { "/** @see elsewhere ", " * {@link List }, {@link List link text }", @@ -51,7 +51,7 @@ public class JavadocUtilTest { } @Test - public void testBlockTag() { + void blockTag() { final String[] text = { "/** @see elsewhere ", " */", }; @@ -61,7 +61,7 @@ public class JavadocUtilTest { } @Test - public void testTagType() { + void tagType() { final String[] text = { "/** @see block", " * {@link List inline}, {@link List#add(Object)}", }; @@ -75,7 +75,7 @@ public class JavadocUtilTest { } @Test - public void testInlineTagLinkText() { + void inlineTagLinkText() { final String[] text = { "/** {@link List link text }", }; @@ -88,7 +88,7 @@ public class JavadocUtilTest { } @Test - public void testInlineTagMethodRef() { + void inlineTagMethodRef() { final String[] text = { "/** {@link List#add(Object)}", }; @@ -101,7 +101,7 @@ public class JavadocUtilTest { } @Test - public void testTagPositions() { + void tagPositions() { final String[] text = { "/** @see elsewhere", " also {@link Name value} */", }; @@ -128,7 +128,7 @@ public class JavadocUtilTest { } @Test - public void testInlineTagPositions() { + void inlineTagPositions() { final String[] text = {"/** Also {@link Name value} */"}; final Comment comment = new Comment(text, 1, 0, text[0].length()); @@ -143,7 +143,7 @@ public class JavadocUtilTest { } @Test - public void testInvalidTags() { + void invalidTags() { final String[] text = { "/** @fake block", " * {@bogus inline}", " * {@link List valid}", }; @@ -166,7 +166,7 @@ public class JavadocUtilTest { } @Test - public void testEmptyBlockComment() { + void emptyBlockComment() { final String emptyComment = ""; assertWithMessage("Should return false when empty string is passed") .that(JavadocUtil.isJavadocComment(emptyComment)) @@ -174,7 +174,7 @@ public class JavadocUtilTest { } @Test - public void testEmptyBlockCommentAst() { + void emptyBlockCommentAst() { final DetailAstImpl commentBegin = new DetailAstImpl(); commentBegin.setType(TokenTypes.BLOCK_COMMENT_BEGIN); commentBegin.setText("/*"); @@ -196,7 +196,7 @@ public class JavadocUtilTest { } @Test - public void testEmptyJavadocComment() { + void emptyJavadocComment() { final String emptyJavadocComment = "*"; assertWithMessage("Should return true when empty javadoc comment is passed") .that(JavadocUtil.isJavadocComment(emptyJavadocComment)) @@ -204,7 +204,7 @@ public class JavadocUtilTest { } @Test - public void testEmptyJavadocCommentAst() { + void emptyJavadocCommentAst() { final DetailAstImpl commentBegin = new DetailAstImpl(); commentBegin.setType(TokenTypes.BLOCK_COMMENT_BEGIN); commentBegin.setText("/*"); @@ -233,21 +233,21 @@ public class JavadocUtilTest { } @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(JavadocUtil.class)) .isTrue(); } @Test - public void testGetTokenNameForId() { + void getTokenNameForId() { assertWithMessage("Invalid token name") .that(JavadocUtil.getTokenName(JavadocTokenTypes.EOF)) .isEqualTo("EOF"); } @Test - public void testGetTokenNameForLargeId() { + void getTokenNameForLargeId() { try { JavadocUtil.getTokenName(30073); assertWithMessage("exception expected").fail(); @@ -259,7 +259,7 @@ public class JavadocUtilTest { } @Test - public void testGetTokenNameForInvalidId() { + void getTokenNameForInvalidId() { try { JavadocUtil.getTokenName(110); assertWithMessage("exception expected").fail(); @@ -271,7 +271,7 @@ public class JavadocUtilTest { } @Test - public void testGetTokenNameForLowerBoundInvalidId() { + void getTokenNameForLowerBoundInvalidId() { try { JavadocUtil.getTokenName(10095); assertWithMessage("exception expected").fail(); @@ -283,7 +283,7 @@ public class JavadocUtilTest { } @Test - public void testGetTokenIdThatIsUnknown() { + void getTokenIdThatIsUnknown() { try { JavadocUtil.getTokenId(""); assertWithMessage("exception expected").fail(); @@ -295,14 +295,14 @@ public class JavadocUtilTest { } @Test - public void testGetTokenId() { + void getTokenId() { final int tokenId = JavadocUtil.getTokenId("JAVADOC"); assertWithMessage("Invalid token id").that(tokenId).isEqualTo(JavadocTokenTypes.JAVADOC); } @Test - public void testGetJavadocCommentContent() { + void getJavadocCommentContent() { final DetailAstImpl detailAST = new DetailAstImpl(); final DetailAstImpl javadoc = new DetailAstImpl(); @@ -314,7 +314,7 @@ public class JavadocUtilTest { } @Test - public void testGetFirstToken() { + void getFirstToken() { final JavadocNodeImpl javadocNode = new JavadocNodeImpl(); final JavadocNodeImpl basetag = new JavadocNodeImpl(); basetag.setType(JavadocTokenTypes.BASE_TAG); @@ -331,7 +331,7 @@ public class JavadocUtilTest { } @Test - public void testGetPreviousSibling() { + void getPreviousSibling() { final JavadocNodeImpl root = new JavadocNodeImpl(); final JavadocNodeImpl node = new JavadocNodeImpl(); @@ -350,14 +350,14 @@ public class JavadocUtilTest { } @Test - public void testGetLastTokenName() { + void getLastTokenName() { assertWithMessage("Unexpected token name") .that(JavadocUtil.getTokenName(10094)) .isEqualTo("RP"); } @Test - public void testEscapeAllControlChars() { + void escapeAllControlChars() { assertWithMessage("invalid result") .that(JavadocUtil.escapeAllControlChars("abc")) .isEqualTo("abc"); --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/ModuleReflectionUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/ModuleReflectionUtilTest.java @@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.PackageObjectFactory.BASE_PACKAGE; import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor; +import com.google.common.collect.ImmutableSet; import com.puppycrawl.tools.checkstyle.AbstractAutomaticBean; import com.puppycrawl.tools.checkstyle.DefaultLogger; import com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent; @@ -38,22 +39,21 @@ import com.puppycrawl.tools.checkstyle.api.Filter; import com.puppycrawl.tools.checkstyle.api.RootModule; import java.io.File; import java.io.IOException; -import java.util.Collections; import java.util.List; import java.util.Set; import org.junit.jupiter.api.Test; -public class ModuleReflectionUtilTest { +final class ModuleReflectionUtilTest { @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(ModuleReflectionUtil.class)) .isTrue(); } @Test - public void testIsCheckstyleModule() { + void isCheckstyleModule() { assertWithMessage("Should return true when checkstyle module is passed") .that(ModuleReflectionUtil.isCheckstyleModule(CheckClass.class)) .isTrue(); @@ -83,9 +83,9 @@ public class ModuleReflectionUtilTest { * ModuleReflectionUtil.getCheckstyleModules is returning an empty set. */ @Test - public void testGetCheckStyleModules() throws IOException { + void getCheckStyleModules() throws IOException { final ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - final Set packages = Collections.singleton(BASE_PACKAGE + ".checks.javadoc.utils"); + final Set packages = ImmutableSet.of(BASE_PACKAGE + ".checks.javadoc.utils"); assertWithMessage("specified package has no checkstyle modules") .that(ModuleReflectionUtil.getCheckstyleModules(packages, classLoader)) @@ -93,7 +93,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testIsValidCheckstyleClass() { + void isValidCheckstyleClass() { assertWithMessage("Should return true when valid checkstyle class is passed") .that(ModuleReflectionUtil.isCheckstyleModule(ValidCheckstyleClass.class)) .isTrue(); @@ -112,7 +112,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testIsCheckstyleCheck() { + void isCheckstyleCheck() { assertWithMessage("Should return true when valid checkstyle check is passed") .that(ModuleReflectionUtil.isCheckstyleTreeWalkerCheck(CheckClass.class)) .isTrue(); @@ -122,7 +122,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testIsFileSetModule() { + void isFileSetModule() { assertWithMessage("Should return true when valid checkstyle file set module is passed") .that(ModuleReflectionUtil.isFileSetModule(FileSetModuleClass.class)) .isTrue(); @@ -132,7 +132,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testIsFilterModule() { + void isFilterModule() { assertWithMessage("Should return true when valid checkstyle filter module is passed") .that(ModuleReflectionUtil.isFilterModule(FilterClass.class)) .isTrue(); @@ -142,7 +142,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testIsFileFilterModule() { + void isFileFilterModule() { assertWithMessage("Should return true when valid checkstyle file filter module is passed") .that(ModuleReflectionUtil.isFileFilterModule(FileFilterModuleClass.class)) .isTrue(); @@ -152,7 +152,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testIsTreeWalkerFilterModule() { + void isTreeWalkerFilterModule() { assertWithMessage("Should return true when valid checkstyle TreeWalker filter module is passed") .that(ModuleReflectionUtil.isTreeWalkerFilterModule(TreeWalkerFilterClass.class)) .isTrue(); @@ -162,7 +162,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testIsAuditListener() { + void isAuditListener() { assertWithMessage("Should return true when valid checkstyle AuditListener module is passed") .that(ModuleReflectionUtil.isAuditListener(DefaultLogger.class)) .isTrue(); @@ -172,7 +172,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testIsRootModule() { + void isRootModule() { assertWithMessage("Should return true when valid checkstyle root module is passed") .that(ModuleReflectionUtil.isRootModule(RootModuleClass.class)) .isTrue(); @@ -182,7 +182,7 @@ public class ModuleReflectionUtilTest { } @Test - public void testKeepEclipseHappy() { + void keepEclipseHappy() { final InvalidNonDefaultConstructorClass test = new InvalidNonDefaultConstructorClass(0); assertWithMessage("should use constructor").that(test).isNotNull(); assertWithMessage("should use field").that(test.getField()).isEqualTo(1); --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/ParserUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/ParserUtilTest.java @@ -26,17 +26,17 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class ParserUtilTest { +final class ParserUtilTest { @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(ParserUtil.class)) .isTrue(); } @Test - public void testCreationOfFakeCommentBlock() { + void creationOfFakeCommentBlock() { final DetailAST testCommentBlock = ParserUtil.createBlockCommentNode("test_comment"); assertWithMessage("Invalid token type") .that(testCommentBlock.getType()) --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/ScopeUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/ScopeUtilTest.java @@ -28,17 +28,17 @@ import com.puppycrawl.tools.checkstyle.api.Scope; import com.puppycrawl.tools.checkstyle.api.TokenTypes; import org.junit.jupiter.api.Test; -public class ScopeUtilTest { +final class ScopeUtilTest { @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(ScopeUtil.class)) .isTrue(); } @Test - public void testInClassBlock() { + void inClassBlock() { assertWithMessage("Should return false when passed is not class") .that(ScopeUtil.isInClassBlock(new DetailAstImpl())) .isFalse(); @@ -76,7 +76,7 @@ public class ScopeUtilTest { } @Test - public void testInEnumBlock() { + void inEnumBlock() { assertWithMessage("Should return false when passed is not enum") .that(ScopeUtil.isInEnumBlock(new DetailAstImpl())) .isFalse(); @@ -114,7 +114,7 @@ public class ScopeUtilTest { } @Test - public void testIsInCodeBlock() { + void isInCodeBlock() { assertWithMessage("invalid result") .that(ScopeUtil.isInCodeBlock(getNode(TokenTypes.CLASS_DEF))) .isFalse(); @@ -139,7 +139,7 @@ public class ScopeUtilTest { } @Test - public void testInRecordBlock() { + void inRecordBlock() { assertWithMessage("Should return false when passed is not record") .that(ScopeUtil.isInRecordBlock(new DetailAstImpl())) .isFalse(); @@ -177,42 +177,42 @@ public class ScopeUtilTest { } @Test - public void testIsOuterMostTypeInterface() { + void isOuterMostTypeInterface() { assertWithMessage("Should return false when passed is not outer most type") .that(ScopeUtil.isOuterMostType(getNode(TokenTypes.INTERFACE_DEF, TokenTypes.MODIFIERS))) .isFalse(); } @Test - public void testIsOuterMostTypeAnnotation() { + void isOuterMostTypeAnnotation() { assertWithMessage("Should return false when passed is not outer most type") .that(ScopeUtil.isOuterMostType(getNode(TokenTypes.ANNOTATION_DEF, TokenTypes.MODIFIERS))) .isFalse(); } @Test - public void testIsOuterMostTypeEnum() { + void isOuterMostTypeEnum() { assertWithMessage("Should return false when passed is not outer most type") .that(ScopeUtil.isOuterMostType(getNode(TokenTypes.ENUM_DEF, TokenTypes.MODIFIERS))) .isFalse(); } @Test - public void testIsOuterMostTypeClass() { + void isOuterMostTypeClass() { assertWithMessage("Should return false when passed is not outer most type") .that(ScopeUtil.isOuterMostType(getNode(TokenTypes.CLASS_DEF, TokenTypes.MODIFIERS))) .isFalse(); } @Test - public void testIsOuterMostTypePackageDef() { + void isOuterMostTypePackageDef() { assertWithMessage("Should return false when passed is not outer most type") .that(ScopeUtil.isOuterMostType(getNode(TokenTypes.PACKAGE_DEF, TokenTypes.DOT))) .isTrue(); } @Test - public void testIsLocalVariableDefCatch() { + void isLocalVariableDefCatch() { assertWithMessage("Should return true when passed is variable def") .that( ScopeUtil.isLocalVariableDef( @@ -221,7 +221,7 @@ public class ScopeUtilTest { } @Test - public void testIsLocalVariableDefUnexpected() { + void isLocalVariableDefUnexpected() { assertWithMessage("Should return false when passed is not variable def") .that(ScopeUtil.isLocalVariableDef(getNode(TokenTypes.LITERAL_CATCH))) .isFalse(); @@ -231,7 +231,7 @@ public class ScopeUtilTest { } @Test - public void testIsLocalVariableDefResource() { + void isLocalVariableDefResource() { final DetailAstImpl node = getNode(TokenTypes.RESOURCE); final DetailAstImpl modifiers = new DetailAstImpl(); modifiers.setType(TokenTypes.MODIFIERS); @@ -251,7 +251,7 @@ public class ScopeUtilTest { } @Test - public void testIsLocalVariableDefVariable() { + void isLocalVariableDefVariable() { assertWithMessage("invalid result") .that(ScopeUtil.isLocalVariableDef(getNode(TokenTypes.SLIST, TokenTypes.VARIABLE_DEF))) .isTrue(); @@ -269,7 +269,7 @@ public class ScopeUtilTest { } @Test - public void testIsClassFieldDef() { + void isClassFieldDef() { assertWithMessage("Should return true when passed is class field def") .that( ScopeUtil.isClassFieldDef( @@ -286,7 +286,7 @@ public class ScopeUtilTest { } @Test - public void testSurroundingScope() { + void surroundingScope() { final Scope publicScope = ScopeUtil.getSurroundingScope( getNodeWithParentScope(TokenTypes.LITERAL_PUBLIC, "public", TokenTypes.ANNOTATION_DEF)); @@ -307,7 +307,7 @@ public class ScopeUtilTest { } @Test - public void testIsInScope() { + void isInScope() { assertWithMessage("Should return true when node is in valid scope") .that( ScopeUtil.isInScope( @@ -325,14 +325,14 @@ public class ScopeUtilTest { } @Test - public void testSurroundingScopeOfNodeChildOfLiteralNewIsAnoninner() { + void surroundingScopeOfNodeChildOfLiteralNewIsAnoninner() { final Scope scope = ScopeUtil.getSurroundingScope(getNode(TokenTypes.LITERAL_NEW, TokenTypes.IDENT)); assertWithMessage("Invalid surrounding scope").that(scope).isEqualTo(Scope.ANONINNER); } @Test - public void testIsInInterfaceBlock() { + void isInInterfaceBlock() { final DetailAST ast = getNode( TokenTypes.INTERFACE_DEF, @@ -349,7 +349,7 @@ public class ScopeUtilTest { } @Test - public void testIsInAnnotationBlock() { + void isInAnnotationBlock() { final DetailAST ast = getNode( TokenTypes.ANNOTATION_DEF, @@ -366,7 +366,7 @@ public class ScopeUtilTest { } @Test - public void testisInInterfaceOrAnnotationBlock() { + void isInInterfaceOrAnnotationBlock() { assertWithMessage("Should return true when node is in interface or annotation block") .that( ScopeUtil.isInInterfaceOrAnnotationBlock( --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/TokenUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/TokenUtilTest.java @@ -34,17 +34,17 @@ import java.util.Optional; import java.util.TreeMap; import org.junit.jupiter.api.Test; -public class TokenUtilTest { +final class TokenUtilTest { @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(TokenUtil.class)) .isTrue(); } @Test - public void testGetIntFromAccessibleField() throws NoSuchFieldException { + void getIntFromAccessibleField() throws NoSuchFieldException { final Field field = Integer.class.getField("MAX_VALUE"); final int maxValue = TokenUtil.getIntFromField(field, 0); @@ -52,7 +52,7 @@ public class TokenUtilTest { } @Test - public void testGetIntFromInaccessibleField() throws NoSuchFieldException { + void getIntFromInaccessibleField() throws NoSuchFieldException { final Field field = Integer.class.getDeclaredField("value"); try { @@ -72,7 +72,7 @@ public class TokenUtilTest { } @Test - public void testNameToValueMapFromPublicIntFields() { + void nameToValueMapFromPublicIntFields() { final Map actualMap = TokenUtil.nameToValueMapFromPublicIntFields(Integer.class); final Map expectedMap = new TreeMap<>(); @@ -85,7 +85,7 @@ public class TokenUtilTest { } @Test - public void testInvertMap() { + void invertMap() { final Map map = new TreeMap<>(); map.put("ZERO", 0); map.put("ONE", 1); @@ -103,7 +103,7 @@ public class TokenUtilTest { } @Test - public void testTokenValueIncorrect() throws IllegalAccessException { + void tokenValueIncorrect() throws IllegalAccessException { int maxId = 0; final Field[] fields = TokenTypes.class.getDeclaredFields(); for (final Field field : fields) { @@ -131,7 +131,7 @@ public class TokenUtilTest { } @Test - public void testTokenValueCorrect() throws IllegalAccessException { + void tokenValueCorrect() throws IllegalAccessException { final Field[] fields = TokenTypes.class.getDeclaredFields(); for (final Field field : fields) { // Only process the int declarations. @@ -147,7 +147,7 @@ public class TokenUtilTest { } @Test - public void testTokenValueIncorrect2() { + void tokenValueIncorrect2() { final int id = 0; try { TokenUtil.getTokenName(id); @@ -160,7 +160,7 @@ public class TokenUtilTest { } @Test - public void testTokenIdIncorrect() { + void tokenIdIncorrect() { final String id = "NON_EXISTENT_VALUE"; try { TokenUtil.getTokenId(id); @@ -173,7 +173,7 @@ public class TokenUtilTest { } @Test - public void testShortDescriptionIncorrect() { + void shortDescriptionIncorrect() { final String id = "NON_EXISTENT_VALUE"; try { TokenUtil.getShortDescription(id); @@ -186,7 +186,7 @@ public class TokenUtilTest { } @Test - public void testIsCommentType() { + void isCommentType() { assertWithMessage("Should return true when valid type passed") .that(TokenUtil.isCommentType(TokenTypes.SINGLE_LINE_COMMENT)) .isTrue(); @@ -211,14 +211,14 @@ public class TokenUtilTest { } @Test - public void testGetTokenTypesTotalNumber() { + void getTokenTypesTotalNumber() { final int tokenTypesTotalNumber = TokenUtil.getTokenTypesTotalNumber(); assertWithMessage("Invalid token total number").that(tokenTypesTotalNumber).isEqualTo(195); } @Test - public void testGetAllTokenIds() { + void getAllTokenIds() { final int[] allTokenIds = TokenUtil.getAllTokenIds(); final int sum = Arrays.stream(allTokenIds).sum(); @@ -227,7 +227,7 @@ public class TokenUtilTest { } @Test - public void testGetTokenNameWithGreatestPossibleId() { + void getTokenNameWithGreatestPossibleId() { final int id = TokenTypes.COMMENT_CONTENT; final String tokenName = TokenUtil.getTokenName(id); @@ -235,7 +235,7 @@ public class TokenUtilTest { } @Test - public void testCorrectBehaviourOfGetTokenId() { + void correctBehaviourOfGetTokenId() { final String id = "COMPILATION_UNIT"; assertWithMessage("Invalid token id") @@ -244,7 +244,7 @@ public class TokenUtilTest { } @Test - public void testCorrectBehaviourOfShortDescription() { + void correctBehaviourOfShortDescription() { final String id = "COMPILATION_UNIT"; final String shortDescription = TokenUtil.getShortDescription(id); @@ -254,7 +254,7 @@ public class TokenUtilTest { } @Test - public void testFindFirstTokenByPredicate() { + void findFirstTokenByPredicate() { final DetailAstImpl astForTest = new DetailAstImpl(); final DetailAstImpl child = new DetailAstImpl(); final DetailAstImpl firstSibling = new DetailAstImpl(); @@ -274,7 +274,7 @@ public class TokenUtilTest { } @Test - public void testForEachChild() { + void forEachChild() { final DetailAstImpl astForTest = new DetailAstImpl(); final DetailAstImpl child = new DetailAstImpl(); final DetailAstImpl firstSibling = new DetailAstImpl(); @@ -296,7 +296,7 @@ public class TokenUtilTest { } @Test - public void testIsTypeDeclaration() { + void isTypeDeclaration() { assertWithMessage("Should return true when valid type passed") .that(TokenUtil.isTypeDeclaration(TokenTypes.CLASS_DEF)) .isTrue(); @@ -315,7 +315,7 @@ public class TokenUtilTest { } @Test - public void testIsOfTypeTrue() { + void isOfTypeTrue() { final int type = TokenTypes.LITERAL_CATCH; final DetailAstImpl astForTest = new DetailAstImpl(); astForTest.setType(type); @@ -331,7 +331,7 @@ public class TokenUtilTest { } @Test - public void testIsOfTypeFalse() { + void isOfTypeFalse() { final int type = TokenTypes.LITERAL_CATCH; final DetailAstImpl astForTest1 = new DetailAstImpl(); final DetailAstImpl astForTest2 = null; @@ -352,7 +352,7 @@ public class TokenUtilTest { } @Test - public void testIsBooleanLiteralType() { + void isBooleanLiteralType() { assertWithMessage("Result is not expected") .that(TokenUtil.isBooleanLiteralType(TokenTypes.LITERAL_TRUE)) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/utils/XpathUtilTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/utils/XpathUtilTest.java @@ -23,6 +23,7 @@ import static com.google.common.truth.Truth.assertWithMessage; import static com.puppycrawl.tools.checkstyle.AbstractPathTestSupport.addEndOfLine; import static com.puppycrawl.tools.checkstyle.internal.utils.TestUtil.isUtilsClassHasPrivateConstructor; import static com.puppycrawl.tools.checkstyle.utils.XpathUtil.getTextAttributeValue; +import static java.nio.charset.StandardCharsets.UTF_8; import com.puppycrawl.tools.checkstyle.DetailAstImpl; import com.puppycrawl.tools.checkstyle.api.CheckstyleException; @@ -32,25 +33,24 @@ import com.puppycrawl.tools.checkstyle.xpath.AbstractNode; import com.puppycrawl.tools.checkstyle.xpath.RootNode; import java.io.File; import java.io.IOException; -import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.List; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; -public class XpathUtilTest { +final class XpathUtilTest { @TempDir public File tempFolder; @Test - public void testIsProperUtilsClass() throws ReflectiveOperationException { + void isProperUtilsClass() throws ReflectiveOperationException { assertWithMessage("Constructor is not private") .that(isUtilsClassHasPrivateConstructor(XpathUtil.class)) .isTrue(); } @Test - public void testSupportsTextAttribute() { + void supportsTextAttribute() { assertWithMessage("Should return true for supported token types") .that(XpathUtil.supportsTextAttribute(createDetailAST(TokenTypes.IDENT))) .isTrue(); @@ -78,7 +78,7 @@ public class XpathUtilTest { } @Test - public void testGetValue() { + void getValue() { assertWithMessage("Returned value differs from expected") .that(getTextAttributeValue(createDetailAST(TokenTypes.STRING_LITERAL, "\"HELLO WORLD\""))) .isEqualTo("HELLO WORLD"); @@ -94,10 +94,10 @@ public class XpathUtilTest { } @Test - public void testPrintXpathNotComment() throws Exception { + void printXpathNotComment() throws Exception { final String fileContent = "class Test { public void method() {int a = 5;}}"; - final File file = File.createTempFile("junit", null, tempFolder); - Files.write(file.toPath(), fileContent.getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(tempFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), fileContent.getBytes(UTF_8)); final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -113,10 +113,10 @@ public class XpathUtilTest { } @Test - public void testPrintXpathComment() throws Exception { + void printXpathComment() throws Exception { final String fileContent = "class Test { /* comment */ }"; - final File file = File.createTempFile("junit", null, tempFolder); - Files.write(file.toPath(), fileContent.getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(tempFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), fileContent.getBytes(UTF_8)); final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -128,10 +128,10 @@ public class XpathUtilTest { } @Test - public void testPrintXpathTwo() throws Exception { + void printXpathTwo() throws Exception { final String fileContent = "class Test { public void method() {int a = 5; int b = 5;}}"; - final File file = File.createTempFile("junit", null, tempFolder); - Files.write(file.toPath(), fileContent.getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(tempFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), fileContent.getBytes(UTF_8)); final String expected = addEndOfLine( "COMPILATION_UNIT -> COMPILATION_UNIT [1:0]", @@ -155,10 +155,10 @@ public class XpathUtilTest { } @Test - public void testInvalidXpath() throws IOException { + void invalidXpath() throws IOException { final String fileContent = "class Test { public void method() {int a = 5; int b = 5;}}"; - final File file = File.createTempFile("junit", null, tempFolder); - Files.write(file.toPath(), fileContent.getBytes(StandardCharsets.UTF_8)); + final File file = Files.createTempFile(tempFolder.toPath(), "junit", null).toFile(); + Files.write(file.toPath(), fileContent.getBytes(UTF_8)); final String invalidXpath = "\\//CLASS_DEF" + "//METHOD_DEF//VARIABLE_DEF//IDENT"; try { XpathUtil.printXpathBranch(invalidXpath, file); @@ -176,7 +176,7 @@ public class XpathUtilTest { } @Test - public void testCreateChildren() { + void createChildren() { final DetailAstImpl rootAst = new DetailAstImpl(); final DetailAstImpl elementAst = new DetailAstImpl(); rootAst.addChild(elementAst); --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/AttributeNodeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/AttributeNodeTest.java @@ -28,31 +28,31 @@ import net.sf.saxon.tree.iter.AxisIterator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class AttributeNodeTest { +final class AttributeNodeTest { private static AttributeNode attributeNode; @BeforeEach - public void init() { + void init() { attributeNode = new AttributeNode("name", "value"); } @Test - public void testGetNamespaceUri() { + void getNamespaceUri() { assertWithMessage("Attribute node should have default namespace URI") .that(attributeNode.getNamespaceUri()) .isEqualTo(NamespaceUri.NULL); } @Test - public void testGetUri() { + void getUri() { assertWithMessage("Attribute node should have blank URI") .that(attributeNode.getURI()) .isEqualTo(""); } @Test - public void testCompareOrder() { + void compareOrder() { try { attributeNode.compareOrder(null); assertWithMessage("Exception is excepted").fail(); @@ -64,7 +64,7 @@ public class AttributeNodeTest { } @Test - public void testGetDepth() { + void getDepth() { final UnsupportedOperationException exception = assertThrows(UnsupportedOperationException.class, attributeNode::getDepth); assertWithMessage("Invalid exception message") @@ -74,14 +74,14 @@ public class AttributeNodeTest { } @Test - public void testHasChildNodes() { + void hasChildNodes() { assertWithMessage("Attribute node shouldn't have children") .that(attributeNode.hasChildNodes()) .isFalse(); } @Test - public void testGetAttributeValue() { + void getAttributeValue() { try { attributeNode.getAttributeValue("", ""); assertWithMessage("Exception is excepted").fail(); @@ -93,7 +93,7 @@ public class AttributeNodeTest { } @Test - public void testGetChildren() { + void getChildren() { final UnsupportedOperationException exception = assertThrows(UnsupportedOperationException.class, attributeNode::getChildren); assertWithMessage("Invalid exception message") @@ -103,7 +103,7 @@ public class AttributeNodeTest { } @Test - public void testGetParent() { + void getParent() { try { attributeNode.getParent(); assertWithMessage("Exception is excepted").fail(); @@ -115,7 +115,7 @@ public class AttributeNodeTest { } @Test - public void testGetRoot() { + void getRoot() { try { attributeNode.getRoot(); assertWithMessage("Exception is excepted").fail(); @@ -127,14 +127,14 @@ public class AttributeNodeTest { } @Test - public void testGetStringValue() { + void getStringValue() { assertWithMessage("Invalid string value") .that(attributeNode.getStringValue()) .isEqualTo("value"); } @Test - public void testIterate() { + void iterate() { try (AxisIterator ignored = attributeNode.iterateAxis(AxisInfo.SELF)) { assertWithMessage("Exception is excepted").fail(); } catch (UnsupportedOperationException ex) { @@ -145,7 +145,7 @@ public class AttributeNodeTest { } @Test - public void testGetLineNumber() { + void getLineNumber() { try { attributeNode.getLineNumber(); assertWithMessage("Exception is excepted").fail(); @@ -157,7 +157,7 @@ public class AttributeNodeTest { } @Test - public void testGetColumnNumber() { + void getColumnNumber() { try { attributeNode.getColumnNumber(); assertWithMessage("Exception is excepted").fail(); @@ -169,7 +169,7 @@ public class AttributeNodeTest { } @Test - public void testGetTokenType() { + void getTokenType() { try { attributeNode.getTokenType(); assertWithMessage("Exception is excepted").fail(); @@ -181,7 +181,7 @@ public class AttributeNodeTest { } @Test - public void testGetUnderlyingNode() { + void getUnderlyingNode() { try { attributeNode.getUnderlyingNode(); assertWithMessage("Exception is excepted").fail(); @@ -193,7 +193,7 @@ public class AttributeNodeTest { } @Test - public void testGetAllNamespaces() { + void getAllNamespaces() { try { attributeNode.getAllNamespaces(); assertWithMessage("Exception is excepted").fail(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/ElementNodeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/ElementNodeTest.java @@ -39,7 +39,7 @@ import net.sf.saxon.tree.iter.EmptyIterator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class ElementNodeTest extends AbstractPathTestSupport { +final class ElementNodeTest extends AbstractPathTestSupport { private static RootNode rootNode; @@ -49,14 +49,14 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @BeforeEach - public void init() throws Exception { + void init() throws Exception { final File file = new File(getPath("InputXpathMapperAst.java")); final DetailAST rootAst = JavaParser.parseFile(file, JavaParser.Options.WITHOUT_COMMENTS); rootNode = new RootNode(rootAst); } @Test - public void testParentChildOrdering() { + void parentChildOrdering() { final DetailAstImpl detailAST = new DetailAstImpl(); detailAST.setType(TokenTypes.VARIABLE_DEF); @@ -75,7 +75,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testSiblingsOrdering() { + void siblingsOrdering() { final DetailAstImpl detailAst1 = new DetailAstImpl(); detailAst1.setType(TokenTypes.VARIABLE_DEF); @@ -99,7 +99,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testCompareOrderWrongInstance() throws Exception { + void compareOrderWrongInstance() throws Exception { final String xpath = "//OBJBLOCK"; final List nodes = getXpathItems(xpath, rootNode); final int result = nodes.get(0).compareOrder(null); @@ -107,7 +107,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testGetParent() throws Exception { + void getParent() throws Exception { final String xpath = "//OBJBLOCK"; final List nodes = getXpathItems(xpath, rootNode); assertWithMessage("Invalid number of nodes").that(nodes).hasSize(1); @@ -118,7 +118,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testRootOfElementNode() throws Exception { + void rootOfElementNode() throws Exception { final String xpath = "//OBJBLOCK"; final List nodes = getXpathItems(xpath, rootNode); assertWithMessage("Invalid number of nodes").that(nodes).hasSize(1); @@ -132,7 +132,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testGetNodeByValueNumInt() throws Exception { + void getNodeByValueNumInt() throws Exception { final String xPath = "//NUM_INT[@text = 123]"; final List nodes = getXpathItems(xPath, rootNode); assertWithMessage("Invalid number of nodes").that(nodes).hasSize(1); @@ -141,7 +141,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testGetNodeByValueStringLiteral() throws Exception { + void getNodeByValueStringLiteral() throws Exception { final String xPath = "//STRING_LITERAL[@text = 'HelloWorld']"; final List nodes = getXpathItems(xPath, rootNode); assertWithMessage("Invalid number of nodes").that(nodes).hasSize(2); @@ -150,14 +150,14 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testGetNodeByValueWithSameTokenText() throws Exception { + void getNodeByValueWithSameTokenText() throws Exception { final String xPath = "//MODIFIERS[@text = 'MODIFIERS']"; final List nodes = getXpathItems(xPath, rootNode); assertWithMessage("Invalid number of nodes").that(nodes).hasSize(0); } @Test - public void testGetAttributeValue() { + void getAttributeValue() { final DetailAstImpl detailAST = new DetailAstImpl(); detailAST.setType(TokenTypes.IDENT); detailAST.setText("HelloWorld"); @@ -170,7 +170,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testGetAttributeCached() { + void getAttributeCached() { final DetailAstImpl detailAST = new DetailAstImpl(); detailAST.setType(TokenTypes.IDENT); detailAST.setText("HelloWorld"); @@ -185,7 +185,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testGetAttributeValueNoAttribute() { + void getAttributeValueNoAttribute() { final DetailAstImpl detailAST = new DetailAstImpl(); detailAST.setType(TokenTypes.CLASS_DEF); detailAST.setText("HelloWorld"); @@ -198,7 +198,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testGetAttributeValueWrongAttribute() { + void getAttributeValueWrongAttribute() { final DetailAstImpl detailAST = new DetailAstImpl(); detailAST.setType(TokenTypes.IDENT); detailAST.setText("HelloWorld"); @@ -211,7 +211,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testIterateAxisEmptyChildren() { + void iterateAxisEmptyChildren() { final DetailAstImpl detailAST = new DetailAstImpl(); detailAST.setType(TokenTypes.METHOD_DEF); final ElementNode elementNode = new ElementNode(rootNode, rootNode, detailAST, 1, 0); @@ -224,7 +224,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testIterateAxisWithChildren() { + void iterateAxisWithChildren() { final DetailAstImpl detailAST = new DetailAstImpl(); detailAST.setType(TokenTypes.METHOD_DEF); final DetailAstImpl childAst = new DetailAstImpl(); @@ -240,7 +240,7 @@ public class ElementNodeTest extends AbstractPathTestSupport { } @Test - public void testIterateAxisWithNoSiblings() { + void iterateAxisWithNoSiblings() { final DetailAstImpl detailAST = new DetailAstImpl(); detailAST.setType(TokenTypes.VARIABLE_DEF); --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/RootNodeTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/RootNodeTest.java @@ -36,7 +36,7 @@ import net.sf.saxon.tree.iter.EmptyIterator; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class RootNodeTest extends AbstractPathTestSupport { +final class RootNodeTest extends AbstractPathTestSupport { private static RootNode rootNode; @@ -46,14 +46,14 @@ public class RootNodeTest extends AbstractPathTestSupport { } @BeforeEach - public void init() throws Exception { + void init() throws Exception { final File file = new File(getPath("InputXpathMapperAst.java")); final DetailAST rootAst = JavaParser.parseFile(file, JavaParser.Options.WITHOUT_COMMENTS); rootNode = new RootNode(rootAst); } @Test - public void testCompareOrder() { + void compareOrder() { try { rootNode.compareOrder(null); assertWithMessage("Exception is excepted").fail(); @@ -65,7 +65,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testXpath() throws Exception { + void xpath() throws Exception { final String xpath = "/"; final List nodes = getXpathItems(xpath, rootNode); assertWithMessage("Invalid number of nodes").that(nodes).hasSize(1); @@ -79,24 +79,24 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetDepth() { + void getDepth() { assertWithMessage("Root node depth should be 0").that(rootNode.getDepth()).isEqualTo(0); } @Test - public void testGetTokenType() { + void getTokenType() { assertWithMessage("Invalid token type") .that(rootNode.getTokenType()) .isEqualTo(TokenTypes.COMPILATION_UNIT); } @Test - public void testGetLineNumber() { + void getLineNumber() { assertWithMessage("Invalid line number").that(rootNode.getLineNumber()).isEqualTo(1); } @Test - public void testGetColumnNumber() { + void getColumnNumber() { assertWithMessage("Invalid column number").that(rootNode.getColumnNumber()).isEqualTo(0); } @@ -106,7 +106,7 @@ public class RootNodeTest extends AbstractPathTestSupport { * Test exists until https://github.com/checkstyle/checkstyle/issues/4997 */ @Test - public void testNonRealGetColumnNumber() { + void nonRealGetColumnNumber() { final DetailAstImpl nonRealNode = new DetailAstImpl(); nonRealNode.setType(TokenTypes.PACKAGE_DEF); nonRealNode.setLineNo(555); @@ -119,12 +119,12 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetLocalPart() { + void getLocalPart() { assertWithMessage("Invalid local part").that(rootNode.getLocalPart()).isEqualTo("ROOT"); } @Test - public void testIterate() { + void iterate() { try (AxisIterator following = rootNode.iterateAxis(AxisInfo.FOLLOWING)) { assertWithMessage("Result iterator does not match expected") .that(following) @@ -158,7 +158,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testRootWithNullDetailAst() { + void rootWithNullDetailAst() { final RootNode emptyRootNode = new RootNode(null); assertWithMessage("Empty node should not have children") .that(emptyRootNode.hasChildNodes()) @@ -177,7 +177,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetStringValue() { + void getStringValue() { try { rootNode.getStringValue(); assertWithMessage("Exception is excepted").fail(); @@ -189,7 +189,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetAttributeValue() { + void getAttributeValue() { try { rootNode.getAttributeValue("", ""); assertWithMessage("Exception is excepted").fail(); @@ -201,7 +201,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetDeclaredNamespaces() { + void getDeclaredNamespaces() { try { rootNode.getDeclaredNamespaces(null); assertWithMessage("Exception is excepted").fail(); @@ -213,7 +213,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testIsId() { + void isId() { try { rootNode.isId(); assertWithMessage("Exception is excepted").fail(); @@ -225,7 +225,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testIsIdref() { + void isIdref() { try { rootNode.isIdref(); assertWithMessage("Exception is excepted").fail(); @@ -237,7 +237,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testIsNilled() { + void isNilled() { try { rootNode.isNilled(); assertWithMessage("Exception is excepted").fail(); @@ -249,7 +249,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testIsStreamed() { + void isStreamed() { try { rootNode.isStreamed(); assertWithMessage("Exception is excepted").fail(); @@ -261,7 +261,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetConfiguration() { + void getConfiguration() { try { rootNode.getConfiguration(); assertWithMessage("Exception is excepted").fail(); @@ -273,7 +273,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testSetSystemId() { + void setSystemId() { try { rootNode.setSystemId("1"); assertWithMessage("Exception is excepted").fail(); @@ -285,7 +285,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetSystemId() { + void getSystemId() { try { rootNode.getSystemId(); assertWithMessage("Exception is excepted").fail(); @@ -297,7 +297,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetPublicId() { + void getPublicId() { try { rootNode.getPublicId(); assertWithMessage("Exception is excepted").fail(); @@ -309,7 +309,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testBaseUri() { + void baseUri() { try { rootNode.getBaseURI(); assertWithMessage("Exception is excepted").fail(); @@ -321,7 +321,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testSaveLocation() { + void saveLocation() { try { rootNode.saveLocation(); assertWithMessage("Exception is excepted").fail(); @@ -333,7 +333,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetStringValueCs() { + void getStringValueCs() { try { rootNode.getUnicodeStringValue(); assertWithMessage("Exception is excepted").fail(); @@ -345,7 +345,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testFingerprint() { + void fingerprint() { try { rootNode.getFingerprint(); assertWithMessage("Exception is excepted").fail(); @@ -357,7 +357,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetDisplayName() { + void getDisplayName() { try { rootNode.getDisplayName(); assertWithMessage("Exception is excepted").fail(); @@ -369,7 +369,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetPrefix() { + void getPrefix() { try { rootNode.getPrefix(); assertWithMessage("Exception is excepted").fail(); @@ -381,7 +381,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetSchemaType() { + void getSchemaType() { try { rootNode.getSchemaType(); assertWithMessage("Exception is excepted").fail(); @@ -393,7 +393,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testAtomize() { + void atomize() { try { rootNode.atomize(); assertWithMessage("Exception is excepted").fail(); @@ -405,7 +405,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGenerateId() { + void generateId() { try { rootNode.generateId(null); assertWithMessage("Exception is excepted").fail(); @@ -417,7 +417,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testCopy() { + void copy() { try { rootNode.copy(null, -1, null); assertWithMessage("Exception is excepted").fail(); @@ -429,7 +429,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testGetAllNamespaces() { + void getAllNamespaces() { try { rootNode.getAllNamespaces(); assertWithMessage("Exception is excepted").fail(); @@ -441,7 +441,7 @@ public class RootNodeTest extends AbstractPathTestSupport { } @Test - public void testSameNodeInfo() { + void sameNodeInfo() { assertWithMessage("Should return true, because object is being compared to itself") .that(rootNode.isSameNodeInfo(rootNode)) .isTrue(); --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/XpathMapperTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/XpathMapperTest.java @@ -31,7 +31,7 @@ import java.util.List; import net.sf.saxon.om.NodeInfo; import org.junit.jupiter.api.Test; -public class XpathMapperTest extends AbstractModuleTestSupport { +final class XpathMapperTest extends AbstractModuleTestSupport { @Override protected String getPackageLocation() { @@ -39,7 +39,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testNodeOrdering() throws Exception { + void nodeOrdering() throws Exception { final String xpath = "//METHOD_DEF/SLIST/*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -60,7 +60,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testFullPath() throws Exception { + void fullPath() throws Exception { final String xpath = "/COMPILATION_UNIT/CLASS_DEF/OBJBLOCK" + "/METHOD_DEF[1]/SLIST/VARIABLE_DEF[2]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); @@ -79,7 +79,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testParent() throws Exception { + void parent() throws Exception { final String xpath = "(//VARIABLE_DEF)[1]/.."; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -94,7 +94,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testCurlyBrackets() throws Exception { + void curlyBrackets() throws Exception { final String xpath = "(//RCURLY)[2]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -110,7 +110,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testOr() throws Exception { + void or() throws Exception { final String xpath = "//CLASS_DEF | //METHOD_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -129,7 +129,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testComplexQueryOne() throws Exception { + void complexQueryOne() throws Exception { final String xpath = "//CLASS_DEF | //CLASS_DEF/OBJBLOCK"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -142,7 +142,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testComplexQueryTwo() throws Exception { + void complexQueryTwo() throws Exception { final String xpath = "//PACKAGE_DEF | //PACKAGE_DEF/ANNOTATIONS"; final RootNode rootNode = getRootNode("InputXpathMapperAnnotation.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -156,7 +156,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testComplexQueryThree() throws Exception { + void complexQueryThree() throws Exception { final String xpath = "//CLASS_DEF | //CLASS_DEF//METHOD_DEF |" + " /COMPILATION_UNIT/CLASS_DEF/OBJBLOCK"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); @@ -176,7 +176,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testAttributeOr() throws Exception { + void attributeOr() throws Exception { final String xpath = "//METHOD_DEF[./IDENT[@text='getSomeMethod'] " + "or ./IDENT[@text='nonExistentMethod']]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); @@ -194,7 +194,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testAttributeAnd() throws Exception { + void attributeAnd() throws Exception { final String xpath = "//METHOD_DEF[./IDENT[@text='callSomeMethod'] and " + "../..[./IDENT[@text='InputXpathMapperAst']]]"; @@ -212,7 +212,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryAllElementsWithAttribute() throws Exception { + void queryAllElementsWithAttribute() throws Exception { final String xpath = "//*[./IDENT[@text]]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -220,7 +220,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementByIndex() throws Exception { + void queryElementByIndex() throws Exception { final String xpath = "(//VARIABLE_DEF)[1]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -237,7 +237,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryAllVariableDefinitionsWithAttribute() throws Exception { + void queryAllVariableDefinitionsWithAttribute() throws Exception { final String xpath = "//VARIABLE_DEF[./IDENT[@*]]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -245,7 +245,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryAllVariableDefWrongAttribute() throws Exception { + void queryAllVariableDefWrongAttribute() throws Exception { final String xpath = "//VARIABLE_DEF[@qwe]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -253,7 +253,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryAllMethodDefinitionsInContext() throws Exception { + void queryAllMethodDefinitionsInContext() throws Exception { final String objectXpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperAst']]//OBJBLOCK"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List objectNodes = getXpathItems(objectXpath, rootNode); @@ -279,7 +279,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryAllClassDefinitions() throws Exception { + void queryAllClassDefinitions() throws Exception { final String xpath = "/COMPILATION_UNIT/CLASS_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -296,7 +296,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryByMethodName() throws Exception { + void queryByMethodName() throws Exception { final String xpath = "//METHOD_DEF[./IDENT[@text='getSomeMethod']]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -311,7 +311,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryMethodDefinitionsByClassName() throws Exception { + void queryMethodDefinitionsByClassName() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperAst']]" + "//OBJBLOCK//METHOD_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); @@ -332,7 +332,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryByClassNameAndMethodName() throws Exception { + void queryByClassNameAndMethodName() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperAst']]//OBJBLOCK" + "//METHOD_DEF[./IDENT[@text='getSomeMethod']]"; @@ -349,7 +349,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryClassDefinitionByClassName() throws Exception { + void queryClassDefinitionByClassName() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperAst']]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -364,7 +364,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryWrongClassName() throws Exception { + void queryWrongClassName() throws Exception { final String xpath = "/CLASS_DEF[@text='WrongName']"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -372,7 +372,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryWrongXpath() throws Exception { + void queryWrongXpath() throws Exception { final String xpath = "/WRONG_XPATH"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -380,7 +380,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryAncestor() throws Exception { + void queryAncestor() throws Exception { final String xpath = "//VARIABLE_DEF[./IDENT[@text='another']]/ancestor::METHOD_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -394,7 +394,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryAncestorOrSelf() throws Exception { + void queryAncestorOrSelf() throws Exception { final String xpath = "//VARIABLE_DEF[./IDENT[@text='another']]" + "/ancestor-or-self::VARIABLE_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); @@ -413,7 +413,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryDescendant() throws Exception { + void queryDescendant() throws Exception { final String xpath = "//METHOD_DEF/descendant::EXPR"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -421,7 +421,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryDescendantOrSelf() throws Exception { + void queryDescendantOrSelf() throws Exception { final String xpath = "//METHOD_DEF/descendant-or-self::METHOD_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -441,7 +441,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryNoChild() throws Exception { + void queryNoChild() throws Exception { final String xpath = "//RCURLY/METHOD_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -449,7 +449,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryNoDescendant() throws Exception { + void queryNoDescendant() throws Exception { final String xpath = "//RCURLY/descendant::METHOD_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -457,7 +457,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryRootNotImplementedAxis() throws Exception { + void queryRootNotImplementedAxis() throws Exception { final String xpath = "//namespace::*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); try { @@ -471,7 +471,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementNotImplementedAxis() throws Exception { + void queryElementNotImplementedAxis() throws Exception { final String xpath = "/COMPILATION_UNIT/CLASS_DEF//namespace::*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); try { @@ -485,7 +485,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQuerySelf() throws Exception { + void querySelf() throws Exception { final String objectXpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperAst']]//OBJBLOCK"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List objectNodes = getXpathItems(objectXpath, rootNode); @@ -502,7 +502,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryNonExistentAttribute() throws Exception { + void queryNonExistentAttribute() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperAst']]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -513,7 +513,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryRootSelf() throws Exception { + void queryRootSelf() throws Exception { final String xpath = "self::node()"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -521,7 +521,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryAnnotation() throws Exception { + void queryAnnotation() throws Exception { final String xpath = "//ANNOTATION[./IDENT[@text='Deprecated']]"; final RootNode rootNode = getRootNode("InputXpathMapperAnnotation.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -535,7 +535,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryNonExistentAnnotation() throws Exception { + void queryNonExistentAnnotation() throws Exception { final String xpath = "//ANNOTATION[@text='SpringBootApplication']"; final RootNode rootNode = getRootNode("InputXpathMapperAnnotation.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -543,7 +543,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryEnumDef() throws Exception { + void queryEnumDef() throws Exception { final String xpath = "/COMPILATION_UNIT/ENUM_DEF"; final RootNode enumRootNode = getRootNode("InputXpathMapperEnum.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, enumRootNode)); @@ -555,7 +555,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryEnumElementsNumber() throws Exception { + void queryEnumElementsNumber() throws Exception { final String xpath = "/COMPILATION_UNIT/ENUM_DEF/OBJBLOCK/ENUM_CONSTANT_DEF"; final RootNode enumRootNode = getRootNode("InputXpathMapperEnum.java"); final List nodes = getXpathItems(xpath, enumRootNode); @@ -563,7 +563,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryEnumElementByName() throws Exception { + void queryEnumElementByName() throws Exception { final String xpath = "//*[./IDENT[@text='TWO']]"; final RootNode enumRootNode = getRootNode("InputXpathMapperEnum.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, enumRootNode)); @@ -579,7 +579,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryInterfaceDef() throws Exception { + void queryInterfaceDef() throws Exception { final String xpath = "//INTERFACE_DEF"; final RootNode interfaceRootNode = getRootNode("InputXpathMapperInterface.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, interfaceRootNode)); @@ -591,7 +591,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryInterfaceMethodDefNumber() throws Exception { + void queryInterfaceMethodDefNumber() throws Exception { final String xpath = "//INTERFACE_DEF/OBJBLOCK/METHOD_DEF"; final RootNode interfaceRootNode = getRootNode("InputXpathMapperInterface.java"); final List nodes = getXpathItems(xpath, interfaceRootNode); @@ -599,7 +599,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryInterfaceParameterDef() throws Exception { + void queryInterfaceParameterDef() throws Exception { final String xpath = "//PARAMETER_DEF[./IDENT[@text='someVariable']]/../.."; final RootNode interfaceRootNode = getRootNode("InputXpathMapperInterface.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, interfaceRootNode)); @@ -614,7 +614,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testIdent() throws Exception { + void ident() throws Exception { final String xpath = "//CLASS_DEF/IDENT[@text='InputXpathMapperAst']"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List nodes = getXpathItems(xpath, rootNode); @@ -629,7 +629,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testIdentByText() throws Exception { + void identByText() throws Exception { final String xpath = "//IDENT[@text='puppycrawl']"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -648,7 +648,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testNumVariableByItsValue() throws Exception { + void numVariableByItsValue() throws Exception { final String xpath = "//VARIABLE_DEF[.//NUM_INT[@text=123]]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -664,7 +664,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testStringVariableByItsValue() throws Exception { + void stringVariableByItsValue() throws Exception { final String xpath = "//VARIABLE_DEF[./ASSIGN/EXPR" + "/STRING_LITERAL[@text='HelloWorld']]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -682,7 +682,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testSameNodesByNameAndByText() throws Exception { + void sameNodesByNameAndByText() throws Exception { final String xpath1 = "//VARIABLE_DEF[./IDENT[@text='another']]/ASSIGN/EXPR/STRING_LITERAL"; final String xpath2 = "//VARIABLE_DEF/ASSIGN/EXPR/STRING_LITERAL[@text='HelloWorld']"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); @@ -692,7 +692,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testMethodDefByAnnotationValue() throws Exception { + void methodDefByAnnotationValue() throws Exception { final String xpath = "//METHOD_DEF[.//ANNOTATION[./IDENT[@text='SuppressWarnings']" + " and .//*[@text='good']]]"; @@ -709,7 +709,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testFirstImport() throws Exception { + void firstImport() throws Exception { final String xpath = "/COMPILATION_UNIT/IMPORT[1]"; final RootNode rootNode = getRootNode("InputXpathMapperPositions.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -721,7 +721,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testSecondImport() throws Exception { + void secondImport() throws Exception { final String xpath = "/COMPILATION_UNIT/IMPORT[2]"; final RootNode rootNode = getRootNode("InputXpathMapperPositions.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -734,7 +734,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testThirdImport() throws Exception { + void thirdImport() throws Exception { final String xpath = "/COMPILATION_UNIT/IMPORT[3]"; final RootNode rootNode = getRootNode("InputXpathMapperPositions.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -748,7 +748,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testLastImport() throws Exception { + void lastImport() throws Exception { final String xpath = "/COMPILATION_UNIT/IMPORT[9]"; final RootNode rootNode = getRootNode("InputXpathMapperPositions.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -768,7 +768,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testFirstCaseGroup() throws Exception { + void firstCaseGroup() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperPositions']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='switchMethod']]" @@ -788,7 +788,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testSecondCaseGroup() throws Exception { + void secondCaseGroup() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperPositions']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='switchMethod']]" @@ -809,7 +809,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testThirdCaseGroup() throws Exception { + void thirdCaseGroup() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperPositions']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='switchMethod']]" @@ -831,7 +831,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testFourthCaseGroup() throws Exception { + void fourthCaseGroup() throws Exception { final String xpath = "//CLASS_DEF[./IDENT[@text='InputXpathMapperPositions']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='switchMethod']]" @@ -854,7 +854,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementFollowingSibling() throws Exception { + void queryElementFollowingSibling() throws Exception { final String xpath = "//METHOD_DEF/following-sibling::*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -873,7 +873,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementNoFollowingSibling() throws Exception { + void queryElementNoFollowingSibling() throws Exception { final String xpath = "//CLASS_DEF/following-sibling::*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -881,7 +881,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementFollowingSiblingRcurly() throws Exception { + void queryElementFollowingSiblingRcurly() throws Exception { final String xpath = "//METHOD_DEF/following-sibling::RCURLY"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -897,7 +897,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementFollowing() throws Exception { + void queryElementFollowing() throws Exception { final String xpath = "//IDENT[@text='variable']/following::*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final List actual = getXpathItems(xpath, rootNode); @@ -907,7 +907,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementFollowingTwo() throws Exception { + void queryElementFollowingTwo() throws Exception { final String xpath = "//LITERAL_RETURN[.//STRING_LITERAL[@text='HelloWorld']]/following::*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -928,7 +928,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementFollowingMethodDef() throws Exception { + void queryElementFollowingMethodDef() throws Exception { final String xpath = "//PACKAGE_DEF/following::METHOD_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -948,7 +948,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementNoFollowing() throws Exception { + void queryElementNoFollowing() throws Exception { final String xpath = "//CLASS_DEF/following::*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -956,7 +956,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementPrecedingSibling() throws Exception { + void queryElementPrecedingSibling() throws Exception { final String xpath = "//VARIABLE_DEF[./IDENT[@text='array']]/preceding-sibling::*"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -977,7 +977,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementPrecedingSiblingVariableDef() throws Exception { + void queryElementPrecedingSiblingVariableDef() throws Exception { final String xpath = "//VARIABLE_DEF[./IDENT[@text='array']]/preceding-sibling::" + "VARIABLE_DEF"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); @@ -996,7 +996,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementPrecedingSiblingArray() throws Exception { + void queryElementPrecedingSiblingArray() throws Exception { final String xpath = "//VARIABLE_DEF[./IDENT[@text='array']]/preceding-sibling::*[1]"; final RootNode rootNode = getRootNode("InputXpathMapperAst.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -1014,7 +1014,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementPrecedingOne() throws Exception { + void queryElementPrecedingOne() throws Exception { final String xpath = "//LITERAL_CLASS/preceding::*"; final RootNode rootNode = getRootNode("InputXpathMapperSingleTopClass.java"); final DetailAST[] actual = @@ -1023,7 +1023,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementPrecedingTwo() throws Exception { + void queryElementPrecedingTwo() throws Exception { final String xpath = "//PACKAGE_DEF/DOT/preceding::*"; final RootNode rootNode = getRootNode("InputXpathMapperSingleTopClass.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -1038,7 +1038,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQueryElementPrecedingLiteralPublic() throws Exception { + void queryElementPrecedingLiteralPublic() throws Exception { final String xpath = "//LITERAL_CLASS/preceding::LITERAL_PUBLIC"; final RootNode rootNode = getRootNode("InputXpathMapperSingleTopClass.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -1052,7 +1052,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testTextBlockByItsValue() throws Exception { + void textBlockByItsValue() throws Exception { final String xpath = "//TEXT_BLOCK_LITERAL_BEGIN[./TEXT_BLOCK_CONTENT" + "[@text='\\n &1line\\n >2line\\n <3line\\n ']]"; @@ -1071,7 +1071,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testQuerySingleLineCommentByCommentContent() throws Exception { + void querySingleLineCommentByCommentContent() throws Exception { final String xpath = "//SINGLE_LINE_COMMENT[./COMMENT_CONTENT[@text=' some comment\\n']]"; final RootNode rootNode = getRootNodeWithComments("InputXpathMapperSingleLineComment.java"); final DetailAST[] actual = convertToArray(getXpathItems(xpath, rootNode)); @@ -1085,7 +1085,7 @@ public class XpathMapperTest extends AbstractModuleTestSupport { } @Test - public void testManyNestedNodes() throws Exception { + void manyNestedNodes() throws Exception { final String xpath = "//STRING_LITERAL"; final RootNode rootNode = getRootNode("InputXpathMapperStringConcat.java"); final List actual = getXpathItems(xpath, rootNode); --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/XpathQueryGeneratorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/XpathQueryGeneratorTest.java @@ -21,6 +21,7 @@ package com.puppycrawl.tools.checkstyle.xpath; import static com.google.common.truth.Truth.assertWithMessage; +import com.google.common.collect.ImmutableList; import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport; import com.puppycrawl.tools.checkstyle.JavaParser; import com.puppycrawl.tools.checkstyle.TreeWalkerAuditEvent; @@ -32,12 +33,11 @@ import com.puppycrawl.tools.checkstyle.api.Violation; import java.io.File; import java.nio.charset.StandardCharsets; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { +final class XpathQueryGeneratorTest extends AbstractModuleTestSupport { private static final int DEFAULT_TAB_WIDTH = 4; @@ -51,14 +51,14 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @BeforeEach - public void init() throws Exception { + void init() throws Exception { final File file = new File(getPath("InputXpathQueryGenerator.java")); fileText = new FileText(file, StandardCharsets.UTF_8.name()); rootAst = JavaParser.parseFile(file, JavaParser.Options.WITH_COMMENTS); } @Test - public void testClassDef() { + void classDef() { final int lineNumber = 12; final int columnNumber = 1; final XpathQueryGenerator queryGenerator = @@ -76,7 +76,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testMethodDef() { + void methodDef() { final int lineNumber = 45; final int columnNumber = 5; final XpathQueryGenerator queryGenerator = @@ -96,7 +96,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testVariableDef() { + void variableDef() { final int lineNumber = 53; final int columnNumber = 13; final XpathQueryGenerator queryGenerator = @@ -126,14 +126,14 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testLcurly() { + void lcurly() { final int lineNumber = 37; final int columnNumber = 20; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='Label']]/SLIST/LITERAL_SWITCH/LCURLY"); assertWithMessage("Generated queries do not match expected ones") @@ -142,14 +142,14 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testRcurly() { + void rcurly() { final int lineNumber = 25; final int columnNumber = 5; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]/OBJBLOCK" + "/INSTANCE_INIT/SLIST/RCURLY"); assertWithMessage("Generated queries do not match expected ones") @@ -158,7 +158,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testExpr() { + void expr() { final int lineNumber = 17; final int columnNumber = 50; final XpathQueryGenerator queryGenerator = @@ -176,14 +176,14 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testLparen() { + void lparen() { final int lineNumber = 45; final int columnNumber = 31; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='callSomeMethod']]/LPAREN"); assertWithMessage("Generated queries do not match expected ones") @@ -192,7 +192,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testEmpty() { + void empty() { final int lineNumber = 300; final int columnNumber = 300; final XpathQueryGenerator queryGenerator = @@ -202,7 +202,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testPackage() { + void testPackage() { final int lineNumber = 2; final int columnNumber = 1; final XpathQueryGenerator queryGenerator = @@ -216,21 +216,21 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testImport() { + void testImport() { final int lineNumber = 5; final int columnNumber = 1; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='File']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='File']]"); assertWithMessage("Generated queries do not match expected ones") .that(actual) .isEqualTo(expected); } @Test - public void testMethodParams() { + void methodParams() { final int lineNumber = 72; final int columnNumber = 30; final XpathQueryGenerator queryGenerator = @@ -262,14 +262,14 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testSwitch() { + void testSwitch() { final int lineNumber = 37; final int columnNumber = 9; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]" + "/OBJBLOCK/METHOD_DEF[./IDENT[@text='Label']]/SLIST/LITERAL_SWITCH"); assertWithMessage("Generated queries do not match expected ones") @@ -278,7 +278,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testSwitchCase() { + void switchCase() { final int lineNumber = 38; final int columnNumber = 13; final XpathQueryGenerator queryGenerator = @@ -298,7 +298,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testVariableStringLiteral() { + void variableStringLiteral() { final int lineNumber = 47; final int columnNumber = 26; final XpathQueryGenerator queryGenerator = @@ -320,14 +320,14 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testComma() { + void comma() { final int lineNumber = 66; final int columnNumber = 36; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='InputXpathQueryGenerator']]/OBJBLOCK/METHOD_DEF[" + "./IDENT[@text='foo']]/SLIST/LITERAL_FOR/FOR_ITERATOR/ELIST/COMMA"); @@ -337,7 +337,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testLiteralVoid() { + void literalVoid() { final int lineNumber = 65; final int columnNumber = 12; final XpathQueryGenerator queryGenerator = @@ -355,42 +355,42 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testFirstImport() { + void firstImport() { final int lineNumber = 4; final int columnNumber = 1; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='JToolBar']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='JToolBar']]"); assertWithMessage("Generated queries do not match expected ones") .that(actual) .isEqualTo(expected); } @Test - public void testLastImport() { + void lastImport() { final int lineNumber = 8; final int columnNumber = 1; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Iterator']]"); + ImmutableList.of("/COMPILATION_UNIT/IMPORT[./DOT/IDENT[@text='Iterator']]"); assertWithMessage("Generated queries do not match expected ones") .that(actual) .isEqualTo(expected); } @Test - public void testImportByText() { + void importByText() { final int lineNumber = 4; final int columnNumber = 8; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/IMPORT/DOT[./IDENT[@text='JToolBar']]/DOT/IDENT[@text='javax']"); assertWithMessage("Generated queries do not match expected ones") .that(actual) @@ -398,22 +398,21 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testIdent() { + void ident() { final int lineNumber = 12; final int columnNumber = 14; final XpathQueryGenerator queryGenerator = new XpathQueryGenerator(rootAst, lineNumber, columnNumber, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( - "/COMPILATION_UNIT/CLASS_DEF/IDENT[@text='InputXpathQueryGenerator']"); + ImmutableList.of("/COMPILATION_UNIT/CLASS_DEF/IDENT[@text='InputXpathQueryGenerator']"); assertWithMessage("Generated queries do not match expected ones") .that(actual) .isEqualTo(expected); } @Test - public void testTabWidthBeforeMethodDef() throws Exception { + void tabWidthBeforeMethodDef() throws Exception { final File testFile = new File(getPath("InputXpathQueryGeneratorTabWidth.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); @@ -440,7 +439,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testTabWidthAfterVoidLiteral() throws Exception { + void tabWidthAfterVoidLiteral() throws Exception { final File testFile = new File(getPath("InputXpathQueryGeneratorTabWidth.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); @@ -464,7 +463,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testTabWidthBeforeSlist() throws Exception { + void tabWidthBeforeSlist() throws Exception { final File testFile = new File(getPath("InputXpathQueryGeneratorTabWidth.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); @@ -475,7 +474,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { new XpathQueryGenerator(detailAst, lineNumber, columnNumber, testFileText, tabWidth); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='InputXpathQueryGeneratorTabWidth']]/OBJBLOCK" + "/METHOD_DEF[./IDENT[@text='tabAfterMe']]/SLIST"); @@ -485,7 +484,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testTabWidthEndOfLine() throws Exception { + void tabWidthEndOfLine() throws Exception { final File testFile = new File(getPath("InputXpathQueryGeneratorTabWidth.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); @@ -496,7 +495,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { new XpathQueryGenerator(detailAst, lineNumber, columnNumber, testFileText, tabWidth); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGeneratorTabWidth']]" + "/OBJBLOCK/VARIABLE_DEF[./IDENT[@text='endLineTab']]/SEMI"); assertWithMessage("Generated queries do not match expected ones") @@ -505,7 +504,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testClassDefWithTokenType() { + void classDefWithTokenType() { final int lineNumber = 12; final int columnNumber = 1; final XpathQueryGenerator queryGenerator = @@ -513,15 +512,14 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { rootAst, lineNumber, columnNumber, TokenTypes.CLASS_DEF, fileText, DEFAULT_TAB_WIDTH); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( - "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]"); + ImmutableList.of("/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator']]"); assertWithMessage("Generated queries do not match expected ones") .that(actual) .isEqualTo(expected); } @Test - public void testConstructorWithTreeWalkerAuditEvent() { + void constructorWithTreeWalkerAuditEvent() { final Violation violation = new Violation(12, 1, "messages.properties", null, null, null, null, null, null); final TreeWalkerAuditEvent event = @@ -541,7 +539,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testEscapeCharacters() throws Exception { + void escapeCharacters() throws Exception { final File testFile = new File(getPath("InputXpathQueryGeneratorEscapeCharacters.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); @@ -589,7 +587,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testTextBlocks() throws Exception { + void textBlocks() throws Exception { final File testFile = new File(getNonCompilablePath("InputXpathQueryGeneratorTextBlock.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); @@ -601,7 +599,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { new XpathQueryGenerator(detailAst, lineNumber, columnNumber, testFileText, tabWidth); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='InputXpathQueryGeneratorTextBlock']]/OBJBLOCK/" + "VARIABLE_DEF[./IDENT[@text='testOne']]/ASSIGN/EXPR/" @@ -613,7 +611,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testTextBlocksWithNewLine() throws Exception { + void textBlocksWithNewLine() throws Exception { final File testFile = new File(getNonCompilablePath("InputXpathQueryGeneratorTextBlockNewLine.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); @@ -626,7 +624,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { new XpathQueryGenerator(detailAst, lineNumber, columnNumber, testFileText, tabWidth); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='InputXpathQueryGeneratorTextBlockNewLine']]/OBJBLOCK/" + "VARIABLE_DEF[./IDENT[@text='testOne']]/ASSIGN/EXPR/" @@ -638,7 +636,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testTextBlocksWithNewCrlf() throws Exception { + void textBlocksWithNewCrlf() throws Exception { final File testFile = new File(getNonCompilablePath("InputXpathQueryGeneratorTextBlockCrlf.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); @@ -651,7 +649,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { new XpathQueryGenerator(detailAst, lineNumber, columnNumber, testFileText, tabWidth); final List actual = queryGenerator.generate(); final List expected = - Collections.singletonList( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='InputXpathQueryGeneratorTextBlockCrlf']]/OBJBLOCK/" + "VARIABLE_DEF[./IDENT[@text='testOne']]/ASSIGN/EXPR/" @@ -664,7 +662,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testXpath() throws Exception { + void xpath() throws Exception { final File testFile = new File(getPath("InputXpathQueryGenerator2.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); @@ -676,7 +674,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { new XpathQueryGenerator(detailAst, lineNumberOne, columnNumberOne, testFileText, tabWidth); final List actualTestOne = queryGeneratorOne.generate(); final List expectedTestOne = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF" + "[./IDENT[@text='InputXpathQueryGenerator2']]" + "/OBJBLOCK/ENUM_DEF[./IDENT[@text='Foo3']]/OBJBLOCK/COMMA[2]"); @@ -686,7 +684,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testXpath2() throws Exception { + void xpath2() throws Exception { final File testFile = new File(getPath("InputXpathQueryGenerator3.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); @@ -698,7 +696,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { new XpathQueryGenerator(detailAst, lineNumber3, columnNumber3, testFileText, tabWidth); final List actualTest3 = queryGenerator3.generate(); final List expectedTest3 = - List.of( + ImmutableList.of( "/COMPILATION_UNIT/CLASS_DEF[./IDENT[@text='InputXpathQueryGenerator3']]" + "/OBJBLOCK/SEMI[1]"); assertWithMessage("Generated queries do not match expected ones") @@ -707,7 +705,7 @@ public class XpathQueryGeneratorTest extends AbstractModuleTestSupport { } @Test - public void testXpath3() throws Exception { + void xpath3() throws Exception { final File testFile = new File(getPath("InputXpathQueryGenerator4.java")); final FileText testFileText = new FileText(testFile, StandardCharsets.UTF_8.name()); final DetailAST detailAst = JavaParser.parseFile(testFile, JavaParser.Options.WITHOUT_COMMENTS); --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/DescendantIteratorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/DescendantIteratorTest.java @@ -25,10 +25,10 @@ import static com.puppycrawl.tools.checkstyle.internal.utils.XpathIteratorUtil.f import net.sf.saxon.om.NodeInfo; import org.junit.jupiter.api.Test; -public class DescendantIteratorTest { +final class DescendantIteratorTest { @Test - public void testIncludeSelf() { + void includeSelf() { final NodeInfo startNode = findNode("CLASS_DEF"); try (DescendantIterator iterator = @@ -46,7 +46,7 @@ public class DescendantIteratorTest { } @Test - public void testWithoutSelf() { + void withoutSelf() { final NodeInfo startNode = findNode("CLASS_DEF"); try (DescendantIterator iterator = @@ -62,7 +62,7 @@ public class DescendantIteratorTest { } @Test - public void testWithNull() { + void withNull() { final NodeInfo startNode = findNode("CLASS_DEF"); try (DescendantIterator iterator = new DescendantIterator(startNode, null)) { --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/FollowingIteratorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/FollowingIteratorTest.java @@ -25,10 +25,10 @@ import static com.puppycrawl.tools.checkstyle.internal.utils.XpathIteratorUtil.f import net.sf.saxon.om.NodeInfo; import org.junit.jupiter.api.Test; -public class FollowingIteratorTest { +final class FollowingIteratorTest { @Test - public void testFollowingSibling() { + void followingSibling() { final NodeInfo startNode = findNode("ANNOTATIONS"); try (FollowingIterator iterator = new FollowingIterator(startNode)) { @@ -45,7 +45,7 @@ public class FollowingIteratorTest { } @Test - public void testNoSibling() { + void noSibling() { final NodeInfo startNode = findNode("CLASS_DEF"); try (FollowingIterator iterator = new FollowingIterator(startNode)) { --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/PrecedingIteratorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/PrecedingIteratorTest.java @@ -25,10 +25,10 @@ import static com.puppycrawl.tools.checkstyle.internal.utils.XpathIteratorUtil.f import net.sf.saxon.om.NodeInfo; import org.junit.jupiter.api.Test; -public class PrecedingIteratorTest { +final class PrecedingIteratorTest { @Test - public void testPrecedingNodes() { + void precedingNodes() { final NodeInfo startNode = findNode("SLIST"); try (PrecedingIterator iterator = new PrecedingIterator(startNode)) { @@ -47,7 +47,7 @@ public class PrecedingIteratorTest { } @Test - public void testNoParent() { + void noParent() { final NodeInfo startNode = findNode("ROOT"); try (PrecedingIterator iterator = new PrecedingIterator(startNode)) { @@ -56,7 +56,7 @@ public class PrecedingIteratorTest { } @Test - public void testReverseOrderOfDescendants() { + void reverseOrderOfDescendants() { final NodeInfo startNode = findNode("RCURLY"); try (PrecedingIterator iterator = new PrecedingIterator(startNode)) { @@ -75,7 +75,7 @@ public class PrecedingIteratorTest { } @Test - public void testNoSibling() { + void noSibling() { final NodeInfo startNode = findNode("ANNOTATIONS"); try (PrecedingIterator iterator = new PrecedingIterator(startNode)) { --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/ReverseDescendantIteratorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/ReverseDescendantIteratorTest.java @@ -25,10 +25,10 @@ import static com.puppycrawl.tools.checkstyle.internal.utils.XpathIteratorUtil.f import net.sf.saxon.om.NodeInfo; import org.junit.jupiter.api.Test; -public class ReverseDescendantIteratorTest { +final class ReverseDescendantIteratorTest { @Test - public void testCorrectOrder() { + void correctOrder() { final NodeInfo startNode = findNode("CLASS_DEF"); try (ReverseDescendantIterator iterator = new ReverseDescendantIterator(startNode)) { --- a/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/ReverseListIteratorTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/xpath/iterators/ReverseListIteratorTest.java @@ -31,10 +31,10 @@ import net.sf.saxon.om.NodeInfo; import net.sf.saxon.om.TreeInfo; import org.junit.jupiter.api.Test; -public class ReverseListIteratorTest { +final class ReverseListIteratorTest { @Test - public void testCorrectOrder() { + void correctOrder() { final List nodes = Arrays.asList(new TestNode(), new TestNode(), new TestNode()); try (ReverseListIterator iterator = new ReverseListIterator(nodes)) { @@ -46,7 +46,7 @@ public class ReverseListIteratorTest { } @Test - public void testNullList() { + void nullList() { try (ReverseListIterator iterator = new ReverseListIterator(null)) { assertWithMessage("Node should be null").that(iterator.next()).isNull(); } --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/ArrayTypeStyleCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck.MSG_KEY import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class ArrayTypeStyleCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ArrayTypeStyleCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/arraytypestyle"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:17: " + getCheckMessage(MSG_KEY), "20:17: " + getCheckMessage(MSG_KEY), }; @@ -40,7 +40,7 @@ public class ArrayTypeStyleCheckExamplesTest extends AbstractExamplesModuleTestS } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "15:6: " + getCheckMessage(MSG_KEY), "22:17: " + getCheckMessage(MSG_KEY), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/AvoidEscapedUnicodeCharactersCheckExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.AvoidEscapedUnicodeCharacte import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AvoidEscapedUnicodeCharactersCheckExamplesTest +final class AvoidEscapedUnicodeCharactersCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class AvoidEscapedUnicodeCharactersCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "16:24: " + getCheckMessage(MSG_KEY), "18:24: " + getCheckMessage(MSG_KEY), @@ -45,7 +45,7 @@ public class AvoidEscapedUnicodeCharactersCheckExamplesTest } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "18:24: " + getCheckMessage(MSG_KEY), "20:24: " + getCheckMessage(MSG_KEY), @@ -57,7 +57,7 @@ public class AvoidEscapedUnicodeCharactersCheckExamplesTest } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "18:24: " + getCheckMessage(MSG_KEY), "20:24: " + getCheckMessage(MSG_KEY), @@ -69,7 +69,7 @@ public class AvoidEscapedUnicodeCharactersCheckExamplesTest } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "18:24: " + getCheckMessage(MSG_KEY), "22:24: " + getCheckMessage(MSG_KEY), @@ -80,7 +80,7 @@ public class AvoidEscapedUnicodeCharactersCheckExamplesTest } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "18:24: " + getCheckMessage(MSG_KEY, "unitAbbrev1"), "20:24: " + getCheckMessage(MSG_KEY), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/DescendantTokenCheckExamplesTest.java @@ -24,119 +24,119 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class DescendantTokenCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class DescendantTokenCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/descendanttoken"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); } @Test - public void testExample11() throws Exception { + void example11() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example11.txt"), expected); } @Test - public void testExample12() throws Exception { + void example12() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example12.txt"), expected); } @Test - public void testExample13() throws Exception { + void example13() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example13.txt"), expected); } @Test - public void testExample14() throws Exception { + void example14() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example14.txt"), expected); } @Test - public void testExample15() throws Exception { + void example15() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example15.txt"), expected); } @Test - public void testExample16() throws Exception { + void example16() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example16.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/FinalParametersCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck.MSG_KE import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class FinalParametersCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class FinalParametersCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/finalparameters"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:32: " + getCheckMessage(MSG_KEY, "n"), "16:25: " + getCheckMessage(MSG_KEY, "x"), @@ -41,7 +41,7 @@ public class FinalParametersCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "16:32: " + getCheckMessage(MSG_KEY, "n"), }; @@ -49,7 +49,7 @@ public class FinalParametersCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "19:27: " + getCheckMessage(MSG_KEY, "args"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/NewlineAtEndOfFileCheckExamplesTest.java @@ -26,21 +26,21 @@ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NewlineAtEndOfFileCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NewlineAtEndOfFileCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/newlineatendoffile"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("Example1.java"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_NEWLINE_EOF), }; @@ -49,7 +49,7 @@ public class NewlineAtEndOfFileCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_WRONG_ENDING), }; @@ -58,7 +58,7 @@ public class NewlineAtEndOfFileCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_NEWLINE_EOF), }; @@ -67,7 +67,7 @@ public class NewlineAtEndOfFileCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_NEWLINE_EOF), }; @@ -76,7 +76,7 @@ public class NewlineAtEndOfFileCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/NoCodeInFileCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/NoCodeInFileCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck.MSG_KEY_N import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class NoCodeInFileCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NoCodeInFileCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/nocodeinfile"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_CODE), }; @@ -40,7 +40,7 @@ public class NoCodeInFileCheckExamplesTest extends AbstractExamplesModuleTestSup } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY_NO_CODE), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/OrderedPropertiesCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/OrderedPropertiesCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class OrderedPropertiesCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class OrderedPropertiesCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/orderedproperties"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/OuterTypeFilenameCheckExamplesTest.java @@ -24,21 +24,21 @@ import static com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck.MSG_ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class OuterTypeFilenameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class OuterTypeFilenameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/outertypefilename"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.java"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_KEY), }; @@ -47,7 +47,7 @@ public class OuterTypeFilenameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_KEY), }; @@ -56,7 +56,7 @@ public class OuterTypeFilenameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_KEY), }; @@ -65,7 +65,7 @@ public class OuterTypeFilenameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "11:1: " + getCheckMessage(MSG_KEY), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/TodoCommentCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck.MSG_KEY; import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class TodoCommentCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class TodoCommentCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/todocomment"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "15:14: " + getCheckMessage(MSG_KEY, "TODO:"), }; @@ -40,7 +40,7 @@ public class TodoCommentCheckExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "1:3: " + getCheckMessage(MSG_KEY, "(TODO)|(FIXME)"), "18:14: " + getCheckMessage(MSG_KEY, "(TODO)|(FIXME)"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/TrailingCommentCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class TrailingCommentCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class TrailingCommentCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/trailingcomment"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/TranslationCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class TranslationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class TranslationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/translation"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/UncommentedMainCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class UncommentedMainCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class UncommentedMainCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/uncommentedmain"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/UniquePropertiesCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class UniquePropertiesCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class UniquePropertiesCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/uniqueproperties"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/UpperEllCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/UpperEllCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.UpperEllCheck.MSG_KEY; import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class UpperEllCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class UpperEllCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/upperell"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "13:15: " + getCheckMessage(MSG_KEY, "L"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationLocationExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocati import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AnnotationLocationExamplesTest extends AbstractExamplesModuleTestSupport { +final class AnnotationLocationExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/annotation/annotationlocation"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "31:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "SuppressWarnings"), "33:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "SuppressWarnings"), @@ -42,14 +42,14 @@ public class AnnotationLocationExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.java"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "24:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Nonnull"), "26:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "Override"), @@ -61,7 +61,7 @@ public class AnnotationLocationExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "33:3: " + getCheckMessage(MSG_KEY_ANNOTATION_LOCATION_ALONE, "SuppressWarnings"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationOnSameLineCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationOnSameLineCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationOnSame import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AnnotationOnSameLineCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AnnotationOnSameLineCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/annotation/annotationonsameline"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "16:3: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "SuppressWarnings"), "33:3: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Override"), @@ -43,7 +43,7 @@ public class AnnotationOnSameLineCheckExamplesTest extends AbstractExamplesModul } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "25:3: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "SuppressWarnings"), "33:3: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Nullable"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/AnnotationUseStyleCheckExamplesTest.java @@ -28,14 +28,14 @@ import static com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationUseSty import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AnnotationUseStyleCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AnnotationUseStyleCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/annotation/annotationusestyle"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "25:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT_NO_ARRAY"), "26:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_PRESENT), @@ -46,7 +46,7 @@ public class AnnotationUseStyleCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), "19:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "EXPANDED"), @@ -58,7 +58,7 @@ public class AnnotationUseStyleCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_KEY_ANNOTATION_PARENS_MISSING), "25:1: " + getCheckMessage(MSG_KEY_ANNOTATION_INCORRECT_STYLE, "COMPACT"), @@ -69,7 +69,7 @@ public class AnnotationUseStyleCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "19:34: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), "26:37: " + getCheckMessage(MSG_KEY_ANNOTATION_TRAILING_COMMA_MISSING), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingDeprecatedCheckExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.javadoc.AbstractJavadocChec import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class MissingDeprecatedCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MissingDeprecatedCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/annotation/missingdeprecated"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "18: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), }; @@ -41,7 +41,7 @@ public class MissingDeprecatedCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "20: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_DEPRECATED), "32: " + getCheckMessage(MSG_KEY_UNCLOSED_HTML_TAG, "p"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/MissingOverrideCheckExamplesTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.annotation.MissingOverrideC import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class MissingOverrideCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MissingOverrideCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class MissingOverrideCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "27:3: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE, "test2"), "33:3: " + getCheckMessage(MSG_KEY_TAG_NOT_VALID_ON, "{@inheritDoc}"), @@ -43,7 +43,7 @@ public class MissingOverrideCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "22:3: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE, "equals"), "30:3: " + getCheckMessage(MSG_KEY_ANNOTATION_MISSING_OVERRIDE, "test"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/PackageAnnotationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/PackageAnnotationCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.annotation.PackageAnnotatio import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class PackageAnnotationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class PackageAnnotationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/annotation/packageannotation"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY), }; @@ -40,14 +40,14 @@ public class PackageAnnotationCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.java"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("example3/package-info.java"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.annotation.SuppressWarnings import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class SuppressWarningsCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuppressWarningsCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarnings"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "13:19: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), "16:21: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""), @@ -41,7 +41,7 @@ public class SuppressWarningsCheckExamplesTest extends AbstractExamplesModuleTes } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "40:21: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), "44:32: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, "unused"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsHolderExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/annotation/SuppressWarningsHolderExamplesTest.java @@ -27,14 +27,14 @@ import com.puppycrawl.tools.checkstyle.checks.sizes.ParameterNumberCheck; import com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck; import org.junit.jupiter.api.Test; -public class SuppressWarningsHolderExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuppressWarningsHolderExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/annotation/suppresswarningsholder"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String pattern1 = "^[a-z][a-zA-Z0-9]*$"; final String pattern2 = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { @@ -55,7 +55,7 @@ public class SuppressWarningsHolderExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "19:15: " + getCheckMessage(ParameterNumberCheck.class, ParameterNumberCheck.MSG_KEY, 7, 8), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/AvoidNestedBlocksCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksChe import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AvoidNestedBlocksCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AvoidNestedBlocksCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/blocks/avoidnestedblocks"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), "23:15: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), @@ -41,7 +41,7 @@ public class AvoidNestedBlocksCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "19:5: " + getCheckMessage(MSG_KEY_BLOCK_NESTED), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyBlockCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyBlockCheckExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck.MSG_ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class EmptyBlockCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class EmptyBlockCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/blocks/emptyblock"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:34: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "for"), "17:9: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "try"), @@ -42,7 +42,7 @@ public class EmptyBlockCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "21:9: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "try"), }; @@ -51,7 +51,7 @@ public class EmptyBlockCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "24:16: " + getCheckMessage(MSG_KEY_BLOCK_NO_STATEMENT, "default"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/EmptyCatchBlockCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyCatchBlockCheck import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class EmptyCatchBlockCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class EmptyCatchBlockCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/blocks/emptycatchblock"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "16:41: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), "31:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), @@ -41,7 +41,7 @@ public class EmptyCatchBlockCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "33:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), }; @@ -50,7 +50,7 @@ public class EmptyCatchBlockCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "18:41: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), "25:39: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), @@ -61,7 +61,7 @@ public class EmptyCatchBlockCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "51:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), }; @@ -70,7 +70,7 @@ public class EmptyCatchBlockCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "18:34: " + getCheckMessage(MSG_KEY_CATCH_BLOCK_EMPTY), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/LeftCurlyCheckExamplesTest.java @@ -26,14 +26,14 @@ import static com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck.MSG_K import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class LeftCurlyCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class LeftCurlyCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/blocks/leftcurly"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "1"), "15:3: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "3"), @@ -43,7 +43,7 @@ public class LeftCurlyCheckExamplesTest extends AbstractExamplesModuleTestSuppor } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "23:13: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", "13"), }; @@ -52,7 +52,7 @@ public class LeftCurlyCheckExamplesTest extends AbstractExamplesModuleTestSuppor } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "1"), "22:13: " + getCheckMessage(MSG_KEY_LINE_NEW, "{", "13"), @@ -62,7 +62,7 @@ public class LeftCurlyCheckExamplesTest extends AbstractExamplesModuleTestSuppor } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "1"), "17:3: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{", "3"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/NeedBracesCheckExamplesTest.java @@ -25,14 +25,14 @@ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class NeedBracesCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NeedBracesCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/blocks/needbraces"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "20:5: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), "24:7: " + getCheckMessage(MSG_KEY_NEED_BRACES, "else"), @@ -47,7 +47,7 @@ public class NeedBracesCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"), "26:7: " + getCheckMessage(MSG_KEY_NEED_BRACES, "else"), @@ -57,7 +57,7 @@ public class NeedBracesCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "33:5: " + getCheckMessage(MSG_KEY_NEED_BRACES, "do"), "40:5: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), @@ -67,14 +67,14 @@ public class NeedBracesCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("Example4.java"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "39:5: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"), }; @@ -83,7 +83,7 @@ public class NeedBracesCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = { "24:38: " + getCheckMessage(MSG_KEY_NEED_BRACES, "->"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/blocks/RightCurlyCheckExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class RightCurlyCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RightCurlyCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/blocks/rightcurly"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "19:5: " + getCheckMessage(MSG_KEY_LINE_SAME, "}", "5"), "32:23: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", "23"), @@ -43,7 +43,7 @@ public class RightCurlyCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "22:21: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", "21"), "43:47: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", "47"), @@ -53,7 +53,7 @@ public class RightCurlyCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "35:16: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", "16"), }; @@ -62,7 +62,7 @@ public class RightCurlyCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "22:5: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", "5"), }; @@ -71,7 +71,7 @@ public class RightCurlyCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "41:16: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}", "16"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ArrayTrailingCommaCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ArrayTrailingCommaCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.ArrayTrailingCommaCh import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class ArrayTrailingCommaCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ArrayTrailingCommaCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/arraytrailingcomma"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:5: " + getCheckMessage(MSG_KEY), "25:5: " + getCheckMessage(MSG_KEY), }; @@ -40,7 +40,7 @@ public class ArrayTrailingCommaCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "15:26: " + getCheckMessage(MSG_KEY), "19:5: " + getCheckMessage(MSG_KEY), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidDoubleBraceInitializationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidDoubleBraceInitializationCheckExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.AvoidDoubleBraceInit import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AvoidDoubleBraceInitializationCheckExamplesTest +final class AvoidDoubleBraceInitializationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class AvoidDoubleBraceInitializationCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "16:43: " + getCheckMessage(MSG_KEY, "list1"), "21:42: " + getCheckMessage(MSG_KEY, "list2"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidInlineConditionalsCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidInlineConditionalsCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class AvoidInlineConditionalsCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AvoidInlineConditionalsCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/avoidinlineconditionals"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/AvoidNoArgumentSuperConstructorCallCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class AvoidNoArgumentSuperConstructorCallCheckExamplesTest +final class AvoidNoArgumentSuperConstructorCallCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class AvoidNoArgumentSuperConstructorCallCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/CovariantEqualsCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/CovariantEqualsCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class CovariantEqualsCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class CovariantEqualsCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/covariantequals"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/DeclarationOrderCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class DeclarationOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class DeclarationOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/declarationorder"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/DefaultComesLastCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class DefaultComesLastCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class DefaultComesLastCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/defaultcomeslast"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/EmptyStatementCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck. import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class EmptyStatementCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class EmptyStatementCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/emptystatement"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "15:14: " + getCheckMessage(MSG_KEY), "17:28: " + getCheckMessage(MSG_KEY), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsAvoidNullCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class EqualsAvoidNullCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class EqualsAvoidNullCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/equalsavoidnull"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsHashCodeCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/EqualsHashCodeCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class EqualsHashCodeCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class EqualsHashCodeCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/equalshashcode"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ExplicitInitializationCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ExplicitInitializationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ExplicitInitializationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/explicitinitialization"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/FallThroughCheckExamplesTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.FallThroughCheck.MSG import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class FallThroughCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class FallThroughCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class FallThroughCheckExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "21:9: " + getCheckMessage(MSG_FALL_THROUGH), "32:9: " + getCheckMessage(MSG_FALL_THROUGH), }; @@ -42,7 +42,7 @@ public class FallThroughCheckExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "23:9: " + getCheckMessage(MSG_FALL_THROUGH), "34:9: " + getCheckMessage(MSG_FALL_THROUGH), @@ -53,7 +53,7 @@ public class FallThroughCheckExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "23:9: " + getCheckMessage(MSG_FALL_THROUGH), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/FinalLocalVariableCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class FinalLocalVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class FinalLocalVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,28 +32,28 @@ public class FinalLocalVariableCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/HiddenFieldCheckExamplesTest.java @@ -24,56 +24,56 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class HiddenFieldCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class HiddenFieldCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/hiddenfield"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalCatchCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class IllegalCatchCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IllegalCatchCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/illegalcatch"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalInstantiationCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class IllegalInstantiationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IllegalInstantiationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/illegalinstantiation"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalThrowsCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class IllegalThrowsCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IllegalThrowsCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/illegalthrows"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class IllegalTokenCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IllegalTokenCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/illegaltoken"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTokenTextCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.IllegalTokenTextChec import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class IllegalTokenTextCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IllegalTokenTextCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/illegaltokentext"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:20: " + getCheckMessage(MSG_KEY, "a href"), }; @@ -40,7 +40,7 @@ public class IllegalTokenTextCheckExamplesTest extends AbstractExamplesModuleTes } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "18:20: " + getCheckMessage(MSG_KEY, "a href"), "19:20: " + getCheckMessage(MSG_KEY, "a href"), @@ -50,7 +50,7 @@ public class IllegalTokenTextCheckExamplesTest extends AbstractExamplesModuleTes } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "17:29: " + getCheckMessage(MSG_KEY, '"'), }; @@ -59,7 +59,7 @@ public class IllegalTokenTextCheckExamplesTest extends AbstractExamplesModuleTes } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "21:17: " + getCheckMessage(MSG_KEY, "^0[^lx]"), "23:18: " + getCheckMessage(MSG_KEY, "^0[^lx]"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/IllegalTypeCheckExamplesTest.java @@ -24,56 +24,56 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class IllegalTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IllegalTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/illegaltype"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/InnerAssignmentCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class InnerAssignmentCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class InnerAssignmentCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/innerassignment"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "21:11: " + getCheckMessage(MSG_KEY), "22:11: " + getCheckMessage(MSG_KEY), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MagicNumberCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MagicNumberCheckExamplesTest.java @@ -24,49 +24,49 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MagicNumberCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MagicNumberCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/magicnumber"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MatchXpathCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MatchXpathCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/matchxpath"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingCtorCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingCtorCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MissingCtorCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MissingCtorCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/missingctor"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingSwitchDefaultCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MissingSwitchDefaultCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MissingSwitchDefaultCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MissingSwitchDefaultCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/missingswitchdefault"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ModifiedControlVariableCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ModifiedControlVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ModifiedControlVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/modifiedcontrolvariable"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleStringLiteralsCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MultipleStringLiteralsCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MultipleStringLiteralsCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/multiplestringliterals"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MultipleVariableDeclarationsCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MultipleVariableDeclarationsCheckExamplesTest +final class MultipleVariableDeclarationsCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class MultipleVariableDeclarationsCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedForDepthCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class NestedForDepthCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NestedForDepthCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/nestedfordepth"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedIfDepthCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class NestedIfDepthCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NestedIfDepthCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/nestedifdepth"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NestedTryDepthCheckExamplesTest.java @@ -24,42 +24,42 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class NestedTryDepthCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NestedTryDepthCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/nestedtrydepth"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NoArrayTrailingCommaCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NoArrayTrailingCommaCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class NoArrayTrailingCommaCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NoArrayTrailingCommaCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/noarraytrailingcomma"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NoCloneCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NoCloneCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class NoCloneCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NoCloneCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/noclone"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NoEnumTrailingCommaCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NoEnumTrailingCommaCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class NoEnumTrailingCommaCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NoEnumTrailingCommaCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/noenumtrailingcomma"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NoFinalizerCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/NoFinalizerCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class NoFinalizerCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NoFinalizerCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/nofinalizer"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/OneStatementPerLineCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/OneStatementPerLineCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class OneStatementPerLineCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class OneStatementPerLineCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/onestatementperline"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/OverloadMethodsDeclarationOrderCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/OverloadMethodsDeclarationOrderCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class OverloadMethodsDeclarationOrderCheckExamplesTest +final class OverloadMethodsDeclarationOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,14 +32,14 @@ public class OverloadMethodsDeclarationOrderCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/PackageDeclarationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/PackageDeclarationCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class PackageDeclarationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class PackageDeclarationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/packagedeclaration"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ParameterAssignmentCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.ParameterAssignmentC import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class ParameterAssignmentCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ParameterAssignmentCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/parameterassignment"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "21:15: " + getCheckMessage(MSG_KEY, "parameter"), "34:27: " + getCheckMessage(MSG_KEY, "a"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/RequireThisCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/RequireThisCheckExamplesTest.java @@ -24,49 +24,49 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RequireThisCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RequireThisCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/requirethis"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/ReturnCountCheckExamplesTest.java @@ -24,42 +24,42 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ReturnCountCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ReturnCountCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/returncount"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanExpressionCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanExpressionCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SimplifyBooleanExpressionCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class SimplifyBooleanExpressionCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/simplifybooleanexpression"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanReturnCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/SimplifyBooleanReturnCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SimplifyBooleanReturnCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class SimplifyBooleanReturnCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/simplifybooleanreturn"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/StringLiteralEqualityCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/StringLiteralEqualityCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class StringLiteralEqualityCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class StringLiteralEqualityCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/stringliteralequality"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperCloneCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperCloneCheckExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.AbstractSuperCheck.M import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class SuperCloneCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuperCloneCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class SuperCloneCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "22:22: " + getCheckMessage(MSG_KEY, "clone"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/SuperFinalizeCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SuperFinalizeCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuperFinalizeCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/superfinalize"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessaryParenthesesCheckExamplesTest.java @@ -28,14 +28,14 @@ import static com.puppycrawl.tools.checkstyle.checks.coding.UnnecessaryParenthes import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class UnnecessaryParenthesesCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class UnnecessaryParenthesesCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/unnecessaryparentheses"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:18: " + getCheckMessage(MSG_ASSIGN), "19:13: " + getCheckMessage(MSG_IDENT, "square"), @@ -53,7 +53,7 @@ public class UnnecessaryParenthesesCheckExamplesTest extends AbstractExamplesMod } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "18:18: " + getCheckMessage(MSG_EXPR), "26:19: " + getCheckMessage(MSG_EXPR), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterOuterTypeDeclarationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterOuterTypeDeclarationCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class UnnecessarySemicolonAfterOuterTypeDeclarationCheckExamplesTest +final class UnnecessarySemicolonAfterOuterTypeDeclarationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,14 +33,14 @@ public class UnnecessarySemicolonAfterOuterTypeDeclarationCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterTypeMemberDeclarationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonAfterTypeMemberDeclarationCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class UnnecessarySemicolonAfterTypeMemberDeclarationCheckExamplesTest +final class UnnecessarySemicolonAfterTypeMemberDeclarationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class UnnecessarySemicolonAfterTypeMemberDeclarationCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInEnumerationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInEnumerationCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class UnnecessarySemicolonInEnumerationCheckExamplesTest +final class UnnecessarySemicolonInEnumerationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,14 +32,14 @@ public class UnnecessarySemicolonInEnumerationCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInTryWithResourcesCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnnecessarySemicolonInTryWithResourcesCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class UnnecessarySemicolonInTryWithResourcesCheckExamplesTest +final class UnnecessarySemicolonInTryWithResourcesCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,14 +33,14 @@ public class UnnecessarySemicolonInTryWithResourcesCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnusedLocalVariableCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/UnusedLocalVariableCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class UnusedLocalVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class UnusedLocalVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/coding/unusedlocalvariable"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/VariableDeclarationUsageDistanceCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class VariableDeclarationUsageDistanceCheckExamplesTest +final class VariableDeclarationUsageDistanceCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,35 +32,35 @@ public class VariableDeclarationUsageDistanceCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/DesignForExtensionCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class DesignForExtensionCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class DesignForExtensionCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/designforextension"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/FinalClassCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.design.FinalClassCheck.MSG_ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class FinalClassCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class FinalClassCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/finalclass"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "19:3: " + getCheckMessage(MSG_KEY, "B"), "50:5: " + getCheckMessage(MSG_KEY, "Class2"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/HideUtilityClassConstructorCheckExamplesTest.java @@ -24,15 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class HideUtilityClassConstructorCheckExamplesTest - extends AbstractExamplesModuleTestSupport { +final class HideUtilityClassConstructorCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/hideutilityclassconstructor"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/InnerTypeLastCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.design.InnerTypeLastCheck.M import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class InnerTypeLastCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class InnerTypeLastCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/innertypelast"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:3: " + getCheckMessage(MSG_KEY), "20:3: " + getCheckMessage(MSG_KEY), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/InterfaceIsTypeCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/InterfaceIsTypeCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.design.InterfaceIsTypeCheck import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class InterfaceIsTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class InterfaceIsTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/interfaceistype"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:3: " + getCheckMessage(MSG_KEY), }; @@ -40,7 +40,7 @@ public class InterfaceIsTypeCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "16:3: " + getCheckMessage(MSG_KEY), "21:3: " + getCheckMessage(MSG_KEY), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/MutableExceptionCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MutableExceptionCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MutableExceptionCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/mutableexception"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/OneTopLevelClassCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class OneTopLevelClassCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class OneTopLevelClassCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/onetoplevelclass"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/ThrowsCountCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ThrowsCountCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ThrowsCountCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/throwscount"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/design/VisibilityModifierCheckExamplesTest.java @@ -25,14 +25,14 @@ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/design/visibilitymodifier"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "23:7: " + getCheckMessage(MSG_KEY, "field1"), "25:20: " + getCheckMessage(MSG_KEY, "field2"), @@ -50,7 +50,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "27:20: " + getCheckMessage(MSG_KEY, "field2"), "30:14: " + getCheckMessage(MSG_KEY, "field3"), @@ -65,7 +65,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "25:7: " + getCheckMessage(MSG_KEY, "field1"), "30:14: " + getCheckMessage(MSG_KEY, "field3"), @@ -82,7 +82,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "25:7: " + getCheckMessage(MSG_KEY, "field1"), "27:20: " + getCheckMessage(MSG_KEY, "field2"), @@ -101,7 +101,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "25:7: " + getCheckMessage(MSG_KEY, "field1"), "27:20: " + getCheckMessage(MSG_KEY, "field2"), @@ -119,7 +119,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = { "28:7: " + getCheckMessage(MSG_KEY, "field1"), "30:20: " + getCheckMessage(MSG_KEY, "field2"), @@ -137,7 +137,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = { "28:7: " + getCheckMessage(MSG_KEY, "field1"), "30:20: " + getCheckMessage(MSG_KEY, "field2"), @@ -155,7 +155,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = { "26:7: " + getCheckMessage(MSG_KEY, "field1"), "28:20: " + getCheckMessage(MSG_KEY, "field2"), @@ -172,7 +172,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = { "23:7: " + getCheckMessage(MSG_KEY, "field1"), "25:20: " + getCheckMessage(MSG_KEY, "field2"), @@ -190,7 +190,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = { "25:7: " + getCheckMessage(MSG_KEY, "field1"), "27:20: " + getCheckMessage(MSG_KEY, "field2"), @@ -208,7 +208,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample11() throws Exception { + void example11() throws Exception { final String[] expected = { "22:20: " + getCheckMessage(MSG_KEY, "someIntValue"), "24:37: " + getCheckMessage(MSG_KEY, "includes"), @@ -221,7 +221,7 @@ public class VisibilityModifierCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample12() throws Exception { + void example12() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("Example12.java"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/header/HeaderCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/header/HeaderCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class HeaderCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class HeaderCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/header/header"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/header/RegexpHeaderCheckExamplesTest.java @@ -24,42 +24,42 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RegexpHeaderCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RegexpHeaderCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/header/regexpheader"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStarImportCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStarImportCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportChec import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AvoidStarImportCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AvoidStarImportCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/imports/avoidstarimport"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "13:15: " + getCheckMessage(MSG_KEY, "java.io.*"), "14:29: " + getCheckMessage(MSG_KEY, "java.lang.Math.*"), @@ -43,7 +43,7 @@ public class AvoidStarImportCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "17:17: " + getCheckMessage(MSG_KEY, "java.util.*"), }; @@ -52,7 +52,7 @@ public class AvoidStarImportCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "16:29: " + getCheckMessage(MSG_KEY, "java.lang.Math.*"), }; @@ -61,7 +61,7 @@ public class AvoidStarImportCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "15:15: " + getCheckMessage(MSG_KEY, "java.io.*"), "17:17: " + getCheckMessage(MSG_KEY, "java.util.*"), @@ -72,7 +72,7 @@ public class AvoidStarImportCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "17:29: " + getCheckMessage(MSG_KEY, "java.lang.Math.*"), }; @@ -81,7 +81,7 @@ public class AvoidStarImportCheckExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = { "18:17: " + getCheckMessage(MSG_KEY, "java.util.*"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/AvoidStaticImportCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.imports.AvoidStaticImportCh import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AvoidStaticImportCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AvoidStaticImportCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/imports/avoidstaticimport"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "12:29: " + getCheckMessage(MSG_KEY, "java.lang.Math.pow"), "13:31: " + getCheckMessage(MSG_KEY, "java.lang.System.*"), @@ -41,7 +41,7 @@ public class AvoidStaticImportCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "16:32: " + getCheckMessage(MSG_KEY, "java.lang.Integer.parseInt"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/CustomImportOrderCheckExamplesTest.java @@ -24,112 +24,112 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class CustomImportOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class CustomImportOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/imports/customimportorder"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); } @Test - public void testExample11() throws Exception { + void example11() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example11.txt"), expected); } @Test - public void testExample12() throws Exception { + void example12() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example12.txt"), expected); } @Test - public void testExample13() throws Exception { + void example13() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example13.txt"), expected); } @Test - public void testExample14() throws Exception { + void example14() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example14.txt"), expected); } @Test - public void testExample15() throws Exception { + void example15() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example15.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/IllegalImportCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/IllegalImportCheckExamplesTest.java @@ -24,70 +24,70 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class IllegalImportCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IllegalImportCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/imports/illegalimport"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheckExamplesTest.java @@ -24,91 +24,91 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ImportOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ImportOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/imports/importorder"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); } @Test - public void testExample11() throws Exception { + void example11() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example11.txt"), expected); } @Test - public void testExample12() throws Exception { + void example12() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example12.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/RedundantImportCheckExamplesTest.java @@ -26,14 +26,14 @@ import static com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportChec import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class RedundantImportCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RedundantImportCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/imports/redundantimport"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "16:1: " + getCheckMessage( --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/imports/UnusedImportsCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck. import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class UnusedImportsCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class UnusedImportsCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/imports/unusedimports"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "19:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), "22:8: " + getCheckMessage(MSG_KEY, "java.util.Map"), @@ -41,7 +41,7 @@ public class UnusedImportsCheckExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "21:8: " + getCheckMessage(MSG_KEY, "java.lang.String"), "24:8: " + getCheckMessage(MSG_KEY, "java.util.Map"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/indentation/CommentsIndentationCheckExamplesTest.java @@ -24,77 +24,77 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class CommentsIndentationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class CommentsIndentationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/indentation/commentsindentation"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class IndentationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IndentationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/indentation/indentation"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/AtclauseOrderCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class AtclauseOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AtclauseOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/atclauseorder"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/InvalidJavadocPositionCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.javadoc.InvalidJavadocPosit import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class InvalidJavadocPositionCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class InvalidJavadocPositionCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/invalidjavadocposition"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocBlockTagLocationCheckExamplesTest.java @@ -22,28 +22,28 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc; import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class JavadocBlockTagLocationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavadocBlockTagLocationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocblocktaglocation"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.java"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.java"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.java"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocContentLocationCheckExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocContentLocat import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class JavadocContentLocationCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavadocContentLocationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadoccontentlocation"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "15:3: " + getCheckMessage(MSG_JAVADOC_CONTENT_SECOND_LINE), }; @@ -41,7 +41,7 @@ public class JavadocContentLocationCheckExamplesTest extends AbstractExamplesMod } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "22:3: " + getCheckMessage(MSG_JAVADOC_CONTENT_FIRST_LINE), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheckExamplesTest.java @@ -24,56 +24,56 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class JavadocMethodCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavadocMethodCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocmethod"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingLeadingAsteriskCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingLeadingAsteriskCheckExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadi import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class JavadocMissingLeadingAsteriskCheckExamplesTest +final class JavadocMissingLeadingAsteriskCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class JavadocMissingLeadingAsteriskCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "34: " + getCheckMessage(MSG_MISSING_ASTERISK), "39: " + getCheckMessage(MSG_MISSING_ASTERISK), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMissingWhitespaceAfterAsteriskCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class JavadocMissingWhitespaceAfterAsteriskCheckExamplesTest +final class JavadocMissingWhitespaceAfterAsteriskCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class JavadocMissingWhitespaceAfterAsteriskCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocPackageCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocPackageCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class JavadocPackageCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavadocPackageCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocpackage"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocParagraphCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class JavadocParagraphCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavadocParagraphCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocparagraph"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocStyleCheckExamplesTest.java @@ -24,49 +24,49 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class JavadocStyleCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavadocStyleCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocstyle"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTagContinuationIndentationCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class JavadocTagContinuationIndentationCheckExamplesTest +final class JavadocTagContinuationIndentationCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,21 +32,21 @@ public class JavadocTagContinuationIndentationCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocTypeCheckExamplesTest.java @@ -24,63 +24,63 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class JavadocTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavadocTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadoctype"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocVariableCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class JavadocVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavadocVariableCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/javadocvariable"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocMethodCheckExamplesTest.java @@ -24,49 +24,49 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MissingJavadocMethodCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MissingJavadocMethodCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocmethod"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocPackageCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MissingJavadocPackageCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MissingJavadocPackageCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadocpackage"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/MissingJavadocTypeCheckExamplesTest.java @@ -24,42 +24,42 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MissingJavadocTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MissingJavadocTypeCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/missingjavadoctype"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/NonEmptyAtclauseDescriptionCheckExamplesTest.java @@ -24,22 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class NonEmptyAtclauseDescriptionCheckExamplesTest - extends AbstractExamplesModuleTestSupport { +final class NonEmptyAtclauseDescriptionCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc" + "/nonemptyatclausedescription"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/RequireEmptyLineBeforeBlockTagGroupCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/RequireEmptyLineBeforeBlockTagGroupCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RequireEmptyLineBeforeBlockTagGroupCheckExamplesTest +final class RequireEmptyLineBeforeBlockTagGroupCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,7 +32,7 @@ public class RequireEmptyLineBeforeBlockTagGroupCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SingleLineJavadocCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SingleLineJavadocCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class SingleLineJavadocCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/singlelinejavadoc"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/SummaryJavadocCheckExamplesTest.java @@ -24,49 +24,49 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SummaryJavadocCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class SummaryJavadocCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/summaryjavadoc"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/javadoc/WriteTagCheckExamplesTest.java @@ -24,35 +24,35 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class WriteTagCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class WriteTagCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/javadoc/writetag"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheckExamplesTest.java @@ -24,15 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.metrics.BooleanExpressionCo import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class BooleanExpressionComplexityCheckExamplesTest - extends AbstractExamplesModuleTestSupport { +final class BooleanExpressionComplexityCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/metrics/booleanexpressioncomplexity"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "20:15: " + getCheckMessage(MSG_KEY, 5, 3), "24:15: " + getCheckMessage(MSG_KEY, 6, 3), }; @@ -41,7 +40,7 @@ public class BooleanExpressionComplexityCheckExamplesTest } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "25:15: " + getCheckMessage(MSG_KEY, 6, 5), }; @@ -50,7 +49,7 @@ public class BooleanExpressionComplexityCheckExamplesTest } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "25:15: " + getCheckMessage(MSG_KEY, 4, 3), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassDataAbstractionCouplingCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ClassDataAbstractionCouplingCheckExamplesTest +final class ClassDataAbstractionCouplingCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,77 +32,77 @@ public class ClassDataAbstractionCouplingCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); } @Test - public void testExample11() throws Exception { + void example11() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example11.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/ClassFanOutComplexityCheckExamplesTest.java @@ -24,84 +24,84 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ClassFanOutComplexityCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ClassFanOutComplexityCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/metrics/classfanoutcomplexity"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); } @Test - public void testExample11() throws Exception { + void example11() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example11.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/CyclomaticComplexityCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class CyclomaticComplexityCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class CyclomaticComplexityCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/metrics/cyclomaticcomplexity"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/JavaNCSSCheckExamplesTest.java @@ -25,35 +25,35 @@ import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") // -@cs[AbbreviationAsWordInName] Test should be named as its main class. -public class JavaNCSSCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class JavaNCSSCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/metrics/javancss"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/metrics/NPathComplexityCheckExamplesTest.java @@ -25,21 +25,21 @@ import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") // -@cs[AbbreviationAsWordInName] Test should be named as its main class. -public class NPathComplexityCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class NPathComplexityCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/metrics/npathcomplexity"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/modifier/ClassMemberImpliedModifierCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/modifier/ClassMemberImpliedModifierCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ClassMemberImpliedModifierCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ClassMemberImpliedModifierCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/modifier/classmemberimpliedmodifier"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/modifier/InterfaceMemberImpliedModifierCheckExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class InterfaceMemberImpliedModifierCheckExamplesTest +final class InterfaceMemberImpliedModifierCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,14 +32,14 @@ public class InterfaceMemberImpliedModifierCheckExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/modifier/ModifierOrderCheckExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ModifierOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ModifierOrderCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/modifier/modifierorder"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/modifier/RedundantModifierCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RedundantModifierCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RedundantModifierCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/modifier/redundantmodifier"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/AbbreviationAsWordInNameExamplesTest.java @@ -25,7 +25,7 @@ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModuleTestSupport { +final class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModuleTestSupport { private static final int DEFAULT_EXPECTED_CAPITAL_COUNT = 4; @Override @@ -34,7 +34,7 @@ public class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModule } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "18:7: " + getCheckMessage(MSG_KEY, "CURRENT_COUNTER", DEFAULT_EXPECTED_CAPITAL_COUNT), "27:8: " + getCheckMessage(MSG_KEY, "incrementCOUNTER", DEFAULT_EXPECTED_CAPITAL_COUNT), @@ -45,7 +45,7 @@ public class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModule } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "21:7: " + getCheckMessage(MSG_KEY, "CURRENT_COUNTER", DEFAULT_EXPECTED_CAPITAL_COUNT), "23:14: " + getCheckMessage(MSG_KEY, "GLOBAL_COUNTER", DEFAULT_EXPECTED_CAPITAL_COUNT), @@ -58,7 +58,7 @@ public class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModule } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final int expectedCapitalCount = 1; final String[] expected = { @@ -70,7 +70,7 @@ public class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModule } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final int expectedCapitalCount = 2; final String[] expected = { @@ -83,7 +83,7 @@ public class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModule } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final int expectedCapitalCount = 1; final String[] expected = { @@ -96,7 +96,7 @@ public class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModule } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final int expectedCapitalCount = 1; final String[] expected = { @@ -109,7 +109,7 @@ public class AbbreviationAsWordInNameExamplesTest extends AbstractExamplesModule } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("Example7.java"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/AbstractClassNameCheckExamplesTest.java @@ -25,7 +25,7 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractClassNameChe import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class AbstractClassNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AbstractClassNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { private static final String DEFAULT_PATTERN = "^Abstract.+$"; @Override @@ -34,7 +34,7 @@ public class AbstractClassNameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "16:3: " + getCheckMessage(MSG_ILLEGAL_ABSTRACT_CLASS_NAME, "Second", DEFAULT_PATTERN), "17:3: " + getCheckMessage(MSG_NO_ABSTRACT_CLASS_MODIFIER, "AbstractThird", DEFAULT_PATTERN), @@ -46,7 +46,7 @@ public class AbstractClassNameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "18:3: " + getCheckMessage(MSG_ILLEGAL_ABSTRACT_CLASS_NAME, "Second", DEFAULT_PATTERN), "21:3: " @@ -57,7 +57,7 @@ public class AbstractClassNameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "19:3: " + getCheckMessage(MSG_NO_ABSTRACT_CLASS_MODIFIER, "AbstractThird", DEFAULT_PATTERN), }; @@ -66,7 +66,7 @@ public class AbstractClassNameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String pattern = "^Generator.+$"; final String[] expected = { --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/CatchParameterNameCheckExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.CatchParameterNameCh import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class CatchParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class CatchParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { private static final String CATCH_PARAM_NAME_PATTERN_1 = "^(e|t|ex|[a-z][a-z][a-zA-Z]+)$"; private static final String CATCH_PARAM_NAME_PATTERN_2 = "^[a-z][a-zA-Z0-9]+$"; @@ -35,7 +35,7 @@ public class CatchParameterNameCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "18:40: " + getCheckMessage(MSG_INVALID_PATTERN, "e123", CATCH_PARAM_NAME_PATTERN_1), "20:35: " + getCheckMessage(MSG_INVALID_PATTERN, "ab", CATCH_PARAM_NAME_PATTERN_1), @@ -48,7 +48,7 @@ public class CatchParameterNameCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "18:34: " + getCheckMessage(MSG_INVALID_PATTERN, "e", CATCH_PARAM_NAME_PATTERN_2), "26:24: " --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/ClassTypeParameterNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractClassNameChe import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class ClassTypeParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ClassTypeParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/classtypeparametername"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String pattern = "^[A-Z]$"; final String[] expected = { "14:18: " + getCheckMessage(MSG_ILLEGAL_ABSTRACT_CLASS_NAME, "t", pattern), @@ -44,7 +44,7 @@ public class ClassTypeParameterNameCheckExamplesTest extends AbstractExamplesMod } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String pattern = "^[A-Z]{2,}$"; final String[] expected = { "15:18: " + getCheckMessage(MSG_ILLEGAL_ABSTRACT_CLASS_NAME, "T", pattern), @@ -57,7 +57,7 @@ public class ClassTypeParameterNameCheckExamplesTest extends AbstractExamplesMod } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String pattern = "(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"; final String[] expected = { "16:18: " + getCheckMessage(MSG_ILLEGAL_ABSTRACT_CLASS_NAME, "t", pattern), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/ConstantNameCheckExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.ConstantNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class ConstantNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ConstantNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { private static final String DEFAULT_PATTERN = "^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; @Override @@ -33,7 +33,7 @@ public class ConstantNameCheckExamplesTest extends AbstractExamplesModuleTestSup } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:20: " + getCheckMessage(MSG_INVALID_PATTERN, "third_Constant3", DEFAULT_PATTERN), "18:28: " + getCheckMessage(MSG_INVALID_PATTERN, "fourth_Const4", DEFAULT_PATTERN), @@ -47,7 +47,7 @@ public class ConstantNameCheckExamplesTest extends AbstractExamplesModuleTestSup } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String pattern = "^log(ger)?$|^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$"; final String[] expected = { @@ -61,7 +61,7 @@ public class ConstantNameCheckExamplesTest extends AbstractExamplesModuleTestSup } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "20:20: " + getCheckMessage(MSG_INVALID_PATTERN, "third_Constant3", DEFAULT_PATTERN), "21:28: " + getCheckMessage(MSG_INVALID_PATTERN, "fourth_Const4", DEFAULT_PATTERN), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/IllegalIdentifierNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class IllegalIdentifierNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class IllegalIdentifierNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/illegalidentifiername"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String format = "(?i)^(?!(record|yield|var|permits|sealed|_)$).+$"; final String[] expected = { @@ -46,7 +46,7 @@ public class IllegalIdentifierNameCheckExamplesTest extends AbstractExamplesModu } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String format = "(?i)^(?!(record|yield|var|permits|sealed|open|transitive|_)$).+$"; final String[] expected = { --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/InterfaceTypeParameterNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class InterfaceTypeParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class InterfaceTypeParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/interfacetypeparametername"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:29: " + getCheckMessage(MSG_INVALID_PATTERN, "t", "^[A-Z]$"), @@ -41,7 +41,7 @@ public class InterfaceTypeParameterNameCheckExamplesTest extends AbstractExample } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "17:28: " + getCheckMessage(MSG_INVALID_PATTERN, "type", "^[a-zA-Z]$"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/LambdaParameterNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class LambdaParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class LambdaParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/lambdaparametername"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:11: " + getCheckMessage(MSG_INVALID_PATTERN, "S", "^[a-z][a-zA-Z0-9]*$"), }; @@ -40,7 +40,7 @@ public class LambdaParameterNameCheckExamplesTest extends AbstractExamplesModule } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "20:40: " + getCheckMessage(MSG_INVALID_PATTERN, "_s", "^[a-z]([a-zA-Z]+)*$"), "25:23: " + getCheckMessage(MSG_INVALID_PATTERN, "Word", "^[a-z]([a-zA-Z]+)*$"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalFinalVariableNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class LocalFinalVariableNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class LocalFinalVariableNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/localfinalvariablename"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:17: " + getCheckMessage(MSG_INVALID_PATTERN, "VAR1", "^[a-z][a-zA-Z0-9]*$"), "20:17: " + getCheckMessage(MSG_INVALID_PATTERN, "VAR2", "^[a-z][a-zA-Z0-9]*$"), @@ -41,7 +41,7 @@ public class LocalFinalVariableNameCheckExamplesTest extends AbstractExamplesMod } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "18:17: " + getCheckMessage(MSG_INVALID_PATTERN, "var1", "^[A-Z][A-Z0-9]*$"), "21:17: " + getCheckMessage(MSG_INVALID_PATTERN, "var2", "^[A-Z][A-Z0-9]*$"), @@ -51,7 +51,7 @@ public class LocalFinalVariableNameCheckExamplesTest extends AbstractExamplesMod } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "19:17: " + getCheckMessage(MSG_INVALID_PATTERN, "scanner", "^[A-Z][A-Z0-9]*$"), "23:30: " + getCheckMessage(MSG_INVALID_PATTERN, "ex", "^[A-Z][A-Z0-9]*$"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/LocalVariableNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class LocalVariableNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class LocalVariableNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/localvariablename"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; final String[] expected = { "15:14: " + getCheckMessage(MSG_INVALID_PATTERN, "VAR", pattern), @@ -42,7 +42,7 @@ public class LocalVariableNameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String pattern = "^[a-z](_?[a-zA-Z0-9]+)*$"; final String[] expected = { "17:14: " + getCheckMessage(MSG_INVALID_PATTERN, "VAR", pattern), @@ -52,7 +52,7 @@ public class LocalVariableNameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String pattern = "^[a-z](_?[a-zA-Z0-9]+)*$"; final String[] expected = { "20:13: " + getCheckMessage(MSG_INVALID_PATTERN, "K", pattern), @@ -63,7 +63,7 @@ public class LocalVariableNameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String pattern = "^[a-z][_a-zA-Z0-9]+$"; final String[] expected = { "21:9: " + getCheckMessage(MSG_INVALID_PATTERN, "g", pattern), @@ -77,7 +77,7 @@ public class LocalVariableNameCheckExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String pattern = "^[a-z][_a-zA-Z0-9]{2,}$"; final String[] expected = { "17:9: " + getCheckMessage(MSG_INVALID_PATTERN, "i", pattern), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MemberNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.MemberNameCheck.MSG_ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class MemberNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MemberNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/membername"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "21:14: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM1", "^[a-z][a-zA-Z0-9]*$"), "23:17: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM2", "^[a-z][a-zA-Z0-9]*$"), @@ -43,7 +43,7 @@ public class MemberNameCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "16:14: " + getCheckMessage(MSG_INVALID_PATTERN, "num1", "^m[A-Z][a-zA-Z0-9]*$"), "20:15: " + getCheckMessage(MSG_INVALID_PATTERN, "num4", "^m[A-Z][a-zA-Z0-9]*$"), @@ -53,7 +53,7 @@ public class MemberNameCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "16:17: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM2", "^[a-z][a-zA-Z0-9]*$"), "18:7: " + getCheckMessage(MSG_INVALID_PATTERN, "NUM3", "^[a-z][a-zA-Z0-9]*$"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodNameCheckExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.MethodNameCheck.MSG_ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class MethodNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MethodNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/methodname"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "15:16: " + getCheckMessage(MSG_INVALID_PATTERN, "Method3", "^[a-z][a-zA-Z0-9]*$"), "16:15: " + getCheckMessage(MSG_INVALID_PATTERN, "Method4", "^[a-z][a-zA-Z0-9]*$"), @@ -42,7 +42,7 @@ public class MethodNameCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "16:15: " + getCheckMessage(MSG_INVALID_PATTERN, "Method2", "^[a-z](_?[a-zA-Z0-9]+)*$"), }; @@ -51,14 +51,14 @@ public class MethodNameCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.java"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "17:15: " + getCheckMessage(MSG_KEY, "Example4"), }; @@ -67,7 +67,7 @@ public class MethodNameCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "19:16: " + getCheckMessage(MSG_INVALID_PATTERN, "Method3", "^[a-z](_?[a-zA-Z0-9]+)*$"), "20:8: " + getCheckMessage(MSG_INVALID_PATTERN, "Method4", "^[a-z](_?[a-zA-Z0-9]+)*$"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/MethodTypeParameterNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class MethodTypeParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MethodTypeParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/methodtypeparametername"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:11: " + getCheckMessage(MSG_INVALID_PATTERN, "a", "^[A-Z]$"), "16:11: " + getCheckMessage(MSG_INVALID_PATTERN, "k", "^[A-Z]$"), @@ -41,7 +41,7 @@ public class MethodTypeParameterNameCheckExamplesTest extends AbstractExamplesMo } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.java"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/PackageNameCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class PackageNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class PackageNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/packagename"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/ParameterNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.ParameterNameCheck.M import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class ParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/parametername"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:20: " + getCheckMessage(MSG_INVALID_PATTERN, "V2", "^[a-z][a-zA-Z0-9]*$"), }; @@ -40,7 +40,7 @@ public class ParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "17:20: " + getCheckMessage(MSG_INVALID_PATTERN, "V3", "^[a-z][_a-zA-Z0-9]+$"), }; @@ -49,7 +49,7 @@ public class ParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "16:20: " + getCheckMessage(MSG_INVALID_PATTERN, "V2", "^[a-z][a-zA-Z0-9]*$"), }; @@ -58,7 +58,7 @@ public class ParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "16:20: " + getCheckMessage(MSG_INVALID_PATTERN, "v_2", "^[a-z][a-zA-Z0-9]+$"), "17:20: " + getCheckMessage(MSG_INVALID_PATTERN, "V3", "^[a-z][a-zA-Z0-9]+$"), @@ -68,7 +68,7 @@ public class ParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "25:26: " + "Parameter name 'V2' must match pattern '^[a-z]([a-z0-9][a-zA-Z0-9]*)?$'", "27:23: " + "Parameter name 'b' must match pattern '^[a-z][a-z0-9][a-zA-Z0-9]*$'", --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/PatternVariableNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/PatternVariableNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class PatternVariableNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class PatternVariableNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/patternvariablename"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String pattern = "^[a-z][a-zA-Z0-9]*$"; @@ -44,7 +44,7 @@ public class PatternVariableNameCheckExamplesTest extends AbstractExamplesModule } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String pattern = "^[a-z](_?[a-zA-Z0-9]+)*$"; @@ -56,7 +56,7 @@ public class PatternVariableNameCheckExamplesTest extends AbstractExamplesModule } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String pattern = "^[a-z][_a-zA-Z0-9]{2,}$"; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordComponentNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordComponentNameCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RecordComponentNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RecordComponentNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/recordcomponentname"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordTypeParameterNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/RecordTypeParameterNameCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RecordTypeParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RecordTypeParameterNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/recordtypeparametername"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/StaticVariableNameCheckExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class StaticVariableNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class StaticVariableNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { public static final String STATIC_VAR_NAME_PATTERN_1 = "^[a-z][a-zA-Z0-9]*$"; public static final String STATIC_VAR_NAME_PATTERN_2 = "^[a-z](_?[a-zA-Z0-9]+)*$"; @@ -35,7 +35,7 @@ public class StaticVariableNameCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "19:21: " + getCheckMessage(MSG_INVALID_PATTERN, "ItStatic1", STATIC_VAR_NAME_PATTERN_1), "20:24: " + getCheckMessage(MSG_INVALID_PATTERN, "ItStatic2", STATIC_VAR_NAME_PATTERN_1), @@ -50,7 +50,7 @@ public class StaticVariableNameCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "21:22: " + getCheckMessage(MSG_INVALID_PATTERN, "ItStatic", STATIC_VAR_NAME_PATTERN_1), "24:22: " + getCheckMessage(MSG_INVALID_PATTERN, "It_Static1", STATIC_VAR_NAME_PATTERN_1), @@ -61,7 +61,7 @@ public class StaticVariableNameCheckExamplesTest extends AbstractExamplesModuleT } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "19:21: " + getCheckMessage(MSG_INVALID_PATTERN, "ItStatic1", STATIC_VAR_NAME_PATTERN_2), "20:24: " + getCheckMessage(MSG_INVALID_PATTERN, "ItStatic2", STATIC_VAR_NAME_PATTERN_2), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/naming/TypeNameCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.naming.AbstractNameCheck.MS import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class TypeNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class TypeNameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/naming/typename"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "15:8: " + getCheckMessage(MSG_INVALID_PATTERN, "Third_Name", "^[A-Z][a-zA-Z0-9]*$"), "16:17: " + getCheckMessage(MSG_INVALID_PATTERN, "FourthName_", "^[A-Z][a-zA-Z0-9]*$"), @@ -41,7 +41,7 @@ public class TypeNameCheckExamplesTest extends AbstractExamplesModuleTestSupport } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "16:7: " + getCheckMessage(MSG_INVALID_PATTERN, "Example2", "^[a-z](_?[a-zA-Z0-9]+)*$"), "18:16: " + getCheckMessage(MSG_INVALID_PATTERN, "SecondName", "^[a-z](_?[a-zA-Z0-9]+)*$"), @@ -51,7 +51,7 @@ public class TypeNameCheckExamplesTest extends AbstractExamplesModuleTestSupport } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "19:13: " + getCheckMessage(MSG_INVALID_PATTERN, "SecondName", "^I_[a-zA-Z0-9]*$"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpCheckExamplesTest.java @@ -24,98 +24,98 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RegexpCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RegexpCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/regexp/regexp"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); } @Test - public void testExample11() throws Exception { + void example11() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example11.txt"), expected); } @Test - public void testExample12() throws Exception { + void example12() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example12.txt"), expected); } @Test - public void testExample13() throws Exception { + void example13() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example13.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpMultilineCheckExamplesTest.java @@ -24,56 +24,56 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RegexpMultilineCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RegexpMultilineCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/regexp/regexpmultiline"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpOnFilenameCheckExamplesTest.java @@ -24,56 +24,56 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RegexpOnFilenameCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RegexpOnFilenameCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/regexp/regexponfilename"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineCheckExamplesTest.java @@ -24,56 +24,56 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RegexpSinglelineCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RegexpSinglelineCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/regexp/regexpsingleline"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/regexp/RegexpSinglelineJavaCheckExamplesTest.java @@ -24,56 +24,56 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RegexpSinglelineJavaCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RegexpSinglelineJavaCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/regexp/regexpsinglelinejava"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/AnonInnerLengthCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class AnonInnerLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class AnonInnerLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/anoninnerlength"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/ExecutableStatementCountCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ExecutableStatementCountCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ExecutableStatementCountCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/executablestatementcount"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/FileLengthCheckExamplesTest.java @@ -24,21 +24,21 @@ import static com.puppycrawl.tools.checkstyle.checks.sizes.FileLengthCheck.MSG_K import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class FileLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class FileLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/filelength"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.java"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "1: " + getCheckMessage(MSG_KEY, 18, 5), }; @@ -47,7 +47,7 @@ public class FileLengthCheckExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.java"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/LambdaBodyLengthExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/LambdaBodyLengthExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.sizes.LambdaBodyLengthCheck import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class LambdaBodyLengthExamplesTest extends AbstractExamplesModuleTestSupport { +final class LambdaBodyLengthExamplesTest extends AbstractExamplesModuleTestSupport { private static final int DEFAULT_MAX = 10; @Override @@ -33,7 +33,7 @@ public class LambdaBodyLengthExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "25:20: " + getCheckMessage(MSG_KEY, 11, DEFAULT_MAX), "36:20: " + getCheckMessage(MSG_KEY, 11, DEFAULT_MAX), @@ -43,7 +43,7 @@ public class LambdaBodyLengthExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final int max = 5; final String[] expected = { --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckExamplesTest.java @@ -24,49 +24,49 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class LineLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class LineLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/linelength"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodCountCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class MethodCountCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MethodCountCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/methodcount"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/MethodLengthCheckExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.sizes.MethodLengthCheck.MSG import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class MethodLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class MethodLengthCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/methodlength"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final int max = 4; @@ -45,7 +45,7 @@ public class MethodLengthCheckExamplesTest extends AbstractExamplesModuleTestSup } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final int max = 4; @@ -57,7 +57,7 @@ public class MethodLengthCheckExamplesTest extends AbstractExamplesModuleTestSup } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "33:3: " + getCheckMessage(MSG_KEY, 6, 4, "firstMethod"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/OuterTypeNumberCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class OuterTypeNumberCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class OuterTypeNumberCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/outertypenumber"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/ParameterNumberCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class ParameterNumberCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class ParameterNumberCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/parameternumber"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/sizes/RecordComponentNumberCheckExamplesTest.java @@ -24,28 +24,28 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class RecordComponentNumberCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class RecordComponentNumberCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/sizes/recordcomponentnumber"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForInitializerPadExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitiali import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class EmptyForInitializerPadExamplesTest extends AbstractExamplesModuleTestSupport { +final class EmptyForInitializerPadExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/emptyforinitializerpad"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:11: " + getCheckMessage(MSG_PRECEDED, ";"), "20:11: " + getCheckMessage(MSG_PRECEDED, ";"), @@ -42,7 +42,7 @@ public class EmptyForInitializerPadExamplesTest extends AbstractExamplesModuleTe } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "20:10: " + getCheckMessage(MSG_NOT_PRECEDED, ";"), "21:10: " + getCheckMessage(MSG_NOT_PRECEDED, ";"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForIteratorPadExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyForIteratorPadExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIterator import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class EmptyForIteratorPadExamplesTest extends AbstractExamplesModuleTestSupport { +final class EmptyForIteratorPadExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/emptyforiteratorpad"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "22:66: " + getCheckMessage(MSG_WS_FOLLOWED, ";"), }; @@ -41,7 +41,7 @@ public class EmptyForIteratorPadExamplesTest extends AbstractExamplesModuleTestS } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "23:65: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/EmptyLineSeparatorExamplesTest.java @@ -26,14 +26,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparat import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class EmptyLineSeparatorExamplesTest extends AbstractExamplesModuleTestSupport { +final class EmptyLineSeparatorExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/emptylineseparator"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "15:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), @@ -45,7 +45,7 @@ public class EmptyLineSeparatorExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "22:3: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "VARIABLE_DEF"), "29:3: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "METHOD_DEF"), @@ -55,7 +55,7 @@ public class EmptyLineSeparatorExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "17:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), @@ -66,7 +66,7 @@ public class EmptyLineSeparatorExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "16:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "17:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), @@ -80,7 +80,7 @@ public class EmptyLineSeparatorExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "17:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"), "18:1: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/FileTabCharacterExamplesTest.java @@ -26,14 +26,14 @@ import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import com.puppycrawl.tools.checkstyle.utils.CommonUtil; import org.junit.jupiter.api.Test; -public class FileTabCharacterExamplesTest extends AbstractExamplesModuleTestSupport { +final class FileTabCharacterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/filetabcharacter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_FILE_CONTAINS_TAB), }; @@ -42,7 +42,7 @@ public class FileTabCharacterExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_CONTAINS_TAB), "17:1: " + getCheckMessage(MSG_CONTAINS_TAB), }; @@ -51,7 +51,7 @@ public class FileTabCharacterExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "15:1: " + getCheckMessage(MSG_FILE_CONTAINS_TAB), }; @@ -60,7 +60,7 @@ public class FileTabCharacterExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "13:1: " + getCheckMessage(MSG_FILE_CONTAINS_TAB), }; @@ -69,7 +69,7 @@ public class FileTabCharacterExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = CommonUtil.EMPTY_STRING_ARRAY; verifyWithInlineConfigParser(getPath("Example5.html"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/GenericWhitespaceCheckExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class GenericWhitespaceCheckExamplesTest extends AbstractExamplesModuleTestSupport { +final class GenericWhitespaceCheckExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/genericwhitespace"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/MethodParamPadExamplesTest.java @@ -26,14 +26,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCh import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class MethodParamPadExamplesTest extends AbstractExamplesModuleTestSupport { +final class MethodParamPadExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/methodparampad"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "19:19: " + getCheckMessage(MSG_WS_PRECEDED, "("), "20:11: " + getCheckMessage(MSG_WS_PRECEDED, "("), @@ -44,7 +44,7 @@ public class MethodParamPadExamplesTest extends AbstractExamplesModuleTestSuppor } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "27:21: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "("), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoLineWrapExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoLineWrapExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoLineWrapCheck. import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class NoLineWrapExamplesTest extends AbstractExamplesModuleTestSupport { +final class NoLineWrapExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/nolinewrap"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_KEY, "package"), "15:1: " + getCheckMessage(MSG_KEY, "import"), @@ -42,7 +42,7 @@ public class NoLineWrapExamplesTest extends AbstractExamplesModuleTestSupport { } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "12:1: " + getCheckMessage(MSG_KEY, "package"), "16:1: " + getCheckMessage(MSG_KEY, "import"), @@ -53,7 +53,7 @@ public class NoLineWrapExamplesTest extends AbstractExamplesModuleTestSupport { } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "14:1: " + getCheckMessage(MSG_KEY, "import"), }; @@ -62,7 +62,7 @@ public class NoLineWrapExamplesTest extends AbstractExamplesModuleTestSupport { } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "18:1: " + getCheckMessage(MSG_KEY, "import"), }; @@ -71,7 +71,7 @@ public class NoLineWrapExamplesTest extends AbstractExamplesModuleTestSupport { } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "19:1: " + getCheckMessage(MSG_KEY, "CLASS_DEF"), "25:3: " + getCheckMessage(MSG_KEY, "METHOD_DEF"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceAfterExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfte import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class NoWhitespaceAfterExamplesTest extends AbstractExamplesModuleTestSupport { +final class NoWhitespaceAfterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespaceafter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "23:12: " + getCheckMessage(MSG_KEY, "."), "28:9: " + getCheckMessage(MSG_KEY, "int"), @@ -42,7 +42,7 @@ public class NoWhitespaceAfterExamplesTest extends AbstractExamplesModuleTestSup } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "19:12: " + getCheckMessage(MSG_KEY, "."), "26:12: " + getCheckMessage(MSG_KEY, "."), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCaseDefaultColonExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeCaseDefaultColonExamplesTest.java @@ -24,7 +24,7 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBefo import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class NoWhitespaceBeforeCaseDefaultColonExamplesTest +final class NoWhitespaceBeforeCaseDefaultColonExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -33,7 +33,7 @@ public class NoWhitespaceBeforeCaseDefaultColonExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "19:14: " + getCheckMessage(MSG_KEY, ":"), "23:15: " + getCheckMessage(MSG_KEY, ":"), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/NoWhitespaceBeforeExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBefo import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class NoWhitespaceBeforeExamplesTest extends AbstractExamplesModuleTestSupport { +final class NoWhitespaceBeforeExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/nowhitespacebefore"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "19:9: " + getCheckMessage(MSG_KEY, "++"), "21:20: " + getCheckMessage(MSG_KEY, ";"), @@ -44,7 +44,7 @@ public class NoWhitespaceBeforeExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "23:31: " + getCheckMessage(MSG_KEY, "..."), }; @@ -53,7 +53,7 @@ public class NoWhitespaceBeforeExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "21:10: " + getCheckMessage(MSG_KEY, "."), "23:74: " + getCheckMessage(MSG_KEY, "::"), }; @@ -62,7 +62,7 @@ public class NoWhitespaceBeforeExamplesTest extends AbstractExamplesModuleTestSu } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "21:11: " + getCheckMessage(MSG_KEY, "."), "23:40: " + getCheckMessage(MSG_KEY, "::"), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/OperatorWrapExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/OperatorWrapExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapChec import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class OperatorWrapExamplesTest extends AbstractExamplesModuleTestSupport { +final class OperatorWrapExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/operatorwrap"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "16:24: " + getCheckMessage(MSG_LINE_NEW, "+"), "19:12: " + getCheckMessage(MSG_LINE_NEW, "=="), @@ -43,7 +43,7 @@ public class OperatorWrapExamplesTest extends AbstractExamplesModuleTestSupport } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "23:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "="), "27:13: " + getCheckMessage(MSG_LINE_PREVIOUS, "+="), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/ParenPadExamplesTest.java @@ -27,14 +27,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPad import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class ParenPadExamplesTest extends AbstractExamplesModuleTestSupport { +final class ParenPadExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/parenpad"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "18:8: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "21:25: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -45,7 +45,7 @@ public class ParenPadExamplesTest extends AbstractExamplesModuleTestSupport { } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "29:27: " + getCheckMessage(MSG_WS_NOT_PRECEDED, ")"), "39:12: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SeparatorWrapExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SeparatorWrapExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapChe import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class SeparatorWrapExamplesTest extends AbstractExamplesModuleTestSupport { +final class SeparatorWrapExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/separatorwrap"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "24:21: " + getCheckMessage(MSG_LINE_PREVIOUS, ","), "26:11: " + getCheckMessage(MSG_LINE_PREVIOUS, "."), @@ -42,7 +42,7 @@ public class SeparatorWrapExamplesTest extends AbstractExamplesModuleTestSupport } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "23:36: " + getCheckMessage(MSG_LINE_NEW, "::"), }; @@ -51,7 +51,7 @@ public class SeparatorWrapExamplesTest extends AbstractExamplesModuleTestSupport } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "19:8: " + getCheckMessage(MSG_LINE_NEW, ","), "22:17: " + getCheckMessage(MSG_LINE_NEW, ","), }; --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SingleSpaceSeparatorExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/SingleSpaceSeparatorExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.SingleSpaceSepar import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class SingleSpaceSeparatorExamplesTest extends AbstractExamplesModuleTestSupport { +final class SingleSpaceSeparatorExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/singlespaceseparator"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "15:15: " + getCheckMessage(MSG_KEY), "16:13: " + getCheckMessage(MSG_KEY), @@ -42,7 +42,7 @@ public class SingleSpaceSeparatorExamplesTest extends AbstractExamplesModuleTest } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "18:19: " + getCheckMessage(MSG_KEY), "20:28: " + getCheckMessage(MSG_KEY), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/TypecastParenPadExamplesTest.java @@ -27,14 +27,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPad import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class TypecastParenPadExamplesTest extends AbstractExamplesModuleTestSupport { +final class TypecastParenPadExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/typecastparenpad"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "17:11: " + getCheckMessage(MSG_WS_FOLLOWED, "("), "17:17: " + getCheckMessage(MSG_WS_PRECEDED, ")"), @@ -46,7 +46,7 @@ public class TypecastParenPadExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "21:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), "25:11: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "("), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAfterExamplesTest.java @@ -24,14 +24,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterC import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class WhitespaceAfterExamplesTest extends AbstractExamplesModuleTestSupport { +final class WhitespaceAfterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/whitespaceafter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "19:12: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "if"), "23:16: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), @@ -50,7 +50,7 @@ public class WhitespaceAfterExamplesTest extends AbstractExamplesModuleTestSuppo } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "19:14: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"), "22:17: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ","), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/whitespace/WhitespaceAroundExamplesTest.java @@ -25,14 +25,14 @@ import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAround import com.puppycrawl.tools.checkstyle.AbstractExamplesModuleTestSupport; import org.junit.jupiter.api.Test; -public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupport { +final class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/checks/whitespace/whitespacearound"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = { "15:20: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "15:20: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "{"), @@ -54,7 +54,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = { "21:10: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), "21:10: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), @@ -78,7 +78,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = { "17:22: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), }; @@ -87,7 +87,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = { "18:8: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), "18:8: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -97,7 +97,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = { "18:28: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "{"), "18:29: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "}"), @@ -107,7 +107,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = { "20:10: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), "20:10: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -117,7 +117,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = { "21:10: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), "21:10: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -127,7 +127,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = { "19:10: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), "19:10: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -137,7 +137,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = { "18:10: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), "18:10: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), @@ -147,7 +147,7 @@ public class WhitespaceAroundExamplesTest extends AbstractExamplesModuleTestSupp } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = { "18:10: " + getCheckMessage(MSG_WS_NOT_PRECEDED, "="), "18:10: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, "="), --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filefilters/BeforeExecutionExclusionFileFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filefilters/BeforeExecutionExclusionFileFilterExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class BeforeExecutionExclusionFileFilterExamplesTest +final class BeforeExecutionExclusionFileFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { @@ -32,21 +32,21 @@ public class BeforeExecutionExclusionFileFilterExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SeverityMatchFilterExamplesTest.java @@ -24,14 +24,14 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SeverityMatchFilterExamplesTest extends AbstractExamplesModuleTestSupport { +final class SeverityMatchFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/filters/severitymatchfilter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWarningsFilterExamplesTest.java @@ -24,21 +24,21 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SuppressWarningsFilterExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuppressWarningsFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/filters/suppresswarningsfilter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyCommentFilterExamplesTest.java @@ -24,63 +24,63 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SuppressWithNearbyCommentFilterExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuppressWithNearbyCommentFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/filters/suppresswithnearbycommentfilter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithNearbyTextFilterExamplesTest.java @@ -24,70 +24,70 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SuppressWithNearbyTextFilterExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuppressWithNearbyTextFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/filters/suppresswithnearbytextfilter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressWithPlainTextCommentFilterExamplesTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SuppressWithPlainTextCommentFilterExamplesTest +final class SuppressWithPlainTextCommentFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override @@ -33,63 +33,63 @@ public class SuppressWithPlainTextCommentFilterExamplesTest } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getNonCompilablePath("Example9.java"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionCommentFilterExamplesTest.java @@ -24,63 +24,63 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SuppressionCommentFilterExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuppressionCommentFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/filters/suppressioncommentfilter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionSingleFilterExamplesTest.java @@ -24,77 +24,77 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SuppressionSingleFilterExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuppressionSingleFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/filters/suppressionsinglefilter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); --- a/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilterExamplesTest.java +++ b/src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/filters/SuppressionXpathSingleFilterExamplesTest.java @@ -24,105 +24,105 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @Disabled("until https://github.com/checkstyle/checkstyle/issues/13345") -public class SuppressionXpathSingleFilterExamplesTest extends AbstractExamplesModuleTestSupport { +final class SuppressionXpathSingleFilterExamplesTest extends AbstractExamplesModuleTestSupport { @Override protected String getPackageLocation() { return "com/puppycrawl/tools/checkstyle/filters/suppressionxpathsinglefilter"; } @Test - public void testExample1() throws Exception { + void example1() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example1.txt"), expected); } @Test - public void testExample2() throws Exception { + void example2() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example2.txt"), expected); } @Test - public void testExample3() throws Exception { + void example3() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example3.txt"), expected); } @Test - public void testExample4() throws Exception { + void example4() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example4.txt"), expected); } @Test - public void testExample5() throws Exception { + void example5() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example5.txt"), expected); } @Test - public void testExample6() throws Exception { + void example6() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example6.txt"), expected); } @Test - public void testExample7() throws Exception { + void example7() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example7.txt"), expected); } @Test - public void testExample8() throws Exception { + void example8() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example8.txt"), expected); } @Test - public void testExample9() throws Exception { + void example9() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example9.txt"), expected); } @Test - public void testExample10() throws Exception { + void example10() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example10.txt"), expected); } @Test - public void testExample11() throws Exception { + void example11() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example11.txt"), expected); } @Test - public void testExample12() throws Exception { + void example12() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example12.txt"), expected); } @Test - public void testExample13() throws Exception { + void example13() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example13.txt"), expected); } @Test - public void testExample14() throws Exception { + void example14() throws Exception { final String[] expected = {}; verifyWithInlineConfigParser(getPath("Example14.txt"), expected);