use of org.kie.workbench.common.forms.migration.tool.FormMigrationSummary in project kie-wb-common by kiegroup.
the class AllFieldTypesFormGenerationTest method doInit.
@Override
protected void doInit() throws Exception {
fieldMappings.put("subform", SubFormFieldDefinition.class);
fieldMappings.put("multiple", MultipleSubFormFieldDefinition.class);
fieldMappings.put("text", TextBoxBaseDefinition.class);
fieldMappings.put("textarea", TextAreaFieldDefinition.class);
fieldMappings.put("character", CharacterBoxFieldDefinition.class);
fieldMappings.put("float", DecimalBoxFieldDefinition.class);
fieldMappings.put("double", DecimalBoxFieldDefinition.class);
fieldMappings.put("bigDecimal", DecimalBoxFieldDefinition.class);
fieldMappings.put("bigInteger", IntegerBoxFieldDefinition.class);
fieldMappings.put("byte", IntegerBoxFieldDefinition.class);
fieldMappings.put("short", IntegerBoxFieldDefinition.class);
fieldMappings.put("integer", IntegerBoxFieldDefinition.class);
fieldMappings.put("long", IntegerBoxFieldDefinition.class);
fieldMappings.put("email", TextBoxFieldDefinition.class);
fieldMappings.put("boolean", CheckBoxFieldDefinition.class);
fieldMappings.put("html", TextAreaFieldDefinition.class);
fieldMappings.put("date", DatePickerFieldDefinition.class);
fieldMappings.put("shortDate", DatePickerFieldDefinition.class);
fieldMappings.put("document", DocumentFieldDefinition.class);
fieldMappings.put("select", StringListBoxFieldDefinition.class);
fieldMappings.put("radio", StringRadioGroupFieldDefinition.class);
List<FormMigrationSummary> summaries = new ArrayList<>();
initForm(form -> userForm = form, DATAOBJECTS_RESOURCES, ALL_FIELD_TYPES, userFormPath);
summaries.add(new FormMigrationSummary(new Resource<>(userForm, userFormPath)));
context = new MigrationContext(workspaceProject, weldContainer, migrationServicesCDIWrapper, new RealSystemAccess(), summaries);
}
use of org.kie.workbench.common.forms.migration.tool.FormMigrationSummary in project kie-wb-common by kiegroup.
the class AllFieldTypesFormGenerationTest method testMigration.
@Test
public void testMigration() {
generator.execute(context);
Assertions.assertThat(context.getSummaries()).isNotEmpty().hasSize(1);
Assertions.assertThat(context.getExtraSummaries()).isEmpty();
// 1 legacyforms + 1 migrated forms
verify(migrationServicesCDIWrapper, times(2)).write(any(Path.class), anyString(), anyString());
FormMigrationSummary summary = context.getSummaries().iterator().next();
Form originalForm = summary.getOriginalForm().get();
FormDefinition newForm = summary.getNewForm().get();
assertNotNull(newForm);
Assertions.assertThat(newForm.getFields()).isNotEmpty().hasSize(fieldMappings.size());
LayoutTemplate newLayout = newForm.getLayoutTemplate();
assertNotNull(newLayout);
Assertions.assertThat(newLayout.getRows()).isNotEmpty().hasSize(// fields + 2 decorators in original form
fieldMappings.size() + 2);
List<LayoutRow> rows = newLayout.getRows();
checkDecoratorRow(rows.get(0));
checkDecoratorRow(rows.get(1));
IntStream indexStream = IntStream.range(0, fieldMappings.size());
indexStream.forEach(index -> {
FieldDefinition newField = newForm.getFields().get(index);
assertNotNull(newField);
Field originalField = originalForm.getField(newField.getName());
assertNotNull(originalField);
checkFieldDefinition(newField, newField.getName(), newField.getLabel(), newField.getBinding(), fieldMappings.get(newField.getName()), newForm, originalField);
LayoutRow row = rows.get(index + 2);
LayoutComponent component = checkRow(row);
checkLayoutFormField(component, newField, newForm);
});
}
use of org.kie.workbench.common.forms.migration.tool.FormMigrationSummary in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorForBPMNForWrongTaskFormNameTest method doInit.
@Override
protected void doInit() throws Exception {
List<FormMigrationSummary> summaries = new ArrayList<>();
initForm(form -> wrongProcessForm = form, BPMN_RESOURCES, WRONG_PROCESS_FORM, wrongProcessPath);
summaries.add(new FormMigrationSummary(new Resource<>(wrongProcessForm, wrongProcessPath)));
initForm(form -> wrontTaskForm = form, BPMN_RESOURCES, WRONG_TASK_FORM, wrongTaskPath);
summaries.add(new FormMigrationSummary(new Resource<>(wrontTaskForm, wrongTaskPath)));
context = new MigrationContext(workspaceProject, weldContainer, migrationServicesCDIWrapper, new RealSystemAccess(), summaries);
generator = new FormDefinitionGenerator(DataObjectFormAdapter::new, this::getBPMNAdapter);
}
use of org.kie.workbench.common.forms.migration.tool.FormMigrationSummary in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorForBPMNWithComplexVariableTest method verifyBPMNForm.
private void verifyBPMNForm(FormMigrationSummary summary, Class<? extends JBPMFormModel> modelType) {
Form originalForm = summary.getOriginalForm().get();
Assertions.assertThat(originalForm.getFormFields()).hasSize(4);
Field originalInvoiceUser = originalForm.getField(INVOICE_USER);
Field originalLines = originalForm.getField(INVOICE_LINES);
Field originalTotal = originalForm.getField(INVOICE_TOTAL);
String expectedExtraForm = summary.getBaseFormName() + "-" + originalForm.getHolders().iterator().next().getUniqeId();
checkMovedField(originalInvoiceUser, expectedExtraForm);
checkMovedField(originalLines, expectedExtraForm);
checkMovedField(originalTotal, expectedExtraForm);
Field invoiceField = originalForm.getField("invoice");
assertNotNull(invoiceField);
assertEquals(FieldTypeBuilder.SUBFORM, invoiceField.getFieldType().getCode());
FormDefinition newFormDefinition = summary.getNewForm().get();
Assertions.assertThat(newFormDefinition.getModel()).isNotNull().isInstanceOf(modelType);
Assertions.assertThat(newFormDefinition.getFields()).isNotNull().hasSize(1);
FieldDefinition newInvoiceField = newFormDefinition.getFieldByName("invoice");
Assertions.assertThat(newInvoiceField).isNotNull().isInstanceOf(SubFormFieldDefinition.class);
LayoutTemplate newFormLayout = newFormDefinition.getLayoutTemplate();
assertNotNull(newFormLayout);
Assertions.assertThat(newFormLayout.getRows()).isNotEmpty().hasSize(1);
LayoutRow newLayoutRow = newFormLayout.getRows().get(0);
assertNotNull(newLayoutRow);
Assertions.assertThat(newLayoutRow.getLayoutColumns()).isNotEmpty().hasSize(1);
LayoutColumn newLayoutColumn = newLayoutRow.getLayoutColumns().get(0);
assertNotNull(newLayoutColumn);
assertEquals("12", newLayoutColumn.getSpan());
Assertions.assertThat(newLayoutColumn.getLayoutComponents()).isNotEmpty().hasSize(1);
checkLayoutFormField(newLayoutColumn.getLayoutComponents().get(0), newInvoiceField, newFormDefinition);
FormMigrationSummary extraSummary = context.getExtraSummaries().stream().filter(extra -> extra.getBaseFormName().equals(expectedExtraForm)).findAny().orElse(null);
FormDefinition newExtraFormDefinition = extraSummary.getNewForm().get();
checkInvoiceFormDefinition(newExtraFormDefinition, originalForm);
}
use of org.kie.workbench.common.forms.migration.tool.FormMigrationSummary in project kie-wb-common by kiegroup.
the class FormDefinitionGeneratorForBPMNWithComplexVariableTest method doInit.
@Override
protected void doInit() throws Exception {
List<FormMigrationSummary> summaries = new ArrayList<>();
initForm(form -> userForm = form, DATAOBJECTS_RESOURCES, USER_FORM, userFormPath);
summaries.add(new FormMigrationSummary(new Resource<>(userForm, userFormPath)));
initForm(form -> lineForm = form, DATAOBJECTS_RESOURCES, LINE_FORM, lineFormPath);
summaries.add(new FormMigrationSummary(new Resource<>(lineForm, lineFormPath)));
initForm(form -> processForm = form, BPMN_RESOURCES, PROCESS_FORM, processFormPath);
summaries.add(new FormMigrationSummary(new Resource<>(processForm, processFormPath)));
initForm(form -> taskForm = form, BPMN_RESOURCES, TASK_FORM, taskFormPath);
summaries.add(new FormMigrationSummary(new Resource<>(taskForm, taskFormPath)));
context = new MigrationContext(workspaceProject, weldContainer, migrationServicesCDIWrapper, new RealSystemAccess(), summaries);
generator = new FormDefinitionGenerator(DataObjectFormAdapter::new, this::getBPMNAdapter);
}
Aggregations