KiePMMLDescrFactory { public static PackageDescr getBaseDescr(final KiePMMLDroolsAST kiePMMLDroolsAST, String packageName) { logger.trace("getBaseDescr {} {}", kiePMMLDroolsAST, packageName); PackageDescrBuilder builder = DescrFactory.newPackage() .name(packageName); builder.newImport().target(KiePMMLStatusHolder.class.getName()); builder.newImport().target(SimplePredicate.class.getName()); builder.newImport().target(PMML4Result.class.getName()); builder.newImport().target(Map.class.getName()); builder.newGlobal().identifier(PMML4_RESULT_IDENTIFIER).type(PMML4_RESULT); builder.newGlobal().identifier(OUTPUTFIELDS_MAP_IDENTIFIER).type(OUTPUTFIELDS_MAP); KiePMMLDescrTypesFactory.factory(builder).declareTypes(kiePMMLDroolsAST.getTypes()); KiePMMLDescrRulesFactory.factory(builder).declareRules(kiePMMLDroolsAST.getRules()); return builder.getDescr(); } private  KiePMMLDescrFactory(); static PackageDescr getBaseDescr(final KiePMMLDroolsAST kiePMMLDroolsAST, String packageName); static final String PMML4_RESULT; static final String PMML4_RESULT_IDENTIFIER; static final String OUTPUTFIELDS_MAP; static final String OUTPUTFIELDS_MAP_IDENTIFIER; }
@Test public void getBaseDescr() { List<KiePMMLDroolsType> types = new ArrayList<>(); types.add(KiePMMLDescrTestUtils.getDroolsType()); types.add(KiePMMLDescrTestUtils.getDottedDroolsType()); List<KiePMMLFieldOperatorValue> orConstraints = Arrays.asList(new KiePMMLFieldOperatorValue(PATTERN_TYPE, BOOLEAN_OPERATOR.OR, Collections.singletonList(new KiePMMLOperatorValue(OPERATOR.LESS_THAN, 35)), null), new KiePMMLFieldOperatorValue(PATTERN_TYPE, BOOLEAN_OPERATOR.AND, Collections.singletonList(new KiePMMLOperatorValue(OPERATOR.GREATER_THAN, 85)), null)); KiePMMLDroolsRule rule = KiePMMLDroolsRule.builder(RULE_NAME, STATUS_TO_SET, Collections.emptyList()) .withOrConstraints(orConstraints) .build(); List<KiePMMLDroolsRule> rules = new ArrayList<>(); rules.add(rule); KiePMMLDroolsAST drooledAST = new KiePMMLDroolsAST(types, rules); PackageDescr packageDescr = KiePMMLDescrFactory.getBaseDescr(drooledAST, PACKAGE_NAME); assertEquals(PACKAGE_NAME, packageDescr.getName()); checkImports(packageDescr.getImports()); checkGlobals(packageDescr.getGlobals()); checkRules(packageDescr.getRules()); }