diff options
author | Paul Duncan <pabs@pablotron.org> | 2018-09-06 08:40:23 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2018-09-06 08:40:23 -0400 |
commit | f422534cd4cf1ba32523c9fc798c207065038ca5 (patch) | |
tree | d3dce87dffeca2acfceab6aa9abf7046843f9145 /java/src/test | |
parent | c02640d395fe95a41183a63bea29113676e92fae (diff) | |
download | luigi-template-f422534cd4cf1ba32523c9fc798c207065038ca5.tar.bz2 luigi-template-f422534cd4cf1ba32523c9fc798c207065038ca5.zip |
java: add pom.xml, mv sources to src/main/java/org/pablotron, add src/test, add initial junit tests, update makefile and .gitignore
Diffstat (limited to 'java/src/test')
-rw-r--r-- | java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java b/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java new file mode 100644 index 0000000..5ff9ede --- /dev/null +++ b/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java @@ -0,0 +1,69 @@ +import java.util.Map; +import java.util.HashMap; + +import org.pablotron.luigi.LuigiError; +import org.pablotron.luigi.Template; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + + +public final class TemplateTest { + private static final Map<String, String> TEST_ARGS = new HashMap<String, String>() {{ + put("bar", "foo"); + }}; + + private static final Map<String, String> TEST_MULTIPLE_ARGS = new HashMap<String, String>() {{ + put("bar", "foo"); + put("baz", "bar"); + }}; + + @Test + public void testNew() throws LuigiError { + final Template t = new Template(""); + + assertNotNull(t); + } + + @Test + public void testRun() throws LuigiError { + final Template t = new Template("foo%{bar}"); + final String r = t.run(TEST_ARGS); + + assertEquals("foofoo", r); + } + + @Test + public void testMultipleKeys() throws LuigiError { + final Template t = new Template("foo%{bar}%{baz}"); + final String r = t.run(TEST_MULTIPLE_ARGS); + + assertEquals("foofoobar", r); + } + + @Test + public void testWhitespace() throws LuigiError { + final Template t = new Template("%{ bar}%{ bar }%{bar }"); + final String r = t.run(TEST_ARGS); + + assertEquals("foofoofoo", r); + } + + @Test + public void testNewlines() throws LuigiError { + final Template t = new Template("%{\nbar}%{\n bar\n }%{bar\n}"); + final String r = t.run(TEST_ARGS); + + assertEquals("foofoofoo", r); + } + + @Test + public void testToString() throws LuigiError { + final Template t = new Template("foo%{bar}"); + final String r = t.toString(); + + assertEquals("foo%{bar}", r); + } +}; |