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.UnaryProcedure;
25 import org.apache.commons.functor.core.LeftIdentity;
26 import org.apache.commons.functor.core.NoOp;
27 import org.junit.Test;
28
29
30
31
32
33 public class TestRightBoundProcedure extends BaseFunctorTest {
34
35
36
37
38 protected Object makeFunctor() {
39 return new RightBoundProcedure<Object>(NoOp.INSTANCE,"xyzzy");
40 }
41
42
43
44
45 @Test
46 public void testRun() throws Exception {
47 UnaryProcedure<Object> p = new RightBoundProcedure<Object>(
48 new BinaryFunctionBinaryProcedure<Object, Object>(LeftIdentity.FUNCTION), "foo");
49 p.run(Boolean.TRUE);
50 p.run(Boolean.FALSE);
51 }
52
53 @Test
54 public void testEquals() throws Exception {
55 UnaryProcedure<Object> f = new RightBoundProcedure<Object>(NoOp.INSTANCE,"xyzzy");
56 assertEquals(f,f);
57 assertObjectsAreEqual(f,new RightBoundProcedure<Object>(NoOp.INSTANCE,"xyzzy"));
58 assertObjectsAreNotEqual(f,NoOp.INSTANCE);
59 assertObjectsAreNotEqual(f,new RightBoundProcedure<Object>(new BinaryFunctionBinaryProcedure<Object, Object>(LeftIdentity.FUNCTION),"xyzzy"));
60 assertObjectsAreNotEqual(f,new RightBoundProcedure<Object>(NoOp.INSTANCE,"foo"));
61 assertObjectsAreNotEqual(f,new RightBoundProcedure<Object>(NoOp.INSTANCE,null));
62 }
63
64 @Test
65 public void testAdaptNull() throws Exception {
66 assertNull(RightBoundProcedure.bind(null,"xyzzy"));
67 }
68
69 @Test
70 public void testAdapt() throws Exception {
71 assertNotNull(RightBoundProcedure.bind(NoOp.INSTANCE,"xyzzy"));
72 assertNotNull(RightBoundProcedure.bind(NoOp.INSTANCE,null));
73 }
74 }