DefineFunctionUtils { static MethodDeclaration getDefineFunctionMethodDeclaration(final DefineFunction defineFunction) { final Expression expression = defineFunction.getExpression(); if (expression != null) { return getExpressionMethodDeclaration(defineFunction.getName(), expression, defineFunction.getDataType(), defineFunction.getParameterFields()); } else { throw new KiePMMLException("Define Function without Expression are not supported, yet"); } } private  DefineFunctionUtils();   }
@Test public void getDefineFunctionMethodDeclarationUnsupportedExpression() { for (Supplier<Expression> supplier : unsupportedExpressionSupplier) { DefineFunction defineFunction = defineFunctionCreator.apply(supplier); try { DefineFunctionUtils.getDefineFunctionMethodDeclaration(defineFunction); fail(String.format("Expecting KiePMMLException for %s", defineFunction)); } catch (Exception e) { assertEquals(KiePMMLException.class, e.getClass()); } } }
@Test public void getDefineFunctionMethodDeclarationSupportedExpression() { for (Supplier<Expression> supplier : supportedExpressionSupplier) { DefineFunction defineFunction = defineFunctionCreator.apply(supplier); try { DefineFunctionUtils.getDefineFunctionMethodDeclaration(defineFunction); } catch (Exception e) { fail(String.format("Unexpected %s for %s", e, defineFunction.getExpression().getClass())); } } }
@Test(expected = KiePMMLException.class) public void getDefineFunctionMethodDeclarationWithoutExpression() { DefineFunctionUtils.getDefineFunctionMethodDeclaration(new DefineFunction()); }