Cleanup tests

This commit is contained in:
Erik C. Thauvin 2025-05-03 19:00:34 -07:00
parent c8c38b5612
commit 9d8ab4a7bc
Signed by: erik
GPG key ID: 776702A6A2DA330E
3 changed files with 311 additions and 235 deletions

4
.idea/misc.xml generated
View file

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="EntryPointsManager"> <component name="EntryPointsManager">
<entry_points version="2.0">
<entry_point TYPE="field" FQNAME="rife.bld.extension.checkstyle.OutputFormat PLAIN" />
<entry_point TYPE="field" FQNAME="rife.bld.extension.checkstyle.OutputFormat SARIF" />
</entry_points>
<pattern value="rife.bld.extension.CheckstyleOperationBuild" /> <pattern value="rife.bld.extension.CheckstyleOperationBuild" />
<pattern value="rife.bld.extension.CheckstyleOperationBuild" method="jacoco" /> <pattern value="rife.bld.extension.CheckstyleOperationBuild" method="jacoco" />
<pattern value="rife.bld.extension.CheckstyleOperationBuild" method="pmd" /> <pattern value="rife.bld.extension.CheckstyleOperationBuild" method="pmd" />

View file

@ -455,6 +455,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
* @return the checkstyle operation * @return the checkstyle operation
* @see #sourceDir(Collection) * @see #sourceDir(Collection)
*/ */
@SuppressWarnings("UnusedReturnValue")
public CheckstyleOperation sourceDir(File... dir) { public CheckstyleOperation sourceDir(File... dir) {
return sourceDir(List.of(dir)); return sourceDir(List.of(dir));
} }
@ -466,6 +467,7 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
* @return the checkstyle operation * @return the checkstyle operation
* @see #sourceDirPaths(Collection) * @see #sourceDirPaths(Collection)
*/ */
@SuppressWarnings("UnusedReturnValue")
public CheckstyleOperation sourceDir(Path... dir) { public CheckstyleOperation sourceDir(Path... dir) {
return sourceDirPaths(List.of(dir)); return sourceDirPaths(List.of(dir));
} }

View file

