Skip to content

Commit 66d92ba

Browse files
author
Vincent Potucek
committed
use default field for default test path
1 parent 9bc702f commit 66d92ba

24 files changed

+79
-93
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -49,7 +49,7 @@ void noConfigOnHelp() throws IOException {
4949
"tasks.named('check').configure {",
5050
" dependsOn(canary)",
5151
"}");
52-
setFile("src/main/java/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
52+
setFile(TEST_PATH).toResource("java/googlejavaformat/JavaCodeUnformatted.test");
5353

5454
String help = gradleRunner().withArguments("help").build().getOutput();
5555
Assertions.assertThat(help).doesNotContain("Canary was configured");

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,13 +53,13 @@ private void testIncludeExcludeOption(boolean excludeJava) throws IOException {
5353

5454
String withoutHeader = getTestResource("groovy/licenseheader/JavaCodeWithoutHeader.test");
5555

56-
setFile("src/main/java/test.java").toContent(withoutHeader);
56+
setFile(TEST_PATH).toContent(withoutHeader);
5757
setFile("src/main/groovy/test.java").toContent(withoutHeader);
5858
setFile("src/main/groovy/test.groovy").toContent(withoutHeader);
5959

6060
gradleRunner().withArguments("spotlessApply").build();
6161

62-
assertFile("src/main/java/test.java").hasContent(withoutHeader);
62+
assertFile(TEST_PATH).hasContent(withoutHeader);
6363
assertFile("src/main/groovy/test.groovy").hasContent(HEADER + "\n" + withoutHeader);
6464
if (excludeJava) {
6565
assertFile("src/main/groovy/test.java").hasContent(withoutHeader);

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ void integration() throws IOException {
3535
" googleJavaFormat()",
3636
" }",
3737
"}");
38-
setFile("src/main/java/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
38+
setFile(TEST_PATH).toResource("java/googlejavaformat/JavaCodeUnformatted.test");
3939
setFile("src/main/groovy/test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
4040
setFile("src/main/groovy/test.groovy").toResource("java/googlejavaformat/JavaCodeUnformatted.test");
4141

4242
gradleRunner().withArguments("spotlessApply").build();
4343

44-
assertFile("src/main/java/test.java").sameAsResource("java/googlejavaformat/JavaCodeFormatted.test");
44+
assertFile(TEST_PATH).sameAsResource("java/googlejavaformat/JavaCodeFormatted.test");
4545
assertFile("src/main/groovy/test.java").sameAsResource("java/googlejavaformat/JavaCodeFormatted.test");
4646
assertFile("src/main/groovy/test.groovy").sameAsResource("java/googlejavaformat/JavaCodeUnformatted.test");
4747
}
@@ -76,9 +76,9 @@ void removeUnusedImportsWithCleanthat() throws IOException {
7676
" java { removeUnusedImports('cleanthat-javaparser-unnecessaryimport') }",
7777
"}");
7878

79-
setFile("src/main/java/test.java").toResource("java/removeunusedimports/Jdk17TextBlockUnformatted.test");
79+
setFile(TEST_PATH).toResource("java/removeunusedimports/Jdk17TextBlockUnformatted.test");
8080
gradleRunner().withArguments("spotlessApply").build();
81-
assertFile("src/main/java/test.java").sameAsResource("java/removeunusedimports/Jdk17TextBlockFormatted.test");
81+
assertFile(TEST_PATH).sameAsResource("java/removeunusedimports/Jdk17TextBlockFormatted.test");
8282
}
8383

8484
@Test
@@ -122,9 +122,9 @@ void fenceWithTargetExcludeNoMatch() throws Exception {
122122
" }",
123123
"}");
124124

125-
setFile("src/main/java/test.java").toResource("java/targetExclude/TargetExcludeNoMatchUnformatted.test");
125+
setFile(TEST_PATH).toResource("java/targetExclude/TargetExcludeNoMatchUnformatted.test");
126126
gradleRunner().withArguments("spotlessApply").build();
127-
assertFile("src/main/java/test.java").sameAsResource("java/targetExclude/TargetExcludeNoMatchFormatted.test");
127+
assertFile(TEST_PATH).sameAsResource("java/targetExclude/TargetExcludeNoMatchFormatted.test");
128128
}
129129

130130
/**
@@ -148,8 +148,8 @@ void fenceWithTargetExcludeMatch() throws Exception {
148148
" }",
149149
"}");
150150

151-
setFile("src/main/java/test.java").toResource("java/targetExclude/TargetExcludeMatch.test");
151+
setFile(TEST_PATH).toResource("java/targetExclude/TargetExcludeMatch.test");
152152
gradleRunner().withArguments("spotlessApply").build();
153-
assertFile("src/main/java/test.java").sameAsResource("java/targetExclude/TargetExcludeMatch.test");
153+
assertFile(TEST_PATH).sameAsResource("java/targetExclude/TargetExcludeMatch.test");
154154
}
155155
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,10 +38,9 @@ void testSingleDependencyIncludingTransitives() throws Exception {
3838
}
3939

4040
private void assertResolveDependenciesWorks() throws Exception {
41-
String path = "src/main/java/test.java";
4241
String unformattedContent = "package a;";
43-
setFile(path).toContent(unformattedContent);
42+
setFile(TEST_PATH).toContent(unformattedContent);
4443
mavenRunner().withArguments("spotless:apply").runNoError();
45-
assertFile(path).hasContent(unformattedContent.replace(" ", " "));
44+
assertFile(TEST_PATH).hasContent(unformattedContent.replace(" ", " "));
4645
}
4746
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,8 +34,8 @@ private void runTest() throws Exception {
3434
String notFormatted = "<a><b> c</b></a>";
3535
String formatted = "<a>\n\t<b> c</b>\n</a>";
3636
//writePomWithFormatSteps includes java. WTP does not care about file extensions.
37-
setFile("src/main/java/test.java").toContent(notFormatted);
37+
setFile(TEST_PATH).toContent(notFormatted);
3838
mavenRunner().withArguments("spotless:apply").runNoError();
39-
assertFile("src/main/java/test.java").hasContent(formatted);
39+
assertFile(TEST_PATH).hasContent(formatted);
4040
}
4141
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -39,8 +39,8 @@ void fromContentWithSelfclosingTag() throws Exception {
3939
private void runTest() throws Exception {
4040
String noTrailingNewline = "public class Java {}";
4141
String hasTrailingNewline = noTrailingNewline + "\n";
42-
setFile("src/main/java/test.java").toContent(noTrailingNewline);
42+
setFile(TEST_PATH).toContent(noTrailingNewline);
4343
mavenRunner().withArguments("spotless:apply").runNoError();
44-
assertFile("src/main/java/test.java").hasContent(hasTrailingNewline);
44+
assertFile(TEST_PATH).hasContent(hasTrailingNewline);
4545
}
4646
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -48,9 +48,8 @@ private void runToSpacesTest() throws Exception {
4848
}
4949

5050
private void runTest(String source, String target) throws Exception {
51-
String path = "src/main/java/test.java";
52-
setFile(path).toResource(source);
51+
setFile(TEST_PATH).toResource(source);
5352
mavenRunner().withArguments("spotless:apply").runNoError();
54-
assertFile(path).sameAsResource(target);
53+
assertFile(TEST_PATH).sameAsResource(target);
5554
}
5655
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021 DiffPlug
2+
* Copyright 2021-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,9 +51,8 @@ public void groovyFromJarState() throws Exception {
5151
}
5252

5353
private void runTest(String sourceContent, String targetContent) throws Exception {
54-
String path = "src/main/java/test.java";
55-
setFile(path).toContent(sourceContent);
54+
setFile(TEST_PATH).toContent(sourceContent);
5655
mavenRunner().withArguments("spotless:apply").runNoError();
57-
assertFile(path).hasContent(targetContent);
56+
assertFile(TEST_PATH).hasContent(targetContent);
5857
}
5958
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -142,10 +142,9 @@ void unsupportedModuleInfo() throws Exception {
142142
}
143143

144144
private void runTest() throws Exception {
145-
String path = "src/main/java/test.java";
146-
setFile(path).toResource("license/MissingLicense.test");
145+
setFile(TEST_PATH).toResource("license/MissingLicense.test");
147146
mavenRunner().withArguments("spotless:apply").runNoError();
148-
assertFile(path).sameAsResource("license/HasLicense.test");
147+
assertFile(TEST_PATH).sameAsResource("license/HasLicense.test");
149148
}
150149

151150
private void testUnsupportedFile(String file) throws Exception {

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2021 DiffPlug
2+
* Copyright 2016-2025 DiffPlug
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -44,10 +44,9 @@ private void runToUnixTest() throws Exception {
4444
}
4545

4646
private void runTest(String sourceContent, String targetContent) throws Exception {
47-
String path = "src/main/java/test.java";
48-
setFile(path).toContent(sourceContent);
47+
setFile(TEST_PATH).toContent(sourceContent);
4948
mavenRunner().withArguments("spotless:apply").runNoError();
50-
assertFile(path).hasContent(targetContent);
49+
assertFile(TEST_PATH).hasContent(targetContent);
5150
}
5251

5352
private String getClassWithLineEndings(String lineEnding) {

0 commit comments

Comments
 (0)