use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_acl method queryAndAssert.
private void queryAndAssert(final String path1, final String value1, final Node node1) {
final NodeQuery query = NodeQuery.create().query(QueryExpr.from(CompareExpr.eq(FieldExpr.from(path1), ValueExpr.string(value1)))).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 FindNodesByQueryCommandTest_compare method compare_exists.
@Test
public void compare_exists() throws Exception {
final PropertyTree data = new PropertyTree();
data.addString("myCategory", "article");
final Node node1 = createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).build());
final PropertyTree data2 = new PropertyTree();
data2.addString("myCategory", "document");
createNode(CreateNodeParams.create().name("my-node-2").parent(NodePath.ROOT).data(data2).build());
createNode(CreateNodeParams.create().name("child-node").parent(node1.path()).build());
printContentRepoIndex();
final FindNodesByQueryResult result = doQuery("myCategory LIKE '*' AND NOT myCategory = 'article'");
assertEquals(1, result.getHits());
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order_geoDistance method order_by_geoDistance.
@Test
public void order_by_geoDistance() throws Exception {
createGeoLocations();
final FindNodesByQueryResult result = doQuery("_parentPath = '/' ORDER BY geoDistance('myLocation', '" + OSLO.getLatitude() + "," + OSLO.getLongitude() + "')");
assertOrder(result);
}
use of com.enonic.xp.node.FindNodesByQueryResult in project xp by enonic.
the class FindNodesByQueryCommandTest_order method testByLongAndBooleanSorting.
@Test
public void testByLongAndBooleanSorting() {
String[] orders = { FIELD_LONG + " " + ORDER_DESC, FIELD_BOOL + " " + 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 testByLongAndStringAndBooleanSorting.
@Test
public void testByLongAndStringAndBooleanSorting() {
String[] orders = { FIELD_LONG + " " + ORDER_DESC, FIELD_STRING + " " + ORDER_DESC, FIELD_BOOL + " " + ORDER_ASC };
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());
}
Aggregations