DerivedFieldFunctionUtils { static MethodDeclaration getDerivedFieldMethodDeclaration(final DerivedField derivedField, final AtomicInteger arityCounter) { final Expression expression = derivedField.getExpression(); if (expression != null) { return getExpressionMethodDeclaration(expression, derivedField.getDataType(), arityCounter); } else { throw new KiePMMLException("Derived field without Expression are not supported, yet"); } } private  DerivedFieldFunctionUtils();   }
@Test public void getDerivedFieldMethodDeclarationUnsupportedExpression() { for (Supplier<Expression> supplier : unsupportedExpressionSupplier) { DerivedField derivedField = derivedFieldCreator.apply(supplier); try { DerivedFieldFunctionUtils.getDerivedFieldMethodDeclaration(derivedField, new AtomicInteger()); fail(String.format("Expecting KiePMMLException for %s", derivedField)); } catch (Exception e) { assertEquals(KiePMMLException.class, e.getClass()); } } }
@Test public void getDerivedFieldMethodDeclarationSupportedExpression() { for (Supplier<Expression> supplier : supportedExpressionSupplier) { DerivedField derivedField = derivedFieldCreator.apply(supplier); try { DerivedFieldFunctionUtils.getDerivedFieldMethodDeclaration(derivedField, new AtomicInteger()); } catch (Exception e) { fail(String.format("Unexpected %s for %s", e, derivedField.getExpression().getClass())); } } }
@Test(expected = KiePMMLException.class) public void getDerivedFieldMethodDeclarationWithoutExpression() { DerivedFieldFunctionUtils.getDerivedFieldMethodDeclaration(new DerivedField(), new AtomicInteger()); }