Search in sources :

Example 1 with TestFieldManager

use of org.kie.workbench.common.forms.fields.test.TestFieldManager in project kie-wb-common by kiegroup.

the class FormDefinitionGeneratorImplTest method init.

@Before
public void init() throws Exception {
    SimpleFileSystemProvider simpleFileSystemProvider = new SimpleFileSystemProvider();
    simpleFileSystemProvider.forceAsDefault();
    Definitions processDefinitions = BPMN2Utils.getDefinitions(FormDefinitionGeneratorImplTest.class.getResourceAsStream(PROCESS_PATH));
    // Prepare BPMNFormModelGenerator
    when(kieModuleService.resolveModule(any())).thenReturn(module);
    when(module.getRootPath()).thenReturn(path);
    when(moduleClassLoaderHelper.getModuleClassLoader(module)).thenReturn(moduleClassLoader);
    when(moduleClassLoader.loadClass(anyString())).thenAnswer(invocation -> Object.class);
    BPMNFormModelGenerator bpmnFormModelGenerator = spy(new BPMNFormModelGeneratorImpl(kieModuleService, moduleClassLoaderHelper));
    FormModelHandlerManager formModelHandlerManager = new TestFormModelHandlerManager(kieModuleService, moduleClassLoaderHelper, new TestFieldManager());
    BPMNFormGeneratorService<Path> bpmnFormGeneratorService = new BPMNVFSFormDefinitionGeneratorService(new TestFieldManager(), formModelHandlerManager, formFinderService, formDefinitionSerializer, ioService, commentedOptionFactory, synchronizationUtil);
    generator = spy(new TestFormDefinitionGeneratorImpl(formGenerationModelProviders, ioService, bpmnFormModelGenerator, formDefinitionSerializer, bpmnFormGeneratorService, processDefinitions));
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getPath()).thenReturn(diagramPath);
    when(diagram.getGraph()).thenReturn(graph);
    when(diagramPath.toURI()).thenReturn("default:///src/main/resources" + PROCESS_PATH);
}
Also used : SimpleFileSystemProvider(org.uberfire.java.nio.fs.file.SimpleFileSystemProvider) Path(org.uberfire.backend.vfs.Path) FormModelHandlerManager(org.kie.workbench.common.forms.editor.service.backend.FormModelHandlerManager) Definitions(org.eclipse.bpmn2.Definitions) BPMNFormModelGenerator(org.kie.workbench.common.forms.jbpm.server.service.BPMNFormModelGenerator) BPMNFormModelGeneratorImpl(org.kie.workbench.common.forms.jbpm.server.service.impl.BPMNFormModelGeneratorImpl) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) BPMNVFSFormDefinitionGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.authoring.BPMNVFSFormDefinitionGeneratorService) Before(org.junit.Before)

Example 2 with TestFieldManager

use of org.kie.workbench.common.forms.fields.test.TestFieldManager in project kie-wb-common by kiegroup.

the class FormEditorHelperTest method loadContent.

private void loadContent() {
    testFieldManager = spy(new TestFieldManager());
    when(editorFieldLayoutComponents.get()).thenAnswer(invocationOnMock -> {
        final EditorFieldLayoutComponent mocked = mock(EditorFieldLayoutComponent.class);
        return mocked;
    });
    when(formEditorService.loadContent(any())).then(invocation -> {
        FormDefinition form = new FormDefinition();
        form.setName("EmployeeTestForm");
        form.setId("_random_id");
        content = new FormModelerContent();
        PortableJavaModel model = new PortableJavaModel("com.test.Employee");
        model.getProperties().addAll(modelProperties);
        form.setModel(model);
        content.setDefinition(form);
        content.setOverview(new Overview());
        return content;
    });
    when(testFieldManager.getBaseFieldTypes()).thenAnswer(invocationOnMock -> {
        List<String> baseFields = new ArrayList<>();
        baseFields.add("TextBox");
        baseFields.add("CheckBox");
        return baseFields;
    });
    editorServiceCallerMock = new CallerMock<>(formEditorService);
    formEditorHelper = new TestFormEditorHelper(testFieldManager, editorFieldLayoutComponents);
    formEditorService.loadContent(null);
    formEditorHelper.initHelper(content);
    assertEquals(formEditorHelper.getEditorFieldTypes().size(), formEditorHelper.getBaseFieldsDraggables().size());
}
Also used : FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) ArrayList(java.util.ArrayList) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) TestFormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.test.TestFormEditorHelper) EditorFieldLayoutComponent(org.kie.workbench.common.forms.editor.client.editor.rendering.EditorFieldLayoutComponent) Overview(org.guvnor.common.services.shared.metadata.model.Overview) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) Mockito.anyString(org.mockito.Mockito.anyString) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 3 with TestFieldManager

