NotFunction extends BaseFEELFunction { public FEELFnResult<Boolean> invoke(@ParameterName("negand") Object negand) { if ( negand != null && !(negand instanceof Boolean) ) { return FEELFnResult.ofError( new InvalidParametersEvent( Severity.ERROR, "negand", "must be a boolean value" ) ); } return FEELFnResult.ofResult( negand == null ? null : !((Boolean) negand) ); } NotFunction(); FEELFnResult<Boolean> invoke(@ParameterName("negand") Object negand);  }
@Test public void invokeNull() { FunctionTestUtil.assertResultNull(notFunction.invoke(null)); }
@Test public void invokeWrongType() { FunctionTestUtil.assertResultError(notFunction.invoke(1), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(notFunction.invoke("test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(notFunction.invoke(BigDecimal.ZERO), InvalidParametersEvent.class); }
@Test public void invokeTrue() { FunctionTestUtil.assertResult(notFunction.invoke(true), false); }
@Test public void invokeFalse() { FunctionTestUtil.assertResult(notFunction.invoke(false), true); }