ContainsFunction extends BaseFEELFunction { public FEELFnResult<Boolean> invoke(@ParameterName("string") String string, @ParameterName("match") String match) { if ( string == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "string", "cannot be null")); } if ( match == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "match", "cannot be null")); } return FEELFnResult.ofResult(string.contains(match)); } ContainsFunction(); FEELFnResult<Boolean> invoke(@ParameterName("string") String string, @ParameterName("match") String match);  }
@Test public void invokeParamsNull() { FunctionTestUtil.assertResultError(containsFunction.invoke((String) null, null), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(containsFunction.invoke(null, "test"), InvalidParametersEvent.class); FunctionTestUtil.assertResultError(containsFunction.invoke("test", null), InvalidParametersEvent.class); }
@Test public void invokeContains() { FunctionTestUtil.assertResult(containsFunction.invoke("test", "es"), true); FunctionTestUtil.assertResult(containsFunction.invoke("test", "t"), true); FunctionTestUtil.assertResult(containsFunction.invoke("testy", "y"), true); }
@Test public void invokeNotContains() { FunctionTestUtil.assertResult(containsFunction.invoke("test", "ex"), false); FunctionTestUtil.assertResult(containsFunction.invoke("test", "u"), false); FunctionTestUtil.assertResult(containsFunction.invoke("test", "esty"), false); }