ArgumentParser { public String getRemainingStringValue(String exceptionMessage) throws SyntaxException { if (remainingArguments.size() > 1) { throw new SyntaxException(exceptionMessage); } if (remainingArguments.size() == 0) { return null; } return retrieveSingleStringValue(remainingArguments.get(0), exceptionMessage); } ArgumentParser(List<Argument> arguments); void initialize(List<Argument> arguments); String getStringValueForTag(String tag, String exceptionMessage); Integer getNumericValueForTag(String tag, String exceptionMessage); List<String> getStringListForTag(String tag, String exceptionMessage); Set<String> getSingleTags(); String getRemainingStringValue(String exceptionMessage); void throwOnUnvalidSeenSingleTag(String... validTags); void throwOnUnvalidSeenTagWithValue(String... validTags);  }
@Test(expected = SyntaxException.class) public void getRemainingStringValueShouldThrowOnWrongArgumentType() throws Exception { ArgumentParser argumentParser = new ArgumentParser(Lists.<Argument>newArrayList(NUMBER_ARGUMENT)); argumentParser.getRemainingStringValue(EXCEPTION_MESSAGE); }
@Test(expected = SyntaxException.class) public void getRemainingStringValueShouldThrowOnMultipleElementsInStringList() throws Exception { ArgumentParser argumentParser = new ArgumentParser(Lists.<Argument>newArrayList(STRING_LIST_ARGUMENT)); argumentParser.getRemainingStringValue(EXCEPTION_MESSAGE); }
@Test public void getRemainingStringValueShouldWork() throws Exception { ArgumentParser argumentParser = new ArgumentParser(Lists.<Argument>newArrayList(SINGLE_STRING_ARGUMENT)); assertThat(argumentParser.getRemainingStringValue(EXCEPTION_MESSAGE)).isEqualTo(STRING_VALUE); }
@Test public void getRemainingStringValueShouldReturnNullWhenCalledWithOnlyTagWithValue() throws Exception { ArgumentParser argumentParser = new ArgumentParser(Lists.newArrayList(ANY_TAG_ARGUMENT, STRING_LIST_ARGUMENT)); assertThat(argumentParser.getRemainingStringValue(EXCEPTION_MESSAGE)).isNull(); }
@Test public void getRemainingStringValueShouldReturnNullByDefault() throws Exception { ArgumentParser argumentParser = new ArgumentParser(Lists.<Argument>newArrayList()); assertThat(argumentParser.getRemainingStringValue(EXCEPTION_MESSAGE)).isNull(); }