Search in sources :

Example 36 with FindNodesByQueryResult

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")));
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Node(com.enonic.xp.node.Node) NodeQuery(com.enonic.xp.node.NodeQuery) Test(org.junit.jupiter.api.Test)

Example 37 with FindNodesByQueryResult

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());
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 38 with FindNodesByQueryResult

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());
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 39 with FindNodesByQueryResult

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());
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Example 40 with FindNodesByQueryResult

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());
}
Also used : FindNodesByQueryResult(com.enonic.xp.node.FindNodesByQueryResult) Node(com.enonic.xp.node.Node) Test(org.junit.jupiter.api.Test)

Aggregations

FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)84 NodeQuery (com.enonic.xp.node.NodeQuery)61 Test (org.junit.jupiter.api.Test)55 Node (com.enonic.xp.node.Node)32 BucketAggregation (com.enonic.xp.aggregation.BucketAggregation)19 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)19 Bucket (com.enonic.xp.aggregation.Bucket)14 PropertyTree (com.enonic.xp.data.PropertyTree)13 Nodes (com.enonic.xp.node.Nodes)9 DynamicConstraintExpr (com.enonic.xp.query.expr.DynamicConstraintExpr)9 Aggregation (com.enonic.xp.aggregation.Aggregation)8 Buckets (com.enonic.xp.aggregation.Buckets)6 QueryExpr (com.enonic.xp.query.expr.QueryExpr)4 DateRangeBucket (com.enonic.xp.aggregation.DateRangeBucket)3 NodeHit (com.enonic.xp.node.NodeHit)3 CompareExpr (com.enonic.xp.query.expr.CompareExpr)3 NumericRangeBucket (com.enonic.xp.aggregation.NumericRangeBucket)2 SingleValueMetricAggregation (com.enonic.xp.aggregation.SingleValueMetricAggregation)2 ContentId (com.enonic.xp.content.ContentId)2 Context (com.enonic.xp.context.Context)2