Search in sources :

Example 1 with InputTypeConfig

use of com.enonic.xp.inputtype.InputTypeConfig in project xp by enonic.

the class XmlInputTypeConfigMapperTest method parseAttributes.

@Test
public void parseAttributes() {
    final InputTypeConfig config = build("attributes.xml");
    assertNotNull(config);
    assertEquals(2, config.getSize());
    assertEquals("other=world[a=1],other=world[a=1,b=2]", toString(config.getProperties("other")));
}
Also used : InputTypeConfig(com.enonic.xp.inputtype.InputTypeConfig) Test(org.junit.jupiter.api.Test)

Example 2 with InputTypeConfig

use of com.enonic.xp.inputtype.InputTypeConfig in project xp by enonic.

the class XmlInputTypeConfigMapperTest method parseNone.

@Test
public void parseNone() {
    final InputTypeConfig config = build("none.xml");
    assertNotNull(config);
    assertEquals(0, config.getSize());
}
Also used : InputTypeConfig(com.enonic.xp.inputtype.InputTypeConfig) Test(org.junit.jupiter.api.Test)

Example 3 with InputTypeConfig

use of com.enonic.xp.inputtype.InputTypeConfig in project xp by enonic.

the class XmlInputTypeConfigMapperTest method parseAliased.

@Test
public void parseAliased() {
    final InputTypeConfig config = build("aliased.xml", InputTypeName.CONTENT_SELECTOR);
    assertNotNull(config);
    assertEquals(2, config.getSize());
    assertEquals("allowContentType=contentTypeTest[]", toString(config.getProperties("allowContentType")));
    assertEquals("relationshipType=myapp:relationshipTypeTest[]", toString(config.getProperties("relationshipType")));
}
Also used : InputTypeConfig(com.enonic.xp.inputtype.InputTypeConfig) Test(org.junit.jupiter.api.Test)

Example 4 with InputTypeConfig

use of com.enonic.xp.inputtype.InputTypeConfig in project xp by enonic.

the class XmlInputTypeConfigMapperTest method parseSimple.

@Test
public void parseSimple() {
    final InputTypeConfig config = build("simple.xml");
    assertNotNull(config);
    assertEquals(2, config.getSize());
    assertEquals("timezone=true[]", toString(config.getProperties("timezone")));
    assertEquals("other=world[]", toString(config.getProperties("other")));
}
Also used : InputTypeConfig(com.enonic.xp.inputtype.InputTypeConfig) Test(org.junit.jupiter.api.Test)

Example 5 with InputTypeConfig

use of com.enonic.xp.inputtype.InputTypeConfig in project xp by enonic.

the class XmlContentTypeParserTest method assertResult.

private void assertResult() throws Exception {
    final ContentType result = this.builder.build();
    assertEquals("myapplication:mytype", result.getName().toString());
    assertEquals("All the Base Types", result.getDisplayName());
    assertEquals("description", result.getDescription());
    assertEquals("${firstName} ${lastName}", result.getDisplayNameExpression());
    assertEquals("Display Name Label", result.getDisplayNameLabel());
    assertEquals("myapplication:content", result.getSuperType().toString());
    assertEquals(false, result.isAbstract());
    assertEquals(true, result.isFinal());
    assertEquals(4, result.getForm().size());
    final FormItem item = result.getForm().getFormItem("myDate");
    assertNotNull(item);
    final Input input = (Input) item;
    assertEquals(InputTypeName.DATE.toString(), input.getInputType().toString());
    final FormItem contentSelectorItem = result.getForm().getFormItem("someonesParent");
    assertNotNull(contentSelectorItem);
    final Input contentSelectorInput = (Input) contentSelectorItem;
    assertEquals(InputTypeName.CONTENT_SELECTOR.toString(), contentSelectorInput.getInputType().toString());
    assertEquals("mytype", contentSelectorInput.getInputTypeConfig().getProperty("allowContentType").getValue());
    assertEquals(2, contentSelectorInput.getInputTypeConfig().getProperties("allowContentType").size());
    assertEquals("path1", contentSelectorInput.getInputTypeConfig().getProperty("allowPath").getValue());
    assertEquals(2, contentSelectorInput.getInputTypeConfig().getProperties("allowPath").size());
    assertEquals("system:reference", contentSelectorInput.getInputTypeConfig().getProperty("relationshipType").getValue());
    final InputTypeConfig config = input.getInputTypeConfig();
    assertNotNull(config);
    final Input defaultOccurrencesInput = result.getForm().getInput("defaultOccurrences");
    final Occurrences defaultOccurrences = defaultOccurrencesInput.getOccurrences();
    assertEquals(0, defaultOccurrences.getMinimum());
    assertEquals(1, defaultOccurrences.getMaximum());
}
Also used : Input(com.enonic.xp.form.Input) ContentType(com.enonic.xp.schema.content.ContentType) FormItem(com.enonic.xp.form.FormItem) InputTypeConfig(com.enonic.xp.inputtype.InputTypeConfig) Occurrences(com.enonic.xp.form.Occurrences)

Aggregations

InputTypeConfig (com.enonic.xp.inputtype.InputTypeConfig)9 Test (org.junit.jupiter.api.Test)7 FormItem (com.enonic.xp.form.FormItem)2 Input (com.enonic.xp.form.Input)2 Occurrences (com.enonic.xp.form.Occurrences)1 MacroDescriptor (com.enonic.xp.macro.MacroDescriptor)1 ContentType (com.enonic.xp.schema.content.ContentType)1