Search in sources :

Example 16 with Annotation

use of org.kie.soup.project.datamodel.oracle.Annotation 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"));
}
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 17 with Annotation

use of org.kie.soup.project.datamodel.oracle.Annotation 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);
}
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 18 with Annotation

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

the class ModuleDataModelFactFieldsAnnotationsTest method testBaseAnnotations.

protected void testBaseAnnotations(final Map<String, Set<Annotation>> fieldsAnnotations) {
    assertTrue(fieldsAnnotations.containsKey("occupant"));
    final Set<Annotation> occupantAnnotations = fieldsAnnotations.get("occupant");
    assertNotNull(occupantAnnotations);
    assertEquals(1, occupantAnnotations.size());
    final Annotation occupantAnnotation = occupantAnnotations.iterator().next();
    assertEquals("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfFieldDescriptor", occupantAnnotation.getQualifiedTypeName());
    assertEquals("blue", occupantAnnotation.getParameters().get("colour"));
    assertEquals("M", occupantAnnotation.getParameters().get("gender"));
    assertEquals("Brains", occupantAnnotation.getParameters().get("description"));
    assertTrue(fieldsAnnotations.containsKey("positionedOccupant"));
    final Set<Annotation> posOccupantAnnotations = fieldsAnnotations.get("positionedOccupant");
    assertNotNull(posOccupantAnnotations);
    assertEquals(1, posOccupantAnnotations.size());
    final Annotation annotation2 = posOccupantAnnotations.iterator().next();
    assertEquals("org.kie.workbench.common.services.datamodel.backend.server.testclasses.annotations.SmurfFieldPositionDescriptor", annotation2.getQualifiedTypeName());
    assertEquals(1, annotation2.getParameters().get("value"));
}
Also used : Annotation(org.kie.soup.project.datamodel.oracle.Annotation)

Aggregations

Annotation (org.kie.soup.project.datamodel.oracle.Annotation)18 Test (org.junit.Test)14 ModuleDataModelOracleImpl (org.kie.soup.project.datamodel.commons.oracle.ModuleDataModelOracleImpl)14 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)14 ClassFactBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ClassFactBuilder)14 ModuleDataModelOracleBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.projects.ModuleDataModelOracleBuilder)14 Set (java.util.Set)11 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)9 PackageDataModelOracleBuilder (org.kie.workbench.common.services.datamodel.backend.server.builder.packages.PackageDataModelOracleBuilder)9 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)9 IncrementalDataModelService (org.kie.workbench.common.services.datamodel.service.IncrementalDataModelService)9 Path (org.uberfire.backend.vfs.Path)9 Map (java.util.Map)5 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)2 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 ConstraintViolation (javax.validation.ConstraintViolation)1