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));
}
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());
}
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);
}
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);
}
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);
}
Aggregations