From 878e07414367b4cc69843c3e9d91da02bc7c7043 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 6 Sep 2018 18:18:55 -0400 Subject: java: mv src/main/java/org/pablotron/luigi/{,errors/}*Errors.java and update code --- .../java/org/pablotron/luigi/tests/CacheTest.java | 5 +-- .../pablotron/luigi/tests/DefaultFiltersTest.java | 7 +--- .../java/org/pablotron/luigi/tests/ErrorsTest.java | 44 ++++++++++++++++++++++ .../org/pablotron/luigi/tests/FiltersTest.java | 6 +-- .../org/pablotron/luigi/tests/TemplateTest.java | 4 +- 5 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 java/src/test/java/org/pablotron/luigi/tests/ErrorsTest.java (limited to 'java/src/test') diff --git a/java/src/test/java/org/pablotron/luigi/tests/CacheTest.java b/java/src/test/java/org/pablotron/luigi/tests/CacheTest.java index c91b727..9aff8fc 100644 --- a/java/src/test/java/org/pablotron/luigi/tests/CacheTest.java +++ b/java/src/test/java/org/pablotron/luigi/tests/CacheTest.java @@ -4,10 +4,7 @@ import java.util.HashMap; import org.pablotron.luigi.Template; import org.pablotron.luigi.Filter; import org.pablotron.luigi.Cache; -import org.pablotron.luigi.LuigiError; -import org.pablotron.luigi.UnknownKeyError; -import org.pablotron.luigi.UnknownFilterError; -import org.pablotron.luigi.UnknownTemplateError; +import org.pablotron.luigi.errors.LuigiError; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/java/src/test/java/org/pablotron/luigi/tests/DefaultFiltersTest.java b/java/src/test/java/org/pablotron/luigi/tests/DefaultFiltersTest.java index c839ded..fe0bc51 100644 --- a/java/src/test/java/org/pablotron/luigi/tests/DefaultFiltersTest.java +++ b/java/src/test/java/org/pablotron/luigi/tests/DefaultFiltersTest.java @@ -3,15 +3,12 @@ import java.util.HashMap; import java.util.List; import java.util.ArrayList; -import org.pablotron.luigi.LuigiError; import org.pablotron.luigi.Template; import org.pablotron.luigi.Filter; -import org.pablotron.luigi.FilterError; -import org.pablotron.luigi.ResultHandler; +import org.pablotron.luigi.errors.LuigiError; +import org.pablotron.luigi.errors.FilterError; 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 DefaultFiltersTest { diff --git a/java/src/test/java/org/pablotron/luigi/tests/ErrorsTest.java b/java/src/test/java/org/pablotron/luigi/tests/ErrorsTest.java new file mode 100644 index 0000000..a88699d --- /dev/null +++ b/java/src/test/java/org/pablotron/luigi/tests/ErrorsTest.java @@ -0,0 +1,44 @@ +import java.util.Map; +import java.util.HashMap; + +import org.pablotron.luigi.Template; +import org.pablotron.luigi.Cache; +import org.pablotron.luigi.errors.LuigiError; +import org.pablotron.luigi.errors.UnknownKeyError; +import org.pablotron.luigi.errors.UnknownFilterError; +import org.pablotron.luigi.errors.UnknownTemplateError; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + +public final class ErrorsTest { + private static Map TEST_ARGS = new HashMap() {{ + put("bar", "foo"); + }}; + + private static Map TEST_TEMPLATES = new HashMap() {{ + put("foo", "foo%{bar}foo"); + }}; + + @Test + public void testUnknownKeyError() { + assertThrows(UnknownKeyError.class, () -> { + Template.run("foo%{unknown-key}", TEST_ARGS); + }); + } + + @Test + public void testUnknownFilterError() { + assertThrows(UnknownFilterError.class, () -> { + Template.run("foo%{bar | unknown-filter}", TEST_ARGS); + }); + } + + @Test + public void testUnknownTemplateError() { + final Cache cache = new Cache(TEST_TEMPLATES); + assertThrows(UnknownTemplateError.class, () -> { + cache.run("unknown-template", TEST_ARGS); + }); + } +}; diff --git a/java/src/test/java/org/pablotron/luigi/tests/FiltersTest.java b/java/src/test/java/org/pablotron/luigi/tests/FiltersTest.java index 9168529..4800318 100644 --- a/java/src/test/java/org/pablotron/luigi/tests/FiltersTest.java +++ b/java/src/test/java/org/pablotron/luigi/tests/FiltersTest.java @@ -1,15 +1,13 @@ import java.util.Map; import java.util.HashMap; -import org.pablotron.luigi.LuigiError; import org.pablotron.luigi.Template; import org.pablotron.luigi.Filter; -import org.pablotron.luigi.FilterError; +import org.pablotron.luigi.errors.LuigiError; +import org.pablotron.luigi.errors.FilterError; import org.pablotron.luigi.ResultHandler; 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; diff --git a/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java b/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java index eadaab1..f4960cc 100644 --- a/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java +++ b/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java @@ -1,16 +1,14 @@ import java.util.Map; import java.util.HashMap; -import org.pablotron.luigi.LuigiError; import org.pablotron.luigi.Template; +import org.pablotron.luigi.errors.LuigiError; import org.pablotron.luigi.ResultHandler; 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 TEST_ARGS = new HashMap() {{ put("bar", "foo"); -- cgit v1.2.3