ConcatenateFunction extends BaseFEELFunction { public FEELFnResult<List<Object>> invoke(@ParameterName("list") Object[] lists) { if ( lists == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null")); } final List<Object> result = new ArrayList<>(); for ( Object list : lists ) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "lists", "one of the elements in the list is null")); } else if ( list instanceof Collection ) { result.addAll( (Collection) list ); } else { result.add( list ); } } return FEELFnResult.ofResult( result ); } ConcatenateFunction(); FEELFnResult<List<Object>> invoke(@ParameterName("list") Object[] lists);  }
@Test public void invokeNull() { FunctionTestUtil.assertResultError(concatenateFunction.invoke(null), InvalidParametersEvent.class); }
@Test public void invokeEmptyArray() { FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{}), Collections.emptyList()); }
@Test public void invokeArrayWithNull() { FunctionTestUtil.assertResultError(concatenateFunction.invoke(new Object[]{null}), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(concatenateFunction.invoke(new Object[]{1, null}), InvalidParametersEvent.class); }
@Test public void invokeArrayWithList() { FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{"test", 2, Arrays.asList(2, 3)}), Arrays.asList("test", 2, 2, 3)); }
@Test public void invokeArrayWithoutList() { FunctionTestUtil.assertResultList(concatenateFunction.invoke(new Object[]{"test", 2, BigDecimal.valueOf(25.3)}), Arrays.asList("test", 2, BigDecimal.valueOf(25.3))); }