use of org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder in project kie-wb-common by kiegroup.
the class PackageDataModelFactFieldsAnnotationsTest method testCorrectPackageDMOZeroAnnotationAttributes.
@Test
public void testCorrectPackageDMOZeroAnnotationAttributes() throws Exception {
// Build ModuleDMO
final ModuleDataModelOracleBuilder moduleBuilder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
final ModuleDataModelOracleImpl moduleLoader = new ModuleDataModelOracleImpl();
final ClassFactBuilder cb = new ClassFactBuilder(moduleBuilder, Product.class, false, 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("Product", oracle.getFactTypes()[0]);
oracle.getTypeFieldsAnnotations("Product", new Callback<Map<String, Set<Annotation>>>() {
@Override
public void callback(final Map<String, Set<Annotation>> fieldsAnnotations) {
assertNotNull(fieldsAnnotations);
assertEquals(0, fieldsAnnotations.size());
}
});
}
use of org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder in project kie-wb-common by kiegroup.
the class ModuleDataModelFactAnnotationsTest method testModuleDMOZeroAnnotationAttributes.
@Test
public void testModuleDMOZeroAnnotationAttributes() throws Exception {
final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
final ClassFactBuilder cb = new ClassFactBuilder(builder, Product.class, false, TypeSource.JAVA_PROJECT);
cb.build(oracle);
assertEquals(1, oracle.getModuleModelFields().size());
assertContains("org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product", oracle.getModuleModelFields().keySet());
final Set<Annotation> annotations = oracle.getModuleTypeAnnotations().get("org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product");
assertNotNull(annotations);
assertEquals(0, annotations.size());
}
use of org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder in project kie-wb-common by kiegroup.
the class ModuleDataModelFactAnnotationsTest method annotationsWithMemberOfTypeClass.
@Test
public void annotationsWithMemberOfTypeClass() throws Exception {
final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
final ClassFactBuilder cb = new ClassFactBuilder(builder, JAXBSmurf.class, false, TypeSource.JAVA_PROJECT);
cb.build(oracle);
assertEquals(1, oracle.getModuleModelFields().size());
assertContains("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.JAXBSmurf", oracle.getModuleModelFields().keySet());
final Set<Annotation> annotations = oracle.getModuleTypeAnnotations().get("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.JAXBSmurf");
assertNotNull(annotations);
assertEquals(1, annotations.size());
final Annotation annotation = annotations.iterator().next();
assertEquals("javax.xml.bind.annotation.XmlType", annotation.getQualifiedTypeName());
assertEquals(5, annotation.getParameters().size());
assertEquals("smurf-namespace", annotation.getParameters().get("namespace"));
assertEquals("smurf-xsd", annotation.getParameters().get("name"));
assertArraysEqual(new String[] { "name", "colour" }, (String[]) annotation.getParameters().get("propOrder"));
assertTrue(annotation.getParameters().get("factoryClass").toString().contains("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.JAXBSmurfFactory"));
}
use of org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder in project kie-wb-common by kiegroup.
the class ModuleDataModelFactAnnotationsTest method testModuleDMOAnnotationAttributes.
@Test
public void testModuleDMOAnnotationAttributes() throws Exception {
final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
final ClassFactBuilder cb = new ClassFactBuilder(builder, Smurf.class, false, TypeSource.JAVA_PROJECT);
cb.build(oracle);
assertEquals(1, oracle.getModuleModelFields().size());
assertContains("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.Smurf", oracle.getModuleModelFields().keySet());
final Set<Annotation> annotations = oracle.getModuleTypeAnnotations().get("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.Smurf");
assertNotNull(annotations);
assertEquals(1, annotations.size());
final Annotation annotation = annotations.iterator().next();
assertEquals("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfDescriptor", annotation.getQualifiedTypeName());
assertEquals("blue", annotation.getParameters().get("colour"));
assertEquals("M", annotation.getParameters().get("gender"));
assertEquals("Brains", annotation.getParameters().get("description"));
}
use of org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder in project kie-wb-common by kiegroup.
the class ModuleDataModelFactFieldsAnnotationsTest method testModuleDMOInheritedAnnotationAttributes.
@Test
public void testModuleDMOInheritedAnnotationAttributes() throws Exception {
final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
final ClassFactBuilder cb = new ClassFactBuilder(builder, SmurfMajorHouse.class, false, TypeSource.JAVA_PROJECT);
cb.build(oracle);
assertEquals(1, oracle.getModuleModelFields().size());
assertContains("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfMajorHouse", oracle.getModuleModelFields().keySet());
final Map<String, Set<Annotation>> fieldsAnnotations = oracle.getModuleTypeFieldsAnnotations().get("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfMajorHouse");
assertNotNull(fieldsAnnotations);
assertEquals(3, fieldsAnnotations.size());
assertTrue(fieldsAnnotations.containsKey("major"));
final Set<Annotation> majorAnnotations = fieldsAnnotations.get("major");
assertNotNull(majorAnnotations);
assertEquals(1, majorAnnotations.size());
final Annotation majorAnnotation = majorAnnotations.iterator().next();
assertEquals("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfFieldDescriptor", majorAnnotation.getQualifiedTypeName());
assertEquals("red", majorAnnotation.getParameters().get("colour"));
assertEquals("M", majorAnnotation.getParameters().get("gender"));
assertEquals("Papa Smurf", majorAnnotation.getParameters().get("description"));
testBaseAnnotations(fieldsAnnotations);
}
Aggregations