@ -18,6 +18,8 @@ package rife.bld.extension;
import org.assertj.core.api.AutoCloseableSoftAssertions; import org.assertj.core.api.AutoCloseableSoftAssertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs; import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS; import org.junit.jupiter.api.condition.OS;
@ -41,12 +43,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatCode;
class CheckstyleOperationTest { class CheckstyleOperationTest {
public static final String SRC_MAIN_JAVA = "src/main/java";
public static final String SRC_TEST_JAVA = "src/test/java";
private static final String ADD = "add"; private static final String ADD = "add";
private static final String BAR = "bar"; private static final String BAR = "bar";
private static final String FOO = "foo"; private static final String FOO = "foo";
private static final String REMOVE = "remove"; private static final String REMOVE = "remove";
private static final String SRC_MAIN_JAVA = "src/main/java";
private static final String SRC_TEST_JAVA = "src/test/java";
@BeforeAll @BeforeAll
static void beforeAll() { static void beforeAll() {
@ -59,272 +61,340 @@ class CheckstyleOperationTest {
logger.setUseParentHandlers(false); logger.setUseParentHandlers(false);
} }
private CheckstyleOperation newCheckstyleOperation() {
@Test return new CheckstyleOperation().fromProject(new Project());
void branchMatchingXpath() {
var op = new CheckstyleOperation().fromProject(new Project()).branchMatchingXpath(FOO);
assertThat(op.options().get("-b")).isEqualTo(FOO);
} }
@Test @Nested
@EnabledOnOs(OS.LINUX) @DisplayName("Exclude Tests")
void checkAllParameters() throws IOException { class ExcludeTests {
var args = Files.readAllLines(Paths.get("src", "test", "resources", "checkstyle-args.txt")); private static final String e = "-e ";
private static final String x = "-x ";
private final File srcMainJavaDir = new File(SRC_MAIN_JAVA);
private final File srcTestJavaDir = new File(SRC_TEST_JAVA);
assertThat(args).isNotEmpty(); @Test
void excludeFromFileArray() {
var op = newCheckstyleOperation().exclude(srcTestJavaDir, srcMainJavaDir);
assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.contains(e + srcTestJavaDir.getAbsolutePath()).contains(e + srcMainJavaDir.getAbsolutePath());
}
var params = new CheckstyleOperation() @Test
.fromProject(new Project()) void excludeFromFileList() {
.branchMatchingXpath("xpath") var op = newCheckstyleOperation()
.debug(true) .exclude(List.of(srcTestJavaDir, srcMainJavaDir));
.configurationFile(new File("config")) assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.exclude(SRC_MAIN_JAVA) .contains(e + srcTestJavaDir.getAbsolutePath()).contains(e + srcMainJavaDir.getAbsolutePath());
.excludeRegex("regex") }
.executeIgnoredModules(true)
.format(OutputFormat.XML)
.generateXpathSuppression(true)
.javadocTree(true)
.outputPath(new File("optionPath"))
.propertiesFile(new File("properties"))
.suppressionLineColumnNumber("12")
.tabWith(1)
.tree(true)
.treeWithComments(true)
.treeWithJavadoc(true)
.executeConstructProcessCommandList();
try (var softly = new AutoCloseableSoftAssertions()) { @Test
for (var p : args) { void excludeFromPathArray() {
var found = false; var op = newCheckstyleOperation()
for (var a : params) { .exclude(srcTestJavaDir.toPath(), srcMainJavaDir.toPath());
if (a.startsWith(p)) { assertThat(String.join(" ", op.executeConstructProcessCommandList()))
found = true; .contains(e + srcTestJavaDir.getAbsolutePath()).contains(e + srcMainJavaDir.getAbsolutePath());
break; }
}
} @Test
softly.assertThat(found).as(p + " not found.").isTrue(); void excludeFromPathList() {
} var op = newCheckstyleOperation()
.excludePaths(List.of(srcTestJavaDir.toPath(), srcMainJavaDir.toPath()));
assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.contains(e + srcTestJavaDir.getAbsolutePath()).contains(e + srcMainJavaDir.getAbsolutePath());
}
@Test
void excludeFromStringArray() {
var op = newCheckstyleOperation().exclude(SRC_MAIN_JAVA, SRC_TEST_JAVA);
assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.contains(e + srcTestJavaDir.getAbsolutePath()).contains(e + srcMainJavaDir.getAbsolutePath());
}
@Test
void excludeFromStringList() {
var op = newCheckstyleOperation()
.excludeStrings(List.of(SRC_MAIN_JAVA, SRC_TEST_JAVA));
assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.contains(e + srcMainJavaDir.getAbsolutePath()).contains(e + srcTestJavaDir.getAbsolutePath());
}
@Test
void excludeNonExistingPath() {
var op = newCheckstyleOperation().exclude(FOO);
assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.doesNotContain(e + FOO);
}
@Test
void excludeNonExistingPaths() {
var op = newCheckstyleOperation().exclude(FOO, BAR);
assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.doesNotContain(e + FOO).doesNotContain(e + BAR);
}
@Test
void excludeRegex() {
var op = newCheckstyleOperation().excludeRegex(FOO, BAR);
assertThat(String.join(" ", op.executeConstructProcessCommandList())).contains(x + FOO, x + BAR);
}
@Test
void excludeRegexFromList() {
var op = newCheckstyleOperation().excludeRegex(List.of(FOO, BAR));
assertThat(String.join(" ", op.executeConstructProcessCommandList())).contains(x + FOO, x + BAR);
} }
} }
@Test @Nested
void configurationFile() { @DisplayName("Execute Tests")
var op = new CheckstyleOperation().fromProject(new Project()).configurationFile(FOO); class ExecuteTests {
assertThat(op.options().get("-c")).isEqualTo(FOO); @Test
void execute() throws IOException, ExitStatusException, InterruptedException {
var tmpFile = File.createTempFile("checkstyle-google", ".txt");
tmpFile.deleteOnExit();
var op = new CheckstyleOperation()
.fromProject(new WebProject())
.sourceDir(SRC_MAIN_JAVA, SRC_TEST_JAVA)
.configurationFile(Path.of("src/test/resources/google_checks.xml"))
.outputPath(tmpFile.toPath());
op.execute();
assertThat(tmpFile).as("tmp file should exist").exists();
}
@Test
void executeConstructProcessCommandList() {
var op = new CheckstyleOperation().fromProject(new BaseProject())
.configurationFile("config/checkstyle.xml")
.branchMatchingXpath("xpath")
.propertiesFile("config/checkstyle.properties")
.debug(true)
.executeIgnoredModules(true)
.sourceDir(SRC_MAIN_JAVA, SRC_TEST_JAVA);
assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.startsWith("java -cp ")
.endsWith(
"com.puppycrawl.tools.checkstyle.Main " +
"-p config/checkstyle.properties " +
"-b xpath " +
"-c config/checkstyle.xml " +
"-d -E " +
new File(SRC_MAIN_JAVA).getAbsolutePath() + " " +
new File(SRC_TEST_JAVA).getAbsolutePath());
}
@Test
void executeIgnoredModules() {
var op = newCheckstyleOperation().executeIgnoredModules(true);
assertThat(op.options().containsKey("-E")).as(ADD).isTrue();
op = op.executeIgnoredModules(false);
assertThat(op.options().containsKey("-E")).as(REMOVE).isFalse();
}
@Test
void executeNoProject() {
var op = new CheckstyleOperation();
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
}
@Test
void executeSunChecks() throws IOException {
var tmpFile = File.createTempFile("checkstyle-sun", ".txt");
tmpFile.deleteOnExit();
var op = newCheckstyleOperation()
.sourceDir(SRC_MAIN_JAVA, SRC_TEST_JAVA)
.configurationFile("src/test/resources/sun_checks.xml")
.outputPath(tmpFile.getAbsolutePath());
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
assertThat(tmpFile).as("tmp file should exist").exists();
}
} }
@Test @Nested
void debug() { @DisplayName("Options Tests")
var op = new CheckstyleOperation().fromProject(new Project()).debug(true); class OptionsTests {
assertThat(op.options().containsKey("-d")).as(ADD).isTrue(); @Test
op = op.debug(false); void branchMatchingXpath() {
assertThat(op.options().containsKey("-d")).as(REMOVE).isFalse(); var op = newCheckstyleOperation().branchMatchingXpath(FOO);
} assertThat(op.options().get("-b")).isEqualTo(FOO);
}
@Test @Test
void exclude() { @EnabledOnOs(OS.LINUX)
var foo = new File(SRC_MAIN_JAVA); void checkAllParameters() throws IOException {
var bar = new File(SRC_TEST_JAVA); var args = Files.readAllLines(Paths.get("src", "test", "resources", "checkstyle-args.txt"));
var e = "-e ";
var op = new CheckstyleOperation().fromProject(new Project()).exclude(SRC_MAIN_JAVA, SRC_TEST_JAVA); assertThat(args).isNotEmpty();
assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("String...")
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath());
op = new CheckstyleOperation().fromProject(new Project()).excludeStrings(List.of(SRC_MAIN_JAVA, SRC_TEST_JAVA)); var params = newCheckstyleOperation()
assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("List(String...)") .branchMatchingXpath("xpath")
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath()); .debug(true)
.configurationFile(new File("config"))
.exclude(SRC_MAIN_JAVA)
.excludeRegex("regex")
.executeIgnoredModules(true)
.format(OutputFormat.XML)
.generateXpathSuppression(true)
.javadocTree(true)
.outputPath(new File("optionPath"))
.propertiesFile(new File("properties"))
.suppressionLineColumnNumber("12")
.tabWith(1)
.tree(true)
.treeWithComments(true)
.treeWithJavadoc(true)
.executeConstructProcessCommandList();
op = new CheckstyleOperation().fromProject(new Project()).exclude(foo, bar); try (var softly = new AutoCloseableSoftAssertions()) {
assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("File...") for (var p : args) {
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath()); var found = false;
for (var a : params) {
if (a.startsWith(p)) {
found = true;
break;
}
}
softly.assertThat(found).as("%s not found.", p).isTrue();
}
}
}
op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(foo, bar)); @Test
assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("List(File...)") void configurationFile() {
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath()); var op = newCheckstyleOperation().configurationFile(FOO);
assertThat(op.options().get("-c")).isEqualTo(FOO);
}
op = new CheckstyleOperation().fromProject(new Project()).exclude(foo.toPath(), bar.toPath()); @Test
assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("Path...") void debug() {
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath()); var op = newCheckstyleOperation().debug(true);
assertThat(op.options().containsKey("-d")).as(ADD).isTrue();
op = op.debug(false);
assertThat(op.options().containsKey("-d")).as(REMOVE).isFalse();
}
op = new CheckstyleOperation().fromProject(new Project()).excludePaths(List.of(foo.toPath(), bar.toPath())); @Test
assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("List(Path...)") void format() {
.contains(e + foo.getAbsolutePath()).contains(e + bar.getAbsolutePath()); var op = newCheckstyleOperation().format(OutputFormat.XML);
} assertThat(op.options().get("-f")).isEqualTo("xml");
}
@Test @Test
void excludeRegex() { void generateXpathSuppression() {
var op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(FOO, BAR); var op = newCheckstyleOperation().generateXpathSuppression(true);
var x = "-x "; assertThat(op.options().containsKey("-g")).as(ADD).isTrue();
assertThat(String.join(" ", op.executeConstructProcessCommandList())).contains(x + FOO, x + BAR); op = op.generateXpathSuppression(false);
assertThat(op.options().containsKey("-g")).as(REMOVE).isFalse();
}
op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(List.of(FOO, BAR)); @Test
assertThat(String.join(" ", op.executeConstructProcessCommandList())).as("as list").contains(x + FOO, x + BAR); void javadocTree() {
} var op = newCheckstyleOperation().javadocTree(true);
assertThat(op.options().containsKey("-j")).as(ADD).isTrue();
op = op.javadocTree(false);
assertThat(op.options().containsKey("-j")).as(REMOVE).isFalse();
}
@Test @Test
void execute() throws IOException, ExitStatusException, InterruptedException { void outputPath() {
var tmpFile = File.createTempFile("checkstyle-google", ".txt"); var op = newCheckstyleOperation().outputPath(FOO);
tmpFile.deleteOnExit(); assertThat(op.options().get("-o")).isEqualTo(FOO);
var op = new CheckstyleOperation() }
.fromProject(new WebProject())
.sourceDir(SRC_MAIN_JAVA, SRC_TEST_JAVA)
.configurationFile(Path.of("src/test/resources/google_checks.xml"))
.outputPath(tmpFile.toPath());
op.execute();
assertThat(tmpFile).exists();
}
@Test @Test
void executeConstructProcessCommandList() { void propertiesFile() {
var op = new CheckstyleOperation().fromProject(new BaseProject()) var op = newCheckstyleOperation().propertiesFile(FOO);
.configurationFile("config/checkstyle.xml") assertThat(op.options().get("-p")).isEqualTo(FOO);
.branchMatchingXpath("xpath")
.propertiesFile("config/checkstyle.properties")
.debug(true)
.executeIgnoredModules(true)
.sourceDir(SRC_MAIN_JAVA, SRC_TEST_JAVA);
assertThat(String.join(" ", op.executeConstructProcessCommandList()))
.startsWith("java -cp ")
.endsWith(
"com.puppycrawl.tools.checkstyle.Main " +
"-p config/checkstyle.properties " +
"-b xpath " +
"-c config/checkstyle.xml " +
"-d -E " +
new File(SRC_MAIN_JAVA).getAbsolutePath() + " " +
new File(SRC_TEST_JAVA).getAbsolutePath());
}
@Test var fooPath = Path.of(FOO);
void executeIgnoredModules() { op = op.propertiesFile(fooPath);
var op = new CheckstyleOperation().fromProject(new Project()).executeIgnoredModules(true); assertThat(op.options().get("-p")).isEqualTo(fooPath.toFile().getAbsolutePath());
assertThat(op.options().containsKey("-E")).as(ADD).isTrue(); }
op = op.executeIgnoredModules(false);
assertThat(op.options().containsKey("-E")).as(REMOVE).isFalse();
}
@Test @Test
void executeNoProject() { void suppressionLineColumnNumber() {
var op = new CheckstyleOperation(); var op = newCheckstyleOperation().suppressionLineColumnNumber(FOO + ':' + BAR);
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class); assertThat(op.options().get("-s")).isEqualTo(FOO + ':' + BAR);
} }
@Test @Test
void executeSunChecks() throws IOException { void tabWith() {
var tmpFile = File.createTempFile("checkstyle-sun", ".txt"); var op = newCheckstyleOperation().tabWith(9);
tmpFile.deleteOnExit(); assertThat(op.options().get("-w")).isEqualTo("9");
var op = new CheckstyleOperation() }
.fromProject(new WebProject())
.sourceDir(SRC_MAIN_JAVA, SRC_TEST_JAVA)
.configurationFile("src/test/resources/sun_checks.xml")
.outputPath(tmpFile.getAbsolutePath());
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
assertThat(tmpFile).exists();
}
@Test @Test
void format() { void tree() {
var op = new CheckstyleOperation().fromProject(new Project()).format(OutputFormat.XML); var op = newCheckstyleOperation().tree(true);
assertThat(op.options().get("-f")).isEqualTo("xml"); assertThat(op.options().containsKey("-t")).as(ADD).isTrue();
} op = op.tree(false);
assertThat(op.options().containsKey("-t")).as(REMOVE).isFalse();
}
@Test @Test
void generateXpathSuppression() { void treeWithComments() {
var op = new CheckstyleOperation().fromProject(new Project()).generateXpathSuppression(true); var op = newCheckstyleOperation().treeWithComments(true);
assertThat(op.options().containsKey("-g")).as(ADD).isTrue(); assertThat(op.options().containsKey("-T")).as(ADD).isTrue();
op = op.generateXpathSuppression(false); op = op.treeWithComments(false);
assertThat(op.options().containsKey("-g")).as(REMOVE).isFalse(); assertThat(op.options().containsKey("-T")).as(REMOVE).isFalse();
} }
@Test @Test
void javadocTree() { void treeWithJavadoc() {
var op = new CheckstyleOperation().fromProject(new Project()).javadocTree(true); var op = newCheckstyleOperation().treeWithJavadoc(true);
assertThat(op.options().containsKey("-j")).as(ADD).isTrue(); assertThat(op.options().containsKey("-J")).as(ADD).isTrue();
op = op.javadocTree(false); op = op.treeWithJavadoc(false);
assertThat(op.options().containsKey("-j")).as(REMOVE).isFalse(); assertThat(op.options().containsKey("-J")).as(REMOVE).isFalse();
} }
@Test @Nested
void outputPath() { @DisplayName("Source Dir Tests")
var op = new CheckstyleOperation().fromProject(new Project()).outputPath(FOO); class SourceDirTests {
assertThat(op.options().get("-o")).isEqualTo(FOO); private final File bar = new File(BAR);
} private final File foo = new File(FOO);
private final CheckstyleOperation op = newCheckstyleOperation().sourceDir(FOO, BAR);
@Test @Test
void propertiesFile() { void sourceDirFromFileArray() {
var op = new CheckstyleOperation().fromProject(new Project()).propertiesFile(FOO); op.sourceDir(foo, bar);
assertThat(op.options().get("-p")).isEqualTo(FOO); assertThat(op.sourceDir()).as("File...").hasSize(2).contains(foo, bar);
op.sourceDir().clear();
}
var fooPath = Path.of(FOO); @Test
op = op.propertiesFile(fooPath); void sourceDirFromFileList() {
assertThat(op.options().get("-p")).isEqualTo(fooPath.toFile().getAbsolutePath()); op.sourceDir(List.of(foo, bar));
} assertThat(op.sourceDir()).as("List(File...)").hasSize(2).contains(foo, bar);
op.sourceDir().clear();
}
@Test @Test
void sourceDir() { void sourceDirFromPathArray() {
var foo = new File(FOO); op.sourceDir(foo.toPath(), bar.toPath());
var bar = new File(BAR); assertThat(op.sourceDir()).as("Path...").hasSize(2).contains(foo, bar);
op.sourceDir().clear();
}
var op = new CheckstyleOperation().fromProject(new Project()).sourceDir(FOO, BAR); @Test
assertThat(op.sourceDir()).as("String...").hasSize(2).contains(foo, bar); void sourceDirFromPathList() {
op.sourceDir().clear(); op.sourceDirPaths(List.of(foo.toPath(), bar.toPath()));
assertThat(op.sourceDir()).as("List(Path...)").hasSize(2).contains(foo, bar);
op.sourceDir().clear();
}
op = op.sourceDirStrings(List.of(FOO, BAR)); @Test
assertThat(op.sourceDir()).as("List(String...)").hasSize(2).contains(foo, bar); void sourceDirFromStringArray() {
op.sourceDir().clear(); op.sourceDir("foo", "bar");
assertThat(op.sourceDir()).as("String...").hasSize(2).contains(foo, bar);
op.sourceDir().clear();
}
op = op.sourceDir(foo, bar); @Test
assertThat(op.sourceDir()).as("File...").hasSize(2).contains(foo, bar); void sourceDirFromStringList() {
op.sourceDir().clear(); op.sourceDirStrings(List.of(FOO, BAR));
assertThat(op.sourceDir()).as("List(String...)").hasSize(2).contains(foo, bar);
op = op.sourceDir(List.of(foo, bar)); op.sourceDir().clear();
assertThat(op.sourceDir()).as("List(File...)").hasSize(2).contains(foo, bar); }
op.sourceDir().clear(); }
op = op.sourceDir(foo.toPath(), bar.toPath());
assertThat(op.sourceDir()).as("Path...").hasSize(2).contains(foo, bar);
op.sourceDir().clear();
op = op.sourceDirPaths(List.of(foo.toPath(), bar.toPath()));
assertThat(op.sourceDir()).as("List(Path...)").hasSize(2).contains(foo, bar);
op.sourceDir().clear();
}
@Test
void suppressionLineColumnNumber() {
var op = new CheckstyleOperation().fromProject(new Project()).suppressionLineColumnNumber(FOO + ':' + BAR);
assertThat(op.options().get("-s")).isEqualTo(FOO + ':' + BAR);
}
@Test
void tabWith() {
var op = new CheckstyleOperation().fromProject(new Project()).tabWith(9);
assertThat(op.options().get("-w")).isEqualTo("9");
}
@Test
void tree() {
var op = new CheckstyleOperation().fromProject(new Project()).tree(true);
assertThat(op.options().containsKey("-t")).as(ADD).isTrue();
op = op.tree(false);
assertThat(op.options().containsKey("-t")).as(REMOVE).isFalse();
}
@Test
void treeWithComments() {
var op = new CheckstyleOperation().fromProject(new Project()).treeWithComments(true);
assertThat(op.options().containsKey("-T")).as(ADD).isTrue();
op = op.treeWithComments(false);
assertThat(op.options().containsKey("-T")).as(REMOVE).isFalse();
}
@Test
void treeWithJavadoc() {
var op = new CheckstyleOperation().fromProject(new Project()).treeWithJavadoc(true);
assertThat(op.options().containsKey("-J")).as(ADD).isTrue();
op = op.treeWithJavadoc(false);
assertThat(op.options().containsKey("-J")).as(REMOVE).isFalse();
} }
} }