emptyList());
assertThat(options.files()).isEmpty();
assertThat(options.stdin()).isFalse();
@@ -56,7 +56,7 @@ public void defaults() {
}
@Test
- public void hello() {
+ void hello() {
CommandLineOptions options =
CommandLineOptionsParser.parse(Arrays.asList("-lines=1:10,20:30", "-i", "Hello.java", "Goodbye.java"));
assertThat(options.lines().asRanges()).containsExactly(Range.closedOpen(0, 10), Range.closedOpen(19, 30));
@@ -65,32 +65,32 @@ public void hello() {
}
@Test
- public void stdin() {
+ void stdin() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-")).stdin()).isTrue();
}
@Test
- public void styleFlagsAreUnsupported() {
+ void styleFlagsAreUnsupported() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-aosp", "--aosp", "-a", "--ojf", "-ojf"))
.unsupportedFlags())
.containsExactly("-aosp", "--aosp", "-a", "--ojf", "-ojf");
}
@Test
- public void help() {
+ void help() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-help")).help())
.isTrue();
}
@Test
- public void lengths() {
+ void lengths() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-length", "1", "--length", "2"))
.lengths())
.containsExactly(1, 2);
}
@Test
- public void lines() {
+ void lines() {
assertThat(CommandLineOptionsParser.parse(
Arrays.asList("--lines", "1:2", "-lines=4:5", "--line", "7:8", "-line=10:11"))
.lines()
@@ -103,54 +103,54 @@ public void lines() {
}
@Test
- public void offset() {
+ void offset() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-offset", "1", "--offset", "2"))
.offsets())
.containsExactly(1, 2);
}
@Test
- public void inPlace() {
+ void inPlace() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-i", "A.java")).inPlace())
.isTrue();
}
@Test
- public void version() {
+ void version() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-v")).version())
.isTrue();
}
@Test
- public void skipSortingImports() {
+ void skipSortingImports() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--skip-sorting-imports"))
.sortImports())
.isFalse();
}
@Test
- public void skipRemovingUnusedImports() {
+ void skipRemovingUnusedImports() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--skip-removing-unused-imports"))
.removeUnusedImports())
.isFalse();
}
@Test
- public void dryRun() {
+ void dryRun() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--dry-run")).dryRun())
.isTrue();
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-n")).dryRun()).isTrue();
}
@Test
- public void setExitIfChanged() {
+ void setExitIfChanged() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--set-exit-if-changed"))
.setExitIfChanged())
.isTrue();
}
@Test
- public void mergedLines() {
+ void mergedLines() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-lines=1:5", "-lines=2:8"))
.lines()
.asRanges())
@@ -158,7 +158,7 @@ public void mergedLines() {
}
@Test
- public void repeatedLines() {
+ void repeatedLines() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("-lines=1:1", "-lines=1:1"))
.lines()
.asRanges())
@@ -166,7 +166,7 @@ public void repeatedLines() {
}
@Test
- public void paramsFile() throws IOException {
+ void paramsFile() throws IOException {
Path outer = Files.createFile(testFolder.resolve("outer"));
Path exit = Files.createFile(testFolder.resolve("exit"));
Path nested = Files.createFile(testFolder.resolve("nested"));
@@ -182,7 +182,7 @@ public void paramsFile() throws IOException {
}
@Test
- public void paramsFileWithNesting() throws IOException {
+ void paramsFileWithNesting() throws IOException {
Path outer = Files.createFile(testFolder.resolve("outer"));
Path exit = Files.createFile(testFolder.resolve("exit"));
Path nested1 = Files.createFile(testFolder.resolve("nested1"));
@@ -202,7 +202,7 @@ public void paramsFileWithNesting() throws IOException {
}
@Test
- public void paramsFileWithRecursion() throws IOException {
+ void paramsFileWithRecursion() throws IOException {
Path outer = Files.createFile(testFolder.resolve("outer"));
Path exit = Files.createFile(testFolder.resolve("exit"));
Path nested1 = Files.createFile(testFolder.resolve("nested1"));
@@ -221,7 +221,7 @@ public void paramsFileWithRecursion() throws IOException {
}
@Test
- public void paramsFileWithQuotesAndWhitespaces() throws IOException {
+ void paramsFileWithQuotesAndWhitespaces() throws IOException {
Path outer = Files.createFile(testFolder.resolve("outer with whitespace"));
Path exit = Files.createFile(testFolder.resolve("exit with whitespace"));
Path nested = Files.createFile(testFolder.resolve("nested with whitespace"));
@@ -237,7 +237,7 @@ public void paramsFileWithQuotesAndWhitespaces() throws IOException {
}
@Test
- public void assumeFilename() {
+ void assumeFilename() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--assume-filename", "Foo.java"))
.assumeFilename())
.hasValue("Foo.java");
@@ -246,7 +246,7 @@ public void assumeFilename() {
}
@Test
- public void skipReflowLongStrings() {
+ void skipReflowLongStrings() {
assertThat(CommandLineOptionsParser.parse(Arrays.asList("--skip-reflowing-long-strings"))
.reflowLongStrings())
.isFalse();
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/DiagnosticTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/DiagnosticTest.java
index d5dae53d2..5961a4335 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/DiagnosticTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/DiagnosticTest.java
@@ -35,25 +35,25 @@
import org.junit.jupiter.api.parallel.ExecutionMode;
@Execution(ExecutionMode.CONCURRENT)
-public class DiagnosticTest {
+final class DiagnosticTest {
@TempDir
public Path testFolder;
private Locale backupLocale;
@BeforeEach
- public void setUpLocale() throws Exception {
+ void setUpLocale() throws Exception {
backupLocale = Locale.getDefault();
Locale.setDefault(Locale.ROOT);
}
@AfterEach
- public void restoreLocale() throws Exception {
+ void restoreLocale() throws Exception {
Locale.setDefault(backupLocale);
}
@Test
- public void parseError() throws Exception {
+ void parseError() throws Exception {
@SuppressWarnings("for-rollout:StringConcatToTextBlock")
String input = Joiner.on('\n')
.join(
@@ -83,7 +83,7 @@ public void parseError() throws Exception {
}
@Test
- public void lexError() throws Exception {
+ void lexError() throws Exception {
String input = "\\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuu00not-actually-a-unicode-escape-sequence";
StringWriter stdout = new StringWriter();
@@ -100,7 +100,7 @@ public void lexError() throws Exception {
}
@Test
- public void oneFileParseError() throws Exception {
+ void oneFileParseError() throws Exception {
String one = "class One {\n";
String two = "class Two {}\n";
@@ -121,7 +121,7 @@ public void oneFileParseError() throws Exception {
}
@Test
- public void oneFileParseErrorReplace() throws Exception {
+ void oneFileParseErrorReplace() throws Exception {
String one = "class One {}}\n";
String two = "class Two {\n}\n";
@@ -145,7 +145,7 @@ public void oneFileParseErrorReplace() throws Exception {
}
@Test
- public void parseError2() throws FormatterException, IOException, UsageException {
+ void parseError2() throws FormatterException, IOException, UsageException {
String input = "class Foo { void f() {\n g() } }";
Path path = testFolder.resolve("A.java");
@@ -163,7 +163,7 @@ public void parseError2() throws FormatterException, IOException, UsageException
}
@Test
- public void parseErrorStdin() throws FormatterException, IOException, UsageException {
+ void parseErrorStdin() throws FormatterException, IOException, UsageException {
String input = "class Foo { void f() {\n g() } }";
InputStream inStream = new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8));
@@ -178,7 +178,7 @@ public void parseErrorStdin() throws FormatterException, IOException, UsageExcep
}
@Test
- public void lexError2() throws FormatterException, IOException, UsageException {
+ void lexError2() throws FormatterException, IOException, UsageException {
String input = "class Foo { void f() {\n g('foo'); } }";
Path path = testFolder.resolve("A.java");
@@ -196,7 +196,7 @@ public void lexError2() throws FormatterException, IOException, UsageException {
}
@Test
- public void lexErrorStdin() throws FormatterException, IOException, UsageException {
+ void lexErrorStdin() throws FormatterException, IOException, UsageException {
String input = "class Foo { void f() {\n g('foo'); } }";
InputStream inStream = new ByteArrayInputStream(input.getBytes(StandardCharsets.UTF_8));
StringWriter out = new StringWriter();
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/FormatterTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/FormatterTest.java
index ae8796bd9..73d290b1e 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/FormatterTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/FormatterTest.java
@@ -41,13 +41,13 @@
import org.junit.jupiter.api.parallel.ExecutionMode;
@Execution(ExecutionMode.CONCURRENT)
-public final class FormatterTest {
+final class FormatterTest {
@TempDir
public Path testFolder;
@Test
- public void testFormatNonJavaFiles() throws Exception {
+ void formatNonJavaFiles() throws Exception {
StringWriter out = new StringWriter();
StringWriter err = new StringWriter();
Main main = new Main(new PrintWriter(out, true), new PrintWriter(err, true), System.in);
@@ -62,7 +62,7 @@ public void testFormatNonJavaFiles() throws Exception {
}
@Test
- public void testFormatStdinStdoutWithDashFlag() throws Exception {
+ void formatStdinStdoutWithDashFlag() throws Exception {
@SuppressWarnings("for-rollout:StringConcatToTextBlock")
String input = "class Foo{\n" + "void f\n" + "() {\n" + "}\n" + "}\n";
@SuppressWarnings("for-rollout:StringConcatToTextBlock")
@@ -83,7 +83,7 @@ public void testFormatStdinStdoutWithDashFlag() throws Exception {
}
@Test
- public void testFormatLengthUpToEOF() throws Exception {
+ void formatLengthUpToEOF() throws Exception {
@SuppressWarnings("for-rollout:StringConcatToTextBlock")
String input = "class Foo{\n" + "void f\n" + "() {\n" + "}\n" + "}\n\n\n\n\n\n";
@SuppressWarnings("for-rollout:StringConcatToTextBlock")
@@ -102,7 +102,7 @@ public void testFormatLengthUpToEOF() throws Exception {
}
@Test
- public void testFormatLengthOutOfRange() throws Exception {
+ void formatLengthOutOfRange() throws Exception {
String input = "class Foo{}\n";
Path path = testFolder.resolve("Foo.java");
@@ -118,7 +118,7 @@ public void testFormatLengthOutOfRange() throws Exception {
}
@Test
- public void blankInClassBody() throws FormatterException {
+ void blankInClassBody() throws FormatterException {
String input = "package test;\nclass T {\n\n}\n";
String output = Formatter.create().formatSource(input);
String expect = "package test;\n\nclass T {}\n";
@@ -126,7 +126,7 @@ public void blankInClassBody() throws FormatterException {
}
@Test
- public void blankInClassBodyNoTrailing() throws FormatterException {
+ void blankInClassBodyNoTrailing() throws FormatterException {
String input = "package test;\nclass T {\n\n}";
String output = Formatter.create().formatSource(input);
String expect = "package test;\n\nclass T {}\n";
@@ -134,7 +134,7 @@ public void blankInClassBodyNoTrailing() throws FormatterException {
}
@Test
- public void docCommentTrailingBlank() throws FormatterException {
+ void docCommentTrailingBlank() throws FormatterException {
String input = "class T {\n/** asd */\n\nint x;\n}";
String output = Formatter.create().formatSource(input);
String expect = "class T {\n /** asd */\n int x;\n}\n";
@@ -142,7 +142,7 @@ public void docCommentTrailingBlank() throws FormatterException {
}
@Test
- public void blockCommentInteriorTrailingBlank() throws FormatterException {
+ void blockCommentInteriorTrailingBlank() throws FormatterException {
String input = "class T {\n/*\n* asd \n* fgh\n*/ \n\nint x;\n}";
String output = Formatter.create().formatSource(input);
String expect = "class T {\n /*\n * asd\n * fgh\n */\n\n int x;\n}\n";
@@ -150,7 +150,7 @@ public void blockCommentInteriorTrailingBlank() throws FormatterException {
}
@Test
- public void blockCommentTrailingBlank() throws FormatterException {
+ void blockCommentTrailingBlank() throws FormatterException {
String input = "class T {\n/* asd */ \n\nint x;\n}";
String output = Formatter.create().formatSource(input);
String expect = "class T {\n /* asd */\n\n int x;\n}\n";
@@ -158,7 +158,7 @@ public void blockCommentTrailingBlank() throws FormatterException {
}
@Test
- public void lineCommentTrailingBlank() throws FormatterException {
+ void lineCommentTrailingBlank() throws FormatterException {
String input = "class T {\n// asd \n\nint x;\n}";
String output = Formatter.create().formatSource(input);
String expect = "class T {\n // asd\n\n int x;\n}\n";
@@ -166,7 +166,7 @@ public void lineCommentTrailingBlank() throws FormatterException {
}
@Test
- public void lineCommentTrailingThinSpace() throws FormatterException {
+ void lineCommentTrailingThinSpace() throws FormatterException {
// The Unicode thin space is matched by CharMatcher.whitespace() but not trim().
String input = "class T {\n // asd\u2009\n}\n";
String output = Formatter.create().formatSource(input);
@@ -175,7 +175,7 @@ public void lineCommentTrailingThinSpace() throws FormatterException {
}
@Test
- public void noBlankAfterLineCommentWithInteriorBlankLine() throws FormatterException {
+ void noBlankAfterLineCommentWithInteriorBlankLine() throws FormatterException {
String input = "class T {\n// asd \n\n// dsa \nint x;\n}";
String output = Formatter.create().formatSource(input);
String expect = "class T {\n // asd\n\n // dsa\n int x;\n}\n";
@@ -183,7 +183,7 @@ public void noBlankAfterLineCommentWithInteriorBlankLine() throws FormatterExcep
}
@Test
- public void badConstructor() throws FormatterException {
+ void badConstructor() throws FormatterException {
String input = "class X { Y() {} }";
String output = Formatter.create().formatSource(input);
String expect = "class X {\n Y() {}\n}\n";
@@ -191,7 +191,7 @@ public void badConstructor() throws FormatterException {
}
@Test
- public void voidMethod() throws FormatterException {
+ void voidMethod() throws FormatterException {
String input = "class X { void Y() {} }";
String output = Formatter.create().formatSource(input);
String expect = "class X {\n void Y() {}\n}\n";
@@ -214,7 +214,7 @@ public void voidMethod() throws FormatterException {
"import javax.annotations.Nullable;");
@Test
- public void importsNotReorderedByDefault() throws FormatterException {
+ void importsNotReorderedByDefault() throws FormatterException {
String input = "package com.google.example;\n" + UNORDERED_IMPORTS + "\npublic class ExampleTest {}\n";
String output = Formatter.create().formatSource(input);
String expect = "package com.google.example;\n\n" + UNORDERED_IMPORTS + "\n\npublic class ExampleTest {}\n";
@@ -222,7 +222,7 @@ public void importsNotReorderedByDefault() throws FormatterException {
}
@Test
- public void importsFixedIfRequested() throws FormatterException {
+ void importsFixedIfRequested() throws FormatterException {
String input = "package com.google.example;\n"
+ UNORDERED_IMPORTS
+ "\npublic class ExampleTest {\n"
@@ -241,24 +241,24 @@ public void importsFixedIfRequested() throws FormatterException {
}
@Test
- public void importOrderingWithoutFormatting() throws IOException, UsageException {
+ void importOrderingWithoutFormatting() throws IOException, UsageException {
importOrdering("--fix-imports-only", "com/palantir/javaformat/java/testimports/A.imports-only");
}
@Test
- public void importOrderingAndFormatting() throws IOException, UsageException {
+ void importOrderingAndFormatting() throws IOException, UsageException {
importOrdering(null, "com/palantir/javaformat/java/testimports/A.imports-and-formatting");
}
@Test
- public void formattingWithoutImportOrdering() throws IOException, UsageException {
+ void formattingWithoutImportOrdering() throws IOException, UsageException {
importOrdering(
"--skip-sorting-imports",
"com/palantir/javaformat/java/testimports/A.formatting-and-unused-import-removal");
}
@Test
- public void formattingWithoutRemovingUnusedImports() throws IOException, UsageException {
+ void formattingWithoutRemovingUnusedImports() throws IOException, UsageException {
importOrdering(
"--skip-removing-unused-imports",
"com/palantir/javaformat/java/testimports/A.formatting-and-import-sorting");
@@ -294,24 +294,24 @@ private String getResource(String resourceName) throws IOException {
// regression test for google-java-format#47
@Test
- public void testTrailingCommentWithoutTerminalNewline() throws Exception {
+ void trailingCommentWithoutTerminalNewline() throws Exception {
assertThat(Formatter.create().formatSource("/*\n * my comment */")).isEqualTo("/*\n * my comment */\n");
}
@Test
- public void testEmptyArray() throws Exception {
+ void emptyArray() throws Exception {
assertThat(Formatter.create().formatSource("class T { int x[] = {,}; }"))
.isEqualTo("class T {\n int x[] = {,};\n}\n");
}
@Test
- public void stringEscapeLength() throws Exception {
+ void stringEscapeLength() throws Exception {
assertThat(Formatter.create().formatSource("class T {{ f(\"\\\"\"); }}"))
.isEqualTo("class T {\n {\n f(\"\\\"\");\n }\n}\n");
}
@Test
- public void wrapLineComment() throws Exception {
+ void wrapLineComment() throws Exception {
assertThat(Formatter.create()
.formatSource("class T {\n"
+ " public static void main(String[] args) { // one long incredibly"
@@ -330,7 +330,7 @@ public void wrapLineComment() throws Exception {
}
@Test
- public void onlyWrapLineCommentOnWhitespace() throws Exception {
+ void onlyWrapLineCommentOnWhitespace() throws Exception {
assertThat(Formatter.create()
.formatSource("class T {\n"
+ " public static void main(String[] args) { // one_long_incredibly"
@@ -349,7 +349,7 @@ public void onlyWrapLineCommentOnWhitespace() throws Exception {
}
@Test
- public void onlyWrapLineCommentOnWhitespace_noLeadingWhitespace() throws Exception {
+ void onlyWrapLineCommentOnWhitespace_noLeadingWhitespace() throws Exception {
assertThat(Formatter.create()
.formatSource("class T {\n"
+ " public static void main(String[] args) { //one_long_incredibly"
@@ -368,13 +368,13 @@ public void onlyWrapLineCommentOnWhitespace_noLeadingWhitespace() throws Excepti
}
@Test
- public void throwsFormatterException() throws Exception {
+ void throwsFormatterException() throws Exception {
assertThatThrownBy(() -> Formatter.create().formatSourceAndFixImports("package foo; public class {"))
.isInstanceOf(FormatterException.class);
}
@Test
- public void blankLinesImportComment() throws FormatterException {
+ void blankLinesImportComment() throws FormatterException {
@SuppressWarnings("for-rollout:StringConcatToTextBlock")
String withBlank = "package p;\n"
+ "\n"
@@ -403,7 +403,7 @@ public void blankLinesImportComment() throws FormatterException {
}
@Test
- public void wrapMarkdownDocstringComment() throws Exception {
+ void wrapMarkdownDocstringComment() throws Exception {
String input = "class T {\n"
+ " /// one long incredibly unbroken sentence moving from topic to topic so that no-one"
+ " had a chance to interrupt;\n"
@@ -419,7 +419,7 @@ public void wrapMarkdownDocstringComment() throws Exception {
}
@Test
- public void dontWrapMoeLineComments() throws Exception {
+ void dontWrapMoeLineComments() throws Exception {
assertThat(Formatter.create()
.formatSource("class T {\n"
+ " // MOE: one long incredibly"
@@ -510,7 +510,7 @@ void indentsCommentsThatShareALineLinearly() throws FormatterException {
}
@Test
- public void removeTrailingTabsInComments() throws FormatterException {
+ void removeTrailingTabsInComments() throws FormatterException {
String input = "class Foo {\n void f() {\n int x = 0; // comment\t\t\t\n return;\n }\n}\n";
String expected = "class Foo {\n void f() {\n int x = 0; // comment\n return;\n }\n}\n";
Formatter formatter = Formatter.createFormatter(
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/FormatterVersionTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/FormatterVersionTest.java
index b04e99446..6de9a576b 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/FormatterVersionTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/FormatterVersionTest.java
@@ -25,10 +25,10 @@
* Guards CI's {@code jdk} legs: without this, a leg that runs on an older JDK than the one it asked for with
* {@code -PjavaRuntime} skips the {@code ModuleImport} golden and the module import tests, and still passes.
*/
-public class FormatterVersionTest {
+final class FormatterVersionTest {
@Test
- public void runsOnTheJdkTheTestTaskAskedFor() {
+ void runsOnTheJdkTheTestTaskAskedFor() {
String expected = System.getProperty("expectedJavaVersion");
Assumptions.assumeTrue(expected != null, "expectedJavaVersion is set by the Gradle build");
assertThat(Formatter.getRuntimeVersion()).isEqualTo(Integer.parseInt(expected));
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/JavadocFormattingTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/JavadocFormattingTest.java
index 3a6fcdb7c..da51929fe 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/JavadocFormattingTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/JavadocFormattingTest.java
@@ -26,7 +26,7 @@
/** Tests formatting javadoc. */
@Execution(ExecutionMode.CONCURRENT)
-public final class JavadocFormattingTest {
+final class JavadocFormattingTest {
private final Formatter formatter = new Formatter(
JavaFormatterOptions.builder()
@@ -36,7 +36,7 @@ public final class JavadocFormattingTest {
false);
@Test
- public void notJavadoc() {
+ void notJavadoc() {
String[] input = {
"/**/", //
"class Test {}",
@@ -49,7 +49,7 @@ public void notJavadoc() {
}
@Test
- public void empty() {
+ void empty() {
String[] input = {
"/***/", //
"class Test {}",
@@ -61,7 +61,7 @@ public void empty() {
}
@Test
- public void bannerCommentIsNotJavadoc() {
+ void bannerCommentIsNotJavadoc() {
// A comment that opens with three or more asterisks is left to the plain comment handling: reflowing it as
// javadoc would push the asterisks onto a line of their own and turn its paragraphs into tags.
String[] input = {
@@ -78,7 +78,7 @@ public void bannerCommentIsNotJavadoc() {
}
@Test
- public void emptyMultipleLines() {
+ void emptyMultipleLines() {
String[] input = {
"/**", //
" */",
@@ -91,7 +91,7 @@ public void emptyMultipleLines() {
}
@Test
- public void simple() {
+ void simple() {
String[] input = {
"/** */", //
"class Test {}",
@@ -103,7 +103,7 @@ public void simple() {
}
@Test
- public void commentMostlyUntouched() {
+ void commentMostlyUntouched() {
// This test isn't necessarily what we'd want to do, but it's what we do now, and it's OK-ish.
String[] input = {
"/**", " * Foo.", " *", " * bar", " */", "class Test {}",
@@ -115,7 +115,7 @@ public void commentMostlyUntouched() {
}
@Test
- public void moeComments() {
+ void moeComments() {
String[] input = {
"/**",
" * Deatomizes the given user.",
@@ -168,7 +168,7 @@ public void moeComments() {
}
@Test
- public void moeCommentBeginOnlyInMiddleOfDoc() {
+ void moeCommentBeginOnlyInMiddleOfDoc() {
// We don't really care what happens here so long as we don't explode.
String[] input = {
"/**", //
@@ -190,7 +190,7 @@ public void moeCommentBeginOnlyInMiddleOfDoc() {
}
@Test
- public void moeCommentBeginOnlyAtEndOfDoc() {
+ void moeCommentBeginOnlyAtEndOfDoc() {
// We don't really care what happens here so long as we don't explode.
// TODO(cpovirk): OK, maybe try to leave it in....
String[] input = {
@@ -208,7 +208,7 @@ public void moeCommentBeginOnlyAtEndOfDoc() {
}
@Test
- public void moeCommentEndOnly() {
+ void moeCommentEndOnly() {
// We don't really care what happens here so long as we don't explode.
String[] input = {
"/**", //
@@ -228,7 +228,7 @@ public void moeCommentEndOnly() {
}
@Test
- public void tableMostlyUntouched() {
+ void tableMostlyUntouched() {
String[] input = {
"/**",
" * Foo.",
@@ -261,7 +261,7 @@ public void tableMostlyUntouched() {
}
@Test
- public void preMostlyUntouched() {
+ void preMostlyUntouched() {
/*
* Arguably we shouldn't insert the space between "*" and "4," since doing so changes the
* rendered HTML output (by inserting a space there). However, inserting a space between "*" and
@@ -300,7 +300,7 @@ public void preMostlyUntouched() {
}
@Test
- public void preCodeExample() {
+ void preCodeExample() {
// We should figure out whether we want a newline or blank line before
or not.
String[] input = {
"/**",
@@ -326,7 +326,7 @@ public void preCodeExample() {
}
@Test
- public void preNotWrapped() {
+ void preNotWrapped() {
String[] input = {
"/**",
" * Example:",
@@ -353,7 +353,7 @@ public void preNotWrapped() {
}
@Test
- public void javaCodeInPre() {
+ void javaCodeInPre() {
String[] input = {
"/**",
" * Example:",
@@ -380,7 +380,7 @@ public void javaCodeInPre() {
}
@Test
- public void joinLines() {
+ void joinLines() {
String[] input = {
"/**", //
" * foo",
@@ -397,7 +397,7 @@ public void joinLines() {
}
@Test
- public void oneLinerIs100() {
+ void oneLinerIs100() {
String[] input = {
"/**",
" * 567890123 567890123 567890123 567890123 567890123 567890123 567890123 567890123 " + "567890123 567",
@@ -412,7 +412,7 @@ public void oneLinerIs100() {
}
@Test
- public void oneLinerWouldBe101() {
+ void oneLinerWouldBe101() {
String[] input = {
"/**",
" * 567890123 567890123 567890123 567890123 567890123 567890123 567890123 567890123 " + "567890123 5678",
@@ -429,7 +429,7 @@ public void oneLinerWouldBe101() {
}
@Test
- public void multilineWrap() {
+ void multilineWrap() {
String[] input = {
"/**",
" * 456789012 456789012 456789012 456789012 456789012 456789012 456789012 456789012 "
@@ -448,7 +448,7 @@ public void multilineWrap() {
}
@Test
- public void tooLong() {
+ void tooLong() {
String[] input = {
"/**",
" * abc",
@@ -471,7 +471,7 @@ public void tooLong() {
}
@Test
- public void joinedTokens() {
+ void joinedTokens() {
/*
* Originally, 4, , and 8901 are separate tokens. Test that we join them (and thus don't
* split them across lines).
@@ -494,7 +494,7 @@ public void joinedTokens() {
}
@Test
- public void joinedAtSign() {
+ void joinedAtSign() {
/*
* The last 456789012 would fit on the first line with the others. But putting it there would
* mean the next line would start with @5678901, which would then be interpreted as a tag.
@@ -517,7 +517,7 @@ public void joinedAtSign() {
}
@Test
- public void joinedMultipleAtSign() {
+ void joinedMultipleAtSign() {
// This is the same as above except that it tests multiple consecutive @... tokens.
String[] input = {
"/**",
@@ -537,7 +537,7 @@ public void joinedMultipleAtSign() {
}
@Test
- public void noAsterisk() {
+ void noAsterisk() {
String[] input = {
"/**", //
" abcdef",
@@ -556,7 +556,7 @@ public void noAsterisk() {
}
@Test
- public void significantAsterisks() {
+ void significantAsterisks() {
String[] input = {
"/** *", //
" * *",
@@ -571,7 +571,7 @@ public void significantAsterisks() {
}
@Test
- public void links() {
+ void links() {
String[] input = {
"/**",
" * 456789012 456789012 456789012 456789012 456789012 456789012 456789012 456789012 " + "456789012 4567 defghi",
@@ -651,7 +651,7 @@ public void heading() {
}
@Test
- public void blockquote() {
+ void blockquote() {
String[] input = {
"/**", //
" * abcdef
ghi",
@@ -676,7 +676,7 @@ public void blockquote() {
}
@Test
- public void lists() {
+ void lists() {
String[] input = {
"/**", //
"* hi",
@@ -708,7 +708,7 @@ public void lists() {
}
@Test
- public void lists2() {
+ void lists2() {
String[] input = {
"/**", //
" * Foo.",
@@ -738,7 +738,7 @@ public void lists2() {
}
@Test
- public void closeInnerListStillNewline() {
+ void closeInnerListStillNewline() {
String[] input = {
"/**", //
" * Foo.",
@@ -765,7 +765,7 @@ public void closeInnerListStillNewline() {
}
@Test
- public void listItemWrap() {
+ void listItemWrap() {
String[] input = {
"/**", //
" * Foo.",
@@ -790,7 +790,7 @@ public void listItemWrap() {
}
@Test
- public void unclosedList() {
+ void unclosedList() {
String[] input = {
"/**", //
" * Foo.",
@@ -815,7 +815,7 @@ public void unclosedList() {
}
@Test
- public void br() {
+ void br() {
String[] input = {
"/**", //
" * abc
def",
@@ -833,7 +833,7 @@ public void br() {
}
@Test
- public void brSpaceBug() {
+ void brSpaceBug() {
// TODO(b/28983091): Remove the space before
here.
String[] input = {
"/**", //
@@ -852,7 +852,7 @@ public void brSpaceBug() {
}
@Test
- public void brAtSignBug() {
+ void brAtSignBug() {
/*
* This is a bug -- more of a "spec" bug than an implementation bug, and hard to fix.
* Fortunately, some very quick searching didn't turn up any instances in the Google codebase.
@@ -874,7 +874,7 @@ public void brAtSignBug() {
}
@Test
- public void unicodeCharacterCountArguableBug() {
+ void unicodeCharacterCountArguableBug() {
/*
* We might prefer for multi-char characters like 𝄞 to be treated as taking up one column (or
* perhaps for all characters to be treated based on their width in monospace fonts). But
@@ -898,7 +898,7 @@ public void unicodeCharacterCountArguableBug() {
}
@Test
- public void blankLineBeforeParams() {
+ void blankLineBeforeParams() {
String[] input = {
"/**", //
" * hello world",
@@ -918,7 +918,7 @@ public void blankLineBeforeParams() {
}
@Test
- public void onlyParams() {
+ void onlyParams() {
String[] input = {
"/**", //
" *",
@@ -935,7 +935,7 @@ public void onlyParams() {
}
@Test
- public void paramsContinuationIndented() {
+ void paramsContinuationIndented() {
String[] input = {
"/**", //
" * hello world",
@@ -960,7 +960,7 @@ public void paramsContinuationIndented() {
}
@Test
- public void paramsOtherIndents() {
+ void paramsOtherIndents() {
String[] input = {
"/**", //
" * hello world",
@@ -991,7 +991,7 @@ public void paramsOtherIndents() {
}
@Test
- public void paragraphTag() {
+ void paragraphTag() {
String[] input = {
"class Test {",
" /**",
@@ -1028,7 +1028,7 @@ public void paragraphTag() {
}
@Test
- public void xhtmlParagraphTag() {
+ void xhtmlParagraphTag() {
String[] input = {
"class Test {", " /**", " * helloworld", " */", " void f() {}", "", "}",
};
@@ -1039,7 +1039,7 @@ public void xhtmlParagraphTag() {
}
@Test
- public void removeInitialParagraphTag() {
+ void removeInitialParagraphTag() {
String[] input = {
"/**", //
" * hello
world",
@@ -1058,7 +1058,7 @@ public void removeInitialParagraphTag() {
}
@Test
- public void inferParagraphTags() {
+ void inferParagraphTags() {
String[] input = {
"/**",
" *",
@@ -1112,7 +1112,7 @@ public void inferParagraphTags() {
}
@Test
- public void paragraphTagNewlines() throws Exception {
+ void paragraphTagNewlines() throws Exception {
String input = new String(
ByteStreams.toByteArray(getClass().getResourceAsStream("testjavadoc/B28750242.input")), UTF_8);
String expected = new String(
@@ -1122,7 +1122,7 @@ public void paragraphTagNewlines() throws Exception {
}
@Test
- public void listItemSpaces() throws Exception {
+ void listItemSpaces() throws Exception {
String input = new String(
ByteStreams.toByteArray(getClass().getResourceAsStream("testjavadoc/B31404367.input")), UTF_8);
String expected = new String(
@@ -1132,7 +1132,7 @@ public void listItemSpaces() throws Exception {
}
@Test
- public void htmlTagsInCode() {
+ void htmlTagsInCode() {
String[] input = {
"/** abc {@code {}
} def */", //
"class Test {}",
@@ -1145,7 +1145,7 @@ public void htmlTagsInCode() {
}
@Test
- public void loneBraceDoesNotStartInlineTag() {
+ void loneBraceDoesNotStartInlineTag() {
String[] input = {
"/** { } */", //
"class Test {}",
@@ -1162,7 +1162,7 @@ public void loneBraceDoesNotStartInlineTag() {
}
@Test
- public void unicodeEscapesNotReplaced() {
+ void unicodeEscapesNotReplaced() {
// Test that we don't replace them with their interpretations.
String[] input = {
"/** foo \\u0000 bar \\u6c34 baz */", //
@@ -1177,7 +1177,7 @@ public void unicodeEscapesNotReplaced() {
@Test
@SuppressWarnings("UnicodeEscape")
- public void unicodeEscapesNotInterpretedBug() {
+ void unicodeEscapesNotInterpretedBug() {
/*
* In theory, "\u003C" should be treated exactly like <, and so too should the escaped versions of
* @, *, and other special chars. We don't recognize that, though, so we don't put what is
@@ -1195,7 +1195,7 @@ public void unicodeEscapesNotInterpretedBug() {
}
@Test
- public void trailingLink() {
+ void trailingLink() {
// Eclipse's parser seems to want to discard the line break after {@link}. Test that we see it.
String[] input = {
"/**", //
@@ -1212,7 +1212,7 @@ public void trailingLink() {
}
@Test
- public void doesNotBreakLink() {
+ void doesNotBreakLink() {
String[] input = {
"/**", //
" * This line is too long for the link to fit on a single line isn't it yes indeed too long {@link Foo}",
@@ -1234,7 +1234,7 @@ public void doesNotBreakLink() {
* same line.
*/
@Test
- public void wrapsLongInlineTag_withoutBreakingFirstWhitespace() {
+ void wrapsLongInlineTag_withoutBreakingFirstWhitespace() {
String[] input = {
"/**", //
" * This line is too long for the link to fit on a single line isn't it yes indeed too long {@link "
@@ -1281,7 +1281,7 @@ void mergesClosingBraceWithFollowingTag() {
}
@Test
- public void codeInCode() {
+ void codeInCode() {
// Eclipse's parser seems to get confused at the second {@code}. Test that we handle it.
String[] input = {
"/** abc {@code {@code foo}} def */", //
@@ -1295,7 +1295,7 @@ public void codeInCode() {
}
@Test
- public void quotedTextSplitAcrossLinks() {
+ void quotedTextSplitAcrossLinks() {
/*
* This demonstrates one of multiple reasons that we can't hand the Javadoc *content* to
* Eclipse's lexer as if it were Java code.
@@ -1315,7 +1315,7 @@ public void quotedTextSplitAcrossLinks() {
}
@Test
- public void standardizeTags() {
+ void standardizeTags() {
String[] input = {
"/**", " * foo", " *", " *
bar", " *", " *
baz
", " * baz", " */", "class Test {}",
};
@@ -1326,7 +1326,7 @@ public void standardizeTags() {
}
@Test
- public void removeCloseTags() {
+ void removeCloseTags() {
String[] input = {
"/**", //
" * foo
",
@@ -1347,7 +1347,7 @@ public void removeCloseTags() {
}
@Test
- public void javadocFullSentences() {
+ void javadocFullSentences() {
String[] input = {
"/** In our application, bats are often found hanging from the ceiling, especially on"
+ " Wednesdays. Sometimes sick bats have issues where their claws do not close entirely."
@@ -1366,7 +1366,7 @@ public void javadocFullSentences() {
}
@Test
- public void javadocSentenceFragment() {
+ void javadocSentenceFragment() {
String[] input = {
"/** Provides a comfy, grippable surface for sick bats with claw-closing problems, which are"
+ " sometimes found hanging from the ceiling on Wednesdays. */",
@@ -1383,7 +1383,7 @@ public void javadocSentenceFragment() {
}
@Test
- public void javadocCanEndAnywhere() {
+ void javadocCanEndAnywhere() {
String[] input = {
"/** foo world", " */", "class Test {}",
};
@@ -1416,7 +1416,7 @@ public void windowsLineSeparator() throws FormatterException {
}
@Test
- public void u2028LineSeparator() {
+ void u2028LineSeparator() {
String[] input = {
"public class Foo {",
" /**\u2028",
@@ -1437,7 +1437,7 @@ public void u2028LineSeparator() {
}
@Test
- public void blankLinesAroundSnippetAndNoMangling() {
+ void blankLinesAroundSnippetAndNoMangling() {
String[] input = {
"/**", //
" * hello world",
@@ -1468,7 +1468,7 @@ public void blankLinesAroundSnippetAndNoMangling() {
}
@Test
- public void notASnippetUnlessOuterTag() {
+ void notASnippetUnlessOuterTag() {
String[] input = {
"/** I would like to tell you about the {@code {@snippet ...}} tag. */", "class Test {}",
};
@@ -1479,7 +1479,7 @@ public void notASnippetUnlessOuterTag() {
}
@Test
- public void snippetKeepsCommentsAndIndentation() {
+ void snippetKeepsCommentsAndIndentation() {
String[] input = {
"/**", //
" * Example usage:",
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/LineRangesToCharRangesTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/LineRangesToCharRangesTest.java
index 1d8da1d42..bac61b94c 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/LineRangesToCharRangesTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/LineRangesToCharRangesTest.java
@@ -27,7 +27,7 @@
/** Tests for {@link Utils#lineRangesToCharRanges} */
@Execution(ExecutionMode.CONCURRENT)
-public class LineRangesToCharRangesTest {
+final class LineRangesToCharRangesTest {
@SafeVarargs
final Set> getCharRanges(String input, Range... ranges) {
@@ -39,12 +39,12 @@ final Set> getCharRanges(String input, Range... ranges)
}
@Test
- public void emptyLineRanges() throws Exception {
+ void emptyLineRanges() throws Exception {
assertThat(getCharRanges("", Range.closedOpen(0, 1))).isEmpty();
}
@Test
- public void lineRanges() throws Exception {
+ void lineRanges() throws Exception {
assertThat(getCharRanges("_\n_\n_\n", Range.closedOpen(0, 1))).containsExactly(Range.closedOpen(0, 1));
assertThat(getCharRanges("_\n_\n_\n", Range.closedOpen(1, 2))).containsExactly(Range.closedOpen(2, 3));
assertThat(getCharRanges("_\n_\n_\n", Range.closedOpen(2, 3))).containsExactly(Range.closedOpen(4, 5));
@@ -52,7 +52,7 @@ public void lineRanges() throws Exception {
}
@Test
- public void blankLineRange() throws Exception {
+ void blankLineRange() throws Exception {
assertThat(getCharRanges("hello\n\nworld", Range.closedOpen(0, 1))).containsExactly(Range.closedOpen(0, 5));
assertThat(getCharRanges("hello\n\nworld", Range.closedOpen(1, 2))).isEmpty();
assertThat(getCharRanges("hello\n\nworld", Range.closedOpen(2, 3))).containsExactly(Range.closedOpen(7, 12));
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/MainTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/MainTest.java
index 73b5efd8b..3f675eac5 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/MainTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/MainTest.java
@@ -43,7 +43,7 @@
import org.junit.jupiter.api.parallel.ExecutionMode;
@Execution(ExecutionMode.CONCURRENT)
-public class MainTest {
+final class MainTest {
private static final ImmutableList ADD_EXPORTS = ImmutableList.of(
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
@@ -59,7 +59,7 @@ public class MainTest {
private final Joiner joiner = Joiner.on(System.lineSeparator());
@Test
- public void testUsageOutput() {
+ void usageOutput() {
StringWriter out = new StringWriter();
StringWriter err = new StringWriter();
Main main = new Main(new PrintWriter(out, true), new PrintWriter(err, true), System.in);
@@ -85,7 +85,7 @@ public void testUsageOutput() {
}
@Test
- public void version() throws UsageException {
+ void version() throws UsageException {
StringWriter out = new StringWriter();
StringWriter err = new StringWriter();
Main main = new Main(new PrintWriter(out, true), new PrintWriter(err, true), System.in);
@@ -96,7 +96,7 @@ public void version() throws UsageException {
// Main used to leave its thread pool running after format returned. The command line does not notice, because it
// exits, but anything that runs Main in-process kept the idle threads (#40, from google/google-java-format#384).
@Test
- public void formatLeavesNoPoolThreadRunning() throws Exception {
+ void formatLeavesNoPoolThreadRunning() throws Exception {
Path path = Files.writeString(testFolder.resolve("A.java"), "class A {}\n");
Main main = new Main(
new PrintWriter(new StringWriter(), true), new PrintWriter(new StringWriter(), true), System.in);
@@ -117,7 +117,7 @@ public void formatLeavesNoPoolThreadRunning() throws Exception {
}
@Test
- public void preserveOriginalFile() throws Exception {
+ void preserveOriginalFile() throws Exception {
Path path = Files.createFile(testFolder.resolve("Test.java"));
Files.write(path, "class Test {}\n".getBytes(UTF_8));
try {
@@ -134,7 +134,7 @@ public void preserveOriginalFile() throws Exception {
}
@Test
- public void testMain() throws Exception {
+ void printsUsageWithoutArguments() throws Exception {
Process process = formatterMain().start();
process.waitFor();
String err = new String(ByteStreams.toByteArray(process.getErrorStream()), UTF_8);
@@ -144,7 +144,7 @@ public void testMain() throws Exception {
// end to end javadoc formatting test
@Test
- public void javadoc() throws Exception {
+ void javadoc() throws Exception {
String[] input = {
"/**",
" * graph",
@@ -190,7 +190,7 @@ public void javadoc() throws Exception {
// end to end import fixing test
@Test
- public void imports() throws Exception {
+ void imports() throws Exception {
String[] input = {
"import java.util.LinkedList;",
"import java.util.List;",
@@ -224,7 +224,7 @@ public void imports() throws Exception {
}
@Test
- public void optimizeImportsDoesNotLeaveEmptyLines() throws Exception {
+ void optimizeImportsDoesNotLeaveEmptyLines() throws Exception {
String[] input = {
"package abc;",
"",
@@ -265,7 +265,7 @@ public void optimizeImportsDoesNotLeaveEmptyLines() throws Exception {
// test that -lines handling works with import removal
@Test
- public void importRemovalLines() throws Exception {
+ void importRemovalLines() throws Exception {
String[] input = {
"import java.util.ArrayList;",
"import java.util.List;",
@@ -295,7 +295,7 @@ public void importRemovalLines() throws Exception {
// what a second run would, and what the entry point of the Gradle and Spotless step gives (#37, from
// google/google-java-format#1436).
@Test
- public void unusedImportRemovalLeavesOneBlankLine() throws Exception {
+ void unusedImportRemovalLeavesOneBlankLine() throws Exception {
String[] input = {
"package com.example;",
"",
@@ -333,7 +333,7 @@ public void unusedImportRemovalLeavesOneBlankLine() throws Exception {
// test that errors are reported on the right line when imports are removed
@Test
- public void importRemoveErrorParseError() throws Exception {
+ void importRemoveErrorParseError() throws Exception {
Locale backupLocale = Locale.getDefault();
try {
Locale.setDefault(Locale.ROOT);
@@ -359,7 +359,7 @@ public void importRemoveErrorParseError() throws Exception {
}
@Test
- public void packageInfo() throws Exception {
+ void packageInfo() throws Exception {
String[] input = {
"@CheckReturnValue",
"@ParametersAreNonnullByDefault",
@@ -380,7 +380,7 @@ public void packageInfo() throws Exception {
}
@Test
- public void newline() throws Exception {
+ void newline() throws Exception {
StringWriter out = new StringWriter();
StringWriter err = new StringWriter();
Main main = new Main(
@@ -392,7 +392,7 @@ public void newline() throws Exception {
}
@Test
- public void dryRunStdinUnchanged() throws Exception {
+ void dryRunStdinUnchanged() throws Exception {
StringWriter out = new StringWriter();
StringWriter err = new StringWriter();
Main main = new Main(
@@ -405,7 +405,7 @@ public void dryRunStdinUnchanged() throws Exception {
}
@Test
- public void dryRunStdinChanged() throws Exception {
+ void dryRunStdinChanged() throws Exception {
StringWriter out = new StringWriter();
StringWriter err = new StringWriter();
String input = "class Test {\n}\n";
@@ -419,7 +419,7 @@ public void dryRunStdinChanged() throws Exception {
}
@Test
- public void dryRunFiles() throws Exception {
+ void dryRunFiles() throws Exception {
Path a = Files.createFile(testFolder.resolve("A.java"));
Path b = Files.createFile(testFolder.resolve("B.java"));
Path c = Files.createFile(testFolder.resolve("C.java"));
@@ -447,7 +447,7 @@ public void dryRunFiles() throws Exception {
}
@Test
- public void keepGoingWhenFilesDontExist() throws Exception {
+ void keepGoingWhenFilesDontExist() throws Exception {
Path a = Files.createFile(testFolder.resolve("A.java"));
Path b = Files.createFile(testFolder.resolve("B.java"));
Path c = Files.createFile(testFolder.resolve("C.java"));
@@ -478,7 +478,7 @@ public void keepGoingWhenFilesDontExist() throws Exception {
}
@Test
- public void exitIfChangedStdin() throws Exception {
+ void exitIfChangedStdin() throws Exception {
Path path = Files.createFile(testFolder.resolve("Test.java"));
Files.write(path, "class Test {\n}\n".getBytes(UTF_8));
Process process = formatterMain("-").redirectInput(path.toFile()).start();
@@ -490,7 +490,7 @@ public void exitIfChangedStdin() throws Exception {
}
@Test
- public void exitIfChangedFiles() throws Exception {
+ void exitIfChangedFiles() throws Exception {
Path path = Files.createFile(testFolder.resolve("Test.java"));
Files.write(path, "class Test {\n}\n".getBytes(UTF_8));
Process process = formatterMain(path.toAbsolutePath().toString()).start();
@@ -502,7 +502,7 @@ public void exitIfChangedFiles() throws Exception {
}
@Test
- public void styleIsAlwaysOjf() throws Exception {
+ void styleIsAlwaysOjf() throws Exception {
String input = "class T {\nvoid f() {\nint x;\n}\n}\n";
String expected = "class T {\n void f() {\n int x;\n }\n}\n";
@@ -518,7 +518,7 @@ public void styleIsAlwaysOjf() throws Exception {
}
@Test
- public void styleFlagIsIgnoredWithAWarning() throws Exception {
+ void styleFlagIsIgnoredWithAWarning() throws Exception {
String input = "class T {\nvoid f() {\nint x;\n}\n}\n";
String expected = "class T {\n void f() {\n int x;\n }\n}\n";
@@ -537,7 +537,7 @@ public void styleFlagIsIgnoredWithAWarning() throws Exception {
}
@Test
- public void unknownFlagIsAnError() throws Exception {
+ void unknownFlagIsAnError() throws Exception {
Path path = Files.createFile(testFolder.resolve("Test.java"));
Files.write(path, "class Test {\n}\n".getBytes(UTF_8));
Process process =
@@ -550,7 +550,7 @@ public void unknownFlagIsAnError() throws Exception {
}
@Test
- public void noFilesIsNotAnError() throws Exception {
+ void noFilesIsNotAnError() throws Exception {
// What a script gets when it passes on an empty list, as in $(git ls-files '*.java').
Process process = formatterMain("--ojf", "--replace").start();
process.waitFor();
@@ -560,7 +560,7 @@ public void noFilesIsNotAnError() throws Exception {
}
@Test
- public void helpIsNotAnError() throws Exception {
+ void helpIsNotAnError() throws Exception {
Process process = formatterMain("--help").start();
process.waitFor();
String err = new String(ByteStreams.toByteArray(process.getErrorStream()), UTF_8);
@@ -569,7 +569,7 @@ public void helpIsNotAnError() throws Exception {
}
@Test
- public void exitIfChangedLosesToParseError() throws Exception {
+ void exitIfChangedLosesToParseError() throws Exception {
Path unformatted = Files.createFile(testFolder.resolve("Unformatted.java"));
Files.write(unformatted, "class Unformatted {\n}\n".getBytes(UTF_8));
Path broken = Files.createFile(testFolder.resolve("Broken.java"));
@@ -588,7 +588,7 @@ public void exitIfChangedLosesToParseError() throws Exception {
}
@Test
- public void assumeFilename_error() throws Exception {
+ void assumeFilename_error() throws Exception {
String[] input = {
"class Test {}}",
};
@@ -603,7 +603,7 @@ public void assumeFilename_error() throws Exception {
}
@Test
- public void assumeFilename_dryRun() throws Exception {
+ void assumeFilename_dryRun() throws Exception {
String[] input = {
"class Test {", //
"}",
@@ -619,7 +619,7 @@ public void assumeFilename_dryRun() throws Exception {
}
@Test
- public void reflowLongStrings() throws Exception {
+ void reflowLongStrings() throws Exception {
String[] input = {
"class T {", //
" String s = \"one long incredibly unbroken sentence moving from topic to topic so that no"
@@ -645,7 +645,7 @@ public void reflowLongStrings() throws Exception {
}
@Test
- public void noReflowLongStrings() throws Exception {
+ void noReflowLongStrings() throws Exception {
String[] input = {
"class T {", //
" String s = \"one long incredibly unbroken sentence moving from topic to topic so that no"
@@ -673,7 +673,7 @@ public void noReflowLongStrings() throws Exception {
// A comment between two imports goes with the import after it, where it used to fail the whole file with "Imports
// not contiguous" (#39, from google/google-java-format#424). A second run leaves the result alone.
@Test
- public void commentBetweenImportsMovesWithTheImportAfterIt() throws Exception {
+ void commentBetweenImportsMovesWithTheImportAfterIt() throws Exception {
String[] input = {
"import b.B;", "", "// why we need A", "import a.A;", "", "class T {", " A a;", " B b;", "}", "",
};
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/ModifierOrdererTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/ModifierOrdererTest.java
index dc3ecc8f0..5082811a7 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/ModifierOrdererTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/ModifierOrdererTest.java
@@ -27,24 +27,24 @@
/** {@link ModifierOrderer}Test */
@Execution(ExecutionMode.CONCURRENT)
-public class ModifierOrdererTest {
+final class ModifierOrdererTest {
@Test
- public void simple() throws FormatterException {
+ void simple() throws FormatterException {
assertThat(ModifierOrderer.reorderModifiers("static abstract class InnerClass {}")
.getText())
.isEqualTo("abstract static class InnerClass {}");
}
@Test
- public void comment() throws FormatterException {
+ void comment() throws FormatterException {
assertThat(ModifierOrderer.reorderModifiers("static/*1*/abstract/*2*/public")
.getText())
.isEqualTo("public/*1*/abstract/*2*/static");
}
@Test
- public void everything() throws FormatterException {
+ void everything() throws FormatterException {
assertThat(ModifierOrderer.reorderModifiers(
"strictfp native synchronized volatile transient final static abstract"
+ " private protected public")
@@ -54,7 +54,7 @@ public void everything() throws FormatterException {
}
@Test
- public void everythingIncludingDefault() throws FormatterException {
+ void everythingIncludingDefault() throws FormatterException {
assertThat(ModifierOrderer.reorderModifiers(
"strictfp native synchronized volatile transient final static default abstract"
+ " private protected public")
@@ -64,7 +64,7 @@ public void everythingIncludingDefault() throws FormatterException {
}
@Test
- public void subRange() throws FormatterException {
+ void subRange() throws FormatterException {
String[] lines = {
"class Test {", //
" static public int a;",
@@ -83,7 +83,7 @@ public void subRange() throws FormatterException {
}
@Test
- public void whitespace() throws FormatterException {
+ void whitespace() throws FormatterException {
String[] lines = {
"class Test {", //
" static",
@@ -101,13 +101,13 @@ public void whitespace() throws FormatterException {
}
@Test
- public void sealedClass() throws FormatterException {
+ void sealedClass() throws FormatterException {
assertThat(ModifierOrderer.reorderModifiers("non-sealed sealed public").getText())
.isEqualTo("public sealed non-sealed");
}
@Test
- public void nonSealedBeforeAccessModifier() throws FormatterException {
+ void nonSealedBeforeAccessModifier() throws FormatterException {
assertThat(ModifierOrderer.reorderModifiers("non-sealed private interface B extends I {}")
.getText())
.isEqualTo("private non-sealed interface B extends I {}");
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/ModuleImportTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/ModuleImportTest.java
index 9284f84a7..e2c7cc43f 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/ModuleImportTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/ModuleImportTest.java
@@ -30,10 +30,10 @@
* End-to-end tests for module import declarations (JEP 511) through the pipeline the Gradle plugin and Spotless use,
* which reorders imports before formatting. The {@code ModuleImport} golden only exercises {@code formatSource}.
*/
-public class ModuleImportTest {
+final class ModuleImportTest {
@BeforeAll
- public static void requiresAParserThatProducesModuleImports() {
+ static void requiresAParserThatProducesModuleImports() {
// Module imports parse from JDK 23 on, as a preview feature there; the formatter enables preview.
Assumptions.assumeTrue(
Formatter.getRuntimeVersion() >= 23, "import module requires running on JDK 23 or later");
@@ -48,7 +48,7 @@ private static void assertFormats(String input, String expected) throws Formatte
}
@Test
- public void formatsAndFixesImports() throws FormatterException {
+ void formatsAndFixesImports() throws FormatterException {
String input = """
import module java.base;
class Example {}
@@ -62,7 +62,7 @@ class Example {}
}
@Test
- public void fixesImportsOnlyFromTheCommandLine() throws Exception {
+ void fixesImportsOnlyFromTheCommandLine() throws Exception {
// The flag combination from the #1506 report, which failed with `Expected ; after import`.
String input = """
import module java.base;
@@ -87,7 +87,7 @@ class Example {}
}
@Test
- public void keepsACommentBetweenModuleAndTheModuleName() throws FormatterException {
+ void keepsACommentBetweenModuleAndTheModuleName() throws FormatterException {
String input = """
import module /* comment */ java.base;
class Example {}
@@ -101,7 +101,7 @@ class Example {}
}
@Test
- public void keepsACommentBetweenThePartsOfTheModuleName() throws FormatterException {
+ void keepsACommentBetweenThePartsOfTheModuleName() throws FormatterException {
String input = """
import module java./* comment */base;
class Example {}
@@ -128,7 +128,7 @@ class Example {}
}
@Test
- public void normalizesWhitespaceInsideTheModuleName() throws FormatterException {
+ void normalizesWhitespaceInsideTheModuleName() throws FormatterException {
String input = """
import module java . base;
class Example {}
@@ -142,7 +142,7 @@ class Example {}
}
@Test
- public void keepsBothCopiesOfADuplicateThatCarriesAComment() throws FormatterException {
+ void keepsBothCopiesOfADuplicateThatCarriesAComment() throws FormatterException {
// Identical declarations collapse; ones that differ are both kept, so no comment is dropped.
String input = """
import module /* explanation A */ java.base;
@@ -159,7 +159,7 @@ class Example {}
}
@Test
- public void acceptsALineBreakAfterModule() throws FormatterException {
+ void acceptsALineBreakAfterModule() throws FormatterException {
String input = """
import module
java.base;
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/ReplacementTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/ReplacementTest.java
index b600cebab..f08161f61 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/ReplacementTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/ReplacementTest.java
@@ -29,7 +29,7 @@ final class ReplacementTest {
JsonMapper.builder().addModule(new GuavaModule()).build();
@Test
- void test_serialization() throws IOException {
+ void serialization() throws IOException {
Replacement given = Replacement.create(3, 8, "Replacement Text");
String rawJson = MAPPER.writeValueAsString(given);
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/StringWrapperTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/StringWrapperTest.java
index bb0e925af..1379bd871 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/StringWrapperTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/StringWrapperTest.java
@@ -37,9 +37,9 @@
import org.junit.jupiter.api.parallel.ExecutionMode;
@Execution(ExecutionMode.CONCURRENT)
-public class StringWrapperTest {
+final class StringWrapperTest {
@Test
- public void testAwkwardLineEndWrapping() throws Exception {
+ void awkwardLineEndWrapping() throws Exception {
String input = lines(
"class T {",
// This is a wide line, but has to be split in code because of 100-char limit.
@@ -64,7 +64,7 @@ public void testAwkwardLineEndWrapping() throws Exception {
}
@Test
- public void wrapsAStringWithEscapedBackslashes() throws Exception {
+ void wrapsAStringWithEscapedBackslashes() throws Exception {
// In D:\\tempDb the second backslash and the t are not an escaped tab. Splitting there left a lone backslash
// at the end of a piece, where it escaped the closing quote.
String input = lines(
@@ -84,7 +84,7 @@ public void wrapsAStringWithEscapedBackslashes() throws Exception {
}
@Test
- public void wrappingKeepsTheValueOfAStringWithEscapes() throws Exception {
+ void wrappingKeepsTheValueOfAStringWithEscapes() throws Exception {
// At 40 columns the first line fills up right inside C:\\temp, where \\t is not an escaped tab.
String input = lines("class T {", " String s = \"copy the file to C:\\\\temp and back\";", "}");
diff --git a/open-java-format/src/test/java/com/palantir/javaformat/java/TypeNameClassifierTest.java b/open-java-format/src/test/java/com/palantir/javaformat/java/TypeNameClassifierTest.java
index 907cbb972..27c1a5358 100644
--- a/open-java-format/src/test/java/com/palantir/javaformat/java/TypeNameClassifierTest.java
+++ b/open-java-format/src/test/java/com/palantir/javaformat/java/TypeNameClassifierTest.java
@@ -24,9 +24,9 @@
import org.junit.jupiter.api.parallel.ExecutionMode;
@Execution(ExecutionMode.CONCURRENT)
-public final class TypeNameClassifierTest {
+final class TypeNameClassifierTest {
@Test
- public void caseFormat() throws Exception {
+ void caseFormat() throws Exception {
assertThat(JavaCaseFormat.from("CONST")).isEqualTo(JavaCaseFormat.UPPERCASE);
assertThat(JavaCaseFormat.from("TypeName")).isEqualTo(JavaCaseFormat.UPPER_CAMEL);
assertThat(JavaCaseFormat.from("fieldName")).isEqualTo(JavaCaseFormat.LOWER_CAMEL);
@@ -49,7 +49,7 @@ private static Optional getPrefix(String qualifiedName) {
}
@Test
- public void typePrefixLength() {
+ void typePrefixLength() {
assertThat(getPrefix("fieldName")).isEmpty();
assertThat(getPrefix("CONST")).isEmpty();
assertThat(getPrefix("ClassName")).hasValue(0);
@@ -65,7 +65,7 @@ public void typePrefixLength() {
}
@Test
- public void ambiguousClass() {
+ void ambiguousClass() {
assertThat(getPrefix("com.google.security.acl.proto2api.ACL.Entry.newBuilder"))
.hasValue(7);
// A human would probably identify this as "class-shaped", but just looking