public void testIncompleteMathExpression() throws IllegalFilterException { Expression testAttribute1 = new LiteralExpressionImpl(Integer.valueOf(4)); MathExpressionImpl mathTest = new AddImpl(null, null); mathTest.setExpression1(testAttribute1); try { mathTest.evaluate(testFeature); fail("math expressions should not work if right hand side is not set"); } catch (IllegalArgumentException ife) { } mathTest = new AddImpl(null, null); mathTest.setExpression2(testAttribute1); try { mathTest.evaluate(testFeature); fail("math expressions should not work if left hand side is not set"); } catch (IllegalArgumentException ife) { } }
+ testAttribute2.evaluate(testFeature) + " = " + mathTest.evaluate(testFeature)); assertEquals(Integer.valueOf(6), mathTest.evaluate(testFeature, Integer.class)); + testAttribute2.evaluate(testFeature) + " = " + mathTest.evaluate(testFeature)); assertEquals(Integer.valueOf(2), mathTest.evaluate(testFeature, Integer.class)); + testAttribute2.evaluate(testFeature) + " = " + mathTest.evaluate(testFeature)); assertEquals(Integer.valueOf(8), mathTest.evaluate(testFeature, Integer.class)); + testAttribute2.evaluate(testFeature) + " = " + mathTest.evaluate(testFeature)); assertEquals(new Double(2), mathTest.evaluate(testFeature));
mathTest.setExpression2(testAttribute2); assertEquals(Integer.valueOf(6), mathTest.evaluate(testObject, Integer.class)); mathTest.setExpression2(testAttribute2); assertEquals(Integer.valueOf(2), mathTest.evaluate(testObject, Integer.class)); mathTest.setExpression2(testAttribute2); assertEquals(Integer.valueOf(8), mathTest.evaluate(testObject, Integer.class)); mathTest.setExpression2(testAttribute2); assertEquals(new Double(2), mathTest.evaluate(testObject));