FloorFunction extends BaseFEELFunction { public FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n) { if ( n == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "n", "cannot be null")); } return FEELFnResult.ofResult( n.setScale( 0, BigDecimal.ROUND_FLOOR ) ); } FloorFunction(); FEELFnResult<BigDecimal> invoke(@ParameterName( "n" ) BigDecimal n); static final FloorFunction INSTANCE; }
@Test public void invokeNull() { FunctionTestUtil.assertResultError(floorFunction.invoke(null), InvalidParametersEvent.class); }
@Test public void invokeZero() { FunctionTestUtil.assertResultBigDecimal(floorFunction.invoke(BigDecimal.ZERO), BigDecimal.ZERO); }
@Test public void invokePositive() { FunctionTestUtil.assertResultBigDecimal(floorFunction.invoke(BigDecimal.valueOf(10.2)), BigDecimal.valueOf(10)); }
@Test public void invokeNegative() { FunctionTestUtil.assertResultBigDecimal(floorFunction.invoke(BigDecimal.valueOf(-10.2)), BigDecimal.valueOf(-11)); }