diff --git a/src/main/java/strman/Strman.java b/src/main/java/strman/Strman.java index 0adffe3..b110f82 100644 --- a/src/main/java/strman/Strman.java +++ b/src/main/java/strman/Strman.java @@ -16,6 +16,10 @@ public interface Strman { * @return full string */ static String append(final String value, final String... appends) throws IllegalArgumentException { + return appendArray(value, appends); + } + + static String appendArray(String value, String[] appends) { if (value == null) { throw new IllegalArgumentException("'value' should be not null."); } diff --git a/src/test/java/strman/StrmanTest.java b/src/test/java/strman/StrmanTest.java index 8e01434..60e52e2 100644 --- a/src/test/java/strman/StrmanTest.java +++ b/src/test/java/strman/StrmanTest.java @@ -5,6 +5,7 @@ import org.junit.Test; import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertThat; import static strman.Strman.append; +import static strman.Strman.appendArray; public class StrmanTest { @@ -19,4 +20,19 @@ public class StrmanTest { public void appendShouldThrowIllegalArgumentExceptionWhenValueIsNull() throws Exception { append(null); } + + @Test + public void shouldAppendStringArrayToEndOfValue() throws Exception { + assertThat(appendArray("f", new String[]{"o", "o", "b", "a", "r"}), equalTo("foobar")); + assertThat(appendArray("foobar", new String[]{}), equalTo("foobar")); + assertThat(appendArray("", new String[]{"foobar"}), equalTo("foobar")); + } + + + @Test(expected = IllegalArgumentException.class) + public void appendArrayShouldThrowIllegalArgumentExceptionWhenValueIsNull() throws Exception { + appendArray(null, new String[]{}); + } + + } \ No newline at end of file