commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ki...@apache.org
Subject svn commit: r1365329 [2/2] - in /commons/proper/functor/trunk/src: main/java/org/apache/commons/functor/core/composite/ test/java/org/apache/commons/functor/core/composite/
Date Tue, 24 Jul 2012 22:34:25 GMT
Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryFunction.java?rev=1365329&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryFunction.java
(added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryFunction.java
Tue Jul 24 22:34:23 2012
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.composite;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.BinaryFunction;
+import org.apache.commons.functor.UnaryFunction;
+import org.junit.Test;
+
+
+/**
+ * Tests for TransformedBinaryFunction.
+ * @version $Revision: $ $Date: $
+ */
+public class TestTransformedBinaryFunction extends BaseFunctorTest {
+
+    private static class Sum implements BinaryFunction<Integer, Integer, Integer>,
Serializable {
+        private static final long serialVersionUID = 2255396324585938931L;
+        public Integer evaluate(Integer left, Integer right) {
+            return left+right;
+        }
+        @Override
+        public boolean equals(Object obj) {
+            return obj == this || obj != null && obj instanceof Sum;
+        }
+        @Override
+        public int hashCode() {
+            return "Sum".hashCode();
+        }
+    }
+
+    private static class AddOne implements UnaryFunction<Integer, Integer>, Serializable
{
+        private static final long serialVersionUID = 8759620198239402369L;
+        public Integer evaluate(Integer obj) {
+            return obj + 1;
+        }
+        @Override
+        public boolean equals(Object obj) {
+            return obj == this || obj != null && obj instanceof AddOne;
+        }
+        @Override
+        public int hashCode() {
+            return "AddOne".hashCode();
+        }
+    }
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new TransformedBinaryFunction<Integer, Integer, Integer>(new Sum(),
new AddOne());
+    }
+
+    @Test
+    public void testRun() {
+        TransformedBinaryFunction<Integer, Integer, Integer> transform = new TransformedBinaryFunction<Integer,
Integer, Integer>(new Sum(), new AddOne());
+        assertEquals(Integer.valueOf(4), transform.evaluate(1, 2));
+    }
+
+    @Test
+    public void testEquals() {
+        TransformedBinaryFunction<Integer, Integer, Integer> t = new TransformedBinaryFunction<Integer,
Integer, Integer>(new Sum(), new AddOne());
+        BinaryFunction<Integer, Integer, Integer> f = new BinaryFunction<Integer,
Integer, Integer>() {
+            public Integer evaluate(Integer left, Integer right) {
+                return left-right;
+            }
+        };
+        UnaryFunction<Integer, Integer> p = new UnaryFunction<Integer, Integer>()
{
+            public Integer evaluate(Integer obj) {
+                return obj-1;
+            }
+        };
+        assertEquals(t,t);
+        assertObjectsAreEqual(t,new TransformedBinaryFunction<Integer, Integer, Integer>(new
Sum(), new AddOne()));
+        assertObjectsAreNotEqual(t,new TransformedBinaryFunction<Integer, Integer, Integer>(f,
new AddOne()));
+        assertObjectsAreNotEqual(t,new TransformedBinaryFunction<Integer, Integer, Integer>(new
Sum(), p));
+        assertTrue(!t.equals(null));
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryProcedure.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryProcedure.java?rev=1365329&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryProcedure.java
(added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryProcedure.java
Tue Jul 24 22:34:23 2012
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.composite;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.BinaryFunction;
+import org.apache.commons.functor.UnaryProcedure;
+import org.junit.Test;
+
+
+/**
+ * Tests for TransformedBinaryProcedure.
+ * @version $Revision: $ $Date: $
+ */
+public class TestTransformedBinaryProcedure extends BaseFunctorTest {
+
+    private static class Sum implements BinaryFunction<Integer, Integer, Integer>,
Serializable {
+        private static final long serialVersionUID = 2255396324585938931L;
+        public Integer evaluate(Integer left, Integer right) {
+            return left+right;
+        }
+        @Override
+        public boolean equals(Object obj) {
+            return obj == this || obj != null && obj instanceof Sum;
+        }
+        @Override
+        public int hashCode() {
+            return "Sum".hashCode();
+        }
+    }
+
+    private static class Total implements UnaryProcedure<Integer>, Serializable {
+        private static final long serialVersionUID = 8532164308852418241L;
+        private int total = 0;
+        public void run(Integer obj) {
+            total += obj;
+        }
+        public Integer getTotal() {
+            return total;
+        }
+        @Override
+        public boolean equals(Object obj) {
+            return obj == this || obj != null && obj instanceof Total;
+        }
+        @Override
+        public int hashCode() {
+            return "Total".hashCode();
+        }
+    }
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new TransformedBinaryProcedure<Integer, Integer>(new Sum(), new Total());
+    }
+
+    @Test
+    public void testRun() {
+        Total t = new Total();
+        TransformedBinaryProcedure<Integer, Integer> transform = new TransformedBinaryProcedure<Integer,
Integer>(new Sum(), t);
+        transform.run(1, 2);
+        assertEquals(Integer.valueOf(3), t.getTotal());
+    }
+
+    @Test
+    public void testEquals() {
+        TransformedBinaryProcedure<Integer, Integer> t = new TransformedBinaryProcedure<Integer,
Integer>(new Sum(), new Total());
+        BinaryFunction<Integer, Integer, Integer> f = new BinaryFunction<Integer,
Integer, Integer>() {
+            public Integer evaluate(Integer left, Integer right) {
+                return left-right;
+            }
+        };
+        UnaryProcedure<Integer> p = new UnaryProcedure<Integer>() {
+            public void run(Integer obj) {
+                // Do nothing
+            }
+        };
+        assertEquals(t,t);
+        assertObjectsAreEqual(t,new TransformedBinaryProcedure<Integer, Integer>(new
Sum(), new Total()));
+        assertObjectsAreNotEqual(t,new TransformedBinaryProcedure<Integer, Integer>(f,
new Total()));
+        assertObjectsAreNotEqual(t,new TransformedBinaryProcedure<Integer, Integer>(new
Sum(), p));
+        assertTrue(!t.equals(null));
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedBinaryProcedure.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedFunction.java?rev=1365329&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedFunction.java
(added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedFunction.java
Tue Jul 24 22:34:23 2012
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.composite;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.Function;
+import org.apache.commons.functor.UnaryFunction;
+import org.junit.Test;
+
+/**
+ * Tests for TransformedFunction.
+ * @version $Revision: $ $Date: $
+ */
+public class TestTransformedFunction extends BaseFunctorTest {
+
+    private static class One implements Function<Integer>, Serializable {
+        private static final long serialVersionUID = 8160546546365936087L;
+        public Integer evaluate() {
+            return new Integer(1);
+        }
+        @Override
+        public boolean equals(Object obj) {
+            return obj == this || obj != null && obj instanceof One;
+        }
+        @Override
+        public int hashCode() {
+            return "One".hashCode();
+        }
+    };
+
+    private static class AddOne implements UnaryFunction<Integer, Integer>, Serializable
{
+        private static final long serialVersionUID = 2005155787293129721L;
+        public Integer evaluate(Integer obj) {
+            return obj + 1;
+        }
+        @Override
+        public boolean equals(Object obj) {
+            return obj == this || obj != null && obj instanceof AddOne;
+        }
+        @Override
+        public int hashCode() {
+            return "AddOne".hashCode();
+        }
+    };
+
+    private One one = new One();
+    private AddOne addOne = new AddOne();
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new TransformedFunction<Integer>(one, addOne);
+    }
+
+    @Test
+    public void testRun() {
+        TransformedFunction<Integer> p = new TransformedFunction<Integer>(one,
addOne);
+        assertEquals(Integer.valueOf(2),p.evaluate());
+    }
+
+    @Test
+    public void testEquals() {
+        TransformedFunction<Integer> t = new TransformedFunction<Integer>(one,
addOne);
+        Function<Integer> f = new Function<Integer>() {
+            public Integer evaluate() {
+                return new Integer(2);
+            }
+        };
+        UnaryFunction<Integer, Integer> p = new UnaryFunction<Integer, Integer>()
{
+            public Integer evaluate(Integer obj) {
+                return obj + 2;
+            }
+        };
+        assertEquals(t,t);
+        assertObjectsAreEqual(t,new TransformedFunction<Integer>(one, addOne));
+        assertObjectsAreNotEqual(t,new TransformedFunction<Integer>(f, addOne));
+        assertObjectsAreNotEqual(t,new TransformedFunction<Integer>(one, p));
+        assertTrue(!t.equals(null));
+    }
+
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedProcedure.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedProcedure.java?rev=1365329&view=auto
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedProcedure.java
(added)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedProcedure.java
Tue Jul 24 22:34:23 2012
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.functor.core.composite;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.Serializable;
+
+import org.apache.commons.functor.BaseFunctorTest;
+import org.apache.commons.functor.Function;
+import org.apache.commons.functor.UnaryProcedure;
+import org.junit.Test;
+
+/**
+ * Tests for TransformedProcedure.
+ * @version $Revision: $ $Date: $
+ */
+public class TestTransformedProcedure extends BaseFunctorTest{
+
+    private static class One implements Function<Integer>, Serializable {
+        private static final long serialVersionUID = 7385852113529459456L;
+        public Integer evaluate() {
+            return new Integer(1);
+        }
+        @Override
+        public boolean equals(Object obj) {
+            return obj == this || obj != null && obj instanceof One;
+        }
+        @Override
+        public int hashCode() {
+            return "One".hashCode();
+        }
+    };
+
+    private static class AggregatorProcedure implements UnaryProcedure<Integer>, Serializable
{
+        private static final long serialVersionUID = -2744193737701268327L;
+        private int total = 0;
+        public void run(Integer obj) {
+            total += obj;
+        }
+        public int getTotal() {
+            return total;
+        }
+        @Override
+        public boolean equals(Object obj) {
+            return obj == this || obj != null && obj instanceof AggregatorProcedure;
+        }
+        @Override
+        public int hashCode() {
+            return "AggregatorProcedure".hashCode();
+        }
+    };
+
+    private One one = new One();
+    private AggregatorProcedure aggregator = new AggregatorProcedure();
+
+    @Override
+    protected Object makeFunctor() throws Exception {
+        return new TransformedProcedure(one, aggregator);
+    }
+
+    @Test
+    public void testRun() {
+        TransformedProcedure p = new TransformedProcedure(one, aggregator);
+        p.run();
+        assertEquals(1,aggregator.getTotal());
+    }
+
+    @Test
+    public void testEquals() {
+        TransformedProcedure t = new TransformedProcedure(one, aggregator);
+        Function<Integer> f = new Function<Integer>() {
+            public Integer evaluate() {
+                return new Integer(2);
+            }
+        };
+        UnaryProcedure<Integer> p = new UnaryProcedure<Integer>() {
+            public void run(Integer obj) {
+                // Do nothing
+            }
+        };
+        assertEquals(t,t);
+        assertObjectsAreEqual(t,new TransformedProcedure(one, aggregator));
+        assertObjectsAreNotEqual(t,new TransformedProcedure(f, aggregator));
+        assertObjectsAreNotEqual(t,new TransformedProcedure(one, p));
+        assertTrue(!t.equals(null));
+    }
+}

Propchange: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransformedProcedure.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedFunction.java?rev=1365329&r1=1365328&r2=1365329&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedFunction.java
(original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedFunction.java
Tue Jul 24 22:34:23 2012
@@ -19,6 +19,7 @@ package org.apache.commons.functor.core.
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.BinaryFunction;
@@ -57,6 +58,7 @@ public class TestTransposedFunction exte
         assertObjectsAreEqual(f,new TransposedFunction<Object, Object, Object>(LeftIdentity.FUNCTION));
         assertObjectsAreNotEqual(f,new TransposedFunction<Object, Object, Object>(RightIdentity.FUNCTION));
         assertObjectsAreNotEqual(f,Constant.of("y"));
+        assertTrue(!f.equals((TransposedFunction<?, ?, ?>)null));
     }
 
     @Test

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java?rev=1365329&r1=1365328&r2=1365329&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java
(original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedPredicate.java
Tue Jul 24 22:34:23 2012
@@ -61,6 +61,7 @@ public class TestTransposedPredicate ext
         assertObjectsAreEqual(p,TransposedPredicate.transpose(Constant.TRUE));
         assertObjectsAreNotEqual(p,new TransposedPredicate<Object, Object>(Constant.FALSE));
         assertObjectsAreNotEqual(p,Constant.TRUE);
+        assertTrue(!p.equals((TransposedPredicate<?, ?>)null));
     }
 
     @Test

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java?rev=1365329&r1=1365328&r2=1365329&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java
(original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestTransposedProcedure.java
Tue Jul 24 22:34:23 2012
@@ -19,6 +19,7 @@ package org.apache.commons.functor.core.
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.BinaryProcedure;
@@ -60,6 +61,7 @@ public class TestTransposedProcedure ext
         assertObjectsAreEqual(p,TransposedProcedure.transpose(NoOp.INSTANCE));
         assertObjectsAreNotEqual(p,new TransposedProcedure<Object, Object>(new TransposedProcedure<Object,
Object>(NoOp.INSTANCE)));
         assertObjectsAreNotEqual(p,NoOp.INSTANCE);
+        assertTrue(!p.equals((TransposedProcedure<?, ?>)null));
     }
 
     @Test

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java?rev=1365329&r1=1365328&r2=1365329&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java
(original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryAnd.java
Tue Jul 24 22:34:23 2012
@@ -102,6 +102,7 @@ public class TestUnaryAnd extends BaseFu
         }
     }
 
+    @SuppressWarnings("rawtypes")
     @Test
     public void testEquals() throws Exception {
         UnaryAnd<Object> p = new UnaryAnd<Object>();
@@ -121,6 +122,14 @@ public class TestUnaryAnd extends BaseFu
         }
 
         assertObjectsAreNotEqual(p,Constant.truePredicate());
+        UnaryAnd<Object> r = new UnaryAnd<Object>();
+        r.and(Constant.truePredicate());
+        r.and(new UnaryAnd<Object>(Constant.truePredicate(),Constant.falsePredicate()));
+        assertObjectsAreEqual(r, new UnaryAnd<Object>(r.getUnaryPredicateList()));
+        assertObjectsAreNotEqual(p, new UnaryAnd((Iterable<UnaryPredicate<Object>>)null));
+        assertObjectsAreNotEqual(p, new UnaryAnd((UnaryPredicate<Object>[])null));
+        assertObjectsAreNotEqual(p, new UnaryAnd((UnaryPredicate<Object>)null));
+        assertTrue(!p.equals(null));
     }
 
 }

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryFunction.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryFunction.java?rev=1365329&r1=1365328&r2=1365329&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryFunction.java
(original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryFunction.java
Tue Jul 24 22:34:23 2012
@@ -18,6 +18,7 @@ package org.apache.commons.functor.core.
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.commons.functor.BaseFunctorTest;
 import org.apache.commons.functor.BinaryFunction;
@@ -80,6 +81,7 @@ public class TestUnaryCompositeBinaryFun
                 LeftIdentity.FUNCTION,
                 Constant.of("left"),
                 Identity.instance()));
+        assertTrue(!((UnaryCompositeBinaryFunction<?,?,?>)f).equals(null));
     }
 
 }

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryPredicate.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryPredicate.java?rev=1365329&r1=1365328&r2=1365329&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryPredicate.java
(original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryCompositeBinaryPredicate.java
Tue Jul 24 22:34:23 2012
@@ -73,8 +73,17 @@ public class TestUnaryCompositeBinaryPre
                 Constant.FALSE));
         assertObjectsAreNotEqual(f,new UnaryCompositeBinaryPredicate<Boolean, Boolean>(
                 LeftIdentity.PREDICATE,
+                Constant.FALSE,
+                Constant.FALSE));
+        assertObjectsAreNotEqual(f,new UnaryCompositeBinaryPredicate<Boolean, Boolean>(
+                LeftIdentity.PREDICATE,
                 new Identity<Boolean>(),
                 Constant.TRUE));
