Search in sources :

Example 11 with Input

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

the class XmlContentTypeParserTest method testI18n_optionSet.

@Test
public void testI18n_optionSet() throws Exception {
    parse(this.parser, "-i18n.xml");
    final ContentType result = this.builder.build();
    final FormItem item = result.getForm().getFormItem("radioOptionSet");
    assertNotNull(item);
    final FormOptionSet radioOptionSet = (FormOptionSet) item;
    assertEquals(FormItemType.FORM_OPTION_SET, radioOptionSet.getType());
    assertEquals("translated.help-text", radioOptionSet.getHelpTextI18nKey());
    assertEquals("translated.label", radioOptionSet.getLabelI18nKey());
    final Input inputInsideOption = radioOptionSet.getFormItems().getInput(FormItemPath.from("option_1.text-input"));
    assertEquals("translated.help-text", inputInsideOption.getHelpTextI18nKey());
    assertEquals("translated.label", inputInsideOption.getLabelI18nKey());
    final FormOptionSetOption radioOption = radioOptionSet.getFormItems().getItemByName("option_1").toFormOptionSetOption();
    assertEquals("translated.help-text", radioOption.getHelpTextI18nKey());
    assertEquals("translated.label", radioOption.getLabelI18nKey());
}
Also used : FormOptionSet(com.enonic.xp.form.FormOptionSet) Input(com.enonic.xp.form.Input) ContentType(com.enonic.xp.schema.content.ContentType) FormItem(com.enonic.xp.form.FormItem) FormOptionSetOption(com.enonic.xp.form.FormOptionSetOption) Test(org.junit.jupiter.api.Test)

Example 12 with Input

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

the class InputValidationVisitorTest method validateInputTypeInvalid.

@Test
public void validateInputTypeInvalid() throws Exception {
    Input myTextLine = Input.create().name("myTextLine").inputType(InputTypeName.TEXT_LINE).label("My text line").required(true).build();
    Form form = Form.create().addFormItem(myTextLine).build();
    PropertyTree propertyTree = new PropertyTree();
    propertyTree.setLong("myTextLine", 33L);
    final InputValidationVisitor validationVisitor = new InputValidationVisitor(propertyTree, InputTypes.BUILTIN);
    assertThrows(InputTypeValidationException.class, () -> validationVisitor.traverse(form));
}
Also used : Input(com.enonic.xp.form.Input) Form(com.enonic.xp.form.Form) PropertyTree(com.enonic.xp.data.PropertyTree) Test(org.junit.jupiter.api.Test)

Example 13 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 14 with Input

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

the class TimeTypeTest method testCreateDefaultValue.

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

Example 15 with Input

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

the class DataConfigProcessorTest method test_data_form_with_html_area.

@Test
public void test_data_form_with_html_area() throws Exception {
    Input myTextLine = Input.create().name("htmlArea").inputType(InputTypeName.HTML_AREA).label("htmlArea").required(true).build();
    Form form = Form.create().addFormItem(myTextLine).build();
    final PatternIndexConfigDocument result = processForm(form);
    assertEquals(2, result.getPathIndexConfigs().size());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(DATA + ".htmlArea")).getIndexValueProcessors().get(0).getName());
}
Also used : Input(com.enonic.xp.form.Input) Form(com.enonic.xp.form.Form) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) 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