Search in sources :

Example 1 with PortableJavaModel

use of org.kie.workbench.common.forms.model.impl.PortableJavaModel 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 2 with PortableJavaModel

use of org.kie.workbench.common.forms.model.impl.PortableJavaModel in project kie-wb-common by kiegroup.

the class MultipleSubformBackendFormRenderingContextManagerTest method getNestedForms.

@Override
protected FormDefinition[] getNestedForms() {
    JavaFormModel model = new PortableJavaModel(Person.class.getName());
    FormDefinition creationForm = new FormDefinition(model);
    creationForm.setId("person-creation");
    FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Long.class.getName()));
    field.setName("id");
    field.setBinding("id");
    creationForm.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
    field.setName("name");
    field.setBinding("name");
    creationForm.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
    field.setName("lastName");
    field.setBinding("lastName");
    creationForm.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
    field.setName("birthday");
    field.setBinding("birthday");
    creationForm.getFields().add(field);
    FormDefinition editionForm = new FormDefinition(model);
    editionForm.setId("person-edition");
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Long.class.getName()));
    field.setName("id");
    field.setBinding("id");
    editionForm.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
    field.setName("name");
    field.setBinding("name");
    editionForm.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
    field.setName("lastName");
    field.setBinding("lastName");
    editionForm.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
    field.setName("birthday");
    field.setBinding("birthday");
    editionForm.getFields().add(field);
    return new FormDefinition[] { creationForm, editionForm };
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) MultipleSubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) 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) Person(org.kie.workbench.common.forms.dynamic.backend.server.context.generation.dynamic.impl.model.Person) Date(java.util.Date)

Example 3 with PortableJavaModel

use of org.kie.workbench.common.forms.model.impl.PortableJavaModel in project kie-wb-common by kiegroup.

the class NestedFormBackendFormRenderingContextManagerTest method getNestedForms.

@Override
protected FormDefinition[] getNestedForms() {
    FormDefinition form = new FormDefinition(new PortableJavaModel(Person.class.getName()));
    form.setId(Person.class.getName());
    FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
    field.setName("name");
    field.setBinding("name");
    form.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(String.class.getName()));
    field.setName("lastName");
    field.setBinding("lastName");
    form.getFields().add(field);
    field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(Date.class.getName()));
    field.setName("birthday");
    field.setBinding("birthday");
    form.getFields().add(field);
    return new FormDefinition[] { form };
}
Also used : FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) Person(org.kie.workbench.common.forms.dynamic.backend.server.context.generation.dynamic.impl.model.Person) Date(java.util.Date)

Example 4 with PortableJavaModel

use of org.kie.workbench.common.forms.model.impl.PortableJavaModel in project kie-wb-common by kiegroup.

the class NestedFormBackendFormRenderingContextManagerTest method getRootForm.

@Override
protected FormDefinition getRootForm() {
    FormDefinition form = new FormDefinition(new PortableJavaModel(Person.class.getName()));
    FieldDefinition field = fieldManager.getDefinitionByDataType(new TypeInfoImpl(TypeKind.OBJECT, Person.class.getName(), false));
    field.setName("person");
    field.setBinding("person");
    SubFormFieldDefinition subForm = (SubFormFieldDefinition) field;
    subForm.setNestedForm(Person.class.getName());
    form.getFields().add(field);
    return form;
}
Also used : SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) PortableJavaModel(org.kie.workbench.common.forms.model.impl.PortableJavaModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) Person(org.kie.workbench.common.forms.dynamic.backend.server.context.generation.dynamic.impl.model.Person)

Example 5 with PortableJavaModel

use of org.kie.workbench.common.forms.model.impl.PortableJavaModel 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)

Aggregations

PortableJavaModel (org.kie.workbench.common.forms.model.impl.PortableJavaModel)8 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)7 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)5 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)5 Date (java.util.Date)3 Person (org.kie.workbench.common.forms.dynamic.backend.server.context.generation.dynamic.impl.model.Person)3 MultipleSubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.multipleSubform.definition.MultipleSubFormFieldDefinition)3 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)3 TestFieldManager (org.kie.workbench.common.forms.fields.test.TestFieldManager)3 Before (org.junit.Before)2 JavaFormModel (org.kie.workbench.common.forms.model.JavaFormModel)2 Mockito.anyString (org.mockito.Mockito.anyString)2 ArrayList (java.util.ArrayList)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 Employee (org.kie.workbench.common.forms.dynamic.test.model.Employee)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 FormModelerContent (org.kie.workbench.common.forms.editor.model.FormModelerContent)1 BasicTypeFieldProvider (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.BasicTypeFieldProvider)1 EnumListBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.selectors.listBox.definition.EnumListBoxFieldDefinition)1