@Test public void testNoParamExpression() { Fields fields = new Fields( "a", "b" ).applyTypes( String.class, double.class ); String expression = "(int) (Math.random() * Integer.MAX_VALUE)"; Number integer = (Number) evaluate( new ExpressionFunction( new Fields( "result" ), expression ), getEntry( fields, "1", 2.0 ) ); assertNotNull( integer ); // Fields.NONE as argument selector integer = (Number) evaluate( new ExpressionFunction( new Fields( "result" ), expression ), TupleEntry.NULL ); assertNotNull( integer ); try { evaluate( new ExpressionFunction( new Fields( "result" ), "(int) (Math.random() * Integer.MAX_VALUE) + parameter" ), getEntry( fields, "1", 2.0 ) ); fail( "should throw exception" ); } catch( Exception exception ) { // ignore } }
@Test public void testNoParamExpression() { Fields fields = new Fields( "a", "b" ).applyTypes( String.class, double.class ); String expression = "(int) (Math.random() * Integer.MAX_VALUE)"; Number integer = (Number) evaluate( new ExpressionFunction( new Fields( "result" ), expression ), getEntry( fields, "1", 2.0 ) ); assertNotNull( integer ); // Fields.NONE as argument selector integer = (Number) evaluate( new ExpressionFunction( new Fields( "result" ), expression ), TupleEntry.NULL ); assertNotNull( integer ); try { evaluate( new ExpressionFunction( new Fields( "result" ), "(int) (Math.random() * Integer.MAX_VALUE) + parameter" ), getEntry( fields, "1", 2.0 ) ); fail( "should throw exception" ); } catch( Exception exception ) { // ignore } }