Skip to content

Commit 338a70a

Browse files
author
Vincent Potucek
committed
use default field for default test path
1 parent 1e9438e commit 338a70a

31 files changed

+108
-108
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/KotlinExtensionTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ void testWithCustomMaxWidthDefaultStyleKtfmt() throws IOException {
231231
}
232232

233233
private void checkKtlintOfficialStyle() throws IOException {
234-
testPath = "src/main/kotlin/Main.kt";
235-
setFile(testPath).toResource("kotlin/ktlint/experimentalEditorConfigOverride.dirty");
234+
TEST_PATH = "src/main/kotlin/Main.kt";
235+
setFile(TEST_PATH).toResource("kotlin/ktlint/experimentalEditorConfigOverride.dirty");
236236
gradleRunner().withArguments("spotlessApply").build();
237-
assertFile(testPath).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.ktlintOfficial.clean");
237+
assertFile(TEST_PATH).sameAsResource("kotlin/ktlint/experimentalEditorConfigOverride.ktlintOfficial.clean");
238238
}
239239
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenProvisionerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void testSingleDependencyIncludingTransitives() throws Exception {
3939

4040
private void assertResolveDependenciesWorks() throws Exception {
4141
String unformattedContent = "package a;";
42-
setFile(testPath).toContent(unformattedContent);
42+
setFile(TEST_PATH).toContent(unformattedContent);
4343
mavenRunner().withArguments("spotless:apply").runNoError();
44-
assertFile(testPath).hasContent(unformattedContent.replace(" ", " "));
44+
assertFile(TEST_PATH).hasContent(unformattedContent.replace(" ", " "));
4545
}
4646
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/antlr4/Antlr4FormatterTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ void applyUsingDefaultVersionSelfclosing() throws Exception {
4646
}
4747

4848
private void runTest() throws Exception {
49-
testPath = "src/main/antlr4/Hello.g4";
50-
setFile(testPath).toResource("antlr4/Hello.unformatted.g4");
49+
TEST_PATH = "src/main/antlr4/Hello.g4";
50+
setFile(TEST_PATH).toResource("antlr4/Hello.unformatted.g4");
5151
mavenRunner().withArguments("spotless:apply").runNoError();
52-
assertFile(testPath).sameAsResource("antlr4/Hello.formatted.g4");
52+
assertFile(TEST_PATH).sameAsResource("antlr4/Hello.formatted.g4");
5353
}
5454
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/IndentTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ private void runToSpacesTest() throws Exception {
4848
}
4949

5050
private void runTest(String source, String target) throws Exception {
51-
setFile(testPath).toResource(source);
51+
setFile(TEST_PATH).toResource(source);
5252
mavenRunner().withArguments("spotless:apply").runNoError();
53-
assertFile(testPath).sameAsResource(target);
53+
assertFile(TEST_PATH).sameAsResource(target);
5454
}
5555
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/Jsr223Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ public void groovyFromJarState() throws Exception {
5151
}
5252

5353
private void runTest(String sourceContent, String targetContent) throws Exception {
54-
setFile(testPath).toContent(sourceContent);
54+
setFile(TEST_PATH).toContent(sourceContent);
5555
mavenRunner().withArguments("spotless:apply").runNoError();
56-
assertFile(testPath).hasContent(targetContent);
56+
assertFile(TEST_PATH).hasContent(targetContent);
5757
}
5858
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LicenseHeaderTest.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ void fromContentCpp() throws Exception {
4444
" </content>",
4545
"</licenseHeader>");
4646

47-
testPath = "src/test/cpp/file.c++";
47+
TEST_PATH = "src/test/cpp/file.c++";
4848
String cppContent = "#include <whatsoever.h>";
49-
setFile(testPath).toContent(cppContent);
49+
setFile(TEST_PATH).toContent(cppContent);
5050
mavenRunner().withArguments("spotless:apply").runNoError();
51-
assertFile(testPath).hasContent(cppLicense + '\n' + cppContent);
51+
assertFile(TEST_PATH).hasContent(cppLicense + '\n' + cppContent);
5252
}
5353

5454
@Test
@@ -61,10 +61,10 @@ void fromContentGroovy() throws Exception {
6161
" </content>",
6262
"</licenseHeader>");
6363

64-
testPath = "src/main/groovy/test.groovy";
65-
setFile(testPath).toResource("license/MissingLicense.test");
64+
TEST_PATH = "src/main/groovy/test.groovy";
65+
setFile(TEST_PATH).toResource("license/MissingLicense.test");
6666
mavenRunner().withArguments("spotless:apply").runNoError();
67-
assertFile(testPath).sameAsResource("license/HasLicense.test");
67+
assertFile(TEST_PATH).sameAsResource("license/HasLicense.test");
6868
}
6969

