use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class TestMathFunctions method testRoundToWhole.
@Test
public void testRoundToWhole() {
FunctionInterface round = fff.getInstance(cl, "Round");
round.reset();
round.insertFloatOperand(10.5);
round.insertIntegerOperand(0);
double actual = (Double) round.evaluateWithTypeChecking();
assertEquals(11.0, actual, 0.000001);
}
use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class TestMathFunctions method testMaxNumberList.
@Test
public void testMaxNumberList() {
FunctionInterface max = fff.getInstance(cl, "Max");
max.reset();
List<Object> numbers = new ArrayList<>();
numbers.add(Math.PI);
numbers.add(3);
numbers.add(5L);
max.insertListOperand(numbers);
double actual = (Double) max.evaluateWithTypeChecking();
assertEquals(5.0, actual, 0.000001);
}
use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class TestMathFunctions method testMaxDateList.
@Test
public void testMaxDateList() throws ParseException {
FunctionInterface max = fff.getInstance(cl, "Max");
max.reset();
SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd");
List<Date> dates = new ArrayList<>();
dates.add(parser.parse("2017-11-10"));
dates.add(parser.parse("2015-11-10"));
dates.add(parser.parse("2019-10-11"));
max.insertListOperand(dates);
Date actual = (Date) max.evaluateWithTypeChecking();
assertEquals(parser.parse("2019-10-11"), actual);
}
use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class StandardFunctionsTest method testGetFileExtension.
@Test
public void testGetFileExtension() {
FunctionInterface fi = fff.getInstance(cl, "GetFileExtension");
Navajo doc = createTestNavajo();
fi.setInMessage(doc);
fi.reset();
fi.insertOperand(Operand.NULL);
Object o = fi.evaluateWithTypeChecking();
assertNull(o);
}
use of com.dexels.navajo.expression.api.FunctionInterface in project navajo by Dexels.
the class StandardFunctionsTest method testIsEmpty.
@Test
public void testIsEmpty() {
FunctionInterface fi = fff.getInstance(cl, "IsEmpty");
// Empty String.
fi.reset();
fi.insertStringOperand("");
Object o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Boolean.TRUE, o);
// Non Empty String.
fi.reset();
fi.insertStringOperand("aap");
o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Boolean.FALSE, o);
// Null value.
fi.reset();
fi.insertOperand(Operand.NULL);
o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Boolean.TRUE, o);
// Empty list
fi.reset();
fi.insertListOperand(new ArrayList<Object>());
o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Boolean.TRUE, o);
// Non Empty list.
fi.reset();
boolean thing = new ArrayList<String>().add("noot");
fi.insertBooleanOperand(thing);
o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Boolean.FALSE, o);
// Empty Binary.
fi.reset();
fi.insertBinaryOperand(new Binary());
o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Boolean.TRUE, o);
// Non Empty Binary.
fi.reset();
fi.insertBinaryOperand(new Binary("aap".getBytes()));
o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Boolean.FALSE, o);
// Non empty Clocktime.
fi.reset();
fi.insertClockTimeOperand(new ClockTime(new Date()));
o = fi.evaluateWithTypeChecking();
assertNotNull(o);
assertEquals(Boolean.FALSE, o);
}
Aggregations