use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class FormGenerationWithSynchronizationTest method testModelPropertiesConflict.
@Test
public void testModelPropertiesConflict() {
List<ModelProperty> modelProperties = new ArrayList<>();
modelProperties.add(new ModelPropertyImpl(NAME_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
modelProperties.add(new ModelPropertyImpl(LASTNAME_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
modelProperties.add(new ModelPropertyImpl(AGE_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(MARRIED_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
modelProperties.add(new ModelPropertyImpl(ADDRESS_PROPERTY, new TypeInfoImpl(Boolean.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(), Integer.class.getName());
assertTrue(field instanceof IntegerBoxFieldDefinition);
field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Integer.class.getName());
assertTrue(field instanceof IntegerBoxFieldDefinition);
field = formDefinition.getFieldByBinding(AGE_PROPERTY);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(MARRIED_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Integer.class.getName());
assertTrue(field instanceof IntegerBoxFieldDefinition);
field = formDefinition.getFieldByBinding(ADDRESS_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Boolean.class.getName());
assertTrue(field instanceof CheckBoxFieldDefinition);
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class BPMNFormGenerationTest method checkPersonalDataForm.
private void checkPersonalDataForm(FormDefinition form, Map<String, FormDefinition> allForms) {
assertNotNull(form);
assertEquals(2, form.getFields().size());
FieldDefinition field = form.getFieldByBinding("address");
assertFieldStatus(field, "address", String.class.getName());
field = form.getFieldByBinding("phone");
assertFieldStatus(field, "phone", String.class.getName());
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class BPMNFormGenerationTest method checkPersonForm.
private void checkPersonForm(FormDefinition form, Map<String, FormDefinition> allForms) {
assertNotNull(form);
assertTrue(form.getModel() instanceof JavaFormModel);
assertEquals(4, form.getFields().size());
FieldDefinition field = form.getFieldByBinding("name");
assertFieldStatus(field, "name", String.class.getName());
field = form.getFieldByBinding("type");
assertFieldStatus(field, "type", PersonType.class.getName());
assertTrue(field instanceof EnumListBoxFieldDefinition);
field = form.getFieldByBinding("personalData");
assertFieldStatus(field, "personalData", PersonalData.class.getName());
assertTrue(field instanceof SubFormFieldDefinition);
SubFormFieldDefinition subForm = (SubFormFieldDefinition) field;
assertNotNull(subForm.getNestedForm());
assertNotNull(allForms.get(subForm.getNestedForm()));
field = form.getFieldByBinding("log");
assertFieldStatus(field, "log", LogEntry.class.getName());
assertTrue(field instanceof MultipleSubFormFieldDefinition);
MultipleSubFormFieldDefinition multipleSubForm = (MultipleSubFormFieldDefinition) field;
assertNotNull(multipleSubForm.getCreationForm());
assertEquals(multipleSubForm.getCreationForm(), multipleSubForm.getEditionForm());
FormDefinition nestedForm = allForms.get(multipleSubForm.getCreationForm());
assertNotNull(nestedForm);
assertNotNull(multipleSubForm.getColumnMetas());
assertEquals(nestedForm.getFields().size(), multipleSubForm.getColumnMetas().size());
multipleSubForm.getColumnMetas().forEach(columnMeta -> {
FieldDefinition nestedField = nestedForm.getFieldByBinding(columnMeta.getProperty());
assertNotNull(nestedField);
assertEquals(nestedField.getLabel(), columnMeta.getLabel());
});
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class BPMNFormGenerationTest method checkLogEntryForm.
private void checkLogEntryForm(FormDefinition form) {
assertNotNull(form);
assertEquals(2, form.getFields().size());
FieldDefinition field = form.getFieldByBinding("date");
assertFieldStatus(field, "date", Date.class.getName());
field = form.getFieldByBinding("text");
assertFieldStatus(field, "text", String.class.getName());
}
use of org.kie.workbench.common.forms.model.FieldDefinition in project kie-wb-common by kiegroup.
the class BPMNFormGenerationTest method testSimpleVariables.
@Test
public void testSimpleVariables() {
List<ModelProperty> variables = new ArrayList<>();
variables.add(new ModelPropertyImpl("employee", new TypeInfoImpl(String.class.getName())));
variables.add(new ModelPropertyImpl("manager", new TypeInfoImpl(String.class.getName())));
variables.add(new ModelPropertyImpl("performance", new TypeInfoImpl(Integer.class.getName())));
variables.add(new ModelPropertyImpl("approved", new TypeInfoImpl(Boolean.class.getName())));
model = getModel(getModelId(), variables);
Collection<FormDefinition> forms = getModelForms(model, classLoader);
try {
verify(classLoader, never()).loadClass(anyString());
} catch (ClassNotFoundException e) {
fail("We shouldn't be here: " + e.getMessage());
}
assertNotNull("There should one form", forms);
assertEquals("There should one form", 1, forms.size());
FormDefinition form = forms.iterator().next();
assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getId());
assertEquals(getModelId() + BPMNVariableUtils.TASK_FORM_SUFFIX, form.getName());
assertEquals(form.getModel(), model);
assertEquals("There should be 4 fields", 4, form.getFields().size());
variables.forEach(variable -> {
FieldDefinition field = form.getFieldByBinding(variable.getName());
assertFieldStatus(field, variable);
});
}
Aggregations