Search in sources :

Example 1 with PatternIndexConfigDocument

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

the class IndexConfigFactoryTest method default_full.

@Test
public void default_full() throws Exception {
    IndexConfigDocument config = create(" {" + "\"default\": {\n" + "                \"decideByType\": true,\n" + "                \"enabled\": true,\n" + "                \"nGram\": false,\n" + "                \"fulltext\": false,\n" + "                \"includeInAllText\": false,\n" + "                \"path\": true,\n" + "                \"indexValueProcessors\": [],\n" + "                \"languages\": []\n" + "            }" + "}");
    assertTrue(config instanceof PatternIndexConfigDocument);
    final PatternIndexConfigDocument patternIndexConfigDocument = (PatternIndexConfigDocument) config;
    final IndexConfig defaultConfig = patternIndexConfigDocument.getDefaultConfig();
    assertEquals(true, defaultConfig.isDecideByType());
    assertEquals(true, defaultConfig.isEnabled());
    assertEquals(false, defaultConfig.isnGram());
    assertEquals(false, defaultConfig.isFulltext());
    assertEquals(false, defaultConfig.isIncludeInAllText());
    assertEquals(true, defaultConfig.isPath());
}
Also used : IndexConfig(com.enonic.xp.index.IndexConfig) PathIndexConfig(com.enonic.xp.index.PathIndexConfig) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) IndexConfigDocument(com.enonic.xp.index.IndexConfigDocument) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 2 with PatternIndexConfigDocument

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

the class IndexConfigFactoryTest method createFullConfig.

private PatternIndexConfigDocument createFullConfig() {
    final IndexConfigDocument indexConfigDoc = create("{\n" + "            \"configs\": [\n" + "                {\n" + "                    \"path\": \"displayName\",\n" + "                    \"config\": \"fulltext\"" + "                },\n" + "                {\n" + "                    \"path\": \"myHtmlField\",\n" + "                    \"config\": {\n" + "                        \"decideByType\": false,\n" + "                        \"enabled\": true,\n" + "                        \"nGram\": false,\n" + "                        \"fulltext\": false,\n" + "                        \"includeInAllText\": true,\n" + "                        \"indexValueProcessors\": [\n" + "                            \"htmlStripper\"\n" + "                        ],\n" + "                        \"languages\": [\n" + "                            \"en\",\"no\"\n" + "                        ]\n" + "                    }\n" + "                },\n" + "                {\n" + "                    \"path\": \"type\",\n" + "                    \"config\": {\n" + "                        \"decideByType\": false,\n" + "                        \"enabled\": false,\n" + "                        \"nGram\": false,\n" + "                        \"fulltext\": false,\n" + "                        \"includeInAllText\": false,\n" + "                        \"path\": false,\n" + "                        \"indexValueProcessors\": []\n" + "                    }\n" + "                }\n" + "            ]\n" + "        }");
    assertTrue(indexConfigDoc instanceof PatternIndexConfigDocument);
    return (PatternIndexConfigDocument) indexConfigDoc;
}
Also used : PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) IndexConfigDocument(com.enonic.xp.index.IndexConfigDocument) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument)

Example 3 with PatternIndexConfigDocument

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

the class IndexConfigVisitorTest method top_htmlArea.

@Test
public void top_htmlArea() 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.Builder builder = PatternIndexConfigDocument.create();
    final IndexConfigVisitor validationVisitor = new IndexConfigVisitor("parent", builder);
    validationVisitor.traverse(form);
    final PatternIndexConfigDocument document = builder.build();
    assertEquals(1, document.getPathIndexConfigs().size());
    assertEquals("htmlStripper", document.getConfigForPath(PropertyPath.from("parent.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)

Example 4 with PatternIndexConfigDocument

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

the class IndexConfigVisitorTest method htmlArea_in_optionSet.

@Test
public void htmlArea_in_optionSet() throws Exception {
    FormOptionSet formOptionSet = FormOptionSet.create().name("myOptionSet").label("My option set").helpText("Option set help text").addOptionSetOption(FormOptionSetOption.create().name("myOptionSetOption1").label("option label1").helpText("Option help text").addFormItem(Input.create().name("myTextLine1").label("textArea").inputType(InputTypeName.TEXT_AREA).build()).build()).addOptionSetOption(FormOptionSetOption.create().name("myOptionSetOption2").label("option label2").helpText("Option help text").addFormItem(Input.create().name("htmlArea").label("htmlArea").inputType(InputTypeName.HTML_AREA).build()).build()).build();
    Form form = Form.create().addFormItem(formOptionSet).build();
    final PatternIndexConfigDocument.Builder builder = PatternIndexConfigDocument.create();
    final IndexConfigVisitor validationVisitor = new IndexConfigVisitor("parent", builder);
    validationVisitor.traverse(form);
    final PatternIndexConfigDocument document = builder.build();
    assertEquals(1, document.getPathIndexConfigs().size());
    assertEquals("htmlStripper", document.getConfigForPath(PropertyPath.from("parent.myoptionset.myoptionsetoption2.htmlArea")).getIndexValueProcessors().get(0).getName());
}
Also used : FormOptionSet(com.enonic.xp.form.FormOptionSet) Form(com.enonic.xp.form.Form) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 5 with PatternIndexConfigDocument

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

the class PageConfigProcessorTest method test_page_config_form_with_html_area_simple.

@Test
public void test_page_config_form_with_html_area_simple() 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(6, result.getPathIndexConfigs().size());
    assertTrue(result.getPathIndexConfigs().contains(PathIndexConfig.create().path(PropertyPath.from(COMPONENTS, PAGE, CONFIG, descriptorKey.getApplicationKey().toString(), descriptorKey.getName())).indexConfig(IndexConfig.BY_TYPE).build()));
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(COMPONENTS, PAGE, CONFIG, descriptorKey.getApplicationKey().toString(), descriptorKey.getName(), "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

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