static BlockStmt getAttributeVariableDeclaration(final String variableName,
                                                     final Attribute attribute,
                                                     final List<Field<?>> fields) {
        final MethodDeclaration methodDeclaration = ATTRIBUTE_TEMPLATE.getMethodsByName(GETKIEPMMLATTRIBUTE).get(0).clone();
        final BlockStmt attributeBody = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration)));
        final VariableDeclarator variableDeclarator = getVariableDeclarator(attributeBody, ATTRIBUTE) .orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_IN_BODY, ATTRIBUTE, attributeBody)));
        variableDeclarator.setName(variableName);
        final BlockStmt toReturn = new BlockStmt();
        String predicateVariableName =  String.format("%s_Predicate", variableName);
        BlockStmt toAdd = getKiePMMLPredicate(predicateVariableName, attribute.getPredicate(), fields);
        toAdd.getStatements().forEach(toReturn::addStatement);

        final Expression complexPartialScoreExpression;
        if (attribute.getComplexPartialScore() != null) {
            String complexPartialScoreVariableName = String.format("%s_ComplexPartialScore", variableName);
            toAdd = getComplexPartialScoreVariableDeclaration(complexPartialScoreVariableName, attribute.getComplexPartialScore());
            toAdd.getStatements().forEach(toReturn::addStatement);
            complexPartialScoreExpression = new NameExpr(complexPartialScoreVariableName);
        } else {
            complexPartialScoreExpression = new NullLiteralExpr();
        }

        final MethodCallExpr initializer = variableDeclarator.getInitializer()
                .orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_INITIALIZER_TEMPLATE, ATTRIBUTE, attributeBody)))
                .asMethodCallExpr();
        final MethodCallExpr builder = getChainedMethodCallExprFrom("builder", initializer);
        builder.setArgument(0, new StringLiteralExpr(variableName));
        builder.setArgument(2, new NameExpr(predicateVariableName));
        getChainedMethodCallExprFrom("withPartialScore", initializer).setArgument(0, getExpressionForObject(attribute.getPartialScore()));
        getChainedMethodCallExprFrom("withComplexPartialScore", initializer).setArgument(0, complexPartialScoreExpression);
        attributeBody.getStatements().forEach(toReturn::addStatement);
        return toReturn;
    }
@Test
    void getAttributeVariableDeclarationWithComplexPartialScore() throws IOException {
        final String variableName = "variableName";
        Attribute attribute = new Attribute();
        attribute.setReasonCode(REASON_CODE);
        Array.Type arrayType = Array.Type.STRING;
        List<String> values = getStringObjects(arrayType, 4);
        CompoundPredicate compoundPredicate = getCompoundPredicate(values, arrayType);
        attribute.setPredicate(compoundPredicate);
        attribute.setComplexPartialScore(getComplexPartialScore());
        String valuesString = values.stream()
                .map(valueString -> "\"" + valueString + "\"")
                .collect(Collectors.joining(","));
        DataDictionary dataDictionary = new DataDictionary();
        for (Predicate predicate : compoundPredicate.getPredicates()) {
            DataField toAdd = null;
            if (predicate instanceof SimplePredicate) {
                toAdd = new DataField();
                toAdd.setName(((SimplePredicate) predicate).getField());
                toAdd.setDataType(DataType.DOUBLE);
            } else if (predicate instanceof SimpleSetPredicate) {
                toAdd = new DataField();
                toAdd.setName(((SimpleSetPredicate) predicate).getField());
                toAdd.setDataType(DataType.DOUBLE);
            }
            if (toAdd != null) {
                dataDictionary.addDataFields(toAdd);
            }
        }

        BlockStmt retrieved = KiePMMLAttributeFactory.getAttributeVariableDeclaration(variableName, attribute,
                getFieldsFromDataDictionary(dataDictionary));
        String text = getFileContent(TEST_01_SOURCE);
        Statement expected = JavaParserUtils.parseBlock(String.format(text, variableName, valuesString));
        assertThat(JavaParserUtils.equalsNode(expected, retrieved)).isTrue();
        List<Class<?>> imports = Arrays.asList(KiePMMLAttribute.class,
                KiePMMLComplexPartialScore.class,
                KiePMMLCompoundPredicate.class,
                KiePMMLConstant.class,
                KiePMMLSimplePredicate.class,
                KiePMMLSimpleSetPredicate.class,
                Arrays.class,
                Collections.class);
        commonValidateCompilationWithImports(retrieved, imports);
    }