Search in sources :

Example 6 with Input

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

the class TextAreaTypeTest method testCreateDefaultValue.

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

Example 7 with Input

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

the class DateTimeTypeTest method testCreateDefaultValue_withTimezone_format1.

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

Example 8 with Input

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

the class DateTimeTypeTest method testRelativeDefaultValue_date_time.

@Test
public void testRelativeDefaultValue_date_time() {
    final Input input = getDefaultInputBuilder(InputTypeName.DATE_TIME, "+1year -5months -36d +2minutes -1h").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());
}
Also used : Input(com.enonic.xp.form.Input) Value(com.enonic.xp.data.Value) Test(org.junit.jupiter.api.Test)

Example 9 with Input

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

the class DateTimeTypeTest method testRelativeDefaultValue_only_relative_time_exists.

@Test
public void testRelativeDefaultValue_only_relative_time_exists() {
    final Input input = getDefaultInputBuilder(InputTypeName.DATE_TIME, "+1hour -5minutes -36s").inputTypeConfig(InputTypeConfig.create().property(InputTypeProperty.create("timezone", "false").build()).build()).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)

Example 10 with Input

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

the class DateTypeTest method testRelativeDefaultValue.

@Test
public void testRelativeDefaultValue() {
    final Input input = getDefaultInputBuilder(InputTypeName.DATE, "+1year -5months -36d").build();
    final Value value = this.type.createDefaultValue(input);
    assertNotNull(value);
    assertSame(ValueTypes.LOCAL_DATE, value.getType());
    assertEquals(value.getObject(), LocalDate.now().plusYears(1).plusMonths(-5).plusDays(-36));
}
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