Added/Updated tests
This commit is contained in:
parent
a7674039df
commit
c219852e85
1 changed files with 24 additions and 19 deletions
|
@ -58,18 +58,23 @@ class CheckstyleOperationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void exclude() {
|
void exclude() {
|
||||||
var op = new CheckstyleOperation().fromProject(new Project()).exclude(FOO);
|
var op = new CheckstyleOperation().fromProject(new Project()).exclude(FOO, BAR);
|
||||||
assertThat(op.options.get("-e")).isEqualTo(FOO);
|
assertThat(op.executeConstructProcessCommandList()).contains("-e " + FOO, "-e " + BAR);
|
||||||
op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(FOO));
|
|
||||||
assertThat(op.options.get("-e")).as("as list").isEqualTo(FOO);
|
op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(FOO, BAR));
|
||||||
|
assertThat(op.executeConstructProcessCommandList()).as("as list").contains("-e " + FOO, "-e " + BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void excludedPathPattern() {
|
void excludeRegex() {
|
||||||
var op = new CheckstyleOperation().fromProject(new Project()).excludedPathPattern(FOO);
|
var op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(FOO, BAR);
|
||||||
assertThat(op.options.get("-x")).isEqualTo(FOO);
|
assertThat(op.executeConstructProcessCommandList()).contains("-x " + FOO, "-x " + BAR);
|
||||||
|
|
||||||
|
op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(List.of(FOO, BAR));
|
||||||
|
assertThat(op.executeConstructProcessCommandList()).as("as list").contains("-x " + FOO, "-x " + BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void execute() throws IOException, ExitStatusException, InterruptedException {
|
void execute() throws IOException, ExitStatusException, InterruptedException {
|
||||||
var tmpFile = File.createTempFile("checkstyle-google", ".txt");
|
var tmpFile = File.createTempFile("checkstyle-google", ".txt");
|
||||||
|
@ -78,7 +83,7 @@ class CheckstyleOperationTest {
|
||||||
.fromProject(new WebProject())
|
.fromProject(new WebProject())
|
||||||
.sourceDir("src/main/java", "src/test/java")
|
.sourceDir("src/main/java", "src/test/java")
|
||||||
.configurationFile("src/test/resources/google_checks.xml")
|
.configurationFile("src/test/resources/google_checks.xml")
|
||||||
.output(tmpFile.getAbsolutePath());
|
.outputPath(tmpFile.getAbsolutePath());
|
||||||
op.execute();
|
op.execute();
|
||||||
assertThat(tmpFile).exists();
|
assertThat(tmpFile).exists();
|
||||||
}
|
}
|
||||||
|
@ -119,15 +124,15 @@ class CheckstyleOperationTest {
|
||||||
.fromProject(new WebProject())
|
.fromProject(new WebProject())
|
||||||
.sourceDir(List.of("src/main/java", "src/test/java"))
|
.sourceDir(List.of("src/main/java", "src/test/java"))
|
||||||
.configurationFile("src/test/resources/sun_checks.xml")
|
.configurationFile("src/test/resources/sun_checks.xml")
|
||||||
.output(tmpFile.getAbsolutePath());
|
.outputPath(tmpFile.getAbsolutePath());
|
||||||
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
|
assertThatCode(op::execute).isInstanceOf(ExitStatusException.class);
|
||||||
assertThat(tmpFile).exists();
|
assertThat(tmpFile).exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void format() {
|
void format() {
|
||||||
var op = new CheckstyleOperation().fromProject(new Project()).format(FOO);
|
var op = new CheckstyleOperation().fromProject(new Project()).format(CheckstyleFormatOption.XML);
|
||||||
assertThat(op.options.get("-f")).isEqualTo(FOO);
|
assertThat(op.options.get("-f")).isEqualTo("xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -147,14 +152,8 @@ class CheckstyleOperationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void lineColumn() {
|
void outputPath() {
|
||||||
var op = new CheckstyleOperation().fromProject(new Project()).lineColumn(FOO);
|
var op = new CheckstyleOperation().fromProject(new Project()).outputPath(FOO);
|
||||||
assertThat(op.options.get("-s")).isEqualTo(FOO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void output() {
|
|
||||||
var op = new CheckstyleOperation().fromProject(new Project()).output(FOO);
|
|
||||||
assertThat(op.options.get("-o")).isEqualTo(FOO);
|
assertThat(op.options.get("-o")).isEqualTo(FOO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +171,12 @@ class CheckstyleOperationTest {
|
||||||
assertThat(op.sourceDirs).as("foo, bar").hasSize(2).contains(FOO).contains(BAR);
|
assertThat(op.sourceDirs).as("foo, bar").hasSize(2).contains(FOO).contains(BAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void suppressionLineColumnNumber() {
|
||||||
|
var op = new CheckstyleOperation().fromProject(new Project()).suppressionLineColumnNumber(FOO + ':' + BAR);
|
||||||
|
assertThat(op.options.get("-s")).isEqualTo(FOO + ':' + BAR);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void tabWith() {
|
void tabWith() {
|
||||||
var op = new CheckstyleOperation().fromProject(new Project()).tabWith(9);
|
var op = new CheckstyleOperation().fromProject(new Project()).tabWith(9);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue