use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.
the class ClassFactBuilderTest method testSuperTypes.
@Test
public void testSuperTypes() throws Exception {
final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
final ClassFactBuilder cb = new ClassFactBuilder(builder, PapaSmurf.class, false, type -> TypeSource.JAVA_PROJECT);
cb.build(oracle);
assertEquals(2, oracle.getModuleSuperTypes().get(PapaSmurf.class.getName()).size());
}
use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.
the class ModuleDataModelFactAnnotationsTest method testModuleDMOAnnotationAttributes2.
@Test
public void testModuleDMOAnnotationAttributes2() throws Exception {
final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
final ClassFactBuilder cb = new ClassFactBuilder(builder, RoleSmurf.class, false, type -> TypeSource.JAVA_PROJECT);
cb.build(oracle);
assertEquals(1, oracle.getModuleModelFields().size());
assertContains("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.RoleSmurf", oracle.getModuleModelFields().keySet());
final Set<Annotation> annotations = oracle.getModuleTypeAnnotations().get("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.RoleSmurf");
assertNotNull(annotations);
assertEquals(1, annotations.size());
final Annotation annotation = annotations.iterator().next();
assertEquals("org.kie.api.definition.type.Role", annotation.getQualifiedTypeName());
assertEquals("EVENT", annotation.getParameters().get("value"));
}
use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.
the class TestPackageNameDrlFileIndexer method getModuleDataModelOracle.
@Override
protected ModuleDataModelOracle getModuleDataModelOracle(Path path) {
final ModuleDataModelOracle dmo = new ModuleDataModelOracleImpl();
dmo.addModuleModelFields(new HashMap<String, ModelField[]>() {
{
put("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", new ModelField[] { new ModelField("age", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER) });
put("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", new ModelField[] { new ModelField("amount", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER) });
put("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", new ModelField[] { new ModelField("applicant", "org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, "org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant") });
put("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Bank", new ModelField[] { new ModelField("mortgage", "org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, "org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage") });
}
});
return dmo;
}
use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.
the class TestDrlFileIndexer method getModuleDataModelOracle.
@Override
protected ModuleDataModelOracle getModuleDataModelOracle(Path path) {
final ModuleDataModelOracle dmo = new ModuleDataModelOracleImpl();
dmo.addModuleModelFields(new HashMap<String, ModelField[]>() {
{
put("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", new ModelField[] { new ModelField("age", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER) });
put("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", new ModelField[] { new ModelField("amount", "java.lang.Integer", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, DataType.TYPE_NUMERIC_INTEGER) });
put("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", new ModelField[] { new ModelField("applicant", "org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, "org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant") });
put("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Bank", new ModelField[] { new ModelField("mortgage", "org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage", ModelField.FIELD_CLASS_TYPE.REGULAR_CLASS, ModelField.FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, "org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Mortgage") });
}
});
return dmo;
}
use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.
the class PackageDataModelOracleTest method testDirectRecursion.
@Test
public void testDirectRecursion() throws Exception {
// Build ModuleDMO
final ModuleDataModelOracleBuilder moduleBuilder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
final ModuleDataModelOracleImpl moduleLoader = new ModuleDataModelOracleImpl();
final ClassFactBuilder cb = new ClassFactBuilder(moduleBuilder, new HashMap<String, FactBuilder>(), TestDirectRecursionClass.class, false, type -> TypeSource.JAVA_PROJECT);
cb.build(moduleLoader);
// Build PackageDMO
final PackageDataModelOracleBuilder packageBuilder = PackageDataModelOracleBuilder.newPackageOracleBuilder(new RawMVELEvaluator(), "org.kie.workbench.common.widgets.client.datamodel.testclasses");
packageBuilder.setModuleOracle(moduleLoader);
final PackageDataModelOracle packageLoader = packageBuilder.build();
// Emulate server-to-client conversions
final Caller<IncrementalDataModelService> service = new MockIncrementalDataModelServiceCaller(packageLoader);
final AsyncPackageDataModelOracle oracle = new AsyncPackageDataModelOracleImpl(service, validatorInstance);
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
dataModel.setPackageName(packageLoader.getPackageName());
dataModel.setModelFields(packageLoader.getModuleModelFields());
dataModel.setTypeAnnotations(packageLoader.getModuleTypeAnnotations());
dataModel.setTypeFieldsAnnotations(packageLoader.getModuleTypeFieldsAnnotations());
PackageDataModelOracleTestUtils.populateDataModelOracle(mock(Path.class), new MockHasImports(), oracle, dataModel);
assertEquals(1, oracle.getFactTypes().length);
assertEquals("TestDirectRecursionClass", oracle.getFactTypes()[0]);
oracle.getFieldCompletions("TestDirectRecursionClass", new Callback<ModelField[]>() {
@Override
public void callback(final ModelField[] result) {
assertEquals(2, result.length);
assertEquals("TestDirectRecursionClass", result[0].getClassName());
assertEquals("recursiveField", result[0].getName());
assertEquals("TestDirectRecursionClass", result[1].getClassName());
assertEquals(DataType.TYPE_THIS, result[1].getName());
}
});
}
Aggregations