CountFunction extends BaseFEELFunction { public FEELFnResult<BigDecimal> invoke(@ParameterName( "list" ) List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null")); } return FEELFnResult.ofResult( BigDecimal.valueOf( list.size() ) ); } CountFunction(); FEELFnResult<BigDecimal> invoke(@ParameterName( "list" ) List list); FEELFnResult<BigDecimal> invoke(@ParameterName( "c" ) Object[] list);  }
@Test public void invokeParamListNull() { FunctionTestUtil.assertResultError(countFunction.invoke((List) null), InvalidParametersEvent.class); }
@Test public void invokeParamListEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(Collections.emptyList()), BigDecimal.ZERO); }
@Test public void invokeParamListNonEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(Arrays.asList(1, 2, "test")), BigDecimal.valueOf(3)); }
@Test public void invokeParamArrayNull() { FunctionTestUtil.assertResultError(countFunction.invoke((Object[]) null), InvalidParametersEvent.class); }
@Test public void invokeParamArrayEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(new Object[]{}), BigDecimal.ZERO); }
@Test public void invokeParamArrayNonEmpty() { FunctionTestUtil.assertResult(countFunction.invoke(new Object[]{1, 2, "test"}), BigDecimal.valueOf(3)); }