Search in sources :

Example 6 with AbstractNode

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

Example 7 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseEntityReferenceNode.

@Test
public void parseEntityReferenceNode() {
    DocumentReference documentReference = new DocumentReference("xwiki", "Main", "WebHome");
    when(serializer.serialize(documentReference)).thenReturn("xwiki:Main.WebHome");
    AbstractNode testAST = new EntityReferenceNode(documentReference);
    ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
    assertEquals(":entity_e9f8294b0de086574bed923c45695bc8afc27d3ede9c35ed44db8d2100929de4", result.getQuery());
    assertEquals("xwiki:Main.WebHome", result.getQueryParameters().get("entity_e9f8294b0de086574bed923c45695bc8afc27d3ede9c35ed44db8d2100929de4"));
}
Also used : AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) EntityReferenceNode(org.xwiki.notifications.filters.expression.EntityReferenceNode) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 8 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseWithAndNode.

@Test
public void parseWithAndNode() {
    AbstractNode testAST = value(TEST_VALUE_1).eq(value(TEST_VALUE_2)).and(value(TEST_VALUE_1).eq(value(TEST_VALUE_2)));
    assertEquals(String.format("(:%s = :%s) AND (:%s = :%s)", TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER, TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER), parser.parse(testAST).getQuery());
}
Also used : AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) Test(org.junit.Test)

Example 9 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseWithInListOfReadEventsNode.

@Test
public void parseWithInListOfReadEventsNode() {
    DocumentReference user = new DocumentReference("xwiki", "XWiki", "userA");
    when(serializer.serialize(user)).thenReturn("xwiki:XWiki.UserA");
    AbstractNode testAST = new NotNode(new InListOfReadEventsNode(user));
    ExpressionNodeToHQLConverter.HQLQuery result = parser.parse(testAST);
    assertEquals(" NOT (" + "event IN (select status.activityEvent from ActivityEventStatusImpl status " + "where status.activityEvent = event and status.entityId = :userStatusRead " + "and status.read = true))", result.getQuery());
    assertEquals("xwiki:XWiki.UserA", result.getQueryParameters().get("userStatusRead"));
}
Also used : NotNode(org.xwiki.notifications.filters.expression.NotNode) AbstractNode(org.xwiki.notifications.filters.expression.generics.AbstractNode) InListOfReadEventsNode(org.xwiki.notifications.filters.internal.status.InListOfReadEventsNode) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 10 with AbstractNode

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

the class ExpressionNodeToHQLConverterTest method parseWithOrNode.

@Test
public void parseWithOrNode() {
    AbstractNode testAST = value(TEST_VALUE_1).eq(value(TEST_VALUE_2)).or(value(TEST_VALUE_1).eq(value(TEST_VALUE_2)));
    assertEquals(String.format("(:%s = :%s) OR (:%s = :%s)", TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER, TEST_VALUE_1_IDENTIFIER, TEST_VALUE_2_IDENTIFIER), parser.parse(testAST).getQuery());
}
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