MinFunction implements DDMExpressionFunction.Function1<Object[], BigDecimal> { @Override public BigDecimal apply(Object[] values) { return Stream.of( values ).map( value -> new BigDecimal(value.toString()) ).collect( Collectors.minBy((num1, num2) -> num1.compareTo(num2)) ).orElse( BigDecimal.ZERO ); }  @Override BigDecimal apply(Object[] values); @Override String getName(); static final String NAME; }
@Test public void testEmptyArray() { MinFunction minFunction = new MinFunction(); BigDecimal result = minFunction.apply(new BigDecimal[0]); Assert.assertEquals(BigDecimal.ZERO, result); }
@Test public void testMax() { MinFunction minFunction = new MinFunction(); BigDecimal result = minFunction.apply( new BigDecimal[] { new BigDecimal(1), new BigDecimal(10), new BigDecimal(3), new BigDecimal(19), new BigDecimal(17) }); Assert.assertEquals(BigDecimal.ONE, result); }