KiePMMLDescrRhsFactory { protected void commonDeclareOutputFields(final List<KiePMMLOutputField> outputFields, final Object result, final StringJoiner joiner) { outputFields.forEach(kiePMMLOutputField -> { if (PREDICTED_VALUE.equals(kiePMMLOutputField.getResultFeature())) { joiner.add(String.format(ADD_PMML4_OUTPUT_FIELD, kiePMMLOutputField.getName(), result)); } }); } private  KiePMMLDescrRhsFactory(final RuleDescrBuilder builder); static KiePMMLDescrRhsFactory factory(final RuleDescrBuilder builder); void declareRhs(final KiePMMLDroolsRule rule); static final String SET_PMML4_RESULT_CODE; static final String ADD_PMML4_RESULT_VARIABLE; static final String ADD_PMML4_OUTPUT_FIELD; static final String ADD_OUTPUTFIELD_VALUE; static final String UPDATE_STATUS_HOLDER_STATUS; static final String UPDATE_STATUS_HOLDER_ACCUMULATE; static final String UPDATE_STATUS_HOLDER; static final String RETURN_ACCUMULATION; static final String FOCUS_AGENDA_GROUP; }
@Test public void commonDeclareOutputFields() { String outputFieldName = "OUTPUTFIELDNAME"; Object result = "RESULT"; List<KiePMMLOutputField> outputFields = Collections.singletonList(KiePMMLOutputField.builder(outputFieldName, null).withResultFeature(PREDICTED_VALUE).build()); StringJoiner joiner = new StringJoiner(""); KiePMMLDescrRhsFactory.factory(ruleBuilder).commonDeclareOutputFields(outputFields, result, joiner); String retrieved = joiner.toString(); String expected = String.format(ADD_PMML4_OUTPUT_FIELD, outputFieldName, result); assertEquals(expected, retrieved); }