23-FixVerboseOrRedundantCodeConstructs#2

This commit is contained in:
Adrian-Devries 2025-04-24 12:54:07 +02:00
parent 55a31b2892
commit 65184aeb81

View file

@ -93,7 +93,8 @@ public class CommandlineApplicationTest {
@Test @Test
public void testNotExistingScenarioFile() { public void testNotExistingScenarioFile() {
final String[] args = new String[] { "-s", Paths.get(Simple.NOT_EXISTING).toString(), Paths.get(Simple.NOT_EXISTING).toString() }; final String s = Paths.get(Simple.NOT_EXISTING).toString();
final String[] args = new String[] { "-s", s, s };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).isNotEmpty(); assertThat(CommandLine.getErrorOutput()).isNotEmpty();
assertThat(CommandLine.getErrorOutput()).contains("Not a valid path for scenario definition specified"); assertThat(CommandLine.getErrorOutput()).contains("Not a valid path for scenario definition specified");
@ -153,7 +154,6 @@ public class CommandlineApplicationTest {
@Test @Test
public void testValidOutputConfiguration() throws IOException { public void testValidOutputConfiguration() throws IOException {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r", final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-o", this.output.toString(), "-r",
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
@ -173,7 +173,6 @@ public class CommandlineApplicationTest {
@Test @Test
public void testPrint() { public void testPrint() {
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-p", "-r", final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-p", "-r",
Paths.get(Simple.REPOSITORY_URI).toString(), "-o", this.output.toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; Paths.get(Simple.REPOSITORY_URI).toString(), "-o", this.output.toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
@ -196,9 +195,9 @@ public class CommandlineApplicationTest {
@Test @Test
public void testAssertionsExtraktion() { public void testAssertionsExtraktion() {
final String[] args = new String[] { "-d", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", final String s = Paths.get(Simple.REPOSITORY_URI).toString();
Paths.get(Simple.REPOSITORY_URI).toString(), "-o", this.output.toString(), "-c", Paths.get(ASSERTIONS).toString(), final String[] args = new String[] { "-d", "-s", Paths.get(Simple.SCENARIOS).toString(), "-r", s, "-o", this.output.toString(),
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() }; "-c", Paths.get(ASSERTIONS).toString(), s, Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT); assertThat(CommandLine.getErrorOutput()).contains(RESULT_OUTPUT);
assertThat(CommandLine.getErrorOutput()).contains("Can not find assertions for "); assertThat(CommandLine.getErrorOutput()).contains("Can not find assertions for ");
@ -248,9 +247,9 @@ public class CommandlineApplicationTest {
@Test @Test
public void loadMultipleScenarios() { public void loadMultipleScenarios() {
final Path p = Paths.get(Simple.REPOSITORY_URI);
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS), "-s", "s2=" + Paths.get(Simple.OTHER_SCENARIOS), final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS), "-s", "s2=" + Paths.get(Simple.OTHER_SCENARIOS),
"-r", "s1=" + Paths.get(Simple.REPOSITORY_URI), "-r", "s2=" + Paths.get(Simple.REPOSITORY_URI), "-r", "s1=" + p, "-r", "s2=" + p, Paths.get(Simple.SIMPLE_VALID).toString() };
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed"); assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed");
} }
@ -265,26 +264,27 @@ public class CommandlineApplicationTest {
@Test @Test
public void loadMultipleScenariosMissingRepository() { public void loadMultipleScenariosMissingRepository() {
final Path p = Paths.get(Simple.REPOSITORY_URI);
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS), "-s", "s2=" + Paths.get(Simple.OTHER_SCENARIOS), final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS), "-s", "s2=" + Paths.get(Simple.OTHER_SCENARIOS),
"-r", "s1=" + Paths.get(Simple.REPOSITORY_URI), "-r", "typo=" + Paths.get(Simple.REPOSITORY_URI), "-r", "s1=" + p, "-r", "typo=" + p, Paths.get(Simple.SIMPLE_VALID).toString() };
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getErrorOutput()).contains("No repository location for scenario definition 's2' specified"); assertThat(CommandLine.getErrorOutput()).contains("No repository location for scenario definition 's2' specified");
} }
@Test @Test
public void loadMultipleOrderedScenarios() { public void loadMultipleOrderedScenarios() {
final String s = Paths.get(Simple.REPOSITORY_URI).toString();
final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-s", final String[] args = new String[] { "-s", Paths.get(Simple.SCENARIOS).toString(), "-s",
Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", Paths.get(Simple.REPOSITORY_URI).toString(), "-r", Paths.get(Simple.OTHER_SCENARIOS).toString(), "-r", s, "-r", s, Paths.get(Simple.SIMPLE_VALID).toString() };
Paths.get(Simple.REPOSITORY_URI).toString(), Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed"); assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed");
} }
@Test @Test
public void checkUnusedRepository() { public void checkUnusedRepository() {
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS), "-r", "s1=" + Paths.get(Simple.REPOSITORY_URI), final Path p = Paths.get(Simple.REPOSITORY_URI);
"-r", "unused=" + Paths.get(Simple.REPOSITORY_URI), Paths.get(Simple.SIMPLE_VALID).toString() }; final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS), "-r", "s1=" + p, "-r", "unused=" + p,
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed"); assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed");
assertThat(CommandLine.getErrorOutput()).contains("Warning: repository definition \"unused\" is not used"); assertThat(CommandLine.getErrorOutput()).contains("Warning: repository definition \"unused\" is not used");
@ -292,8 +292,9 @@ public class CommandlineApplicationTest {
@Test @Test
public void checkDuplicationScenarioDefinition() { public void checkDuplicationScenarioDefinition() {
final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS), "-r", "s1=" + Paths.get(Simple.REPOSITORY_URI), final Path p = Paths.get(Simple.REPOSITORY_URI);
"-r", "unused=" + Paths.get(Simple.REPOSITORY_URI), Paths.get(Simple.SIMPLE_VALID).toString() }; final String[] args = new String[] { "-s", "s1=" + Paths.get(Simple.SCENARIOS), "-r", "s1=" + p, "-r", "unused=" + p,
Paths.get(Simple.SIMPLE_VALID).toString() };
CommandLineApplication.mainProgram(args); CommandLineApplication.mainProgram(args);
assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed"); assertThat(CommandLine.getOutput()).contains("Processing of 1 objects completed");
assertThat(CommandLine.getErrorOutput()).contains("Warning: repository definition \"unused\" is not used"); assertThat(CommandLine.getErrorOutput()).contains("Warning: repository definition \"unused\" is not used");