Search in sources :

Example 1 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method sameIOTaskFormIsCorrectlyGenerated.

@Test
public void sameIOTaskFormIsCorrectlyGenerated() {
    when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
    final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TaskWithTheSameInputsAndOutputs-taskform.frm", taskFormModels.get(3));
    final List<String> expectedProcessFormFields = Arrays.asList("_boolean_", CHECKBOX_FIELDTYPE, "_dataObject_", SUBFORM_FIELDTYPE, "_document_", DOCUMENT_FIELDTYPE, "_float_", DECIMALBOX_FIELDTYPE, "_integer_", INTEGERBOX_FIELDTYPE, "_object_", TEXTAREA_FIELDTYPE, "_string_", TEXTBOX_FIELDTYPE);
    final FormDefinition rootForm = formGenerationResult.getRootForm();
    testFormDefinition(rootForm, expectedProcessFormFields);
    testNestedFormsHaveCorrectId(rootForm, "_dataObject_", DATAOBJECT_FORM_ID);
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 2 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method differentIOTaskFormIsCorrectlyGenerated.

@Test
public void differentIOTaskFormIsCorrectlyGenerated() {
    when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
    final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TaskWithDifferentInputsAndOutputs-taskform.frm", taskFormModels.get(0));
    final List<String> expectedProcessFormFields = Arrays.asList(// inputs
    "_boolean", CHECKBOX_FIELDTYPE, "_dataObject", SUBFORM_FIELDTYPE, "_document", DOCUMENT_FIELDTYPE, "_float", DECIMALBOX_FIELDTYPE, "_integer", INTEGERBOX_FIELDTYPE, "_object", TEXTAREA_FIELDTYPE, "_string", TEXTBOX_FIELDTYPE, // outputs
    "boolean_", CHECKBOX_FIELDTYPE, "dataObject_", SUBFORM_FIELDTYPE, "document_", DOCUMENT_FIELDTYPE, "float_", DECIMALBOX_FIELDTYPE, "integer_", INTEGERBOX_FIELDTYPE, "object_", TEXTAREA_FIELDTYPE, "string_", TEXTBOX_FIELDTYPE);
    final FormDefinition rootForm = formGenerationResult.getRootForm();
    testFormDefinition(rootForm, expectedProcessFormFields);
    testNestedFormsHaveCorrectId(rootForm, "_dataObject", DATAOBJECT_FORM_ID);
    testNestedFormsHaveCorrectId(rootForm, "dataObject_", DATAOBJECT_FORM_ID);
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 3 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class FormGenerationIntegrationTest method emptyTaskFormIsCorrectlyGenerated.

@Test
public void emptyTaskFormIsCorrectlyGenerated() {
    final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_EmptyTask-taskform.frm", taskFormModels.get(1));
    final FormDefinition rootForm = formGenerationResult.getRootForm();
    testFormDefinition(rootForm, Collections.emptyList());
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 4 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class DynamicBPMNFormGeneratorImpl method createFormDefinition.

protected Collection<FormDefinition> createFormDefinition(JBPMFormModel model, ClassLoader classLoader) {
    FormGenerationResult generationResult = formGeneratorService.generateForms(model, classLoader);
    List<FormDefinition> result = new ArrayList<>();
    result.add(generationResult.getRootForm());
    result.addAll(generationResult.getNestedForms());
    return result;
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) ArrayList(java.util.ArrayList) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition)

Example 5 with FormGenerationResult

use of org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult in project kie-wb-common by kiegroup.

the class AbstractBPMNFormGeneratorServiceTest method launchNestedFormTestWithGeneratedFormsValidation.

protected void launchNestedFormTestWithGeneratedFormsValidation() {
    FormGenerationResult result = launchNestedFormsTest();
    assertFalse(result.getNestedForms().isEmpty());
    assertEquals(3, result.getNestedForms().size());
    result.getNestedForms().forEach(form -> {
        assertNotNull(form);
        assertFalse(form.getFields().isEmpty());
        assertTrue(form.getModel() instanceof DataObjectFormModel);
        DataObjectFormModel nestedModel = (DataObjectFormModel) form.getModel();
        String className = nestedModel.getType();
        if (Expense.class.getName().equals(className)) {
            testExpenseForm(form);
        } else if (Client.class.getName().equals(className)) {
            testClientForm(form);
        } else if (Line.class.getName().equals(className)) {
            testLineForm(form);
        } else {
            fail();
        }
        assertNotNull(form.getLayoutTemplate());
        assertEquals(form.getFields().size(), form.getLayoutTemplate().getRows().size());
    });
}
Also used : Line(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Line) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) Expense(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Expense) DataObjectFormModel(org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)

Aggregations

FormGenerationResult (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult)16 FormDefinition (org.kie.workbench.common.forms.model.FormDefinition)13 Test (org.junit.Test)11 ArrayList (java.util.ArrayList)6 ModelProperty (org.kie.workbench.common.forms.model.ModelProperty)5 ModelPropertyImpl (org.kie.workbench.common.forms.model.impl.ModelPropertyImpl)5 TypeInfoImpl (org.kie.workbench.common.forms.model.impl.TypeInfoImpl)5 FieldDefinition (org.kie.workbench.common.forms.model.FieldDefinition)4 CheckBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition)3 IntegerBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition)3 TextBoxFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition)3 TaskFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel)3 BusinessProcessFormModel (org.kie.workbench.common.forms.jbpm.model.authoring.process.BusinessProcessFormModel)2 Expense (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Expense)2 Date (java.util.Date)1 DataObjectFormModel (org.kie.workbench.common.forms.data.modeller.model.DataObjectFormModel)1 DatePickerFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition)1 SubFormFieldDefinition (org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition)1 Line (org.kie.workbench.common.forms.jbpm.server.service.formGeneration.model.Line)1 ServiceException (org.kie.workbench.common.screens.datamodeller.service.ServiceException)1