commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r666222 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/adapter/FunctionPredicate.java test/java/org/apache/commons/functor/adapter/TestFunctionPredicate.java
Date Tue, 10 Jun 2008 17:23:26 GMT
Author: mbenson
Date: Tue Jun 10 10:23:26 2008
New Revision: 666222

URL: http://svn.apache.org/viewvc?rev=666222&view=rev
Log:
unchecked warnings; IllegalArgumentExceptions on null constructor args

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestFunctionPredicate.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java?rev=666222&r1=666221&r2=666222&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/adapter/FunctionPredicate.java
Tue Jun 10 10:23:26 2008
@@ -46,6 +46,9 @@
      * @param function to adapt
      */
     public FunctionPredicate(Function<Boolean> function) {
+        if (function == null) {
+            throw new IllegalArgumentException("Function argument was null");
+        }
         this.function = function;
     }
 

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestFunctionPredicate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestFunctionPredicate.java?rev=666222&r1=666221&r2=666222&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestFunctionPredicate.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/adapter/TestFunctionPredicate.java
Tue Jun 10 10:23:26 2008
@@ -44,7 +44,7 @@
     // ------------------------------------------------------------------------
 
     protected Object makeFunctor() {
-        return new FunctionPredicate(new Constant(Boolean.TRUE));
+        return new FunctionPredicate(Constant.TRUE);
     }
 
     // Lifecycle
@@ -62,43 +62,21 @@
     // ------------------------------------------------------------------------
 
     public void testTestWhenTrue() throws Exception {
-        Predicate p = new FunctionPredicate(new Constant(Boolean.TRUE));
+        Predicate p = new FunctionPredicate(Constant.TRUE);
         assertTrue(p.test());
     }
 
     public void testTestWhenFalse() throws Exception {
-        Predicate p = new FunctionPredicate(new Constant(Boolean.FALSE));
+        Predicate p = new FunctionPredicate(Constant.FALSE);
         assertTrue(!p.test());
     }
 
-    public void testTestWhenNull() throws Exception {
-        Predicate p = new FunctionPredicate(new Constant(null));
-        try {
-            p.test();
-            fail("Expected NullPointerException");
-        } catch(NullPointerException e) {
-            // expected
-        }
-    }
-
-    public void testTestWhenNonBoolean() throws Exception {
-        Predicate p = new FunctionPredicate(new Constant(new Integer(2)));
-        try {
-            p.test();
-            fail("Expected ClassCastException");
-        } catch(ClassCastException e) {
-            // expected
-        }
-    }
-
     public void testEquals() throws Exception {
-        Predicate p = new FunctionPredicate(new Constant(Boolean.TRUE));
+        Predicate p = new FunctionPredicate(Constant.TRUE);
         assertEquals(p,p);
-        assertObjectsAreEqual(p,new FunctionPredicate(new Constant(Boolean.TRUE)));
-        assertObjectsAreNotEqual(p,Constant.truePredicate());
-        assertObjectsAreNotEqual(p,new FunctionPredicate(null));
-        assertObjectsAreNotEqual(p,new FunctionPredicate(new Constant(Boolean.FALSE)));
-        assertObjectsAreEqual(new FunctionPredicate(null),new FunctionPredicate(null));
+        assertObjectsAreEqual(p,new FunctionPredicate(Constant.TRUE));
+        assertObjectsAreNotEqual(p,Constant.TRUE);
+        assertObjectsAreNotEqual(p,new FunctionPredicate(Constant.FALSE));
     }
 
     public void testAdaptNull() throws Exception {
@@ -106,6 +84,6 @@
     }
 
     public void testAdapt() throws Exception {
-        assertNotNull(FunctionPredicate.adapt(new Constant(Boolean.TRUE)));
+        assertNotNull(FunctionPredicate.adapt(Constant.TRUE));
     }
 }



Mime
View raw message