Search in sources :

Example 6 with TestFieldManager

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

the class FormEditorPresenterAbstractTest method setUp.

@Before
public void setUp() throws Exception {
    fieldManager = new TestFieldManager();
    model = new PortableJavaModel("com.test.Employee");
    model.addProperty("name", String.class.getName());
    model.addProperty("lastName", String.class.getName());
    model.addProperty("birthday", Date.class.getName());
    model.addProperty("married", Boolean.class.getName());
    form = new FormDefinition(model);
    form.setName("EmployeeTestForm");
    form.setId("_random_id");
    // model.getProperties().stream().map(fieldManager::getDefinitionByModelProperty).forEach(fieldDefinition -> form.getFields().add(fieldDefinition));
    modelProperties = new ArrayList<>(model.getProperties());
    employeeFields = new ArrayList<>(form.getFields());
    when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
    when(workbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(workbenchContext.getActiveModule()).thenReturn(Optional.empty());
    when(workbenchContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(workbenchContext.getActivePackage()).thenReturn(Optional.empty());
    when(alertsButtonMenuItemBuilder.build()).thenReturn(alertsButtonMenuItem);
}
Also used : PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) Mockito.anyString(org.mockito.Mockito.anyString) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Date(java.util.Date) Before(org.junit.Before)

Example 7 with TestFieldManager

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

the class FieldPropertiesRendererTest method loadContent.

protected void loadContent() {
    fieldManager = spy(new TestFieldManager());
    renderer = spy(new FieldPropertiesRenderer(view, dynamicFormModelGenerator, staticDataBindingEditor, dynamicDataBindingEditor, fieldManager));
    renderer.init();
    when(helper.getCurrentField()).thenReturn(lastNameField);
    when(helper.getCurrentRenderingContext()).thenReturn(context);
    FormDefinition form = new FormDefinition(null);
    when(context.getRootForm()).thenReturn(form);
    when(dynamicFormModelGenerator.getContextForModel(any())).thenReturn(context);
}
Also used : TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 8 with TestFieldManager

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

the class BPMNFormGenerationTest method initTest.

@Before
public void initTest() {
    generatorService = new BPMNRuntimeFormGeneratorService(new TestFieldManager(), new RawMVELEvaluator());
    generator = new DynamicBPMNFormGeneratorImpl(generatorService);
}
Also used : BPMNRuntimeFormGeneratorService(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.impl.runtime.BPMNRuntimeFormGeneratorService) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) Before(org.junit.Before)

Example 9 with TestFieldManager

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

the class FormDefinitionSerializerImplTest method initTest.

@Before
public void initTest() {
    fieldManager = new TestFieldManager();
    definitionSerializer = new FormDefinitionSerializerImpl(new FieldSerializer(), new FormModelSerializer(), new TestMetaDataEntryManager());
    JavaFormModel model = new PortableJavaModel("org.test.MyParentModel");
    formDefinition = new FormDefinition(model);
    formDefinition.setId("testForm");
    formDefinition.setName("testForm");
    formDefinition.setLayoutTemplate(new LayoutTemplate());
    for (BasicTypeFieldProvider provider : fieldManager.getAllBasicTypeProviders()) {
        for (String type : provider.getSupportedTypes()) {
            FieldDefinition field = provider.getFieldByType(new TypeInfoImpl(type));
            assertNotNull(field);
            String fieldDescription = provider.getFieldTypeName() + "_" + type;
            field.setName(fieldDescription);
            field.setLabel(fieldDescription);
            field.setStandaloneClassName(type);
            field.setBinding(fieldDescription);
            model.getProperties().add(new ModelPropertyImpl(fieldDescription, new TypeInfoImpl(type)));
            formDefinition.getFields().add(field);
        }
    }
    SubFormFieldDefinition subForm = new SubFormFieldDefinition();
    subForm.setLabel("SubForm");
    subForm.setNestedForm("");
    subForm.setBinding("model");
    subForm.setStandaloneClassName("org.test.MyTestModel");
    subForm.setBinding("SubForm");
    formDefinition.getFields().add(subForm);
    model.getProperties().add(new ModelPropertyImpl(subForm.getBinding(), new TypeInfoImpl(TypeKind.OBJECT, subForm.getStandaloneClassName(), false)));
    MultipleSubFormFieldDefinition multipleSubForm = new MultipleSubFormFieldDefinition();
    multipleSubForm.setLabel("MultipleSubForm");
    multipleSubForm.setCreationForm("");
    multipleSubForm.setEditionForm("");
    multipleSubForm.setStandaloneClassName("org.test.MyTestModel");
    multipleSubForm.setBinding("MultipleSubForm");
    formDefinition.getFields().add(multipleSubForm);
    model.getProperties().add(new ModelPropertyImpl(multipleSubForm.getBinding(), new TypeInfoImpl(TypeKind.OBJECT, multipleSubForm.getStandaloneClassName(), true)));
    EnumListBoxFieldDefinition enumListBox = new EnumListBoxFieldDefinition();
    enumListBox.setLabel("EnumListBox");
    enumListBox.setBinding("EnumListBox");
    enumListBox.setStandaloneClassName("org.test.MyTestModel");
    formDefinition.getFields().add(enumListBox);
    model.getProperties().add(new ModelPropertyImpl(enumListBox.getBinding(), new TypeInfoImpl(TypeKind.ENUM, enumListBox.getStandaloneClassName(), false)));
}
Also used : LayoutTemplate(org.uberfire.ext.layout.editor.api.editor.LayoutTemplate) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TestMetaDataEntryManager(org.kie.workbench.common.forms.fields.test.TestMetaDataEntryManager) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) EnumListBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) TestFieldManager(org.kie.workbench.common.forms.fields.test.TestFieldManager) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) JavaFormModel(org.kie.workbench.common.forms.model.JavaFormModel) BasicTypeFieldProvider(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider) 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