Skip to content

Commit

Permalink
#37: Remove duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Dec 4, 2015
1 parent 37ba9a2 commit 40ceb13
Showing 1 changed file with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,7 @@ public void parseValidClassnameFilters() {

@Test
public void parseInvalidClassnameFilter() throws Exception {
// @formatter:off
assertAll(
() -> assertThrows(Exception.class, () -> parseArgLine("-n")),
() -> assertThrows(Exception.class, () -> parseArgLine("--filter-classname"))
);
// @formatter:on
assertOptionWithRequiredArgumentThrowsExceptionWithoutArgument("-n", "--filter-classname");
}

@Test
Expand All @@ -94,12 +89,7 @@ public void parseValidTagFilters() {

@Test
public void parseInvalidTagFilter() {
// @formatter:off
assertAll(
() -> assertThrows(Exception.class, () -> parseArgLine("-t")),
() -> assertThrows(Exception.class, () -> parseArgLine("--filter-tags"))
);
// @formatter:on
assertOptionWithRequiredArgumentThrowsExceptionWithoutArgument("-t", "--filter-tags");
}

@Test
Expand All @@ -117,12 +107,7 @@ public void parseValidAdditionalClasspathEntries() {

@Test
public void parseInvalidAdditionalClasspathEntries() {
// @formatter:off
assertAll(
() -> assertThrows(Exception.class, () -> parseArgLine("-p")),
() -> assertThrows(Exception.class, () -> parseArgLine("--classpath"))
);
// @formatter:on
assertOptionWithRequiredArgumentThrowsExceptionWithoutArgument("-p", "--classpath");
}

@Test
Expand All @@ -136,6 +121,15 @@ public void parseExtraArguments() {
// @formatter:on
}

private void assertOptionWithRequiredArgumentThrowsExceptionWithoutArgument(String shortOption, String longOption) {
// @formatter:off
assertAll(
() -> assertThrows(Exception.class, () -> parseArgLine(shortOption)),
() -> assertThrows(Exception.class, () -> parseArgLine(longOption))
);
// @formatter:on
}

private void assertParses(String name, Predicate<CommandLineOptions> property, String... argLines) {
stream(argLines).forEach(argLine -> {
CommandLineOptions options = parseArgLine(argLine);
Expand Down

0 comments on commit 40ceb13

Please sign in to comment.