use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class FindNodesByQueryCommandTest_compare method compare_eq_numeric.
@Test
public void compare_eq_numeric() throws Exception {
final PropertyTree data = new PropertyTree();
data.addDouble("myDouble", 2.0);
final Node node1 = createNode(CreateNodeParams.create().name("my-node-1").parent(NodePath.ROOT).data(data).build());
final PropertyTree data2 = new PropertyTree();
data2.addString("myDouble", "2.0");
createNode(CreateNodeParams.create().name("my-node-2").parent(NodePath.ROOT).data(data2).build());
final NodeQuery query = NodeQuery.create().query(QueryExpr.from(CompareExpr.eq(FieldExpr.from("myDouble"), ValueExpr.number(2.0)))).build();
final FindNodesByQueryResult result = doFindByQuery(query);
assertEquals(1, result.getNodeIds().getSize());
assertTrue(result.getNodeIds().contains(node1.id()));
}
use of com.enonic.xp.data.PropertyTree 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.data.PropertyTree in project xp by enonic.
the class FindNodesByQueryCommandTest_func_range method instant_values.
@Test
public void instant_values() throws Exception {
final PropertyTree node1 = new PropertyTree();
node1.addInstant("publishFrom", Instant.parse("2015-08-01T10:00:00Z"));
final PropertyTree node2 = new PropertyTree();
node2.addInstant("publishFrom", Instant.parse("2015-08-01T11:00:00Z"));
createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node-1").data(node1).build());
createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node-2").data(node2).build());
queryAndAssert(1, "range('publishfrom', instant('2015-08-01T09:00:00Z'), instant('2015-08-01T11:00:00Z') )");
queryAndAssert(2, "range('publishfrom', instant('2015-08-01T09:00:00Z'), instant('2015-08-01T11:00:00Z'), 'false', 'true' )");
queryAndAssert(2, "range('publishfrom', instant('2015-08-01T09:00:00Z'), instant('2015-08-01T12:00:00Z') )");
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class FindNodesByQueryCommandTest_func_range method empty_to_instant.
@Test
public void empty_to_instant() throws Exception {
final PropertyTree node1 = new PropertyTree();
node1.addInstant("publishFrom", Instant.parse("2015-08-01T10:00:00Z"));
final PropertyTree node2 = new PropertyTree();
node2.addInstant("publishFrom", Instant.parse("2015-08-01T11:00:00Z"));
createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node-1").data(node1).build());
createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node-2").data(node2).build());
queryAndAssert(2, "range('publishfrom', instant('2015-08-01T09:00:00Z'), '')");
queryAndAssert(2, "range('publishfrom', '', instant('2017-08-01T09:00:00Z'))");
}
use of com.enonic.xp.data.PropertyTree in project xp by enonic.
the class FindNodesByQueryCommandTest_func_range method empty_to_string.
@Test
public void empty_to_string() throws Exception {
final PropertyTree node1 = new PropertyTree();
node1.addString("myValue", "a");
final PropertyTree node2 = new PropertyTree();
node2.addString("myValue", "b");
final PropertyTree node3 = new PropertyTree();
node3.addString("myValue", "c");
createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node-1").data(node1).build());
createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node-2").data(node2).build());
createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("node-3").data(node3).build());
queryAndAssert(3, "range('myValue', 'a', '', 'true', 'false')");
queryAndAssert(2, "range('myValue', 'b', '', 'true', 'false')");
queryAndAssert(1, "range('myValue', 'c', '', 'true', 'false')");
}
Aggregations