7070
@Test
@@ -123,12 +123,12 @@ void fromContentKotlin() throws Exception {
123123
" </content>",
124124
"</licenseHeader>");
125125

126-
testPath = "src/main/kotlin/test.kt";
126+
TEST_PATH = "src/main/kotlin/test.kt";
127127
String noLicenseHeader = getTestResource("kotlin/licenseheader/KotlinCodeWithoutHeader.test");
128128

129-
setFile(testPath).toContent(noLicenseHeader);
129+
setFile(TEST_PATH).toContent(noLicenseHeader);
130130
mavenRunner().withArguments("spotless:apply").runNoError();
131-
assertFile(testPath).hasContent(KOTLIN_LICENSE_HEADER + '\n' + noLicenseHeader);
131+
assertFile(TEST_PATH).hasContent(KOTLIN_LICENSE_HEADER + '\n' + noLicenseHeader);
132132
}
133133

134134
@Test
@@ -142,9 +142,9 @@ void unsupportedModuleInfo() throws Exception {
142142
}
143143

144144
private void runTest() throws Exception {
145-
setFile(testPath).toResource("license/MissingLicense.test");
145+
setFile(TEST_PATH).toResource("license/MissingLicense.test");
146146
mavenRunner().withArguments("spotless:apply").runNoError();
147-
assertFile(testPath).sameAsResource("license/HasLicense.test");
147+
assertFile(TEST_PATH).sameAsResource("license/HasLicense.test");
148148
}
149149

150150
private void testUnsupportedFile(String file) throws Exception {
@@ -155,12 +155,12 @@ private void testUnsupportedFile(String file) throws Exception {
155155
" </content>",
156156
"</licenseHeader>");
157157

158-
testPath = "src/main/java/com/diffplug/spotless/" + file;
159-
setFile(testPath).toResource("license/" + file + ".test");
158+
TEST_PATH = "src/main/java/com/diffplug/spotless/" + file;
159+
setFile(TEST_PATH).toResource("license/" + file + ".test");
160160

161161
mavenRunner().withArguments("spotless:apply").runNoError();
162162

163163
// file should remain the same
164-
assertFile(testPath).sameAsResource("license/" + file + ".test");
164+
assertFile(TEST_PATH).sameAsResource("license/" + file + ".test");
165165
}
166166
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/LineEndingsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ private void runToUnixTest() throws Exception {
4444
}
4545

4646
private void runTest(String sourceContent, String targetContent) throws Exception {
47-
setFile(testPath).toContent(sourceContent);
47+
setFile(TEST_PATH).toContent(sourceContent);
4848
mavenRunner().withArguments("spotless:apply").runNoError();
49-
assertFile(testPath).hasContent(targetContent);
49+
assertFile(TEST_PATH).hasContent(targetContent);
5050
}
5151

5252
private String getClassWithLineEndings(String lineEnding) {

plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/NativeCmdTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public void fromStdInToStdOut() throws Exception {
4141
}
4242

4343
private void runTest(String sourceContent, String targetContent) throws Exception {
44-
setFile(testPath).toContent(sourceContent);
44+
setFile(TEST_PATH).toContent(sourceContent);
4545
mavenRunner().withArguments("spotless:apply").runNoError();
46-
assertFile(testPath).hasContent(targetContent);
46+
assertFile(TEST_PATH).hasContent(targetContent);
4747
}
4848
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/ReplaceRegexTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ void fromContent() throws Exception {
3434
}
3535

3636
private void runTest(String sourceContent, String targetContent) throws Exception {
37-
setFile(testPath).toContent(sourceContent);
37+
setFile(TEST_PATH).toContent(sourceContent);
3838
mavenRunner().withArguments("spotless:apply").runNoError();
39-
assertFile(testPath).hasContent(targetContent);
39+
assertFile(TEST_PATH).hasContent(targetContent);
4040
}
4141
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/generic/ReplaceTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ void fromContent() throws Exception {
3333
}
3434

3535
private void runTest(String sourceContent, String targetContent) throws Exception {
36-
setFile(testPath).toContent(sourceContent);
36+
setFile(TEST_PATH).toContent(sourceContent);
3737
mavenRunner().withArguments("spotless:apply").runNoError();
38-
assertFile(testPath).hasContent(targetContent);
38+
assertFile(TEST_PATH).hasContent(targetContent);
3939
}
4040
}

0 commit comments

Comments
 (0)