static BlockStmt getCharacteristicVariableDeclaration(final String variableName,
                                                          final Characteristic characteristic,
                                                          final List<Field<?>> fields) {
        final MethodDeclaration methodDeclaration =
                CHARACTERISTIC_TEMPLATE.getMethodsByName(GETKIEPMMLCHARACTERISTIC).get(0).clone();
        final BlockStmt characteristicBody =
                methodDeclaration.getBody().orElseThrow(() -> new KiePMMLException(String.format(MISSING_BODY_TEMPLATE, methodDeclaration)));
        final VariableDeclarator variableDeclarator =
                getVariableDeclarator(characteristicBody, CHARACTERISTIC).orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_IN_BODY, CHARACTERISTIC, characteristicBody)));
        variableDeclarator.setName(variableName);
        final BlockStmt toReturn = new BlockStmt();
        int counter = 0;
        NodeList<Expression> arguments = new NodeList<>();
        for (Attribute attribute : characteristic.getAttributes()) {
            String attributeVariableName = String.format(VARIABLE_NAME_TEMPLATE, variableName, counter);
            BlockStmt toAdd = getAttributeVariableDeclaration(attributeVariableName, attribute, fields);
            toAdd.getStatements().forEach(toReturn::addStatement);
            arguments.add(new NameExpr(attributeVariableName));
            counter++;
        }
        final MethodCallExpr initializer = variableDeclarator.getInitializer()
                .orElseThrow(() -> new KiePMMLException(String.format(MISSING_VARIABLE_INITIALIZER_TEMPLATE,
                                                                      CHARACTERISTIC, characteristicBody)))
                .asMethodCallExpr();
        final MethodCallExpr builder = getChainedMethodCallExprFrom("builder", initializer);
        builder.setArgument(0, new StringLiteralExpr(variableName));
        builder.setArgument(2, getArraysAsListInvocationMethodCall(arguments));
        getChainedMethodCallExprFrom("withBaselineScore", initializer).setArgument(0,
                                                                                   getExpressionForObject(characteristic.getBaselineScore()));
        getChainedMethodCallExprFrom("withReasonCode", initializer).setArgument(0,
                                                                                getExpressionForObject(characteristic.getReasonCode()));
        characteristicBody.getStatements().forEach(toReturn::addStatement);
        return toReturn;
    }
@Test
    void getAttributeVariableDeclarationWithComplexPartialScore() throws IOException {
        final String variableName = "variableName";
        Array.Type arrayType = Array.Type.STRING;
        List<String> values1 = getStringObjects(arrayType, 4);
        Attribute attribute1 = getAttribute(values1, 1);
        List<String> values2 = getStringObjects(arrayType, 4);
        Attribute attribute2 = getAttribute(values2, 2);

        CompoundPredicate compoundPredicate1 = (CompoundPredicate) attribute1.getPredicate();
        CompoundPredicate compoundPredicate2 = (CompoundPredicate) attribute2.getPredicate();
        DataDictionary dataDictionary = new DataDictionary();
        for (Predicate predicate : compoundPredicate1.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);
            }
        }
        for (Predicate predicate : compoundPredicate2.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);
            }
        }

        String valuesString1 = values1.stream()
                .map(valueString -> "\"" + valueString + "\"")
                .collect(Collectors.joining(","));
        String valuesString2 = values2.stream()
                .map(valueString -> "\"" + valueString + "\"")
                .collect(Collectors.joining(","));
        Characteristic characteristic = new Characteristic();
        characteristic.addAttributes(attribute1, attribute2);
        characteristic.setBaselineScore(22);
        characteristic.setReasonCode(REASON_CODE);

        BlockStmt retrieved = KiePMMLCharacteristicFactory.getCharacteristicVariableDeclaration(variableName,
                characteristic,
                getFieldsFromDataDictionary(dataDictionary));
        String text = getFileContent(TEST_01_SOURCE);
        Statement expected = JavaParserUtils.parseBlock(String.format(text, variableName,
                valuesString1,
                valuesString2,
                characteristic.getBaselineScore(),
                characteristic.getReasonCode()));
        assertThat(JavaParserUtils.equalsNode(expected, retrieved)).isTrue();
        List<Class<?>> imports = Arrays.asList(KiePMMLAttribute.class,
                KiePMMLCharacteristic.class,
                KiePMMLComplexPartialScore.class,
                KiePMMLCompoundPredicate.class,
                KiePMMLConstant.class,
                KiePMMLSimplePredicate.class,
                KiePMMLSimpleSetPredicate.class,
                Arrays.class,
                Collections.class);
        commonValidateCompilationWithImports(retrieved, imports);
    }