+        assertObjectsAreNotEqual(f,new UnaryCompositeBinaryPredicate<Boolean, Boolean>(
+                LeftIdentity.PREDICATE,
+                Constant.TRUE,
+                new Identity<Boolean>()));
+        assertTrue(!((UnaryCompositeBinaryPredicate<?,?>)f).equals(null));
     }
 
 }

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java?rev=1365329&r1=1365328&r2=1365329&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java
(original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryNot.java
Tue Jul 24 22:34:23 2012
@@ -58,6 +58,7 @@ public class TestUnaryNot extends BaseFu
         assertObjectsAreEqual(p,UnaryNot.not(Constant.TRUE));
         assertObjectsAreNotEqual(p,new UnaryNot<Object>(Constant.FALSE));
         assertObjectsAreNotEqual(p,Constant.TRUE);
+        assertTrue(!p.equals(null));
     }
 
     @Test

Modified: commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java?rev=1365329&r1=1365328&r2=1365329&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java
(original)
+++ commons/proper/functor/trunk/src/test/java/org/apache/commons/functor/core/composite/TestUnaryOr.java
Tue Jul 24 22:34:23 2012
@@ -129,6 +129,10 @@ public class TestUnaryOr extends BaseFun
         }
 
         assertObjectsAreNotEqual(p,Constant.truePredicate());
+        UnaryOr<Object> s = new UnaryOr<Object>();
+        s.or(Constant.truePredicate());
+        s.or(new UnaryOr<Object>(Constant.truePredicate(),Constant.falsePredicate()));
+        assertObjectsAreEqual(s, new UnaryOr<Object>(s.getUnaryPredicateList()));
     }
 
 }



Mime
View raw message