Search in sources :

Example 6 with FormGenerationResult

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

the class FormGenerationWithSynchronizationTest method testRemoveModelProperties.

@Test
public void testRemoveModelProperties() {
    List<ModelProperty> modelProperties = new ArrayList<>();
    modelProperties.add(new ModelPropertyImpl(NAME_PROPERTY, new TypeInfoImpl(String.class.getName())));
    modelProperties.add(new ModelPropertyImpl(LASTNAME_PROPERTY, new TypeInfoImpl(String.class.getName())));
    newFormModel = new TaskFormModel(PROCESS_ID, TASK_NAME, modelProperties);
    FormGenerationResult generationResult = service.generateForms(newFormModel, source);
    assertNotNull(generationResult);
    assertNotNull(generationResult.getRootForm());
    FormDefinition formDefinition = generationResult.getRootForm();
    assertEquals(newFormModel, formDefinition.getModel());
    assertEquals(ORIGINAL_FORM_FIELDS, Integer.valueOf(formDefinition.getFields().size()));
    FieldDefinition field = formDefinition.getFieldByBinding(NAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
    assertNotNull(field);
    assertEquals(field.getStandaloneClassName(), String.class.getName());
    assertNull(formDefinition.getFieldByBinding(AGE_PROPERTY));
    assertNull(formDefinition.getFieldByBinding(MARRIED_PROPERTY));
    assertNull(formDefinition.getFieldByBinding(ADDRESS_PROPERTY));
    assertNotNull(formDefinition.getFieldByName(AGE_PROPERTY));
    assertNotNull(formDefinition.getFieldByName(MARRIED_PROPERTY));
    assertNotNull(formDefinition.getFieldByName(ADDRESS_PROPERTY));
}
Also used : FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) TextBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.textBox.definition.TextBoxFieldDefinition) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) CheckBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition) IntegerBoxFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.integerBox.definition.IntegerBoxFieldDefinition) ModelProperty(org.kie.workbench.common.forms.model.ModelProperty) ArrayList(java.util.ArrayList) ModelPropertyImpl(org.kie.workbench.common.forms.model.impl.ModelPropertyImpl) TypeInfoImpl(org.kie.workbench.common.forms.model.impl.TypeInfoImpl) TaskFormModel(org.kie.workbench.common.forms.jbpm.model.authoring.task.TaskFormModel) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 7 with FormGenerationResult

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

the class NestedFormsBPMNVFSFormDefinitionGeneratorServiceTest method testCreateNewProcessFormNestedFormsWithModelFormsOnVFS.

@Test
public void testCreateNewProcessFormNestedFormsWithModelFormsOnVFS() {
    when(ioService.exists(any())).thenReturn(false);
    when(formFinderService.findFormsForType(any(), any())).thenAnswer(this::findVFSForms);
    FormGenerationResult result = launchNestedFormsTest();
    FormDefinition rootForm = result.getRootForm();
    assertNotNull(rootForm);
    FieldDefinition expenseField = rootForm.getFieldByBinding(EXPENSE_VARIABLE);
    assertNotNull(expenseField);
    assertTrue(expenseField instanceof SubFormFieldDefinition);
    SubFormFieldDefinition subFormFieldDefinition = (SubFormFieldDefinition) expenseField;
    // The nested form should be the form with a field not the empty one
    assertEquals(EXPENSE_FORM_ID, subFormFieldDefinition.getNestedForm());
    assertEquals(EXPENSE_FORM_ID, subFormFieldDefinition.getStandaloneClassName());
    // since the nested forms exist on VFS there shouldn't be any nested forms on the result
    assertTrue(result.getNestedForms().isEmpty());
    // since the nested forms exist on VFS it shouldn't be any write operation on the VFS
    verify(ioService, never()).write(any(), anyString(), any());
}
Also used : SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) FieldDefinition(org.kie.workbench.common.forms.model.FieldDefinition) SubFormFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.relations.subForm.definition.SubFormFieldDefinition) DatePickerFieldDefinition(org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.datePicker.definition.DatePickerFieldDefinition) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) Test(org.junit.Test)

Example 8 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 inputTaskFormIsCorrectlyGenerated.

@Test
public void inputTaskFormIsCorrectlyGenerated() {
    when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
    final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TaskOnlyWithInputs-taskform.frm", taskFormModels.get(2));
    final List<String> expectedInputTaskFormFields = 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, expectedInputTaskFormFields);
    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 9 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 twinTaskFormIsCorrectlyGenerated.

