ReverseFunction extends BaseFEELFunction { public FEELFnResult<List<Object>> invoke(@ParameterName("list") List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null")); } final List<Object> result = new ArrayList<>( list ); Collections.reverse( result ); return FEELFnResult.ofResult( result ); } ReverseFunction(); FEELFnResult<List<Object>> invoke(@ParameterName("list") List list);  }
@Test public void invokeNull() { FunctionTestUtil.assertResultError(reverseFunction.invoke(null), InvalidParametersEvent.class); }
@Test public void invokeEmptyList() { FunctionTestUtil.assertResultList(reverseFunction.invoke(Collections.emptyList()), Collections.emptyList()); }
@Test public void invokeListTypeHomogenous() { FunctionTestUtil.assertResultList(reverseFunction.invoke(Arrays.asList(1, 2, 3, 4)), Arrays.asList(4, 3, 2, 1)); }
@Test public void invokeListTypeHeterogenous() { FunctionTestUtil.assertResultList( reverseFunction.invoke(Arrays.asList(1, "test", BigDecimal.TEN, Collections.emptyList())), Arrays.asList(Collections.emptyList(), BigDecimal.TEN, "test", 1)); FunctionTestUtil.assertResultList( reverseFunction.invoke(Arrays.asList(1, "test", BigDecimal.TEN, Arrays.asList(1, 2, 3))), Arrays.asList(Arrays.asList(1, 2, 3), BigDecimal.TEN, "test", 1)); }