use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.
the class KiePMMLScorecardModelCharacteristicASTFactoryTest method getKiePMMLScorecardModelCharacteristicASTFactory.
private KiePMMLScorecardModelCharacteristicASTFactory getKiePMMLScorecardModelCharacteristicASTFactory() {
final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
final List<Field<?>> fields = getFieldsFromDataDictionary(samplePmml.getDataDictionary());
DATA_TYPE targetType = getTargetFieldType(fields, scorecardModel);
KiePMMLDataDictionaryASTFactory.factory(fieldTypeMap).declareTypes(fields);
assertFalse(fieldTypeMap.isEmpty());
return KiePMMLScorecardModelCharacteristicASTFactory.factory(fieldTypeMap, Collections.emptyList(), targetType);
}
use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.
the class InstanceFactoriesTestCommon method commonVerifyKiePMMLDefineFunction.
static void commonVerifyKiePMMLDefineFunction(KiePMMLDefineFunction toVerify, DefineFunction source) {
assertNotNull(toVerify);
assertEquals(source.getName(), toVerify.getName());
DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
assertEquals(expectedDataType, toVerify.getDataType());
OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
assertEquals(expectedOpType, toVerify.getOpType());
commonVerifyKiePMMLExpression(toVerify.getKiePMMLExpression(), source.getExpression());
List<ParameterField> sourcesParameterFields = source.getParameterFields();
List<KiePMMLParameterField> toVerifyList = toVerify.getParameterFields();
assertEquals(sourcesParameterFields.size(), toVerifyList.size());
sourcesParameterFields.forEach(paramSource -> {
Optional<KiePMMLParameterField> parameterToVerify = toVerifyList.stream().filter(param -> param.getName().equals(paramSource.getName().getValue())).findFirst();
assertTrue(parameterToVerify.isPresent());
commonVerifyKiePMMLParameterField(parameterToVerify.get(), paramSource);
});
}
use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.
the class InstanceFactoriesTestCommon method commonVerifyKiePMMLDerivedField.
static void commonVerifyKiePMMLDerivedField(KiePMMLDerivedField toVerify, DerivedField source) {
assertNotNull(toVerify);
assertEquals(source.getName().getValue(), toVerify.getName());
DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
assertEquals(expectedDataType, toVerify.getDataType());
OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
assertEquals(expectedOpType, toVerify.getOpType());
String expectedDisplayName = "Display-" + source.getName().getValue();
assertEquals(expectedDisplayName, toVerify.getDisplayName());
commonVerifyKiePMMLExpression(toVerify.getKiePMMLExpression(), source.getExpression());
}
use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.
the class InstanceFactoriesTestCommon method commonVerifyKiePMMLParameterField.
static void commonVerifyKiePMMLParameterField(KiePMMLParameterField toVerify, ParameterField source) {
assertNotNull(toVerify);
assertEquals(source.getName().getValue(), toVerify.getName());
DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
assertEquals(expectedDataType, toVerify.getDataType());
OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
assertEquals(expectedOpType, toVerify.getOpType());
String expectedDisplayName = "Display-" + source.getName().getValue();
assertEquals(expectedDisplayName, toVerify.getDisplayName());
}
use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.
the class ModelUtilsTest method convertToKieOutputField.
@Test
public void convertToKieOutputField() {
final OutputField toConvert = getRandomOutputField();
org.kie.pmml.api.models.OutputField retrieved = ModelUtils.convertToKieOutputField(toConvert, null);
assertNotNull(retrieved);
assertEquals(toConvert.getName().getValue(), retrieved.getName());
OP_TYPE expectedOpType = OP_TYPE.byName(toConvert.getOpType().value());
assertEquals(expectedOpType, retrieved.getOpType());
DATA_TYPE expectedDataType = DATA_TYPE.byName(toConvert.getDataType().value());
assertEquals(expectedDataType, retrieved.getDataType());
assertEquals(toConvert.getTargetField().getValue(), retrieved.getTargetField());
RESULT_FEATURE expectedResultFeature = RESULT_FEATURE.byName(toConvert.getResultFeature().value());
assertEquals(expectedResultFeature, retrieved.getResultFeature());
toConvert.setOpType(null);
toConvert.setTargetField(null);
retrieved = ModelUtils.convertToKieOutputField(toConvert, null);
assertNull(retrieved.getOpType());
assertNull(retrieved.getTargetField());
}
Aggregations