Skip to content

Commit a7a1df7

Browse files
committed
Use the harness a bit in LintSuppressionTest.
1 parent cff607b commit a7a1df7

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
import java.nio.charset.StandardCharsets;
3030
import java.nio.file.Files;
3131
import java.nio.file.Path;
32+
import java.util.Arrays;
33+
import java.util.HashMap;
34+
import java.util.List;
35+
import java.util.Map;
3236
import java.util.stream.Collectors;
3337

3438
import org.junit.jupiter.api.AfterAll;

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ void testNoSuppressionFailsOnWildcardImports() throws Exception {
3232
String path = "src/main/java/TestFile.java";
3333
setFile(path).toResource("java/removewildcardimports/JavaCodeWildcardsUnformatted.test");
3434

35-
var result = mavenRunner().withArguments("spotless:check").runHasError();
36-
assertThat(result.stdOutUtf8()).contains("Unable to format file");
37-
assertThat(result.stdOutUtf8()).contains("Step 'removeWildcardImports' found problem");
38-
assertThat(result.stdOutUtf8()).contains("Do not use wildcard imports");
35+
expectSelfieErrorMsg(mavenRunner().withArguments("spotless:check").runHasError()).toBe("""
36+
Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:VERSION:check (default-cli) on project spotless-maven-plugin-tests: Unable to format file /private/var/folders/8p/37qyn_6506sd85y1jbl91dbw0000gn/T/junit-7771631643861333109/src/main/java/TestFile.java
37+
Step 'removeWildcardImports' found problem in 'TestFile.java':
38+
TestFile.java:L1 removeWildcardImports(import java.util.*;) Do not use wildcard imports (e.g. java.util.*) - replace with specific class imports (e.g. java.util.List) as 'spotlessApply' cannot auto-fix this
39+
TestFile.java:L2 removeWildcardImports(import static java.util.Collections.*;) Do not use wildcard imports (e.g. java.util.*) - replace with specific class imports (e.g. java.util.List) as 'spotlessApply' cannot auto-fix this
40+
TestFile.java:L5 removeWildcardImports(import io.quarkus.maven.dependency.*;) Do not use wildcard imports (e.g. java.util.*) - replace with specific class imports (e.g. java.util.List) as 'spotlessApply' cannot auto-fix this
41+
TestFile.java:L6 removeWildcardImports(import static io.quarkus.vertx.web.Route.HttpMethod.*;) Do not use wildcard imports (e.g. java.util.*) - replace with specific class imports (e.g. java.util.List) as 'spotlessApply' cannot auto-fix this
42+
TestFile.java:L7 removeWildcardImports(import static org.springframework.web.reactive.function.BodyInserters.*;) Do not use wildcard imports (e.g. java.util.*) - replace with specific class imports (e.g. java.util.List) as 'spotlessApply' cannot auto-fix this
43+
""");
3944
}
4045

4146
@Test

0 commit comments

Comments
 (0)