Search in sources :

Example 11 with AbstractNode

use of org.xwiki.notifications.filters.expression.generics.AbstractNode in project xwiki-platform by xwiki.

the class ExpressionNodeToHQLConverterTest method parseWithLesserThanNode.

@Test
public void parseWithLesserThanNode() {
    AbstractNode testAST = new LesserThanNode(new PropertyValueNode(EventProperty.DATE), new StringValueNode(TEST_VALUE_1));
    ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
    assertEquals(String.format("event.date <= :%s", TEST_VALUE_1_IDENTIFIER), result.getQuery());
    assertEquals(TEST_VALUE_1, result.getQueryParameters().get(TEST_VALUE_1_IDENTIFIER));
}
Also used : LesserThanNode(org.xwiki.notifications.filters.expression.LesserThanNode) AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) StringValueNode(org.xwiki.notifications.filters.expression.StringValueNode) PropertyValueNode(org.xwiki.notifications.filters.expression.PropertyValueNode) Test(org.junit.Test)

Example 12 with AbstractNode

use of org.xwiki.notifications.filters.expression.generics.AbstractNode in project xwiki-platform by xwiki.

the class ExpressionNodeToHQLConverterTest method parseWithGreaterThanNode.

@Test
public void parseWithGreaterThanNode() {
    AbstractNode testAST = new GreaterThanNode(new PropertyValueNode(EventProperty.DATE), new StringValueNode(TEST_VALUE_1));
    ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
    assertEquals(String.format("event.date >= :%s", TEST_VALUE_1_IDENTIFIER), result.getQuery());
    assertEquals(TEST_VALUE_1, result.getQueryParameters().get(TEST_VALUE_1_IDENTIFIER));
}
Also used : AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) StringValueNode(org.xwiki.notifications.filters.expression.StringValueNode) GreaterThanNode(org.xwiki.notifications.filters.expression.GreaterThanNode) PropertyValueNode(org.xwiki.notifications.filters.expression.PropertyValueNode) Test(org.junit.Test)

Example 13 with AbstractNode

use of org.xwiki.notifications.filters.expression.generics.AbstractNode in project xwiki-platform by xwiki.

the class ExpressionNodeToHQLConverterTest method parseDateNode.

@Test
public void parseDateNode() {
    Date date = new Date(0);
    AbstractNode testAST = new DateValueNode(date);
    ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
    assertEquals(":date_688218ea2b05763819a1e155109e4bf1e8921dd72e8b43d4c89c89133d4a5357", result.getQuery());
    assertEquals(date, result.getQueryParameters().get("date_688218ea2b05763819a1e155109e4bf1e8921dd72e8b43d4c89c89133d4a5357"));
}
Also used : AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) DateValueNode(org.xwiki.notifications.filters.expression.DateValueNode) Date(java.util.Date) Test(org.junit.Test)

Example 14 with AbstractNode

use of org.xwiki.notifications.filters.expression.generics.AbstractNode in project xwiki-platform by xwiki.

the class TestExpressionToString method test.

@Test
public void test() throws Exception {
    AbstractNode node = new AndNode(new OrNode(new EqualsNode(new PropertyValueNode(EventProperty.WIKI), new StringValueNode("value1")), new NotEqualsNode(new PropertyValueNode(EventProperty.SPACE), new StringValueNode("value2"))), new NotNode(new StartsWith(new PropertyValueNode(EventProperty.PAGE), new StringValueNode("value3%"))));
    assertEquals("((WIKI = \"value1\" OR SPACE <> \"value2\") AND NOT (PAGE STARTS WITH \"value3%\"))", node.toString());
}
Also used : AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 AbstractNode (org.xwiki.notifications.filters.expression.generics.AbstractNode)14 StringValueNode (org.xwiki.notifications.filters.expression.StringValueNode)7 NotEqualsNode (org.xwiki.notifications.filters.expression.NotEqualsNode)4 PropertyValueNode (org.xwiki.notifications.filters.expression.PropertyValueNode)4 EqualsNode (org.xwiki.notifications.filters.expression.EqualsNode)3 DocumentReference (org.xwiki.model.reference.DocumentReference)2 NotNode (org.xwiki.notifications.filters.expression.NotNode)2 Date (java.util.Date)1 DateValueNode (org.xwiki.notifications.filters.expression.DateValueNode)1 EntityReferenceNode (org.xwiki.notifications.filters.expression.EntityReferenceNode)1 GreaterThanNode (org.xwiki.notifications.filters.expression.GreaterThanNode)1 InNode (org.xwiki.notifications.filters.expression.InNode)1 LesserThanNode (org.xwiki.notifications.filters.expression.LesserThanNode)1 StartsWith (org.xwiki.notifications.filters.expression.StartsWith)1 InListOfReadEventsNode (org.xwiki.notifications.filters.internal.status.InListOfReadEventsNode)1