use of org.kie.workbench.common.forms.fields.test.TestFieldManager in project kie-wb-common by kiegroup.

the class EditorFieldLayoutComponentTest method init.

@Before
public void init() {
    fieldManager = spy(new TestFieldManager());
    when(editorFieldLayoutComponents.get()).thenAnswer(invocationOnMock -> {
        final EditorFieldLayoutComponent mocked = mock(EditorFieldLayoutComponent.class);
        return mocked;
    });
    formEditorHelper = spy(new FormEditorHelper(new TestFieldManager(), editorFieldLayoutComponents));
    fieldDefinition = new TextBoxFieldDefinition();
    fieldDefinition.setId(EditorFieldLayoutComponent.FIELD_ID);
    fieldDefinition.setName(EditorFieldLayoutComponent.FIELD_ID);
    fieldDefinition.setBinding(EditorFieldLayoutComponent.FIELD_ID);
    when(formDefinition.getId()).thenReturn(EditorFieldLayoutComponent.FORM_ID);
    when(formDefinition.getFieldById(anyString())).thenReturn(fieldDefinition);
    when(formDefinition.getModel()).thenReturn(formModel);
    when(context.getRootForm()).thenReturn(formDefinition);
    content = new FormModelerContent();
    content.setDefinition(formDefinition);
    content.setOverview(mock(Overview.class));
    formEditorHelper.initHelper(content);
    when(formEditorHelper.getRenderingContext()).thenReturn(context);
    when(formEditorHelper.getFormField(any())).thenReturn(fieldDefinition);
    layoutComponent.addProperty(EditorFieldLayoutComponent.FIELD_ID, EditorFieldLayoutComponent.FIELD_ID);
    layoutComponent.addProperty(EditorFieldLayoutComponent.FORM_ID, EditorFieldLayoutComponent.FORM_ID);
    ctx = new RenderingContext(layoutComponent, widget);
    when(fieldRendererManager.getRendererForField(any())).thenReturn(fieldRenderer);
    when(fieldRenderer.renderWidget()).thenReturn(widget);
    when(propertiesRenderer.getView()).thenReturn(fieldPropertiesRendererView);
    editorFieldLayoutComponent = spy(new EditorFieldLayoutComponent(propertiesRenderer, layoutDragComponentHelper, fieldManager, formEditorContext, syncPaletteEvent) {

        {
            fieldRendererManager = EditorFieldLayoutComponentTest.this.fieldRendererManager;
            translationService = EditorFieldLayoutComponentTest.this.translationService;
        }

        @Override
        protected FormEditorHelper getHelperInstance() {
            return formEditorHelper;
        }
    });
    editorFieldLayoutComponent.initPropertiesConfig();
    propertiesRendererHelper = spy(editorFieldLayoutComponent.getPropertiesRendererHelper());
}
Also used : FormEditorRenderingContext(org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext) RenderingContext(org.uberfire.ext.layout.editor.client.api.RenderingContext) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) Overview(org.guvnor.common.services.shared.metadata.model.Overview) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper) Before(org.junit.Before)

