@Test
public void evaluateApplyCondition(){

	FieldName name = FieldName.create("x");
	Apply condition = new Apply(PMMLFunctions.ISNOTMISSING)
		.addExpressions(new FieldRef(name));
	Apply apply = new Apply(PMMLFunctions.IF)
		.addExpressions(condition);
	try {
		evaluate(apply, name, null);
		fail();
	} catch(FunctionException fe){
		// Ignored
	}
	Expression thenPart = new Apply(PMMLFunctions.ABS)
		.addExpressions(new FieldRef(name));
	apply.addExpressions(thenPart);
	assertEquals(1, evaluate(apply, name, 1));
	assertEquals(1, evaluate(apply, name, -1));
	assertEquals(null, evaluate(apply, name, null));
	Expression elsePart = new Constant("-1")
		.setDataType(DataType.DOUBLE);
	apply.addExpressions(elsePart);
	assertEquals(-1d, evaluate(apply, name, null));
	apply.addExpressions(new FieldRef(name));
	try {
		evaluate(apply, name, null);
		fail();
	} catch(FunctionException fe){
		// Ignored
	}
}