aboutsummaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-09-06 18:18:55 -0400
committerPaul Duncan <pabs@pablotron.org>2018-09-06 18:18:55 -0400
commit878e07414367b4cc69843c3e9d91da02bc7c7043 (patch)
treece9ec236aaa5762139d2e94ddc42f7ec01fb4005 /java
parentc4f3f955179cd217c6e7273561d06468b33e8973 (diff)
downloadluigi-template-878e07414367b4cc69843c3e9d91da02bc7c7043.tar.bz2
luigi-template-878e07414367b4cc69843c3e9d91da02bc7c7043.zip
java: mv src/main/java/org/pablotron/luigi/{,errors/}*Errors.java and update code
Diffstat (limited to 'java')
-rw-r--r--java/src/main/java/org/pablotron/luigi/Cache.java3
-rw-r--r--java/src/main/java/org/pablotron/luigi/Filter.java2
-rw-r--r--java/src/main/java/org/pablotron/luigi/Parser.java2
-rw-r--r--java/src/main/java/org/pablotron/luigi/Template.java2
-rw-r--r--java/src/main/java/org/pablotron/luigi/Test.java2
-rw-r--r--java/src/main/java/org/pablotron/luigi/actions/Action.java2
-rw-r--r--java/src/main/java/org/pablotron/luigi/actions/FilterAction.java6
-rw-r--r--java/src/main/java/org/pablotron/luigi/actions/TextAction.java6
-rw-r--r--java/src/main/java/org/pablotron/luigi/errors/FilterError.java (renamed from java/src/main/java/org/pablotron/luigi/FilterError.java)2
-rw-r--r--java/src/main/java/org/pablotron/luigi/errors/LuigiError.java (renamed from java/src/main/java/org/pablotron/luigi/LuigiError.java)2
-rw-r--r--java/src/main/java/org/pablotron/luigi/errors/UnknownEntryError.java (renamed from java/src/main/java/org/pablotron/luigi/UnknownEntryError.java)2
-rw-r--r--java/src/main/java/org/pablotron/luigi/errors/UnknownFilterError.java (renamed from java/src/main/java/org/pablotron/luigi/UnknownFilterError.java)2
-rw-r--r--java/src/main/java/org/pablotron/luigi/errors/UnknownKeyError.java (renamed from java/src/main/java/org/pablotron/luigi/UnknownKeyError.java)2
-rw-r--r--java/src/main/java/org/pablotron/luigi/errors/UnknownTemplateError.java (renamed from java/src/main/java/org/pablotron/luigi/UnknownTemplateError.java)2
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/CacheTest.java5
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/DefaultFiltersTest.java7
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/ErrorsTest.java44
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/FiltersTest.java6
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java4
19 files changed, 70 insertions, 33 deletions
diff --git a/java/src/main/java/org/pablotron/luigi/Cache.java b/java/src/main/java/org/pablotron/luigi/Cache.java
index 4a591bc..7be8f6c 100644
--- a/java/src/main/java/org/pablotron/luigi/Cache.java
+++ b/java/src/main/java/org/pablotron/luigi/Cache.java
@@ -4,7 +4,8 @@ import java.util.Map;
import java.util.HashMap;
import org.pablotron.luigi.Filter;
import org.pablotron.luigi.Template;
-import org.pablotron.luigi.LuigiError;
+import org.pablotron.luigi.errors.LuigiError;
+import org.pablotron.luigi.errors.UnknownTemplateError;
import org.pablotron.luigi.actions.Action;
public final class Cache {
diff --git a/java/src/main/java/org/pablotron/luigi/Filter.java b/java/src/main/java/org/pablotron/luigi/Filter.java
index d2cd432..676c328 100644
--- a/java/src/main/java/org/pablotron/luigi/Filter.java
+++ b/java/src/main/java/org/pablotron/luigi/Filter.java
@@ -4,6 +4,8 @@ import java.util.Map;
import java.util.HashMap;
import java.nio.charset.Charset;
+import org.pablotron.luigi.errors.FilterError;
+
public final class Filter {
public interface Handler {
public String filter(
diff --git a/java/src/main/java/org/pablotron/luigi/Parser.java b/java/src/main/java/org/pablotron/luigi/Parser.java
index 5be4a9c..01e44f8 100644
--- a/java/src/main/java/org/pablotron/luigi/Parser.java
+++ b/java/src/main/java/org/pablotron/luigi/Parser.java
@@ -8,7 +8,7 @@ import org.pablotron.luigi.actions.Action;
import org.pablotron.luigi.actions.FilterAction;
import org.pablotron.luigi.actions.TextAction;
import org.pablotron.luigi.FilterReference;
-import org.pablotron.luigi.LuigiError;
+import org.pablotron.luigi.errors.LuigiError;
public final class Parser {
private static final Pattern RE_ACTION = Pattern.compile(
diff --git a/java/src/main/java/org/pablotron/luigi/Template.java b/java/src/main/java/org/pablotron/luigi/Template.java
index e5f25a9..91c6f9f 100644
--- a/java/src/main/java/org/pablotron/luigi/Template.java
+++ b/java/src/main/java/org/pablotron/luigi/Template.java
@@ -3,7 +3,7 @@ package org.pablotron.luigi;
import java.util.Map;
import org.pablotron.luigi.Parser;
import org.pablotron.luigi.Filter;
-import org.pablotron.luigi.LuigiError;
+import org.pablotron.luigi.errors.LuigiError;
import org.pablotron.luigi.actions.Action;
public final class Template {
diff --git a/java/src/main/java/org/pablotron/luigi/Test.java b/java/src/main/java/org/pablotron/luigi/Test.java
index 2a560e2..3d25c13 100644
--- a/java/src/main/java/org/pablotron/luigi/Test.java
+++ b/java/src/main/java/org/pablotron/luigi/Test.java
@@ -3,7 +3,7 @@ package org.pablotron.luigi;
import java.util.Map;
import java.util.HashMap;
-import org.pablotron.luigi.LuigiError;
+import org.pablotron.luigi.errors.LuigiError;
import org.pablotron.luigi.Filter;
import org.pablotron.luigi.Template;
import org.pablotron.luigi.Cache;
diff --git a/java/src/main/java/org/pablotron/luigi/actions/Action.java b/java/src/main/java/org/pablotron/luigi/actions/Action.java
index 9708199..a473f62 100644
--- a/java/src/main/java/org/pablotron/luigi/actions/Action.java
+++ b/java/src/main/java/org/pablotron/luigi/actions/Action.java
@@ -2,7 +2,7 @@ package org.pablotron.luigi.actions;
import java.util.Map;
import org.pablotron.luigi.Filter;
-import org.pablotron.luigi.LuigiError;
+import org.pablotron.luigi.errors.LuigiError;
public interface Action {
public String run(
diff --git a/java/src/main/java/org/pablotron/luigi/actions/FilterAction.java b/java/src/main/java/org/pablotron/luigi/actions/FilterAction.java
index 19565dc..091a285 100644
--- a/java/src/main/java/org/pablotron/luigi/actions/FilterAction.java
+++ b/java/src/main/java/org/pablotron/luigi/actions/FilterAction.java
@@ -4,9 +4,9 @@ import java.util.Map;
import org.pablotron.luigi.actions.Action;
import org.pablotron.luigi.FilterReference;
import org.pablotron.luigi.Filter;
-import org.pablotron.luigi.LuigiError;
-import org.pablotron.luigi.UnknownFilterError;
-import org.pablotron.luigi.UnknownKeyError;
+import org.pablotron.luigi.errors.LuigiError;
+import org.pablotron.luigi.errors.UnknownFilterError;
+import org.pablotron.luigi.errors.UnknownKeyError;
public final class FilterAction implements Action {
private final String key;
diff --git a/java/src/main/java/org/pablotron/luigi/actions/TextAction.java b/java/src/main/java/org/pablotron/luigi/actions/TextAction.java
index 0ad4382..32487be 100644
--- a/java/src/main/java/org/pablotron/luigi/actions/TextAction.java
+++ b/java/src/main/java/org/pablotron/luigi/actions/TextAction.java
@@ -3,7 +3,7 @@ package org.pablotron.luigi.actions;
import java.util.Map;
import org.pablotron.luigi.actions.Action;
import org.pablotron.luigi.Filter;
-import org.pablotron.luigi.LuigiError;
+import org.pablotron.luigi.errors.LuigiError;
public final class TextAction implements Action {
private final String text;
@@ -13,8 +13,8 @@ public final class TextAction implements Action {
}
public String run(
- Map<String, Filter.Handler> filters,
- Map<String, String> args
+ final Map<String, Filter.Handler> filters,
+ final Map<String, String> args
) throws LuigiError {
return this.text;
}
diff --git a/java/src/main/java/org/pablotron/luigi/FilterError.java b/java/src/main/java/org/pablotron/luigi/errors/FilterError.java
index cb631a7..f2ff7fb 100644
--- a/java/src/main/java/org/pablotron/luigi/FilterError.java
+++ b/java/src/main/java/org/pablotron/luigi/errors/FilterError.java
@@ -1,4 +1,4 @@
-package org.pablotron.luigi;
+package org.pablotron.luigi.errors;
public class FilterError extends LuigiError {
public FilterError(final String message) {
diff --git a/java/src/main/java/org/pablotron/luigi/LuigiError.java b/java/src/main/java/org/pablotron/luigi/errors/LuigiError.java
index edeb7c7..abf9280 100644
--- a/java/src/main/java/org/pablotron/luigi/LuigiError.java
+++ b/java/src/main/java/org/pablotron/luigi/errors/LuigiError.java
@@ -1,4 +1,4 @@
-package org.pablotron.luigi;
+package org.pablotron.luigi.errors;
public class LuigiError extends Exception {
public LuigiError(final String message) {
diff --git a/java/src/main/java/org/pablotron/luigi/UnknownEntryError.java b/java/src/main/java/org/pablotron/luigi/errors/UnknownEntryError.java
index 8b8a0fd..7710838 100644
--- a/java/src/main/java/org/pablotron/luigi/UnknownEntryError.java
+++ b/java/src/main/java/org/pablotron/luigi/errors/UnknownEntryError.java
@@ -1,4 +1,4 @@
-package org.pablotron.luigi;
+package org.pablotron.luigi.errors;
public class UnknownEntryError extends LuigiError {
public final String type;
diff --git a/java/src/main/java/org/pablotron/luigi/UnknownFilterError.java b/java/src/main/java/org/pablotron/luigi/errors/UnknownFilterError.java
index a56a6c1..7396da6 100644
--- a/java/src/main/java/org/pablotron/luigi/UnknownFilterError.java
+++ b/java/src/main/java/org/pablotron/luigi/errors/UnknownFilterError.java
@@ -1,4 +1,4 @@
-package org.pablotron.luigi;
+package org.pablotron.luigi.errors;
public class UnknownFilterError extends UnknownEntryError {
public UnknownFilterError(final String name) {
diff --git a/java/src/main/java/org/pablotron/luigi/UnknownKeyError.java b/java/src/main/java/org/pablotron/luigi/errors/UnknownKeyError.java
index 88da21a..7b0ae4c 100644
--- a/java/src/main/java/org/pablotron/luigi/UnknownKeyError.java
+++ b/java/src/main/java/org/pablotron/luigi/errors/UnknownKeyError.java
@@ -1,4 +1,4 @@
-package org.pablotron.luigi;
+package org.pablotron.luigi.errors;
public class UnknownKeyError extends UnknownEntryError {
public UnknownKeyError(final String name) {
diff --git a/java/src/main/java/org/pablotron/luigi/UnknownTemplateError.java b/java/src/main/java/org/pablotron/luigi/errors/UnknownTemplateError.java
index 15dae97..e6b4682 100644
--- a/java/src/main/java/org/pablotron/luigi/UnknownTemplateError.java
+++ b/java/src/main/java/org/pablotron/luigi/errors/UnknownTemplateError.java
@@ -1,4 +1,4 @@
-package org.pablotron.luigi;
+package org.pablotron.luigi.errors;
public class UnknownTemplateError extends UnknownEntryError {
public UnknownTemplateError(final String name) {
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<String, String> TEST_ARGS = new HashMap<String, String>() {{
+ put("bar", "foo");
+ }};
+
+ private static Map<String, String> TEST_TEMPLATES = new HashMap<String, String>() {{
+ 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<String, String> TEST_ARGS = new HashMap<String, String>() {{
put("bar", "foo");