public void testParseSimpleEvalExpressionNoParserContext() { String expressionString = "3 + 4"; Expression exp = parser.parseExpression(expressionString, null); assertEquals(7L, exp.getValue(null)); }
public void testParseNullExpressionString() { String expressionString = null; try { parser.parseExpression(expressionString, null); fail("should have thrown iae"); } catch (IllegalArgumentException e) { } }
public void testGetExpressionString() { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, null); assertEquals("maximum", exp.getExpressionString()); }
public void testParseEmptyExpressionString() { String expressionString = ""; try { parser.parseExpression(expressionString, null); fail("Should have failed"); } catch (ParserException e) { } }
public void testParseLiteralExpression() { String expressionString = "'value'"; Expression exp = parser.parseExpression(expressionString, null); assertEquals("value", exp.getValue(null)); }
public void testSetValueCoersionError() { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, null); TestBean context = new TestBean(); try { exp.setValue(context, "bogus"); fail("Should have failed with coersion"); } catch (ValueCoercionException e) { } }
public void testParseNull() { Expression exp = parser.parseExpression("null", null); assertEquals(null, exp.getValue(null)); }
public void testGetValueCoersionError() { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().expectResult(TestBean.class)); TestBean context = new TestBean(); try { exp.getValue(context); fail("Should have failed with coersion"); } catch (ValueCoercionException e) { } }
public void testParseBeanEvalExpressionNoParserContext() { String expressionString = "value"; Expression exp = parser.parseExpression(expressionString, null); assertEquals("foo", exp.getValue(new TestBean())); }
public void testParseBeanEvalExpressionInvalidELVariable() { try { String expressionString = "bogus"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().evaluate(TestBean.class)); exp.getValue(new TestBean()); fail("Should have failed"); } catch (EvaluationException e) { } }
public void testGetExpressionType() { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, null); TestBean context = new TestBean(); assertEquals(int.class, exp.getValueType(context)); }
public void testParseSimpleEvalExpressionNoEvalContextWithTypeCoersion() { String expressionString = "3 + 4"; Expression exp = parser .parseExpression(expressionString, new FluentParserContext().expectResult(Integer.class)); assertEquals(7, exp.getValue(null)); }
public void testSetValueWithTypeCoersion() { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, null); TestBean context = new TestBean(); exp.setValue(context, "5"); assertEquals(5, context.getMaximum()); }
public void testSetValue() { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, null); TestBean context = new TestBean(); exp.setValue(context, 5); assertEquals(5, context.getMaximum()); }
public void testParseEvalExpressionWithContextTypeCoersion() { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().expectResult(Long.class)); assertEquals(2L, exp.getValue(new TestBean())); }
public void testParseTemplateExpression() { String expressionString = "text text text #{value} text text text#{value}"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template()); TestBean target = new TestBean(); assertEquals("text text text foo text text textfoo", exp.getValue(target)); }
public void testGetValueWithCoersion() { String expressionString = "maximum"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().expectResult(String.class)); TestBean context = new TestBean(); assertEquals("2", exp.getValue(context)); }
public void testParseEvalExpressionWithContextCustomELVariableResolver() { String expressionString = "specialProperty"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().evaluate(TestBean.class)); assertEquals("Custom resolver resolved this special property!", exp.getValue(new TestBean())); }
public void testParseTemplateExpressionWithVariables() { String expressionString = "#{value}#{max}"; Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable(new ExpressionVariable("max", "maximum"))); TestBean target = new TestBean(); assertEquals("foo2", exp.getValue(target)); }
public void testVariablesWithCoersion() { Expression exp = parser.parseExpression("max", new FluentParserContext().variable(new ExpressionVariable("max", "maximum", new FluentParserContext().expectResult(Long.class)))); TestBean target = new TestBean(); assertEquals(2L, exp.getValue(target)); }