Avoid duplicate literals (PMD)

This commit is contained in:
Erik C. Thauvin 2024-04-29 04:05:22 -07:00
parent b7fb8d9728
commit d7d9cdf98c
Signed by: erik
GPG key ID: 776702A6A2DA330E

View file

@ -59,19 +59,21 @@ class CheckstyleOperationTest {
@Test @Test
void exclude() { void exclude() {
var op = new CheckstyleOperation().fromProject(new Project()).exclude(FOO, BAR); var op = new CheckstyleOperation().fromProject(new Project()).exclude(FOO, BAR);
assertThat(op.executeConstructProcessCommandList()).contains("-e " + FOO, "-e " + BAR); var e = "-e ";
assertThat(op.executeConstructProcessCommandList()).contains(e + FOO, e + BAR);
op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(FOO, BAR)); op = new CheckstyleOperation().fromProject(new Project()).exclude(List.of(FOO, BAR));
assertThat(op.executeConstructProcessCommandList()).as("as list").contains("-e " + FOO, "-e " + BAR); assertThat(op.executeConstructProcessCommandList()).as("as list").contains(e + FOO, e + BAR);
} }
@Test @Test
void excludeRegex() { void excludeRegex() {
var op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(FOO, BAR); var op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(FOO, BAR);
assertThat(op.executeConstructProcessCommandList()).contains("-x " + FOO, "-x " + BAR); var x = "-x ";
assertThat(op.executeConstructProcessCommandList()).contains(x + FOO, x + BAR);
op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(List.of(FOO, BAR)); op = new CheckstyleOperation().fromProject(new Project()).excludeRegex(List.of(FOO, BAR));
assertThat(op.executeConstructProcessCommandList()).as("as list").contains("-x " + FOO, "-x " + BAR); assertThat(op.executeConstructProcessCommandList()).as("as list").contains(x + FOO, x + BAR);
} }