Search in sources :

Example 21 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl 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, type -> 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);
}
Also used : Set(java.util.Set) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl) ClassFactBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder) Annotation(org.kie.soup.project.datamodel.oracle.Annotation) ModuleDataModelOracleBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder) Test(org.junit.Test)

Example 22 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl 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, type -> 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"));
}
Also used : RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl) ClassFactBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder) Annotation(org.kie.soup.project.datamodel.oracle.Annotation) ModuleDataModelOracleBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder) Test(org.junit.Test)

Example 23 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl 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, type -> 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());
}
Also used : RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl) ClassFactBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder) Annotation(org.kie.soup.project.datamodel.oracle.Annotation) ModuleDataModelOracleBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder) Test(org.junit.Test)

Example 24 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl 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, type -> 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"));
}
Also used : RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl) ClassFactBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder) Annotation(org.kie.soup.project.datamodel.oracle.Annotation) ModuleDataModelOracleBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder) Test(org.junit.Test)

Example 25 with ModuleDataModelOracleImpl

use of org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl in project kie-wb-common by kiegroup.

the class ModuleDataModelFactFieldsGenericsTest method testModuleDMOGenericParameters.

@Test
public void testModuleDMOGenericParameters() throws Exception {
    final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator());
    final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl();
    final ClassFactBuilder cb = new ClassFactBuilder(builder, ProductOrder.class, false, type -> TypeSource.JAVA_PROJECT);
    cb.build(oracle);
    assertEquals(1, oracle.getModuleModelFields().size());
    assertContains(ProductOrder.class.getName(), oracle.getModuleModelFields().keySet());
    assertEquals(2, oracle.getModuleFieldParametersType().size());
    String genericType = oracle.getModuleFieldParametersType().get(ProductOrder.class.getName() + "#products");
    assertNotNull(genericType);
    assertEquals(Product.class.getName(), genericType);
    genericType = oracle.getModuleFieldParametersType().get(ProductOrder.class.getName() + "#productComparator");
    assertNotNull(genericType);
    assertEquals(Product.class.getName(), genericType);
    assertNotNull(cb.getInternalBuilders().get(Product.class.getName()));
}
Also used : RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) Product(org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product) ModuleDataModelOracleImpl(org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl) ClassFactBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder) ProductOrder(org.kie.workbench.common.services.datamodel.backend.server.testclasses.ProductOrder) ModuleDataModelOracleBuilder(org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder) Test(org.junit.Test)

Aggregations

ModuleDataModelOracleImpl (org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)37 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)22 Test (org.junit.Test)20 ClassFactBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder)20 ModuleDataModelOracleBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder)20 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)15 Annotation (org.kie.soup.project.datamodel.oracle.Annotation)14 ModuleDataModelOracle (org.kie.soup.project.datamodel.oracle.ModuleDataModelOracle)14 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)13 Set (java.util.Set)12 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)12 PackageDataModelOracleBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.packages.PackageDataModelOracleBuilder)12 IncrementalDataModelService (org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService)12 Path (org.uberfire.backend.vfs.Path)12 Map (java.util.Map)4 FactBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.projects.FactBuilder)2 Applicant (org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant)1 Before (org.junit.Before)1 APerson (org.kie.workbench.common.dmn.backend.editors.types.classes.APerson)1 Product (org.kie.workbench.common.services.datamodel.backend.server.testclasses.Product)1