Search in sources :

Example 6 with InputTypeConfig

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

the class XmlInputTypeConfigMapperTest method parseCamelCase.

@Test
public void parseCamelCase() {
    final InputTypeConfig config = build("camelcase.xml");
    assertNotNull(config);
    assertEquals(12, config.getSize());
    assertEquals("contentType=test[]", toString(config.getProperties("contentType")));
    assertEquals("myContentType=test[]", toString(config.getProperties("myContentType")));
    assertEquals("mixinType=myapp:test[]", toString(config.getProperties("mixinType")));
    assertEquals("myMixinType=myapp:test[]", toString(config.getProperties("myMixinType")));
    assertEquals("relationshipType=myapp:test[]", toString(config.getProperties("relationshipType")));
    assertEquals("myRelationshipType=myapp:test[]", toString(config.getProperties("myRelationshipType")));
    assertEquals("other1=[mixinType=myapp:test]", toString(config.getProperties("other1")));
    assertEquals("other2=[contentType=test]", toString(config.getProperties("other2")));
    assertEquals("other3=[relationshipType=myapp:test]", toString(config.getProperties("other3")));
    assertEquals("other4=[myMixinType=myapp:test]", toString(config.getProperties("other4")));
    assertEquals("other5=[myContentType=test]", toString(config.getProperties("other5")));
    assertEquals("other6=[myRelationshipType=myapp:test]", toString(config.getProperties("other6")));
}
Also used : InputTypeConfig(com.enonic.xp.inputtype.InputTypeConfig) Test(org.junit.jupiter.api.Test)

Example 7 with InputTypeConfig

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

the class XmlInputTypeConfigMapperTest method parseResolve.

@Test
public void parseResolve() {
    final InputTypeConfig config = build("resolve.xml");
    assertNotNull(config);
    assertEquals(12, config.getSize());
    assertEquals("contentType=test[]", toString(config.getProperties("contentType")));
    assertEquals("myContentType=test[]", toString(config.getProperties("myContentType")));
    assertEquals("mixinType=myapp:test[]", toString(config.getProperties("mixinType")));
    assertEquals("myMixinType=myapp:test[]", toString(config.getProperties("myMixinType")));
    assertEquals("relationshipType=myapp:test[]", toString(config.getProperties("relationshipType")));
    assertEquals("myRelationshipType=myapp:test[]", toString(config.getProperties("myRelationshipType")));
    assertEquals("other1=[mixinType=myapp:test]", toString(config.getProperties("other1")));
    assertEquals("other2=[contentType=test]", toString(config.getProperties("other2")));
    assertEquals("other3=[relationshipType=myapp:test]", toString(config.getProperties("other3")));
    assertEquals("other4=[myMixinType=myapp:test]", toString(config.getProperties("other4")));
    assertEquals("other5=[myContentType=test]", toString(config.getProperties("other5")));
    assertEquals("other6=[myRelationshipType=myapp:test]", toString(config.getProperties("other6")));
}
Also used : InputTypeConfig(com.enonic.xp.inputtype.InputTypeConfig) Test(org.junit.jupiter.api.Test)

Example 8 with InputTypeConfig

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

the class XmlInputTypeConfigMapperTest method parseEmpty.

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

Example 9 with InputTypeConfig

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

the class XmlMacroDescriptorParserTest method assertResult.

private void assertResult() throws Exception {
    final MacroDescriptor result = this.builder.build();
    assertEquals("myapplication:mymacro", result.getKey().toString());
    assertEquals("My macro", result.getDisplayName());
    assertEquals("key.display-name", result.getDisplayNameI18nKey());
    assertEquals("key.description", result.getDescriptionI18nKey());
    assertEquals("This macro is a test", result.getDescription());
    assertEquals(3, result.getForm().size());
    final FormItem item = result.getForm().getFormItem("myDate");
    assertNotNull(item);
    final Input input = (Input) item;
    assertEquals(InputTypeName.DATE.toString(), input.getInputType().toString());
    assertEquals("key.label", input.getLabelI18nKey());
    assertEquals("key.help-text", input.getHelpTextI18nKey());
    final FormItem contentSelectorItem = result.getForm().getFormItem("someonesParent");
    assertNotNull(contentSelectorItem);
    final Input contentSelectorInput = (Input) contentSelectorItem;
    assertEquals(InputTypeName.CONTENT_SELECTOR.toString(), contentSelectorInput.getInputType().toString());
    assertEquals("key.parent", contentSelectorInput.getLabelI18nKey());
    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);
}
Also used : Input(com.enonic.xp.form.Input) MacroDescriptor(com.enonic.xp.macro.MacroDescriptor) FormItem(com.enonic.xp.form.FormItem) InputTypeConfig(com.enonic.xp.inputtype.InputTypeConfig)

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