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