@Test
public void getApplyExpressionNestedBlockStmt() {

    Apply nestedApply = applySupplier.get();
    Constant constant = new Constant();
    constant.setDataType(DataType.STRING);
    constant.setValue("STRING_VALUE");
    String functionName = "EXTERNAL_FUNCTION_NAME";
    Apply apply = new Apply();
    apply.addExpressions(constant, nestedApply);
    apply.setFunction(functionName);
    String variableName = "VARIABLE_NAME";
    BlockStmt retrieved = ExpressionFunctionUtils.getApplyExpressionBlockStmt(variableName, apply,
                                                                              parseClassOrInterfaceType(Object.class.getName()), DEFAULT_PARAMETERTYPE_MAP);
    String expected = "{\n" +
            "    java.lang.Object variableVARIABLE_NAMEConstant1 = \"STRING_VALUE\";\n" +
            "    java.lang.Object variablevariableVARIABLE_NAMEApply2Constant1 = 34.6;\n" +
            "    java.util.Optional<org.kie.pmml.commons.model.tuples.KiePMMLNameValue> kiePMMLNameValue = param1" +
            ".stream().filter((org.kie.pmml.commons.model.tuples.KiePMMLNameValue lmbdParam) -> java.util.Objects" +
            ".equals(\"FIELD_REF\", lmbdParam.getName())).findFirst();\n" +
            "    java.lang.Object variablevariableVARIABLE_NAMEApply2FieldRef2 = (java.lang.Object) " +
            "kiePMMLNameValue.map(org.kie.pmml.commons.model.tuples.KiePMMLNameValue::getValue).orElse(null);\n" +
            "    java.lang.Object variableVARIABLE_NAMEApply2 = this.FUNCTION_NAME(param1, " +
            "variablevariableVARIABLE_NAMEApply2Constant1, variablevariableVARIABLE_NAMEApply2FieldRef2);\n" +
            "    java.lang.Object VARIABLE_NAME = this.EXTERNAL_FUNCTION_NAME(param1, " +
            "variableVARIABLE_NAMEConstant1, variableVARIABLE_NAMEApply2);\n" +
            "}";
    assertEquals(expected, retrieved.toString());
}