Skip to content

Commit dcf727c

Browse files
committed
Add not trivial json tests
1 parent 890ead9 commit dcf727c

File tree

1 file changed

+21
-2
lines changed
  • plugin-maven/src/test/java/com/diffplug/spotless/maven/json

1 file changed

+21
-2
lines changed

plugin-maven/src/test/java/com/diffplug/spotless/maven/json/JsonTest.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
public class JsonTest extends MavenIntegrationHarness {
2323
@Test
24-
public void testFormatJson_WithSimple_defaultConfig() throws Exception {
24+
public void testFormatJson_WithSimple_defaultConfig_sortByKeys() throws Exception {
2525
writePomWithJsonSteps("<simple/>");
2626

2727
setFile("json_test.json").toResource("json/sortByKeysBefore.json");
@@ -30,11 +30,30 @@ public void testFormatJson_WithSimple_defaultConfig() throws Exception {
3030
}
3131

3232
@Test
33-
public void testFormatJson_WithGson_defaultConfig() throws Exception {
33+
public void testFormatJson_WithSimple_defaultConfig_nestedObject() throws Exception {
34+
writePomWithJsonSteps("<simple/>");
35+
36+
setFile("json_test.json").toResource("json/nestedObjectBefore.json");
37+
mavenRunner().withArguments("spotless:apply").runNoError().error();
38+
assertFile("json_test.json").sameAsResource("json/nestedObjectAfter.json");
39+
}
40+
41+
@Test
42+
public void testFormatJson_WithGson_defaultConfig_sortByKeys() throws Exception {
3443
writePomWithJsonSteps("<gson/>");
3544

3645
setFile("json_test.json").toResource("json/sortByKeysBefore.json");
3746
mavenRunner().withArguments("spotless:apply").runNoError().error();
3847
assertFile("json_test.json").sameAsResource("json/sortByKeysAfterDisabled.json");
3948
}
49+
50+
@Test
51+
public void testFormatJson_WithGson_sortByKeys() throws Exception {
52+
writePomWithJsonSteps("<gson><sortByKeys>true</sortByKeys></gson>");
53+
54+
setFile("json_test.json").toResource("json/sortByKeysBefore.json");
55+
mavenRunner().withArguments("spotless:apply").runNoError().error();
56+
assertFile("json_test.json").sameAsResource("json/sortByKeysAfter.json");
57+
}
58+
4059
}

0 commit comments

Comments
 (0)