001 /*
002 * To change this template, choose Tools | Templates
003 * and open the template in the editor.
004 */
005
006 package gate.jape.constraint;
007
008
009 import gate.AnnotationSet;
010 import gate.jape.JapeException;
011 import junit.framework.TestCase;
012
013 /**
014 *
015 * @author philipgooch
016 */
017 public class ComparablePredicateTest extends TestCase {
018
019 public ComparablePredicateTest(String testName) {
020 super(testName);
021 }
022
023 @Override
024 protected void setUp() throws Exception {
025 super.setUp();
026 }
027
028 @Override
029 protected void tearDown() throws Exception {
030 super.tearDown();
031 }
032
033 /**
034 * Test of setValue method, of class ComparablePredicate.
035 */
036 public void testSetValue() {
037 System.out.println("setValue");
038 Object value = new Long(32);
039 ComparablePredicate instance = new ComparablePredicateImpl();
040 instance.setValue(value);
041 assertTrue(true);
042 }
043
044 /**
045 * Test of doMatch method, of class ComparablePredicate.
046 */
047 public void testDoMatch_Object_AnnotationSet() throws Exception {
048 System.out.println("doMatch");
049 Object value = null;
050 AnnotationSet context = null;
051 ComparablePredicate instance = new ComparablePredicateImpl();
052 boolean expResult = false;
053 boolean result = instance.doMatch(value, context);
054 assertEquals(expResult, result);
055
056 }
057
058 /**
059 * Test of doMatch method, of class ComparablePredicate.
060 */
061 public void testDoMatch_Object() throws Exception {
062 System.out.println("doMatch");
063 Object featureValue = null;
064 ComparablePredicate instance = new ComparablePredicateImpl();
065 boolean expResult = false;
066 boolean result = instance.doMatch(featureValue);
067 assertEquals(expResult, result);
068
069 }
070
071 /**
072 * Test of compareValue method, of class ComparablePredicate.
073 */
074 public void testCompareValue() throws Exception {
075 System.out.println("compareValue");
076
077 ComparablePredicate instance = new ComparablePredicateImpl();
078
079 instance.setValue(new Double(12.7));
080 assertEquals(1, instance.compareValue(new String("3")));
081
082 instance.setValue(new Double(12.7));
083 assertEquals(1, instance.compareValue(new Integer(5)));
084
085 instance.setValue(new Long(4));
086 int res = instance.compareValue(new Integer(3));
087 assertEquals(1, res);
088
089 instance.setValue(new String("3"));
090 assertEquals(3, instance.compareValue(new String("001")));
091
092 instance.setValue(new String("3"));
093 assertEquals(2, instance.compareValue(new String("1")));
094
095 instance.setValue(new Long(35));
096 assertEquals(1, instance.compareValue(new String("12")));
097
098 instance.setValue(new Long(3));
099 assertEquals(-1, instance.compareValue(new Integer(17)));
100
101 instance.setValue(new Double(100.0));
102 assertEquals(1, instance.compareValue(new Double(97.3)));
103
104 instance.setValue(new Float(100.0));
105 assertEquals(1, instance.compareValue(new Float(97.3)));
106 }
107
108 public class ComparablePredicateImpl extends ComparablePredicate {
109
110 public String getOperator() {
111 return GREATER;
112 }
113
114 public boolean doMatch(Object featureValue) throws JapeException {
115 return false;
116 }
117 }
118
119 }
|