use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition in project kie-wb-common by kiegroup.
the class FormEditorHelperTest method initFields.
private void initFields() {
TextBoxFieldDefinition name = new TextBoxFieldDefinition();
name.setId("name");
name.setName("name");
name.setLabel("Name");
name.setPlaceHolder("Name");
name.setBinding("name");
name.setStandaloneClassName(String.class.getName());
nameField = name;
TextBoxFieldDefinition lastName = new TextBoxFieldDefinition();
lastName.setId("lastName");
lastName.setName("lastName");
lastName.setLabel("Last Name");
lastName.setPlaceHolder("Last Name");
lastName.setBinding("lastName");
lastName.setStandaloneClassName(String.class.getName());
lastNameField = lastName;
DatePickerFieldDefinition birthday = new DatePickerFieldDefinition();
birthday.setId("birthday");
birthday.setName("birthday");
birthday.setLabel("Birthday");
birthday.setBinding("birthday");
birthday.setStandaloneClassName(Date.class.getName());
CheckBoxFieldDefinition married = new CheckBoxFieldDefinition();
married.setId("married");
married.setName("married");
married.setLabel("Married");
married.setBinding("married");
married.setStandaloneClassName(Boolean.class.getName());
marriedField = married;
IntegerBoxFieldDefinition age = new IntegerBoxFieldDefinition();
age.setId("age");
age.setName("age");
age.setLabel("Age");
age.setBinding("age");
ageField = age;
DecimalBoxFieldDefinition weight = new DecimalBoxFieldDefinition();
weight.setId("weight");
weight.setName("weight");
weight.setLabel("Weight");
weight.setBinding("weight");
weightField = weight;
employeeFields = new ArrayList<>();
employeeFields.add(name);
employeeFields.add(lastName);
employeeFields.add(birthday);
employeeFields.add(married);
employeeFields.add(age);
employeeFields.add(weight);
modelProperties = new ArrayList<>();
employeeFields.forEach(fieldDefinition -> modelProperties.add(new ModelPropertyImpl(fieldDefinition.getBinding(), new TypeInfoImpl(fieldDefinition.getStandaloneClassName()))));
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition in project kie-wb-common by kiegroup.
the class FormGenerationWithSynchronizationTest method testAddModelProperties.
@Test
public void testAddModelProperties() {
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())));
modelProperties.add(new ModelPropertyImpl(AGE_PROPERTY, new TypeInfoImpl(Integer.class.getName())));
modelProperties.add(new ModelPropertyImpl(MARRIED_PROPERTY, new TypeInfoImpl(Boolean.class.getName())));
modelProperties.add(new ModelPropertyImpl(ADDRESS_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(JOB_PROPERTY, new TypeInfoImpl(String.class.getName())));
modelProperties.add(new ModelPropertyImpl(HOBBIES_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(ALL_FORM_FIELDS, Integer.valueOf(formDefinition.getFields().size()));
FieldDefinition field = formDefinition.getFieldByBinding(NAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(LASTNAME_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(AGE_PROPERTY);
assertEquals(field.getStandaloneClassName(), Integer.class.getName());
assertTrue(field instanceof IntegerBoxFieldDefinition);
field = formDefinition.getFieldByBinding(MARRIED_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), Boolean.class.getName());
assertTrue(field instanceof CheckBoxFieldDefinition);
field = formDefinition.getFieldByBinding(ADDRESS_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(JOB_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
field = formDefinition.getFieldByBinding(HOBBIES_PROPERTY);
assertNotNull(field);
assertEquals(field.getStandaloneClassName(), String.class.getName());
assertTrue(field instanceof TextBoxFieldDefinition);
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition 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.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition in project kie-wb-common by kiegroup.
the class FieldRendererManagerImplTest method testFunctionallity.
@Test
public void testFunctionallity() {
testRendererFor(new CheckBoxFieldDefinition());
testRendererFor(new DatePickerFieldDefinition());
testRendererFor(new EnumListBoxFieldDefinition());
testRendererFor(new StringListBoxFieldDefinition());
testRendererFor(new StringRadioGroupFieldDefinition());
testRendererFor(new TextAreaFieldDefinition());
testRendererFor(new IntegerSliderDefinition());
testRendererFor(new DoubleSliderDefinition());
testRendererFor(new MultipleSubFormFieldDefinition());
testRendererFor(new SubFormFieldDefinition());
testRendererFor(new TextBoxFieldDefinition());
testRendererFor(new DecimalBoxFieldDefinition());
testRendererFor(new IntegerBoxFieldDefinition());
}
use of org.kie.workbench.common.forms.fields.shared.fieldTypes.basic.checkBox.definition.CheckBoxFieldDefinition in project kie-wb-common by kiegroup.
the class FormLayoutTemplateGeneratorTest method init.
@Before
public void init() {
templateGenerator = getTemplateGenerator();
form = new FormDefinition();
form.setName("Test");
form.setId("Test-ID");
TextBoxFieldDefinition name = new TextBoxFieldDefinition();
name.setId("name");
name.setName("employee_name");
name.setLabel("Name");
name.setPlaceHolder("Name");
name.setBinding("name");
name.setStandaloneClassName(String.class.getName());
TextBoxFieldDefinition lastName = new TextBoxFieldDefinition();
lastName.setId("lastName");
lastName.setName("employee_lastName");
lastName.setLabel("Last Name");
lastName.setPlaceHolder("Last Name");
lastName.setBinding("lastName");
lastName.setStandaloneClassName(String.class.getName());
DatePickerFieldDefinition birthday = new DatePickerFieldDefinition();
birthday.setId("birthday");
birthday.setName("employee_birthday");
birthday.setLabel("Birthday");
birthday.setBinding("birthday");
birthday.setStandaloneClassName(Date.class.getName());
CheckBoxFieldDefinition married = new CheckBoxFieldDefinition();
married.setId("married");
married.setName("employee_married");
married.setLabel("Married");
married.setBinding("married");
married.setStandaloneClassName(Boolean.class.getName());
form.getFields().add(name);
form.getFields().add(lastName);
form.getFields().add(birthday);
form.getFields().add(married);
}
Aggregations