Example 4 with TestFieldManager

use of org.kie.workbench.common.forms.fields.test.TestFieldManager in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method setup.

@BeforeClass
public static void setup() throws ClassNotFoundException {
    FormModelPropertiesUtil.registerBaseType(DOCUMENT_TYPE);
    FormModelPropertiesUtil.registerBaseType(DocumentFieldType.DOCUMENT_IMPL_TYPE);
    fieldManager = new TestFieldManager() {

        {
            registerFieldProvider(new DocumentFieldProvider() {

                {
                    doRegisterFields();
                }
            });
        }
    };
    formSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager());
    ioService = new IOServiceDotFileImpl();
    templateGenerator = new StaticFormLayoutTemplateGenerator();
    formModelSynchronizationUtil = new FormModelSynchronizationUtilImpl(fieldManager, templateGenerator);
    moduleClassLoader = FormGenerationIntegrationTest.class.getClassLoader();
    formGenerationProcessDefinitions = TestUtils.getDefinitionsFromResources(FormGenerationIntegrationTest.class, DEFINITION_PATH);
    formModelerContent = new FormModelerContent();
    formEditorHelper = new FormEditorHelper(fieldManager, null);
}
Also used : FieldSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FieldSerializer) IOServiceDotFileImpl(org.uberfire.io.impl.IOServiceDotFileImpl) StaticFormLayoutTemplateGenerator(org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator) DocumentFieldProvider(org.kie.workbench.common.forms.jbpm.model.authoring.document.provider.DocumentFieldProvider) FormDefinitionSerializerImpl(org.kie.workbench.common.forms.services.backend.serialization.impl.FormDefinitionSerializerImpl) FormModelerContent(org.kie.workbench.common.forms.editor.model.FormModelerContent) FormModelSerializer(org.kie.workbench.common.forms.services.backend.serialization.impl.FormModelSerializer) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormEditorHelper(org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) FormModelSynchronizationUtilImpl(org.kie.workbench.common.forms.editor.service.shared.model.impl.FormModelSynchronizationUtilImpl) BeforeClass(org.junit.BeforeClass)

Example 5 with TestFieldManager

use of org.kie.workbench.common.forms.fields.test.TestFieldManager in project kie-wb-common by kiegroup.

the class FieldManagerTest method initTest.

@Before
public void initTest() {
    fieldManager = new TestFieldManager();
    Assertions.assertThat(fieldManager.getBaseFieldTypes()).isNotNull().isNotEmpty();
    property = new ModelPropertyImpl("name", new TypeInfoImpl(String.class.getName()));
}
Also used : TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) Before(org.junit.Before)

Aggregations

TestFieldManager (org.kie.workbench.common.forms.fields.test.TestFieldManager)9 Before (org.junit.Before)6 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)4 FormModelerContent (org.kie.workbench.common.forms.editor.model.FormModelerContent)3 PortableJavaModel (org.kie.workbench.common.forms.model.impl.PortableJavaModel)3 Overview (org.guvnor.common.services.shared.metadata.model.Overview)2 FormEditorHelper (org.kie.workbench.common.forms.editor.client.editor.FormEditorHelper)2 TestMetaDataEntryManager (org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager)2 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)2 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)2 Mockito.anyString (org.mockito.Mockito.anyString)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Definitions (org.eclipse.bpmn2.Definitions)1 BeforeClass (org.junit.BeforeClass)1 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)1 StaticFormLayoutTemplateGenerator (org.kie.workbench.common.forms.commons.shared.layout.impl.StaticFormLayoutTemplateGenerator)1 EditorFieldLayoutComponent (org.kie.workbench.common.forms.editor.client.editor.rendering.EditorFieldLayoutComponent)1 TestFormEditorHelper (org.kie.workbench.common.forms.editor.client.editor.test.TestFormEditorHelper)1 FormModelHandlerManager (org.kie.workbench.common.forms.editor.service.backend.FormModelHandlerManager)1