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());
}
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;
}
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());
}
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());
}
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());
}
Aggregations