@Test
public void twinTaskFormIsCorrectlyGenerated() {
    when(module.getRootPath()).thenReturn(rootPathWithNestedForms);
    final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TwinTasks-taskform.frm", taskFormModels.get(4));
    final List<String> expectedProcessFormFields = Arrays.asList("_boolean", CHECKBOX_FIELDTYPE, "_dataObject1", SUBFORM_FIELDTYPE, "_dataObject2", SUBFORM_FIELDTYPE, "_string", TEXTBOX_FIELDTYPE, "_boolean_", CHECKBOX_FIELDTYPE, "_string_", TEXTBOX_FIELDTYPE, "dataObject_", SUBFORM_FIELDTYPE, "integer_", INTEGERBOX_FIELDTYPE);
    final FormDefinition rootForm = formGenerationResult.getRootForm();
    testFormDefinition(rootForm, expectedProcessFormFields);
    testNestedFormsHaveCorrectId(rootForm, "_dataObject1", DATAOBJECT_FORM_ID);
    testNestedFormsHaveCorrectId(rootForm, "_dataObject2", 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 10 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 testNestedFormsGeneration.

@Test
public void testNestedFormsGeneration() {
    when(module.getRootPath()).thenReturn(rootPathWithoutNestedForms);
    ModelDriver modelDriver = new JavaRoasterModelDriver(ioService, Paths.convert(rootPathWithoutNestedForms), moduleClassLoader, filterHolder);
    try {
        ModelDriverResult result = modelDriver.loadModel();
        dataModel = result.getDataModel();
    } catch (ModelDriverException e) {
        throw new ServiceException("It was not possible to load model for URI: " + rootPathWithoutNestedForms.toURI(), e);
    }
    when(dataModelerService.loadModel(module)).thenReturn(dataModel);
    when(commentedOptionFactory.makeCommentedOption(any())).thenReturn(commentedOption);
    final FormGenerationResult formGenerationResult = generateForm("FormGenerationTest_TwinTasks-taskform.frm", taskFormModels.get(4));
    final List<String> expectedDataObjectFormFields = Arrays.asList("nestedObjectForSubform", SUBFORM_FIELDTYPE, "nestedObjectListForMultipleSubform", MULTIPLESUBFORM_FIELDTYPE, "bigDecimalDecimalBox", DECIMALBOX_FIELDTYPE, "bigIntegerIntegerBox", INTEGERBOX_FIELDTYPE, "booleanCheckBox", CHECKBOX_FIELDTYPE, "byteIntegerBox", INTEGERBOX_FIELDTYPE, "charTextBox", TEXTBOX_FIELDTYPE, "dateDatePicker", DATEPICKER_FIELDTYPE, "doubleDecimalBox", DECIMALBOX_FIELDTYPE, "floatDecimalBox", DECIMALBOX_FIELDTYPE, "longIntegerBox", INTEGERBOX_FIELDTYPE, "stringListBox", TEXTBOX_FIELDTYPE, "intIntegerBox", INTEGERBOX_FIELDTYPE, "shortIntegerBox", INTEGERBOX_FIELDTYPE, "bigDecimalRadioGroup", DECIMALBOX_FIELDTYPE, "bigIntegerRadioGroup", INTEGERBOX_FIELDTYPE, "byteRadioGroup", INTEGERBOX_FIELDTYPE, "charRadioGroup", TEXTBOX_FIELDTYPE, "doubleSlider", DECIMALBOX_FIELDTYPE, "doubleRadioGroup", DECIMALBOX_FIELDTYPE, "floatRadioGroup", DECIMALBOX_FIELDTYPE, "intRadioGroup", INTEGERBOX_FIELDTYPE, "intSlider", INTEGERBOX_FIELDTYPE, "longRadioGroup", INTEGERBOX_FIELDTYPE, "stringPicture", TEXTBOX_FIELDTYPE, "stringRadioGroup", TEXTBOX_FIELDTYPE, "stringTextArea", TEXTBOX_FIELDTYPE, "stringTextBox", TEXTBOX_FIELDTYPE, "shortRadioGroup", INTEGERBOX_FIELDTYPE);
    final List<String> expectedNestedDataObjectFormFields = Arrays.asList("stringListBox", TEXBOX_FIELDTYPE, "doubleDecimalBox", DECIMALBOX_FIELDTYPE, "booleanCheckBox", CHECKBOX_FIELDTYPE, "dateDatePicker", DATEPICKER_FIELDTYPE, "charRadioGroup", TEXTBOX_FIELDTYPE, "doubleSlider", DECIMALBOX_FIELDTYPE, "intIntegerBox", INTEGERBOX_FIELDTYPE, "stringPicture", TEXBOX_FIELDTYPE, "stringTextArea", TEXTBOX_FIELDTYPE, "stringTextBox", TEXTBOX_FIELDTYPE);
    final FormDefinition rootForm = formGenerationResult.getRootForm();
    final List<FormDefinition> nestedForms = formGenerationResult.getNestedForms();
    final FormDefinition dataObjectForm = nestedForms.get(0);
    final FormDefinition nestedDataObjectForm = nestedForms.get(1);
    final String dataObjectFormID = dataObjectForm.getId();
    testNestedFormsHaveCorrectId(rootForm, "_dataObject1", dataObjectFormID);
    testNestedFormsHaveCorrectId(rootForm, "_dataObject2", dataObjectFormID);
    testNestedFormsHaveCorrectId(rootForm, "dataObject_", dataObjectFormID);
    final String nestedDataObjectFormID = nestedDataObjectForm.getId();
    testFormDefinition(dataObjectForm, expectedDataObjectFormFields);
    testNestedFormsHaveCorrectId(dataObjectForm, "nestedObjectForSubform", nestedDataObjectFormID);
    testFormDefinition(nestedDataObjectForm, expectedNestedDataObjectFormFields);
}
Also used : ServiceException(org.kie.workbench.common.screens.datamodeller.service.ServiceException) FormGenerationResult(org.kie.workbench.common.forms.jbpm.server.service.formGeneration.FormGenerationResult) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) ModelDriver(org.kie.workbench.common.services.datamodeller.driver.ModelDriver) ModelDriverResult(org.kie.workbench.common.services.datamodeller.driver.model.ModelDriverResult) ModelDriverException(org.kie.workbench.common.services.datamodeller.driver.ModelDriverException) FormDefinition(org.kie.workbench.common.forms.model.FormDefinition) JavaRoasterModelDriver(org.kie.workbench.common.services.datamodeller.driver.impl.JavaRoasterModelDriver) Test(org.junit.Test)

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