Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
jamietanna committed Jun 16, 2021
1 parent 096b133 commit 5141f46
Showing 1 changed file with 156 additions and 0 deletions.
Expand Up @@ -61,4 +61,160 @@ public void formattingWithCustomNumberOfSpaces() throws IOException {
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
}

@Test
public void formattingWithCustomNumberOfSpaces___() throws IOException {
setFile("build.gradle").toLines(
"buildscript { repositories { mavenCentral() } }",
"plugins {",
" id 'java'",
" id 'com.diffplug.spotless'",
"}",
"spotless {",
" json {" +
" target '**/*.json'" +
" simple().indentWithSpaces(6)" +
"}",
"}");
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
}

@Test
public void formattingWithCustomNumberOfSpaces___format() throws IOException {
setFile("build.gradle").toLines(
"buildscript { repositories { mavenCentral() } }",
"plugins {",
" id 'java'",
" id 'com.diffplug.spotless'",
"}",
"spotless {",
" format 'json', {" +
" target '**/*.json'" +
" simple().indentWithSpaces(6)" +
"}",
"}");
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
}

@Test
public void formattingWithCustomNumberOfSpaces___formatWithClass() throws IOException {
setFile("build.gradle").toLines(
"buildscript { repositories { mavenCentral() } }",
"plugins {",
" id 'java'",
" id 'com.diffplug.spotless'",
"}",
"spotless {",
" format 'json', com.diffplug.gradle.spotless.JsonExtension, {" +
" target '**/*.json'" +
" simple().indentWithSpaces(6)" +
"}",
"}");
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
}

@Test
public void defaultFormattingWithTargetAfter() throws IOException {
setFile("build.gradle").toLines(
"buildscript { repositories { mavenCentral() } }",
"plugins {",
" id 'java'",
" id 'com.diffplug.spotless'",
"}",
"spotless {",
" json {" +
" simple()" +
" target 'examples/**/*.json'" +
"}",
"}");
setFile("src/main/resources/example.json").toResource("json/nestedObjectBefore.json");
setFile("examples/main/resources/example.json").toResource("json/nestedObjectBefore.json");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/nestedObjectBefore.json");
assertFile("examples/main/resources/example.json").sameAsResource("json/nestedObjectAfter.json");
}

@Test
public void formattingWithCustomNumberOfSpacesWithTargetAfter() throws IOException {
setFile("build.gradle").toLines(
"buildscript { repositories { mavenCentral() } }",
"plugins {",
" id 'java'",
" id 'com.diffplug.spotless'",
"}",
"spotless {",
" json {" +
" simple {" +
" indentWithSpaces(6)" +
" }",
" target '**/*.json'" +
"}",
"}");
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
}

@Test
public void formattingWithCustomNumberOfSpaces___WithTargetAfter() throws IOException {
setFile("build.gradle").toLines(
"buildscript { repositories { mavenCentral() } }",
"plugins {",
" id 'java'",
" id 'com.diffplug.spotless'",
"}",
"spotless {",
" json {" +
" simple().indentWithSpaces(6)" +
" target '**/*.json'" +
"}",
"}");
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
}

@Test
public void formattingWithCustomNumberOfSpaces___formatWithTargetAfter() throws IOException {
setFile("build.gradle").toLines(
"buildscript { repositories { mavenCentral() } }",
"plugins {",
" id 'java'",
" id 'com.diffplug.spotless'",
"}",
"spotless {",
" format 'json', {" +
" simple().indentWithSpaces(6)" +
" target '**/*.json'" +
"}",
"}");
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
}

@Test
public void formattingWithCustomNumberOfSpaces___formatWithClassWithTargetAfter() throws IOException {
setFile("build.gradle").toLines(
"buildscript { repositories { mavenCentral() } }",
"plugins {",
" id 'java'",
" id 'com.diffplug.spotless'",
"}",
"spotless {",
" format 'json', com.diffplug.gradle.spotless.JsonExtension, {" +
" simple().indentWithSpaces(6)" +
" target '**/*.json'" +
"}",
"}");
setFile("src/main/resources/example.json").toResource("json/singletonArrayBefore.json");
gradleRunner().withArguments("spotlessApply").build();
assertFile("src/main/resources/example.json").sameAsResource("json/singletonArrayAfter6Spaces.json");
}
}

0 comments on commit 5141f46

Please sign in to comment.