use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order method testByStringAndBooleanAndLongSorting.
@Test
public void testByStringAndBooleanAndLongSorting() {
String[] orders = { FIELD_STRING + " " + ORDER_DESC, FIELD_BOOL + " " + ORDER_DESC, FIELD_LONG + " " + ORDER_ASC };
FindNodesByQueryResult result = sort(orders);
Iterator<Node> iterator = getNodes(result.getNodeIds()).iterator();
assertEquals("node2", iterator.next().name().toString());
assertEquals("node1", iterator.next().name().toString());
assertEquals("node3", iterator.next().name().toString());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_func_pathMatch method matches_subPath.
@Test
public void matches_subPath() throws Exception {
createNode(CreateNodeParams.create().name("node1").parent(NodePath.ROOT).build());
final FindNodesByQueryResult result = doQuery("pathMatch('_path', '/node1/node1_1/node1_1_1')");
assertEquals(1, result.getNodeIds().getSize());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_func_pathMatch method score_order_most_matching_first.
@Test
public void score_order_most_matching_first() throws Exception {
final Node node1 = createNode(CreateNodeParams.create().name("node1").setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).build());
final Node node1_1 = createNode(CreateNodeParams.create().name("node1_1").setNodeId(NodeId.from("node1_1")).parent(node1.path()).build());
final Node node1_1_1 = createNode(CreateNodeParams.create().name("node1_1_1").setNodeId(NodeId.from("node1_1_1")).parent(node1_1.path()).build());
final FindNodesByQueryResult result = doQuery("pathMatch('_path', '/node1/node1_1/node1_1_1')");
assertOrder(result, node1_1_1, node1_1, node1);
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_func_pathMatch method matches_subPath_minimum_match.
@Test
public void matches_subPath_minimum_match() throws Exception {
final Node node1 = createNode(CreateNodeParams.create().name("node1").setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).build());
final Node node1_1 = createNode(CreateNodeParams.create().name("node1_1").setNodeId(NodeId.from("node1_1")).parent(node1.path()).build());
final Node node1_1_1 = createNode(CreateNodeParams.create().name("node1_1_1").setNodeId(NodeId.from("node1_1_1")).parent(node1_1.path()).build());
final FindNodesByQueryResult result = doQuery("pathMatch('_path', '/node1/node1_1/node1_1_1', 2)");
assertOrder(result, node1_1_1, node1_1);
}
Aggregations