@Test
public void commonDeclareThen() {

    String ruleName = "RULENAME";
    String statusToSet = "STATUSTOSET";
    String outputFieldName = "OUTPUTFIELDNAME";
    Object result = "RESULT";
    List<KiePMMLOutputField> outputFields = Collections.singletonList(KiePMMLOutputField.builder(outputFieldName, null).withResultFeature(PREDICTED_VALUE).build());
    KiePMMLDroolsRule.Builder builder = KiePMMLDroolsRule.builder(ruleName, statusToSet, outputFields);
    KiePMMLDroolsRule rule = builder.build();
    StringJoiner joiner = new StringJoiner("");
    KiePMMLDescrRhsFactory.factory(ruleBuilder).commonDeclareThen(rule, joiner);
    String retrieved = joiner.toString();
    assertTrue(retrieved.isEmpty());
    //
    ResultCode resultCode = ResultCode.OK;
    builder = builder.withResultCode(resultCode);
    rule = builder.build();
    joiner = new StringJoiner("");
    KiePMMLDescrRhsFactory.factory(ruleBuilder).commonDeclareThen(rule, joiner);
    retrieved = joiner.toString();
    String expected = String.format(SET_PMML4_RESULT_CODE, resultCode);
    assertTrue(retrieved.contains(expected));
    //
    builder = builder.withResult(result);
    rule = builder.build();
    joiner = new StringJoiner("");
    KiePMMLDescrRhsFactory.factory(ruleBuilder).commonDeclareThen(rule, joiner);
    retrieved = joiner.toString();
    expected = String.format(ADD_PMML4_RESULT_VARIABLE, result);
    assertTrue(retrieved.contains(expected));
    expected = String.format(ADD_PMML4_OUTPUT_FIELD, outputFieldName, result);
    assertTrue(retrieved.contains(expected));
    //
    String focusedAgendaGroup = "FOCUSEDAGENDAGROUP";
    builder = builder.withFocusedAgendaGroup(focusedAgendaGroup);
    rule = builder.build();
    joiner = new StringJoiner("");
    KiePMMLDescrRhsFactory.factory(ruleBuilder).commonDeclareThen(rule, joiner);
    retrieved = joiner.toString();
    expected = String.format(FOCUS_AGENDA_GROUP, focusedAgendaGroup);
    assertTrue(retrieved.contains(expected));
    //
}