Search in sources :

Example 11 with PatternIndexConfigDocument

use of com.enonic.xp.index.PatternIndexConfigDocument in project xp by enonic.

the class PageConfigProcessorTest method test_config_with_data.

@Test
public void test_config_with_data() throws Exception {
    final PatternIndexConfigDocument result = processForm(Form.create().addFormItem(FormItemSet.create().name("items").addFormItem(Input.create().name("input").label("input").inputType(InputTypeName.TEXT_LINE).occurrences(0, 5).build()).build()).build());
    assertEquals(5, result.getPathIndexConfigs().size());
    assertTrue(result.getPathIndexConfigs().contains(PathIndexConfig.create().path(PropertyPath.from(COMPONENTS)).indexConfig(IndexConfig.NONE).build()));
    assertTrue(result.getPathIndexConfigs().contains(PathIndexConfig.create().path(PropertyPath.from(COMPONENTS, PAGE, DESCRIPTOR)).indexConfig(IndexConfig.MINIMAL).build()));
    assertTrue(result.getPathIndexConfigs().contains(PathIndexConfig.create().path(PropertyPath.from(COMPONENTS, PAGE, CUSTOMIZED)).indexConfig(IndexConfig.MINIMAL).build()));
    assertTrue(result.getPathIndexConfigs().contains(PathIndexConfig.create().path(PropertyPath.from(COMPONENTS, PAGE, TEMPLATE)).indexConfig(IndexConfig.MINIMAL).build()));
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from(COMPONENTS, PAGE, CONFIG, "appKey", "descriptorName")));
}
Also used : PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 12 with PatternIndexConfigDocument

use of com.enonic.xp.index.PatternIndexConfigDocument in project xp by enonic.

the class PageRegionsConfigProcessorTest method test_text_component.

@Test
public void test_text_component() throws Exception {
    final PatternIndexConfigDocument result = processPage(Page.create().regions(PageRegions.create().build()).build(), null, null);
    assertEquals(TEXT_COMPONENT_INDEX_CONFIG, result.getConfigForPath(PropertyPath.from(COMPONENTS, TextComponentType.INSTANCE.toString(), VALUE)));
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(COMPONENTS, TextComponentType.INSTANCE.toString(), VALUE)).getIndexValueProcessors().get(0).getName());
}
Also used : PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 13 with PatternIndexConfigDocument

use of com.enonic.xp.index.PatternIndexConfigDocument in project xp by enonic.

the class PageRegionsConfigProcessorTest method test_part_inside_layout_component.

@Test
public void test_part_inside_layout_component() throws Exception {
    final String appKeyLayout = "layoutAppKey";
    final String appKeyPart = "partAppKey";
    final String htmlarea = "htmlarea";
    final Page page = Page.create().regions(PageRegions.create().add(Region.create().name("region1").add(LayoutComponent.create().descriptor(DescriptorKey.from(appKeyLayout)).regions(LayoutRegions.create().add(Region.create().name("layoutRegion1").add(PartComponent.create().descriptor(DescriptorKey.from(appKeyPart)).build()).build()).build()).build()).build()).build()).build();
    final PatternIndexConfigDocument result = processPage(page, Arrays.asList(configFormWithHtmlArea).listIterator(), Arrays.asList(configFormWithHtmlArea).listIterator());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(COMPONENTS, LayoutComponentType.INSTANCE.toString(), CONFIG, appKeyLayout, htmlarea)).getIndexValueProcessors().get(0).getName());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(COMPONENTS, PartComponentType.INSTANCE.toString(), CONFIG, appKeyPart, htmlarea)).getIndexValueProcessors().get(0).getName());
}
Also used : Page(com.enonic.xp.page.Page) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 14 with PatternIndexConfigDocument

use of com.enonic.xp.index.PatternIndexConfigDocument in project xp by enonic.

the class PageRegionsConfigProcessorTest method test_complex_component_config.

@Test
public void test_complex_component_config() throws Exception {
    final PropertyTree config = new PropertyTree();
    final PropertySet items = config.addSet("items");
    items.addStrings("input", "a", "b", "c");
    final Page page = Page.create().regions(PageRegions.create().add(Region.create().name("region1").add(PartComponent.create().descriptor(DescriptorKey.from("appKey1:partName1")).config(new PropertyTree()).build()).add(LayoutComponent.create().descriptor(DescriptorKey.from("appKey2:layoutName")).config(new PropertyTree()).regions(LayoutRegions.create().add(Region.create().name("region").add(PartComponent.create().descriptor(DescriptorKey.from("appKey3:partName2")).config(new PropertyTree()).build()).build()).build()).build()).build()).build()).build();
    final Form form = Form.create().addFormItem(FormItemSet.create().name("items").addFormItem(Input.create().name("input").label("input").inputType(InputTypeName.TEXT_LINE).occurrences(0, 5).build()).build()).build();
    final PatternIndexConfigDocument result = processPage(page, Arrays.asList(form, form).listIterator(), singletonList(form).listIterator());
    assertEquals(8, result.getPathIndexConfigs().size());
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appKey1.partName1")));
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appKey2.layoutName")));
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appkey3.partname2")));
}
Also used : Form(com.enonic.xp.form.Form) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Page(com.enonic.xp.page.Page) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 15 with PatternIndexConfigDocument

use of com.enonic.xp.index.PatternIndexConfigDocument in project xp by enonic.

the class SiteConfigProcessorTest method test_empty_site_config.

@Test
public void test_empty_site_config() throws Exception {
    final PatternIndexConfigDocument result = processConfigs(SiteConfigs.create().build(), Form.create().build(), null);
    assertEquals(0, result.getPathIndexConfigs().size());
}
Also used : PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Aggregations

PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)33 Test (org.junit.jupiter.api.Test)26 Form (com.enonic.xp.form.Form)10 PropertyTree (com.enonic.xp.data.PropertyTree)9 PropertySet (com.enonic.xp.data.PropertySet)5 Page (com.enonic.xp.page.Page)5 Input (com.enonic.xp.form.Input)4 PathIndexConfig (com.enonic.xp.index.PathIndexConfig)3 NodeVersion (com.enonic.xp.node.NodeVersion)3 DescriptorKey (com.enonic.xp.page.DescriptorKey)3 SiteConfigs (com.enonic.xp.site.SiteConfigs)3 DumpUpgradeStepResult (com.enonic.xp.dump.DumpUpgradeStepResult)2 IndexConfigDocument (com.enonic.xp.index.IndexConfigDocument)2 Reference (com.enonic.xp.util.Reference)2 ContentConstants (com.enonic.xp.content.ContentConstants)1 Property (com.enonic.xp.data.Property)1 PropertyPath (com.enonic.xp.data.PropertyPath)1 PropertyVisitor (com.enonic.xp.data.PropertyVisitor)1 ValueFactory (com.enonic.xp.data.ValueFactory)1 ValueTypes (com.enonic.xp.data.ValueTypes)1