Search in sources :

Example 1 with StringValueNode

use of org.xwiki.notifications.filters.expression.StringValueNode 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 StringValueNode

use of org.xwiki.notifications.filters.expression.StringValueNode 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 StringValueNode

use of org.xwiki.notifications.filters.expression.StringValueNode 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 StringValueNode

use of org.xwiki.notifications.filters.expression.StringValueNode 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)

Example 5 with StringValueNode

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

the class ExpressionNodeToHQLConverterTest method parseWithNotEqualsNode.

@Test
public void parseWithNotEqualsNode() {
    AbstractNode testAST = new NotEqualsNode(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) NotEqualsNode(org.xwiki.notifications.filters.expression.NotEqualsNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 StringValueNode (org.xwiki.notifications.filters.expression.StringValueNode)9 AbstractNode (org.xwiki.notifications.filters.expression.generics.AbstractNode)7 PropertyValueNode (org.xwiki.notifications.filters.expression.PropertyValueNode)4 EqualsNode (org.xwiki.notifications.filters.expression.EqualsNode)3 NotEqualsNode (org.xwiki.notifications.filters.expression.NotEqualsNode)3 DocumentReference (org.xwiki.model.reference.DocumentReference)1 NotificationFilter (org.xwiki.notifications.filters.NotificationFilter)1 AndNode (org.xwiki.notifications.filters.expression.AndNode)1 ExpressionNode (org.xwiki.notifications.filters.expression.ExpressionNode)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 NotNode (org.xwiki.notifications.filters.expression.NotNode)1 StartsWith (org.xwiki.notifications.filters.expression.StartsWith)1 NotificationPreference (org.xwiki.notifications.preferences.NotificationPreference)1