use of com.enonic.xp.form.Input in project xp by enonic.
the class FormDefaultValuesProcessorImplTest method defaultValue_checkbox.
@Test
public void defaultValue_checkbox() {
Input input = Input.create().name("testInput").label("testInput").inputType(InputTypeName.CHECK_BOX).defaultValue(InputTypeDefault.create().property(InputTypeProperty.create("default", "checked").build()).build()).build();
final Form form = Form.create().addFormItem(input).build();
final FormDefaultValuesProcessor defaultValuesProcessor = new FormDefaultValuesProcessorImpl();
final PropertyTree data = new PropertyTree();
defaultValuesProcessor.setDefaultValues(form, data);
assertTrue(data.getString("testInput").equals("true"));
}
use of com.enonic.xp.form.Input in project xp by enonic.
the class FormDefaultValuesProcessorImplTest method defaultValue_checkbox_invalid.
@Test
public void defaultValue_checkbox_invalid() {
Input input = Input.create().name("testInput").label("testInput").inputType(InputTypeName.CHECK_BOX).defaultValue(InputTypeDefault.create().property(InputTypeProperty.create("default", "unchecked").build()).build()).build();
final Form form = Form.create().addFormItem(input).build();
final FormDefaultValuesProcessor defaultValuesProcessor = new FormDefaultValuesProcessorImpl();
final PropertyTree data = new PropertyTree();
defaultValuesProcessor.setDefaultValues(form, data);
assertNull(data.getString("testInput"));
}
use of com.enonic.xp.form.Input in project xp by enonic.
the class CustomSelectorTypeTest method testCreateDefaultValue.
@Test
public void testCreateDefaultValue() {
final Input input = getDefaultInputBuilder(InputTypeName.CUSTOM_SELECTOR, "testValue").build();
final Value value = this.type.createDefaultValue(input);
assertNotNull(value);
assertEquals("testValue", value.toString());
}
use of com.enonic.xp.form.Input in project xp by enonic.
the class DateTimeTypeTest method testCreateDefaultValue_withTimezone_format2_plus.
@Test
public void testCreateDefaultValue_withTimezone_format2_plus() {
final Input input = getDefaultInputBuilder(InputTypeName.DATE_TIME, "2014-08-16T10:03:45+03:00").inputTypeConfig(InputTypeConfig.create().property(InputTypeProperty.create("timezone", "true").build()).build()).build();
final Value value = this.type.createDefaultValue(input);
assertNotNull(value);
assertSame(ValueTypes.DATE_TIME, value.getType());
assertEquals(value.toString(), "2014-08-16T07:03:45Z");
}
use of com.enonic.xp.form.Input in project xp by enonic.
the class DateTimeTypeTest method testRelativeDefaultValue_date_time_invalid.
@Test
public void testRelativeDefaultValue_date_time_invalid() {
final Input input = getDefaultInputBuilder(InputTypeName.DATE_TIME, "+1year -5months -36d +2minutes -1haaur").build();
assertThrows(IllegalArgumentException.class, () -> this.type.createDefaultValue(input));
}
Aggregations