Skip to content

Commit 5141f46

Browse files
committed
debugging
1 parent 096b133 commit 5141f46

File tree

1 file changed

+156
-0
lines changed

1 file changed

+156
-0
lines changed

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

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,160 @@ public void formattingWithCustomNumberOfSpaces() throws IOException {
6161
gradleRunner().withArguments("spotlessApply").build();
6262
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
6363
}
64+
65+
@Test
66+
public void formattingWithCustomNumberOfSpaces___() throws IOException {
67+
setFile("build.gradle").toLines(
68+
"buildscript { repositories { mavenCentral() } }",
69+
"plugins {",
70+
" id 'java'",
71+
" id 'com.diffplug.spotless'",
72+
"}",
73+
"spotless {",
74+
" json {" +
75+
" target '**/*.json'" +
76+
" simple().indentWithSpaces(6)" +
77+
"}",
78+
"}");
79+
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
80+
gradleRunner().withArguments("spotlessApply").build();
81+
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
82+
}
83+
84+
@Test
85+
public void formattingWithCustomNumberOfSpaces___format() throws IOException {
86+
setFile("build.gradle").toLines(
87+
"buildscript { repositories { mavenCentral() } }",
88+
"plugins {",
89+
" id 'java'",
90+
" id 'com.diffplug.spotless'",
91+
"}",
92+
"spotless {",
93+
" format 'json', {" +
94+
" target '**/*.json'" +
95+
" simple().indentWithSpaces(6)" +
96+
"}",
97+
"}");
98+
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
99+
gradleRunner().withArguments("spotlessApply").build();
100+
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
101+
}
102+
103+
@Test
104+
public void formattingWithCustomNumberOfSpaces___formatWithClass() throws IOException {
105+
setFile("build.gradle").toLines(
106+
"buildscript { repositories { mavenCentral() } }",
107+
"plugins {",
108+
" id 'java'",
109+
" id 'com.diffplug.spotless'",
110+
"}",
111+
"spotless {",
112+
" format 'json', com.diffplug.gradle.spotless.JsonExtension, {" +
113+
" target '**/*.json'" +
114+
" simple().indentWithSpaces(6)" +
115+
"}",
116+
"}");
117+
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
118+
gradleRunner().withArguments("spotlessApply").build();
119+
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
120+
}
121+
122+
@Test
123+
public void defaultFormattingWithTargetAfter() throws IOException {
124+
setFile("build.gradle").toLines(
125+
"buildscript { repositories { mavenCentral() } }",
126+
"plugins {",
127+
" id 'java'",
128+
" id 'com.diffplug.spotless'",
129+
"}",
130+
"spotless {",
131+
" json {" +
132+
" simple()" +
133+
" target 'examples/**/*.json'" +
134+
"}",
135+
"}");
136+
setFile("src/main/resources/example.json").toResource("json/nestedObjectBefore.json");
137+
setFile("examples/main/resources/example.json").toResource("json/nestedObjectBefore.json");
138+
gradleRunner().withArguments("spotlessApply").build();
139+
assertFile("src/main/resources/example.json").sameAsResource("json/nestedObjectBefore.json");
140+
assertFile("examples/main/resources/example.json").sameAsResource("json/nestedObjectAfter.json");
141+
}
142+
143+
@Test
144+
public void formattingWithCustomNumberOfSpacesWithTargetAfter() throws IOException {
145+
setFile("build.gradle").toLines(
146+
"buildscript { repositories { mavenCentral() } }",
147+
"plugins {",
148+
" id 'java'",
149+
" id 'com.diffplug.spotless'",
150+
"}",
151+
"spotless {",
152+
" json {" +
153+
" simple {" +
154+
" indentWithSpaces(6)" +
155+
" }",
156+
" target '**/*.json'" +
157+
"}",
158+
"}");
159+
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
160+
gradleRunner().withArguments("spotlessApply").build();
161+
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
162+
}
163+
164+
@Test
165+
public void formattingWithCustomNumberOfSpaces___WithTargetAfter() throws IOException {
166+
setFile("build.gradle").toLines(
167+
"buildscript { repositories { mavenCentral() } }",
168+
"plugins {",
169+
" id 'java'",
170+
" id 'com.diffplug.spotless'",
171+
"}",
172+
"spotless {",
173+
" json {" +
174+
" simple().indentWithSpaces(6)" +
175+
" target '**/*.json'" +
176+
"}",
177+
"}");
178+
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
179+
gradleRunner().withArguments("spotlessApply").build();
180+
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
181+
}
182+
183+
@Test
184+
public void formattingWithCustomNumberOfSpaces___formatWithTargetAfter() throws IOException {
185+
setFile("build.gradle").toLines(
186+
"buildscript { repositories { mavenCentral() } }",
187+
"plugins {",
188+
" id 'java'",
189+
" id 'com.diffplug.spotless'",
190+
"}",
191+
"spotless {",
192+
" format 'json', {" +
193+
" simple().indentWithSpaces(6)" +
194+
" target '**/*.json'" +
195+
"}",
196+
"}");
197+
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
198+
gradleRunner().withArguments("spotlessApply").build();
199+
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
200+
}
201+
202+
@Test
203+
public void formattingWithCustomNumberOfSpaces___formatWithClassWithTargetAfter() throws IOException {
204+
setFile("build.gradle").toLines(
205+
"buildscript { repositories { mavenCentral() } }",
206+
"plugins {",
207+
" id 'java'",
208+
" id 'com.diffplug.spotless'",
209+
"}",
210+
"spotless {",
211+
" format 'json', com.diffplug.gradle.spotless.JsonExtension, {" +
212+
" simple().indentWithSpaces(6)" +
213+
" target '**/*.json'" +
214+
"}",
215+
"}");
216+
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
217+
gradleRunner().withArguments("spotlessApply").build();
218+
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
219+
}
64220
}

0 commit comments

Comments
 (0)