1   package uba.db.sql.language;
2   
3   import java.util.HashMap;
4   import java.util.Map;
5   
6   import junit.framework.TestCase;
7   import uba.db.testhelpers.TestUtils;
8   
9   /***
10   * @version $Revision: 1.2 $
11   */
12  public class LessThanComparisonTest extends TestCase {
13      private LessThanComparison comp;
14      private LessThanComparison sameComp;
15      private LessThanComparison otherComp;
16  
17      /***
18       * @see junit.framework.TestCase#setUp()
19       */
20      protected void setUp() throws Exception {
21          super.setUp();
22          comp = new LessThanComparison(new ColumnName("a"), new ColumnName("b"));
23          sameComp = new LessThanComparison(new ColumnName("a"), new ColumnName("b"));
24          otherComp = new LessThanComparison(new ColumnName("c"), new IntegerValue(3));
25      }
26  
27      /***
28       * Test de igualdad entre dos instancias.
29       */
30      public void testEquals() throws Exception {
31          TestUtils.assertEqualsImplementation(comp, sameComp, otherComp);
32      }
33  
34      /***
35       * Test: obtener el resultado de una comparacion
36       */
37      public void testIsTrueWith() throws Exception {
38          Map values = new HashMap();
39          values.put(new ColumnName("a"), new Integer(20));
40          values.put(new ColumnName("b"), new Integer(10));
41          values.put(new ColumnName("c"), new Integer(1));
42  
43          EvaluationContext context = new MockEvaluationContext(values);
44  
45          assertFalse(comp.isTrueWith(context));
46          assertEquals(Boolean.FALSE, comp.valueWith(context));
47          assertTrue(otherComp.isTrueWith(context));
48          assertEquals(Boolean.TRUE, otherComp.valueWith(context));
49      }
50  }