Search in sources :

Example 16 with PatternIndexConfigDocument

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

the class XDataConfigProcessorTest method test_data_form_with_html_area.

@Test
public void test_data_form_with_html_area() 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 = processForms(form);
    assertEquals(2, result.getPathIndexConfigs().size());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(EXTRA_DATA + ".appname.localname0.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 17 with PatternIndexConfigDocument

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

the class BaseNodeHandlerTest method createNode.

protected Node createNode(final NodePath parentPath, final String name) {
    final PropertyTree data = new PropertyTree();
    data.setString("displayName", "This is brand new node");
    final PropertySet someData = data.addSet("someData");
    someData.setString("cars", "skoda");
    someData.addString("cars", "tesla model x");
    someData.setString("likes", "plywood");
    someData.setLong("numberOfUselessGadgets", 123L);
    final PatternIndexConfigDocument indexConfig = PatternIndexConfigDocument.create().defaultConfig(IndexConfig.MINIMAL).add("displayName", IndexConfig.FULLTEXT).build();
    return Node.create().id(NodeId.from("nodeId")).parentPath(parentPath).name(name).data(data).indexConfigDocument(indexConfig).permissions(AccessControlList.create().add(AccessControlEntry.create().principal(PrincipalKey.ofRole("admin")).allowAll().build()).build()).nodeState(NodeState.DEFAULT).nodeVersionId(NodeVersionId.from("versionKey")).timestamp(Instant.parse("2010-10-10T10:10:10.10Z")).build();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument)

Example 18 with PatternIndexConfigDocument

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

the class IndexConfigVisitorTest method htmlArea_in_itemSet.

@Test
public void htmlArea_in_itemSet() throws Exception {
    FormItemSet myFormItemSet = FormItemSet.create().name("myFormItemSet").label("My form item set").addFormItem(Input.create().name("htmlArea").inputType(InputTypeName.HTML_AREA).label("htmlArea").required(false).build()).build();
    Form form = Form.create().addFormItem(myFormItemSet).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.myFormItemSet.htmlArea")).getIndexValueProcessors().get(0).getName());
}
Also used : Form(com.enonic.xp.form.Form) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) FormItemSet(com.enonic.xp.form.FormItemSet) Test(org.junit.jupiter.api.Test)

Example 19 with PatternIndexConfigDocument

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

the class PageConfigProcessorTest method test_size.

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

Example 20 with PatternIndexConfigDocument

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

the class OldBaseNodeHandlerTest method createNode.

protected Node createNode(final NodePath parentPath, final String name) {
    final PropertyTree data = new PropertyTree();
    data.setString("displayName", "This is brand new node");
    final PropertySet someData = data.addSet("someData");
    someData.setString("cars", "skoda");
    someData.addString("cars", "tesla model x");
    someData.setString("likes", "plywood");
    someData.setLong("numberOfUselessGadgets", 123L);
    final PatternIndexConfigDocument indexConfig = PatternIndexConfigDocument.create().defaultConfig(IndexConfig.MINIMAL).add("displayName", IndexConfig.FULLTEXT).build();
    return Node.create().id(NodeId.from("nodeId")).parentPath(parentPath).name(name).data(data).indexConfigDocument(indexConfig).permissions(AccessControlList.create().add(AccessControlEntry.create().principal(PrincipalKey.ofAnonymous()).allow(Permission.READ).build()).add(AccessControlEntry.create().principal(PrincipalKey.ofRole("admin")).allowAll().build()).build()).nodeState(NodeState.DEFAULT).nodeVersionId(NodeVersionId.from("versionKey")).timestamp(Instant.parse("2010-10-10T10:10:10.10Z")).build();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument)

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