Search in sources :

Example 41 with Input

use of com.enonic.xp.form.Input in project xp by enonic.

the class DateTimeTypeTest method testCreateDefaultValue_invalid.

@Test
public void testCreateDefaultValue_invalid() {
    final Input input = getDefaultInputBuilder(InputTypeName.DATE_TIME, "2014-18-16T05:03:45").inputTypeConfig(InputTypeConfig.create().property(InputTypeProperty.create("timezone", "true").build()).build()).build();
    assertThrows(IllegalArgumentException.class, () -> this.type.createDefaultValue(input));
}
Also used : Input(com.enonic.xp.form.Input) Test(org.junit.jupiter.api.Test)

Example 42 with Input

use of com.enonic.xp.form.Input in project xp by enonic.

the class DateTimeTypeTest method testCreateDefaultValue_withTimezone_format2_minus.

@Test
public void testCreateDefaultValue_withTimezone_format2_minus() {
    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-16T13:03:45Z");
}
Also used : Input(com.enonic.xp.form.Input) Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Example 43 with Input

use of com.enonic.xp.form.Input in project xp by enonic.

the class CheckBoxTypeTest method testCreateDefaultValue.

@Test
public void testCreateDefaultValue() {
    final Input input = getDefaultInputBuilder(InputTypeName.CHECK_BOX, "checked").build();
    final Value value = this.type.createDefaultValue(input);
    assertNotNull(value);
    assertEquals("true", value.toString());
}
Also used : Input(com.enonic.xp.form.Input) Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Example 44 with Input

use of com.enonic.xp.form.Input in project xp by enonic.

the class DateTimeTypeTest method testCreateDefaultValue_withTimezone_format2_day_change.

@Test
public void testCreateDefaultValue_withTimezone_format2_day_change() {
    final Input input = getDefaultInputBuilder(InputTypeName.DATE_TIME, "2014-08-16T22: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-17T01:03:45Z");
}
Also used : Input(com.enonic.xp.form.Input) Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Example 45 with Input

use of com.enonic.xp.form.Input in project xp by enonic.

the class DateTimeTypeTest method testRelativeDefaultValue_only_relative_date_exists.

@Test
public void testRelativeDefaultValue_only_relative_date_exists() {
    final Input input = getDefaultInputBuilder(InputTypeName.DATE_TIME, "+1year -5months -36d").build();
    final Value value = this.type.createDefaultValue(input);
    assertNotNull(value);
    assertSame(ValueTypes.LOCAL_DATE_TIME, value.getType());
}
Also used : Input(com.enonic.xp.form.Input) Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Aggregations

Input (com.enonic.xp.form.Input)62 Test (org.junit.jupiter.api.Test)47 Value (com.enonic.xp.data.Value)24 Form (com.enonic.xp.form.Form)15 PropertyTree (com.enonic.xp.data.PropertyTree)11 FormItem (com.enonic.xp.form.FormItem)9 FormItemSet (com.enonic.xp.form.FormItemSet)9 FormDefaultValuesProcessor (com.enonic.xp.form.FormDefaultValuesProcessor)7 ContentType (com.enonic.xp.schema.content.ContentType)7 FormOptionSet (com.enonic.xp.form.FormOptionSet)5 FieldSet (com.enonic.xp.form.FieldSet)4 FormOptionSetOption (com.enonic.xp.form.FormOptionSetOption)4 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)4 Property (com.enonic.xp.data.Property)3 Occurrences (com.enonic.xp.form.Occurrences)3 Content (com.enonic.xp.content.Content)2 ExtraData (com.enonic.xp.content.ExtraData)2 ValidationErrors (com.enonic.xp.content.ValidationErrors)2 PropertyPath (com.enonic.xp.data.PropertyPath)2 PropertySet (com.enonic.xp.data.PropertySet)2