@Test public void getKiePMMLSimpleSetPredicateSourcesMap() { String predicateName = "PREDICATENAME"; ARRAY_TYPE arrayType = ARRAY_TYPE.STRING; IN_NOTIN inNotIn = IN_NOTIN.IN; List<Object> values = getObjects(arrayType, 3); KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate = KiePMMLSimpleSetPredicate .builder(predicateName, Collections.emptyList(), arrayType, inNotIn) .withValues(values) .build(); String packageName = "PACKAGENAME"; final Map<String, String> retrieved = KiePMMLPredicateFactory.getKiePMMLSimpleSetPredicateSourcesMap(kiePMMLSimpleSetPredicate, packageName); commonVerifySourceMap(retrieved, packageName, getSanitizedClassName(kiePMMLSimpleSetPredicate.getId()), 1); }
static Map<String, String> getKiePMMLSimpleSetPredicateSourcesMap(final KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate, final String packageName) { String className = getSanitizedClassName(kiePMMLSimpleSetPredicate.getId()); CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(className, packageName, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE_JAVA, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE); ClassOrInterfaceDeclaration predicateTemplate = cloneCU.getClassByName(className) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className)); final ConstructorDeclaration constructorDeclaration = predicateTemplate.getDefaultConstructor() .orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, predicateTemplate.getName()))); setSimpleSetPredicateConstructor(className, kiePMMLSimpleSetPredicate.getName(), constructorDeclaration, kiePMMLSimpleSetPredicate.getArrayType(), kiePMMLSimpleSetPredicate.getInNotIn(), kiePMMLSimpleSetPredicate.getValues()); return Collections.singletonMap(getFullClassName(cloneCU), cloneCU.toString()); }
KiePMMLPredicateFactory { static Map<String, String> getKiePMMLSimpleSetPredicateSourcesMap(final KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate, final String packageName) { String className = getSanitizedClassName(kiePMMLSimpleSetPredicate.getId()); CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(className, packageName, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE_JAVA, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE); ClassOrInterfaceDeclaration predicateTemplate = cloneCU.getClassByName(className) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className)); final ConstructorDeclaration constructorDeclaration = predicateTemplate.getDefaultConstructor() .orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, predicateTemplate.getName()))); setSimpleSetPredicateConstructor(className, kiePMMLSimpleSetPredicate.getName(), constructorDeclaration, kiePMMLSimpleSetPredicate.getArrayType(), kiePMMLSimpleSetPredicate.getInNotIn(), kiePMMLSimpleSetPredicate.getValues()); return Collections.singletonMap(getFullClassName(cloneCU), cloneCU.toString()); } }
KiePMMLPredicateFactory { static Map<String, String> getKiePMMLSimpleSetPredicateSourcesMap(final KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate, final String packageName) { String className = getSanitizedClassName(kiePMMLSimpleSetPredicate.getId()); CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(className, packageName, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE_JAVA, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE); ClassOrInterfaceDeclaration predicateTemplate = cloneCU.getClassByName(className) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className)); final ConstructorDeclaration constructorDeclaration = predicateTemplate.getDefaultConstructor() .orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, predicateTemplate.getName()))); setSimpleSetPredicateConstructor(className, kiePMMLSimpleSetPredicate.getName(), constructorDeclaration, kiePMMLSimpleSetPredicate.getArrayType(), kiePMMLSimpleSetPredicate.getInNotIn(), kiePMMLSimpleSetPredicate.getValues()); return Collections.singletonMap(getFullClassName(cloneCU), cloneCU.toString()); } private  KiePMMLPredicateFactory(); }
KiePMMLPredicateFactory { static Map<String, String> getKiePMMLSimpleSetPredicateSourcesMap(final KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate, final String packageName) { String className = getSanitizedClassName(kiePMMLSimpleSetPredicate.getId()); CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(className, packageName, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE_JAVA, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE); ClassOrInterfaceDeclaration predicateTemplate = cloneCU.getClassByName(className) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className)); final ConstructorDeclaration constructorDeclaration = predicateTemplate.getDefaultConstructor() .orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, predicateTemplate.getName()))); setSimpleSetPredicateConstructor(className, kiePMMLSimpleSetPredicate.getName(), constructorDeclaration, kiePMMLSimpleSetPredicate.getArrayType(), kiePMMLSimpleSetPredicate.getInNotIn(), kiePMMLSimpleSetPredicate.getValues()); return Collections.singletonMap(getFullClassName(cloneCU), cloneCU.toString()); } private  KiePMMLPredicateFactory(); static List<KiePMMLPredicate> getPredicates(List<Predicate> predicates, DataDictionary dataDictionary); static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary); static KiePMMLSimplePredicate getKiePMMLSimplePredicate(SimplePredicate predicate, DataType dataType); static KiePMMLSimpleSetPredicate getKiePMMLSimpleSetPredicate(SimpleSetPredicate predicate); static KiePMMLCompoundPredicate getKiePMMLCompoundPredicate(CompoundPredicate predicate,
                                                                       DataDictionary dataDictionary); static KiePMMLTruePredicate getKiePMMLTruePredicate(); static KiePMMLFalsePredicate getKiePMMLFalsePredicate(); static Map<String, String> getPredicateSourcesMap(final KiePMMLPredicate kiePMMLPredicate,
                                                             final String packageName); }
KiePMMLPredicateFactory { static Map<String, String> getKiePMMLSimpleSetPredicateSourcesMap(final KiePMMLSimpleSetPredicate kiePMMLSimpleSetPredicate, final String packageName) { String className = getSanitizedClassName(kiePMMLSimpleSetPredicate.getId()); CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(className, packageName, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE_JAVA, KIE_PMML_SIMPLE_SET_PREDICATE_TEMPLATE); ClassOrInterfaceDeclaration predicateTemplate = cloneCU.getClassByName(className) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className)); final ConstructorDeclaration constructorDeclaration = predicateTemplate.getDefaultConstructor() .orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, predicateTemplate.getName()))); setSimpleSetPredicateConstructor(className, kiePMMLSimpleSetPredicate.getName(), constructorDeclaration, kiePMMLSimpleSetPredicate.getArrayType(), kiePMMLSimpleSetPredicate.getInNotIn(), kiePMMLSimpleSetPredicate.getValues()); return Collections.singletonMap(getFullClassName(cloneCU), cloneCU.toString()); } private  KiePMMLPredicateFactory(); static List<KiePMMLPredicate> getPredicates(List<Predicate> predicates, DataDictionary dataDictionary); static KiePMMLPredicate getPredicate(Predicate predicate, DataDictionary dataDictionary); static KiePMMLSimplePredicate getKiePMMLSimplePredicate(SimplePredicate predicate, DataType dataType); static KiePMMLSimpleSetPredicate getKiePMMLSimpleSetPredicate(SimpleSetPredicate predicate); static KiePMMLCompoundPredicate getKiePMMLCompoundPredicate(CompoundPredicate predicate,
                                                                       DataDictionary dataDictionary); static KiePMMLTruePredicate getKiePMMLTruePredicate(); static KiePMMLFalsePredicate getKiePMMLFalsePredicate(); static Map<String, String> getPredicateSourcesMap(final KiePMMLPredicate kiePMMLPredicate,
                                                             final String packageName);  }