@Test(expected = TooManyArgumentsException.class) public void tooManyArguments() { ParameterResolver.resolve("''", "a", "b"); }
@Test(expected = TooManyPlaceHoldersException.class) public void tooManyPlaceHolders() { ParameterResolver.resolve("'' ''", "b"); }
@Test(expected = NullPointerException.class) public void checkThatNullParametersExcept() { ParameterResolver.resolve("''", (Object[]) null); }
@Test(expected = NullPointerException.class) public void checkThatANullParameterExcepts() { ParameterResolver.resolve("''", new Object[] {null}); }
@Test public void twoPlaceHolderTwoArgument() { assertThat(ParameterResolver.resolve("''''", "a", "b")).isEqualTo("'a''b'"); assertThat(ParameterResolver.resolve("z''z''z", "a", "b")).isEqualTo("z'a'z'b'z"); }
@Test public void checkThatPartialPlaceHoldersDontCauseIssues() { assertThat(ParameterResolver.resolve("z' '' 'z''z", "a", "b")).isEqualTo("z' 'a' 'z'b'z"); assertThat(ParameterResolver.resolve("'")).isEqualTo("'"); assertThat(ParameterResolver.resolve("z' \\'\\' 'z''z", "a")).isEqualTo("z' \\'\\' 'z'a'z"); }
@Test public void onePlaceHolderOneArgument() { assertThat(ParameterResolver.resolve("''", "a")).isEqualTo("'a'"); }
@Test(expected = ThrowablesCannotBeParametersException.class) public void throwableArgumentsExceptAsItsACommonMistake() { ParameterResolver.resolve("placeholder and throwable argument ''", new RuntimeException()); }
@Test(expected = TooManyArgumentsException.class) public void noPlaceHolderForArgumentExcepts() { ParameterResolver.resolve("a message with no placeholders", "a"); }
@Test(expected = IllegalArgumentException.class) public void emptyMessageExcepts() { ParameterResolver.resolve(""); }
@Test(expected = NullPointerException.class) public void nullMessageExcepts() { ParameterResolver.resolve(null); }