aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-03-02 18:35:52 +0000
committerMichael Williamson <mike@zwobble.org>2016-03-02 20:37:08 +0000
commit0518e1624cae35738e71c98ef6150105524871f3 (patch)
tree9ff34d5992701ca7fdf1b41bf7640d54bd706b7b /src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java
parentf28195e5e952dfda9b584f223dd5ca373fb15fe3 (diff)
Throw more informative exception when relationship is missing
Diffstat (limited to 'src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java')
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java b/src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java
new file mode 100644
index 0000000..2439ee2
--- /dev/null
+++ b/src/test/java/org/zwobble/mammoth/tests/util/MammothAsserts.java
@@ -0,0 +1,15 @@
+package org.zwobble.mammoth.tests.util;
+
+import org.zwobble.mammoth.internal.util.Casts;
+
+public class MammothAsserts {
+ public static <T extends Throwable> T assertThrows(Class<T> exceptionType, Action action) throws T {
+ try {
+ action.run();
+ throw new AssertionError("Expected exception");
+ } catch (RuntimeException exception) {
+ return Casts.tryCast(exceptionType, exception)
+ .orElseThrow(() -> exception);
+ }
+ }
+}