Search in sources :

Example 1 with IndexValueString

use of com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexValueString in project xp by enonic.

the class NodeStoreDocumentFactoryTest method references.

@Test
public void references() throws Exception {
    final PropertyTree data = new PropertyTree();
    data.addReference("myRef", new Reference(NodeId.from("otherNode")));
    final Node node = Node.create().id(NodeId.from("myNodeId")).parentPath(NodePath.ROOT).name("myNode").data(data).build();
    final Collection<IndexDocument> indexDocuments = NodeStoreDocumentFactory.createBuilder().node(node).branch(Branch.from("myBranch")).repositoryId(RepositoryId.from("my-repo")).build().create();
    assertEquals(1, indexDocuments.size());
    final IndexDocument indexDocument = indexDocuments.iterator().next();
    final IndexItems indexItems = indexDocument.getIndexItems();
    final Collection<IndexValue> referenceValues = indexItems.get(NodeIndexPath.REFERENCE.getPath());
    assertEquals(1, referenceValues.size());
    final IndexValue next = referenceValues.iterator().next();
    assertTrue(next instanceof IndexValueString);
    final IndexValueString referenceValue = (IndexValueString) next;
    assertEquals("otherNode", referenceValue.getValue());
}
Also used : IndexDocument(com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument) Reference(com.enonic.xp.util.Reference) PropertyTree(com.enonic.xp.data.PropertyTree) Node(com.enonic.xp.node.Node) IndexValueString(com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexValueString) IndexItems(com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexItems) IndexValue(com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexValue) Test(org.junit.jupiter.api.Test)

Aggregations

PropertyTree (com.enonic.xp.data.PropertyTree)1 Node (com.enonic.xp.node.Node)1 IndexDocument (com.enonic.xp.repo.impl.elasticsearch.document.IndexDocument)1 IndexItems (com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexItems)1 IndexValue (com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexValue)1 IndexValueString (com.enonic.xp.repo.impl.elasticsearch.document.indexitem.IndexValueString)1 Reference (com.enonic.xp.util.Reference)1 Test (org.junit.jupiter.api.Test)1