Skip to content

Commit cb9cbcd

Browse files
committed
lintify JsonStep (tests only)
1 parent 72e9ef7 commit cb9cbcd

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

testlib/src/test/java/com/diffplug/spotless/json/JsonSimpleStepTest.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2021-2023 DiffPlug
2+
* Copyright 2021-2024 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.
@@ -73,14 +73,33 @@ void handlesObjectWithNull() {
7373

7474
@Test
7575
void handlesInvalidJson() {
76-
stepHarness.testResourceExceptionMsg("json/invalidJsonBefore.json")
77-
.contains("Expected a ',' or '}' at 9 [character 0 line 3]");
76+
stepHarness.expectLintsOfResource("json/invalidJsonBefore.json").toBe("L3 jsonSimple(java.lang.IllegalArgumentException) Unable to format JSON",
77+
"\tat com.diffplug.spotless.json.JsonSimpleStep$State.format(JsonSimpleStep.java:109)",
78+
"\tat com.diffplug.spotless.json.JsonSimpleStep$State.lambda$toFormatter$0(JsonSimpleStep.java:94)",
79+
"\tat com.diffplug.spotless.FormatterFunc.apply(FormatterFunc.java:33)",
80+
"\tat com.diffplug.spotless.FormatterStepEqualityOnStateSerialization.format(FormatterStepEqualityOnStateSerialization.java:49)",
81+
"\tat com.diffplug.spotless.LintState.of(LintState.java:141)",
82+
"\tat com.diffplug.spotless.StepHarness.expectLintsOf(StepHarness.java:96)",
83+
"\tat com.diffplug.spotless.StepHarness.expectLintsOfResource(StepHarness.java:92)",
84+
"\tat com.diffplug.spotless.json.JsonSimpleStepTest.handlesInvalidJson(JsonSimpleStepTest.java:76)",
85+
"\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)",
86+
"(... and more)");
7887
}
7988

8089
@Test
8190
void handlesNotJson() {
82-
stepHarness.testResourceExceptionMsg("json/notJsonBefore.json")
83-
.contains("Unable to determine JSON type, expected a '{' or '[' but found '#'");
91+
stepHarness.expectLintsOfResource("json/notJsonBefore.json")
92+
.toBe("LINE_UNDEFINED jsonSimple(java.lang.IllegalArgumentException) Unable to determine JSON type, expected a '{' or '[' but found '#'",
93+
"\tat com.diffplug.spotless.json.JsonSimpleStep$State.lambda$toFormatter$0(JsonSimpleStep.java:100)",
94+
"\tat com.diffplug.spotless.FormatterFunc.apply(FormatterFunc.java:33)",
95+
"\tat com.diffplug.spotless.FormatterStepEqualityOnStateSerialization.format(FormatterStepEqualityOnStateSerialization.java:49)",
96+
"\tat com.diffplug.spotless.LintState.of(LintState.java:141)",
97+
"\tat com.diffplug.spotless.StepHarness.expectLintsOf(StepHarness.java:96)",
98+
"\tat com.diffplug.spotless.StepHarness.expectLintsOfResource(StepHarness.java:92)",
99+
"\tat com.diffplug.spotless.json.JsonSimpleStepTest.handlesNotJson(JsonSimpleStepTest.java:91)",
100+
"\tat java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)",
101+
"\tat java.base/java.lang.reflect.Method.invoke(Method.java:580)",
102+
"(... and more)");
84103
}
85104

86105
@Test

0 commit comments

Comments
 (0)