1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.functor.adapter;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.assertNotNull;
21 import static org.junit.Assert.assertNull;
22
23 import org.apache.commons.functor.BaseFunctorTest;
24 import org.apache.commons.functor.Predicate;
25 import org.apache.commons.functor.core.Constant;
26 import org.apache.commons.functor.core.RightIdentity;
27 import org.junit.Test;
28
29
30
31
32
33 public class TestFullyBoundPredicate extends BaseFunctorTest {
34
35
36
37
38 protected Object makeFunctor() {
39 return new FullyBoundPredicate(Constant.TRUE, null, "xyzzy");
40 }
41
42
43
44
45 @Test
46 public void testTest() throws Exception {
47 Predicate p = new FullyBoundPredicate(
48 new BinaryFunctionBinaryPredicate<Object, Boolean>(RightIdentity.<Object, Boolean> function()), "foo",
49 Boolean.TRUE);
50 assertEquals(true, p.test());
51 }
52
53 @Test
54 public void testEquals() throws Exception {
55 Predicate p = new FullyBoundPredicate(Constant.TRUE, "xyzzy", null);
56 assertEquals(p, p);
57 assertObjectsAreEqual(p, new FullyBoundPredicate(Constant.TRUE, "xyzzy", null));
58 assertObjectsAreNotEqual(p, Constant.TRUE);
59 assertObjectsAreNotEqual(p, new FullyBoundPredicate(Constant.FALSE, "xyzzy", null));
60 assertObjectsAreNotEqual(p, new FullyBoundPredicate(Constant.TRUE, "foo", null));
61 assertObjectsAreNotEqual(p, new FullyBoundPredicate(Constant.TRUE, null, "xyzzy"));
62 }
63
64 @Test
65 public void testAdaptNull() throws Exception {
66 assertNull(FullyBoundPredicate.bind(null, "xyzzy", null));
67 }
68
69 @Test
70 public void testAdapt() throws Exception {
71 assertNotNull(FullyBoundPredicate.bind(Constant.FALSE, "xyzzy", "foobar"));
72 assertNotNull(FullyBoundPredicate.bind(Constant.FALSE, null, null));
73 }
74 }