Search in sources :

Example 16 with AnnotationDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.

the class DataModelerEditorsTestHelper method createTestContext.

public static DataModelerContext createTestContext() {
    DataModelerContext context = new DataModelerContext("123456789");
    context.init(PropertyTypeFactoryImpl.getInstance().getBasePropertyTypes());
    List<AnnotationDefinition> commonAnnotations = CommonAnnotations.getCommonAnnotations();
    Map<String, AnnotationDefinition> annotationDefinitions = new HashMap<String, AnnotationDefinition>();
    for (AnnotationDefinition annotationDefinition : commonAnnotations) {
        annotationDefinitions.put(annotationDefinition.getClassName(), annotationDefinition);
    }
    context.setAnnotationDefinitions(annotationDefinitions);
    EditorModelContent content = new EditorModelContent();
    content.setDataModel(createTestModel());
    content.setCurrentModule(new KieModule());
    context.setEditorModelContent(content);
    return context;
}
Also used : AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) HashMap(java.util.HashMap) EditorModelContent(org.kie.workbench.common.screens.datamodeller.model.EditorModelContent) DataModelerContext(org.kie.workbench.common.screens.datamodeller.client.DataModelerContext) KieModule(org.kie.workbench.common.services.shared.project.KieModule)

Example 17 with AnnotationDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.

the class DataModelerScreenPresenterTestBase method createTestAnnotations.

protected Map<String, AnnotationDefinition> createTestAnnotations() {
    Map<String, AnnotationDefinition> annotationsDef = new HashMap<String, AnnotationDefinition>();
    AnnotationDefinition annotationDefinition = DriverUtils.buildAnnotationDefinition(Label.class);
    annotationsDef.put(annotationDefinition.getClassName(), annotationDefinition);
    annotationDefinition = DriverUtils.buildAnnotationDefinition(Description.class);
    annotationsDef.put(annotationDefinition.getClassName(), annotationDefinition);
    return annotationsDef;
}
Also used : AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) Description(org.kie.api.definition.type.Description) HashMap(java.util.HashMap)

Example 18 with AnnotationDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.

the class DataModelerEditorsTestHelper method createAnnotation.

public static Annotation createAnnotation(Class cls, String memberName, Object value) {
    AnnotationDefinition annotationDefinition = DriverUtils.buildAnnotationDefinition(cls);
    Annotation annotation = new AnnotationImpl(annotationDefinition);
    if (memberName != null) {
        annotation.setValue(memberName, value);
    }
    return annotation;
}
Also used : AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation)

Example 19 with AnnotationDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.

the class ValuePairEditorPageTest method testPageInitialization.

@Test
public void testPageInitialization() {
    modelerServiceCaller = new CallerMock<DataModelerService>(modelerService);
    ValuePairEditorPage editorPage = new ValuePairEditorPage(view, valuePairEditorProvider, modelerServiceCaller, wizardPageStatusChangeEvent);
    editorPage.prepareView();
    AnnotationDefinition annotationDefinition = DriverUtils.buildAnnotationDefinition(Entity.class);
    AnnotationValuePairDefinition valuePairDefinition = annotationDefinition.getValuePair("name");
    when(valuePairEditorProvider.getValuePairEditor(valuePairDefinition)).thenReturn(valuePairEditor);
    editorPage.init(annotationDefinition, valuePairDefinition, ElementType.FIELD, kieModule);
    // the view should be properly initialized with the corresponding editor.
    verify(view, times(1)).setValuePairEditor(valuePairEditor);
    // the "name" value pair is not mandatory, so the page is completed.
    WizardTestUtil.assertPageComplete(true, editorPage);
}
Also used : AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) DataModelerService(org.kie.workbench.common.screens.datamodeller.service.DataModelerService) AnnotationValuePairDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition) Test(org.junit.Test)

Example 20 with AnnotationDefinition

use of org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition in project kie-wb-common by kiegroup.

the class JavaRoasterModelDriverTest method createAnnotation.

private Annotation createAnnotation(Class cls, String memberName, Object value) {
    AnnotationDefinition annotationDefinition = DriverUtils.buildAnnotationDefinition(cls);
    Annotation annotation = new AnnotationImpl(annotationDefinition);
    if (memberName != null) {
        annotation.setValue(memberName, value);
    }
    return annotation;
}
Also used : AnnotationDefinition(org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition) AnnotationImpl(org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl) ClassAnnotation(org.kie.workbench.common.services.datamodeller.annotations.ClassAnnotation) EnumsAnnotation(org.kie.workbench.common.services.datamodeller.annotations.EnumsAnnotation) AnnotationValuesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.AnnotationValuesAnnotation) PrimitivesAnnotation(org.kie.workbench.common.services.datamodeller.annotations.PrimitivesAnnotation) TestAnnotation(org.kie.workbench.common.services.datamodeller.parser.test.TestAnnotation) MarkerAnnotation(org.kie.workbench.common.services.datamodeller.annotations.MarkerAnnotation) Annotation(org.kie.workbench.common.services.datamodeller.core.Annotation)

Aggregations

AnnotationDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationDefinition)21 AnnotationValuePairDefinition (org.kie.workbench.common.services.datamodeller.core.AnnotationValuePairDefinition)8 Annotation (org.kie.workbench.common.services.datamodeller.core.Annotation)6 DataObject (org.kie.workbench.common.services.datamodeller.core.DataObject)5 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 AnnotationImpl (org.kie.workbench.common.services.datamodeller.core.impl.AnnotationImpl)4 DataModelerService (org.kie.workbench.common.screens.datamodeller.service.DataModelerService)3 ArrayList (java.util.ArrayList)2 AnnotationSource (org.jboss.forge.roaster.model.source.AnnotationSource)2 AnnotationDriver (org.kie.workbench.common.services.datamodeller.driver.AnnotationDriver)2 JavaRoasterModelDriver (org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver)2 KieModule (org.kie.workbench.common.services.shared.project.KieModule)2 InputStream (java.io.InputStream)1 List (java.util.List)1 Before (org.junit.Before)1 Description (org.kie.api.definition.type.Description)1 ClassTypeResolver (org.kie.soup.project.datamodel.commons.types.ClassTypeResolver)1 DomainHandler (org.kie.workbench.common.screens.datamodeller.backend.server.handler.DomainHandler)1 DataModelerContext (org.kie.workbench.common.screens.datamodeller.client.DataModelerContext)1