use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_references method incomingReferences.
@Test
public void incomingReferences() throws Exception {
final Node node1 = createNode(CreateNodeParams.create().name("node1").setNodeId(NodeId.from("node1")).parent(NodePath.ROOT).build());
createNodeWithReference("node2", node1.id());
createNodeWithReference("node3", node1.id());
createNodeWithReference("node4", node1.id());
final NodeQuery query = NodeQuery.create().query(QueryParser.parse("_references = 'node1'")).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(3, result.getHits());
assertTrue(result.getNodeIds().contains(NodeId.from("node2")));
assertTrue(result.getNodeIds().contains(NodeId.from("node3")));
assertTrue(result.getNodeIds().contains(NodeId.from("node4")));
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order method testByLongSorting.
@Test
public void testByLongSorting() {
String[] orders = { FIELD_LONG + " " + ORDER_DESC };
FindNodesByQueryResult result = sort(orders);
Iterator<Node> iterator = getNodes(result.getNodeIds()).iterator();
assertEquals("node2", iterator.next().name().toString());
assertEquals("node3", iterator.next().name().toString());
assertEquals("node1", iterator.next().name().toString());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order method testByStringSorting.
@Test
public void testByStringSorting() {
String[] orders = { FIELD_STRING + " " + ORDER_ASC };
FindNodesByQueryResult result = sort(orders);
Iterator<Node> iterator = getNodes(result.getNodeIds()).iterator();
assertEquals("node3", iterator.next().name().toString());
assertEquals("node1", iterator.next().name().toString());
assertEquals("node2", iterator.next().name().toString());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order method testByLongAndStringSorting.
@Test
public void testByLongAndStringSorting() {
String[] orders = { FIELD_LONG + " " + ORDER_ASC, FIELD_STRING + " " + ORDER_DESC };
FindNodesByQueryResult result = sort(orders);
Iterator<Node> iterator = getNodes(result.getNodeIds()).iterator();
assertEquals("node1", iterator.next().name().toString());
assertEquals("node3", iterator.next().name().toString());
assertEquals("node2", iterator.next().name().toString());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order method testByStringAndLongSorting.
@Test
public void testByStringAndLongSorting() {
String[] orders = { FIELD_STRING + " " + 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());
}
Aggregations