1 15 package org.apache.hivemind.conditional; 16 17 import org.apache.hivemind.conditional.EvaluationContext; 18 import org.apache.hivemind.conditional.Evaluator; 19 import org.apache.hivemind.conditional.Node; 20 import org.apache.hivemind.conditional.NodeImpl; 21 import org.apache.hivemind.test.HiveMindTestCase; 22 import org.easymock.MockControl; 23 24 30 public class TestNode extends HiveMindTestCase 31 { 32 public void testConstructorAndGetters() 33 { 34 Node left = (Node) newMock(Node.class); 35 Node right = (Node) newMock(Node.class); 36 Evaluator evaluator = (Evaluator) newMock(Evaluator.class); 37 38 replayControls(); 39 40 Node n = new NodeImpl(left, right, evaluator); 41 42 assertSame(left, n.getLeft()); 43 assertSame(right, n.getRight()); 44 45 verifyControls(); 46 } 47 48 public void testEvaluate() 49 { 50 MockControl control = newControl(Evaluator.class); 51 Evaluator evaluator = (Evaluator) control.getMock(); 52 EvaluationContext context = (EvaluationContext) newMock(EvaluationContext.class); 53 54 Node n = new NodeImpl(evaluator); 55 56 evaluator.evaluate(context, n); 57 control.setReturnValue(false); 58 59 evaluator.evaluate(context, n); 60 control.setReturnValue(true); 61 62 replayControls(); 63 64 assertEquals(false, n.evaluate(context)); 65 assertEquals(true, n.evaluate(context)); 66 67 verifyControls(); 68 } 69 } | Popular Tags |