This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch ISIS-1846_internal_utils
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 62c3f3b353054998359aa15488f984c50878ec57
Author: Andi Huber <ahu...@apache.org>
AuthorDate: Mon Jan 22 22:20:26 2018 +0100

    ISIS-1827 added tests for all ExceptionRecognizers to reflect applib
    additions
---
 ...t.java => ExceptionRecognizerForType2Test.java} | 29 ++++++++++++--------
 .../exceprecog/ExceptionRecognizerGeneralTest.java | 32 ++++++++++++++++++----
 2 files changed, 43 insertions(+), 18 deletions(-)

diff --git 
a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
 
b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2Test.java
similarity index 68%
copy from 
core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
copy to 
core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2Test.java
index 239e59c..c541001 100644
--- 
a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
+++ 
b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerForType2Test.java
@@ -23,20 +23,26 @@ import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertThat;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicates;
+import java.util.function.Function;
 
 import org.junit.Test;
 
-public class ExceptionRecognizerGeneralTest {
+public class ExceptionRecognizerForType2Test {
 
-    private ExceptionRecognizerAbstract ersGeneral;
+    private ExceptionRecognizerForType2 ersForType;
 
     static class FooException extends Exception {
         private static final long serialVersionUID = 1L;
         public FooException() {
             super("foo");
         }
+        
+    }
+    static class BarException extends Exception {
+        private static final long serialVersionUID = 1L;
+        public BarException() {
+            super("bar");
+        }
     }
     
     private Function<String,String> prepend = new Function<String, String>() {
@@ -45,24 +51,23 @@ public class ExceptionRecognizerGeneralTest {
             return "pre: " + input;
         }
     };
-    
-    
+
     @Test
     public void whenRecognized() {
-        ersGeneral = new 
ExceptionRecognizerAbstract(Predicates.<Throwable>alwaysTrue()){};
-        assertThat(ersGeneral.recognize(new FooException()), is("foo"));
+        ersForType = new ExceptionRecognizerForType2(FooException.class);
+        assertThat(ersForType.recognize(new FooException()), is("foo"));
     }
 
     @Test
     public void whenDoesNotRecognize() {
-        ersGeneral = new 
ExceptionRecognizerAbstract(Predicates.<Throwable>alwaysFalse()){};
-        assertThat(ersGeneral.recognize(new FooException()), is(nullValue()));
+        ersForType = new ExceptionRecognizerForType2(FooException.class);
+        assertThat(ersForType.recognize(new BarException()), is(nullValue()));
     }
 
     @Test
     public void whenRecognizedWithMessageParser() {
-        ersGeneral = new 
ExceptionRecognizerAbstract(Predicates.<Throwable>alwaysTrue(), prepend){};
-        assertThat(ersGeneral.recognize(new FooException()), is("pre: foo"));
+        ersForType = new ExceptionRecognizerForType2(FooException.class, 
prepend);
+        assertThat(ersForType.recognize(new FooException()), is("pre: foo"));
     }
 
 }
diff --git 
a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
 
b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
index 239e59c..a2a0118 100644
--- 
a/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
+++ 
b/core/applib/src/test/java/org/apache/isis/applib/services/exceprecog/ExceptionRecognizerGeneralTest.java
@@ -23,8 +23,7 @@ import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.nullValue;
 import static org.junit.Assert.assertThat;
 
-import com.google.common.base.Function;
-import com.google.common.base.Predicates;
+import java.util.function.Predicate;
 
 import org.junit.Test;
 
@@ -39,7 +38,7 @@ public class ExceptionRecognizerGeneralTest {
         }
     }
     
-    private Function<String,String> prepend = new Function<String, String>() {
+    private com.google.common.base.Function<String,String> prepend = new 
com.google.common.base.Function<String, String>() {
         @Override
         public String apply(String input) {
             return "pre: " + input;
@@ -48,20 +47,41 @@ public class ExceptionRecognizerGeneralTest {
     
     
     @Test
+    public void whenRecognized_guava() {
+        ersGeneral = new 
ExceptionRecognizerAbstract(com.google.common.base.Predicates.<Throwable>alwaysTrue()){};
+        assertThat(ersGeneral.recognize(new FooException()), is("foo"));
+    }
+
+    @Test
+    public void whenDoesNotRecognize_guava() {
+        ersGeneral = new 
ExceptionRecognizerAbstract(com.google.common.base.Predicates.<Throwable>alwaysFalse()){};
+        assertThat(ersGeneral.recognize(new FooException()), is(nullValue()));
+    }
+
+    @Test
+    public void whenRecognizedWithMessageParser_guava() {
+        ersGeneral = new 
ExceptionRecognizerAbstract(com.google.common.base.Predicates.<Throwable>alwaysTrue(),
 prepend){};
+        assertThat(ersGeneral.recognize(new FooException()), is("pre: foo"));
+    }
+    
+    private final static Predicate<Throwable> ALWAYS_TRUE = __->true;
+    private final static Predicate<Throwable> ALWAYS_FALSE = __->false;
+    
+    @Test
     public void whenRecognized() {
-        ersGeneral = new 
ExceptionRecognizerAbstract(Predicates.<Throwable>alwaysTrue()){};
+        ersGeneral = new ExceptionRecognizerAbstract(ALWAYS_TRUE){};
         assertThat(ersGeneral.recognize(new FooException()), is("foo"));
     }
 
     @Test
     public void whenDoesNotRecognize() {
-        ersGeneral = new 
ExceptionRecognizerAbstract(Predicates.<Throwable>alwaysFalse()){};
+        ersGeneral = new ExceptionRecognizerAbstract(ALWAYS_FALSE){};
         assertThat(ersGeneral.recognize(new FooException()), is(nullValue()));
     }
 
     @Test
     public void whenRecognizedWithMessageParser() {
-        ersGeneral = new 
ExceptionRecognizerAbstract(Predicates.<Throwable>alwaysTrue(), prepend){};
+        ersGeneral = new ExceptionRecognizerAbstract(ALWAYS_TRUE, s->"pre: " + 
s){};
         assertThat(ersGeneral.recognize(new FooException()), is("pre: foo"));
     }
 

-- 
To stop receiving notification emails like this one, please contact
ahu...@apache.org.

Reply via email to