use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_compare method compare_gt.
@Test
public void compare_gt() throws Exception {
final PropertyTree data = new PropertyTree();
data.setDouble("my-value", 5.5);
createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).build());
final PropertyTree data2 = new PropertyTree();
data2.setDouble("my-value", 10.0);
final Node node2 = createNode(CreateNodeParams.create().name("my-node-2").parent(NodePath.ROOT).data(data2).build());
final NodeQuery query = NodeQuery.create().query(QueryExpr.from(CompareExpr.gt(FieldExpr.from(IndexPath.from("my-value")), ValueExpr.number(7)))).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(1, result.getNodeIds().getSize());
assertTrue(result.getNodeIds().contains(node2.id()));
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_compare method compare_eq.
@Test
public void compare_eq() throws Exception {
final Node node1 = createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).build());
createNode(CreateNodeParams.create().name("my-node-2").parent(NodePath.ROOT).build());
createNode(CreateNodeParams.create().name("child-node").parent(node1.path()).build());
final NodeQuery query = NodeQuery.create().query(QueryExpr.from(CompareExpr.eq(FieldExpr.from(NodeIndexPath.NAME), ValueExpr.string("my-node-1")))).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(1, result.getNodeIds().getSize());
assertTrue(result.getNodeIds().contains(node1.id()));
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodePathsByQueryTest method queryAndExpect.
private void queryAndExpect(final String queryString, final NodePaths expected) {
final NodeQuery query = NodeQuery.create().query(QueryParser.parse(queryString)).withPath(true).build();
final FindNodesByQueryResult result = this.nodeService.findByQuery(query);
assertEquals(expected, NodePaths.from(result.getNodeHits().stream().map(NodeHit::getNodePath).collect(Collectors.toSet())));
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_func_range method queryAndAssert.
private void queryAndAssert(final int exptected, final String queryString) {
final NodeQuery query = NodeQuery.create().query(QueryParser.parse(queryString)).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(exptected, result.getNodeIds().getSize());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_func_stemmed method queryAndAssert.
private void queryAndAssert(final Node node, final String queryString, final int expected) {
final NodeQuery query = NodeQuery.create().query(QueryParser.parse(queryString)).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(expected, result.getNodeIds().getSize());
assertTrue(result.getNodeIds().contains(node.id()));
}
Aggregations