Search in sources :

Example 1 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseWithInNode.

@Test
public void parseWithInNode() {
    AbstractNode testAST = new InNode(new PropertyValueNode(EventProperty.PAGE), Arrays.asList(new StringValueNode(TEST_VALUE_1), new StringValueNode(TEST_VALUE_2)));
    ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
    assertEquals(String.format("event.page IN (:%s, :%s)", TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER), result.getQuery());
    assertEquals(TEST_VALUE_1, result.getQueryParameters().get(TEST_VALUE_1_IDENTIFIER));
    assertEquals(TEST_VALUE_2, result.getQueryParameters().get(TEST_VALUE_2_IDENTIFIER));
}
Also used : InNode(org.xwiki.notifications.filters.expression.InNode) 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 2 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseWithNotNode.

@Test
public void parseWithNotNode() {
    AbstractNode testAST = new NotNode(new EqualsNode(new StringValueNode(TEST_VALUE_1), new StringValueNode(TEST_VALUE_2)));
    assertEquals(String.format(" NOT (:%s = :%s)", TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER), parser.parse(testAST).getQuery());
}
Also used : NotNode(org.xwiki.notifications.filters.expression.NotNode) AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) StringValueNode(org.xwiki.notifications.filters.expression.StringValueNode) EqualsNode(org.xwiki.notifications.filters.expression.EqualsNode) NotEqualsNode(org.xwiki.notifications.filters.expression.NotEqualsNode) Test(org.junit.Test)

Example 3 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseWithEqualsNode.

@Test
public void parseWithEqualsNode() {
    AbstractNode testAST = new EqualsNode(new StringValueNode(TEST_VALUE_1), new StringValueNode(TEST_VALUE_2));
    assertEquals(String.format(":%s = :%s", TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER), parser.parse(testAST).getQuery());
}
Also used : AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) StringValueNode(org.xwiki.notifications.filters.expression.StringValueNode) EqualsNode(org.xwiki.notifications.filters.expression.EqualsNode) NotEqualsNode(org.xwiki.notifications.filters.expression.NotEqualsNode) Test(org.junit.Test)

Example 4 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseWithOrderBy.

@Test
public void parseWithOrderBy() {
    AbstractNode testAST = new OrderByNode(new EqualsNode(new PropertyValueNode(EventProperty.SPACE), new PropertyValueNode(EventProperty.PAGE)), new PropertyValueNode(EventProperty.DATE), OrderByNode.Order.ASC);
    ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
    assertEquals("event.space = event.page ORDER BY event.date ASC", result.getQuery());
}
Also used : AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) EqualsNode(org.xwiki.notifications.filters.expression.EqualsNode) NotEqualsNode(org.xwiki.notifications.filters.expression.NotEqualsNode) PropertyValueNode(org.xwiki.notifications.filters.expression.PropertyValueNode) Test(org.junit.Test)

Example 5 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseWithStartsWithNode.

@Test
public void parseWithStartsWithNode() {
    AbstractNode testAST = new StartsWith(new StringValueNode(TEST_VALUE_1), new StringValueNode(TEST_VALUE_2));
    assertEquals(String.format(":%s LIKE concat(:%s, '%%') ESCAPE '!'", TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER), parser.parse(testAST).getQuery());
}
Also used : AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) StringValueNode(org.xwiki.notifications.filters.expression.StringValueNode) StartsWith(org.xwiki.notifications.filters.expression.StartsWith) 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