use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.
the class KiePMMLModelFactoryUtilsTest method populateGetCreatedKiePMMLMiningFieldsMethod.
@Test
public void populateGetCreatedKiePMMLMiningFieldsMethod() throws IOException {
final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
KiePMMLModelFactoryUtils.populateGetCreatedKiePMMLMiningFieldsMethod(classOrInterfaceDeclaration, compilationDTO.getMiningSchema().getMiningFields(), compilationDTO.getFields());
final MethodDeclaration retrieved = classOrInterfaceDeclaration.getMethodsByName(GET_CREATED_KIEPMMLMININGFIELDS).get(0);
String text = getFileContent(TEST_12_SOURCE);
BlockStmt expected = JavaParserUtils.parseBlock(text);
assertTrue(JavaParserUtils.equalsNode(expected, retrieved.getBody().get()));
}
use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.
the class KiePMMLModelFactoryUtilsTest method populateGetCreatedMiningFieldsMethod.
@Test
public void populateGetCreatedMiningFieldsMethod() throws IOException {
final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
KiePMMLModelFactoryUtils.populateGetCreatedMiningFieldsMethod(classOrInterfaceDeclaration, compilationDTO.getKieMiningFields());
final MethodDeclaration retrieved = classOrInterfaceDeclaration.getMethodsByName(GET_CREATED_MININGFIELDS).get(0);
String text = getFileContent(TEST_14_SOURCE);
MethodDeclaration expected = JavaParserUtils.parseMethod(text);
assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
}
use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.
the class KiePMMLModelFactoryUtilsTest method commonPopulateGetCreatedKiePMMLMiningFieldsMethod.
@Test
public void commonPopulateGetCreatedKiePMMLMiningFieldsMethod() throws IOException {
final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
final MethodDeclaration methodDeclaration = new MethodDeclaration();
KiePMMLModelFactoryUtils.commonPopulateGetCreatedKiePMMLMiningFieldsMethod(methodDeclaration, compilationDTO.getMiningSchema().getMiningFields(), compilationDTO.getFields());
String text = getFileContent(TEST_06_SOURCE);
MethodDeclaration expected = JavaParserUtils.parseMethod(text);
assertTrue(JavaParserUtils.equalsNode(expected, methodDeclaration));
}
use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.
the class KiePMMLModelFactoryUtilsTest method initStaticGetter.
@Test
public void initStaticGetter() throws IOException {
final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
KiePMMLModelFactoryUtils.initStaticGetter(compilationDTO, classOrInterfaceDeclaration);
String text = getFileContent(TEST_04_SOURCE);
MethodDeclaration expected = JavaParserUtils.parseMethod(text);
assertEquals(expected.toString(), staticGetterMethod.toString());
assertTrue(JavaParserUtils.equalsNode(expected, staticGetterMethod));
}
use of org.kie.pmml.compiler.commons.mocks.HasClassLoaderMock in project drools by kiegroup.
the class KiePMMLModelFactoryUtilsTest method init.
@Test
public void init() throws IOException {
final CompilationDTO compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmmlModel, model, new HasClassLoaderMock());
KiePMMLModelFactoryUtils.init(compilationDTO, classOrInterfaceDeclaration);
BlockStmt body = constructorDeclaration.getBody();
String text = getFileContent(TEST_03_SOURCE);
Statement expected = JavaParserUtils.parseConstructorBlock(text);
assertTrue(JavaParserUtils.equalsNode(expected, body));
}
Aggregations