cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r1567829 - in /cxf/trunk/rt/rs/extensions/search/src: main/java/org/apache/cxf/jaxrs/ext/search/odata/ main/java/org/apache/cxf/jaxrs/ext/search/visitor/ test/java/org/apache/cxf/jaxrs/ext/search/jpa/
Date Thu, 13 Feb 2014 02:04:31 GMT
Author: reta
Date: Thu Feb 13 02:04:30 2014
New Revision: 1567829

URL: http://svn.apache.org/r1567829
Log:
[CXF-5430]: Added initial support for OData 2.0 query language. Covered most of advanced use cases (6 test cases to fix)

Added:
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java
      - copied, changed from r1567764, cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorODataTest.java
Removed:
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
Modified:
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/odata/ODataParser.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/visitor/AbstractSearchConditionVisitor.java

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/odata/ODataParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/odata/ODataParser.java?rev=1567829&r1=1567828&r2=1567829&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/odata/ODataParser.java (original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/odata/ODataParser.java Thu Feb 13 02:04:30 2014
@@ -31,6 +31,8 @@ import org.apache.cxf.jaxrs.ext.search.O
 import org.apache.cxf.jaxrs.ext.search.PrimitiveSearchCondition;
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
 import org.apache.cxf.jaxrs.ext.search.SearchParseException;
+import org.apache.cxf.jaxrs.ext.search.collections.CollectionCheckCondition;
+import org.apache.cxf.jaxrs.ext.search.collections.CollectionCheckInfo;
 import org.apache.olingo.odata2.api.edm.EdmLiteral;
 import org.apache.olingo.odata2.api.edm.EdmLiteralKind;
 import org.apache.olingo.odata2.api.edm.EdmSimpleType;
@@ -166,6 +168,12 @@ public class ODataParser<T> extends Abst
                 typedValue = parseType(property.propertyName, null, null, property.propertyName, 
                     property.typeInfo, value.literal);
             }
+            
+            final CollectionCheckInfo checkInfo = property.typeInfo.getCollectionCheckInfo();
+            if (checkInfo != null) {
+                return new CollectionCheckCondition< T >(property.propertyName, typedValue, 
+                    property.typeInfo.getGenericType(), conditionType, condition, checkInfo);
+            }
                         
             return new PrimitiveSearchCondition< T >(property.propertyName, 
                 typedValue, conditionType, condition);

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/visitor/AbstractSearchConditionVisitor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/visitor/AbstractSearchConditionVisitor.java?rev=1567829&r1=1567828&r2=1567829&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/visitor/AbstractSearchConditionVisitor.java (original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/visitor/AbstractSearchConditionVisitor.java Thu Feb 13 02:04:30 2014
@@ -92,7 +92,7 @@ public abstract class AbstractSearchCond
                     valueCls = value.getClass();
                     type = m.getGenericReturnType();
                 } catch (Throwable ex) {
-                    throw new RuntimeException();
+                    throw new RuntimeException(ex);
                 }
                 return doGetPrimitiveFieldClass(ps, name, valueCls, type, value, set);
             }

Copied: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java (from r1567764, cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java)
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java?p2=cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java&p1=cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java&r1=1567764&r2=1567829&rev=1567829&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java (original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/AbstractJPATypedQueryVisitorTest.java Thu Feb 13 02:04:30 2014
@@ -22,9 +22,7 @@ import java.sql.Connection;
 import java.sql.DriverManager;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -37,17 +35,15 @@ import javax.persistence.criteria.Criter
 import javax.persistence.metamodel.SingularAttribute;
 
 import org.apache.cxf.jaxrs.ext.search.SearchCondition;
+import org.apache.cxf.jaxrs.ext.search.SearchConditionParser;
 import org.apache.cxf.jaxrs.ext.search.SearchConditionVisitor;
 import org.apache.cxf.jaxrs.ext.search.SearchUtils;
-import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
 import org.apache.cxf.jaxrs.ext.search.jpa.BookReview.Review;
-
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Test;
 
-public class JPATypedQueryVisitorTest extends Assert {
+public abstract class AbstractJPATypedQueryVisitorTest extends Assert {
 
     private EntityManagerFactory emFactory;
 
@@ -55,6 +51,10 @@ public class JPATypedQueryVisitorTest ex
 
     private Connection connection;
 
+    protected abstract SearchConditionParser<Book> getParser();
+    protected abstract SearchConditionParser<Book> getParser(Map<String, String> visitorProps,
+            Map<String, String> parserBinProps);
+    
     @Before
     public void setUp() throws Exception {
         try {
@@ -170,330 +170,29 @@ public class JPATypedQueryVisitorTest ex
         }
     }
     
-    @Test
-    public void testOrQuery() throws Exception {
-        List<Book> books = queryBooks("id=lt=10,id=gt=10");
-        assertEquals(2, books.size());
-        assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId()
-            || 11 == books.get(0).getId() && 9 == books.get(1).getId());
-    }
-    
-    @Test
-    public void testOrQueryNoMatch() throws Exception {
-        List<Book> books = queryBooks("id==7,id==5");
-        assertEquals(0, books.size());
-    }
-    
-    @Test
-    public void testAndQuery() throws Exception {
-        List<Book> books = queryBooks("id==10;bookTitle==num10");
-        assertEquals(1, books.size());
-        assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle()));
-    }
-    
-    @Test
-    public void testQueryCollection() throws Exception {
-        List<Book> books = 
-            queryBooks("reviews.authors==Ted");
-        assertEquals(3, books.size());
-    }
-    
-    @Test
-    public void testQueryCollection2() throws Exception {
-        List<Book> books = 
-            queryBooks("reviews.book.id==10");
-        assertEquals(1, books.size());
-    }
-    
-    @Test
-    public void testQueryCollection3() throws Exception {
-        List<Book> books = 
-            queryBooks("reviews.book.ownerInfo.name==Barry");
-        assertEquals(1, books.size());
-    }
-    
-    @Test
-    public void testQueryElementCollection() throws Exception {
-        List<Book> books = 
-            queryBooks("authors==John");
-        assertEquals(2, books.size());
-    }
-    
-    @Test
-    public void testNumberOfReviews() throws Exception {
-        List<Book> books = 
-            queryBooks("reviews=gt=0");
-        assertEquals(3, books.size());
-    }
-    
-    @Test
-    public void testNumberOfReviews2() throws Exception {
-        List<Book> books = 
-            queryBooks("reviews=gt=3");
-        assertEquals(0, books.size());
-    }
-    
-    @Test
-    public void testNumberOfReviewAuthors() throws Exception {
-        List<Book> books = 
-            queryBooks("count(reviews.authors)=gt=0");
-        assertEquals(3, books.size());
-    }
-    
-    @Test
-    public void testNumberOfReviewAuthors2() throws Exception {
-        List<Book> books = 
-            queryBooks("count(reviews.authors)=gt=3");
-        assertEquals(0, books.size());
-    }
-    
-    @Test
-    public void testNumberOfAuthors() throws Exception {
-        List<Book> books = 
-            queryBooks("count(authors)=gt=0");
-        assertEquals(3, books.size());
-    }
-    
-    @Test
-    public void testNumberOfAuthors2() throws Exception {
-        List<Book> books = 
-            queryBooks("count(authors)=gt=3");
-        assertEquals(0, books.size());
-    }
-    
-    @Test
-    public void testQueryCollectionSize2() throws Exception {
-        List<Book> books = 
-            queryBooks("reviews.authors=gt=0");
-        assertEquals(3, books.size());
-    }
-    
-    @Test
-    public void testAndQueryCollection() throws Exception {
-        List<Book> books = 
-            queryBooks("id==10;authors==John;reviews.review==good;reviews.authors==Ted");
-        assertEquals(1, books.size());
-        assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle()));
-    }
-    
-    @Test
-    public void testAndQueryNoMatch() throws Exception {
-        List<Book> books = queryBooks("id==10;bookTitle==num9");
-        assertEquals(0, books.size());
-    }
-    
-    @Test
-    public void testEqualsQuery() throws Exception {
-        List<Book> books = queryBooks("id==10");
-        assertEquals(1, books.size());
-        assertTrue(10 == books.get(0).getId());
-    }
-    
-    @Test
-    public void testEqualsCriteriaQueryTuple() throws Exception {
-        List<Tuple> books = criteriaQueryBooksTuple("id==10");
-        assertEquals(1, books.size());
-        Tuple tuple = books.get(0);
-        int tupleId = tuple.get("id", Integer.class);
-        assertEquals(10, tupleId);
-    }
-    
-    @Test
-    public void testEqualsCriteriaQueryCount() throws Exception {
-        assertEquals(1L, criteriaQueryBooksCount("id==10"));
-    }
-    
-    
-    @Test
-    public void testEqualsCriteriaQueryConstruct() throws Exception {
-        List<BookInfo> books = criteriaQueryBooksConstruct("id==10");
-        assertEquals(1, books.size());
-        BookInfo info = books.get(0);
-        assertEquals(10, info.getId());
-        assertEquals("num10", info.getTitle());
-    }
-    
-    @Test
-    public void testOrderByAsc() throws Exception {
-        List<Book> books = criteriaQueryBooksOrderBy("reviews=gt=0", true);
-        assertEquals(3, books.size());
-        assertEquals(9, books.get(0).getId());
-        assertEquals(10, books.get(1).getId());
-        assertEquals(11, books.get(2).getId());
-    }
     
-    @Test
-    public void testOrderByDesc() throws Exception {
-        List<Book> books = criteriaQueryBooksOrderBy("reviews=gt=0", false);
-        assertEquals(3, books.size());
-        assertEquals(11, books.get(0).getId());
-        assertEquals(10, books.get(1).getId());
-        assertEquals(9, books.get(2).getId());
-    }
-    
-    @Test
-    public void testEqualsCriteriaQueryArray() throws Exception {
-        List<Object[]> books = criteriaQueryBooksArray("id==10");
-        assertEquals(1, books.size());
-        Object[] info = books.get(0);
-        assertEquals(10, ((Integer)info[0]).intValue());
-        assertEquals("num10", (String)info[1]);
-    }
-    
-    @Test
-    public void testEqualsAddressQuery() throws Exception {
-        List<Book> books = queryBooks("address==Street1",
-            Collections.singletonMap("address", "address.street"));
-        assertEquals(1, books.size());
-        Book book = books.get(0);
-        assertTrue(9 == book.getId());
-        assertEquals("Street1", book.getAddress().getStreet());
-    }
-    
-    @Test
-    public void testEqualsAddressQuery2() throws Exception {
-        List<Book> books = queryBooks("street==Street1",
-            null,                          
-            Collections.singletonMap("street", "address.street"));
-        assertEquals(1, books.size());
-        Book book = books.get(0);
-        assertTrue(9 == book.getId());
-        assertEquals("Street1", book.getAddress().getStreet());
-    }
-    
-    @Test
-    public void testEqualsAddressQuery3() throws Exception {
-        Map<String, String> beanPropertiesMap = new HashMap<String, String>();
-        beanPropertiesMap.put("street", "address.street");
-        beanPropertiesMap.put("housenum", "address.houseNumber");
-        List<Book> books = 
-            queryBooks("street==Street2;housenum=lt=5", null, beanPropertiesMap);
-        assertEquals(1, books.size());
-        Book book = books.get(0);
-        assertTrue(10 == book.getId());
-        assertEquals("Street2", book.getAddress().getStreet());
-        
-    }
-
-    @Test
-    public void testEqualsOwnerNameQuery() throws Exception {
-        List<Book> books = queryBooks("ownerInfo.name.name==Fred");
-        assertEquals(1, books.size());
-        Book book = books.get(0);
-        assertEquals("Fred", book.getOwnerInfo().getName().getName());
-    }
     
-        
-    @Test
-    // "ownerInfo.name" maps to Name class and this 
-    // does not work in OpenJPA, as opposed to Hibernate
-    // "ownerInfo.name.name" will map to primitive type, see
-    // testEqualsOwnerNameQuery3(), which also works in OpenJPA
-    public void testEqualsOwnerNameQuery2() throws Exception {
-        List<Book> books = queryBooks("ownerInfo.name==Fred");
-        assertEquals(1, books.size());
-        Book book = books.get(0);
-        assertEquals("Fred", book.getOwnerInfo().getName().getName());
-    }
-    
-    @Test
-    public void testEqualsOwnerNameQuery3() throws Exception {
-        List<Book> books = queryBooks("ownerName==Fred", null,
-            Collections.singletonMap("ownerName", "ownerInfo.name.name"));
-        assertEquals(1, books.size());
-        Book book = books.get(0);
-        assertEquals("Fred", book.getOwnerInfo().getName().getName());
-    }
-    
-    @Test
-    public void testFindBookInTownLibrary() throws Exception {
-        List<Book> books = queryBooks("libAddress==town;bookTitle==num10", null,
-            Collections.singletonMap("libAddress", "library.address"));
-        assertEquals(1, books.size());
-        Book book = books.get(0);
-        assertEquals("Barry", book.getOwnerInfo().getName().getName());
-    }
-    
-    @Test
-    public void testEqualsOwnerBirthDate() throws Exception {
-        List<Book> books = queryBooks("ownerbdate==2000-01-01", null,
-            Collections.singletonMap("ownerbdate", "ownerInfo.dateOfBirth"));
-        assertEquals(1, books.size());
-        Book book = books.get(0);
-        assertEquals("Fred", book.getOwnerInfo().getName().getName());
-        
-        Date d = parseDate("2000-01-01");
-        
-        assertEquals("Fred", book.getOwnerInfo().getName().getName());
-        assertEquals(d, book.getOwnerInfo().getDateOfBirth());
-    }
-    
-    private Date parseDate(String value) throws Exception {
-        return new SimpleDateFormat(SearchUtils.DEFAULT_DATE_FORMAT).parse(value);
-    }
-    
-    @Test
-    public void testEqualsWildcard() throws Exception {
-        List<Book> books = queryBooks("bookTitle==num1*");
-        assertEquals(2, books.size());
-        assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId()
-            || 11 == books.get(0).getId() && 10 == books.get(1).getId());
-    }
-    
-    @Test
-    public void testGreaterQuery() throws Exception {
-        List<Book> books = queryBooks("id=gt=10");
-        assertEquals(1, books.size());
-        assertTrue(11 == books.get(0).getId());
-    }
-    
-    @Test
-    public void testGreaterEqualQuery() throws Exception {
-        List<Book> books = queryBooks("id=ge=10");
-        assertEquals(2, books.size());
-        assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId()
-            || 11 == books.get(0).getId() && 10 == books.get(1).getId());
-    }
-    
-    @Test
-    public void testLessEqualQuery() throws Exception {
-        List<Book> books = queryBooks("id=le=10");
-        assertEquals(2, books.size());
-        assertTrue(9 == books.get(0).getId() && 10 == books.get(1).getId()
-            || 9 == books.get(0).getId() && 10 == books.get(1).getId());
-    }
-    
-    @Test
-    public void testNotEqualsQuery() throws Exception {
-        List<Book> books = queryBooks("id!=10");
-        assertEquals(2, books.size());
-        assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId()
-            || 11 == books.get(0).getId() && 9 == books.get(1).getId());
-    }
-    
-    private List<Book> queryBooks(String expression) throws Exception {
+    protected List<Book> queryBooks(String expression) throws Exception {
         return queryBooks(expression, null, null, null);
     }
     
-    private List<Book> queryBooks(String expression, 
+    protected List<Book> queryBooks(String expression, 
                                   Map<String, String> visitorProps) throws Exception {
         return queryBooks(expression, visitorProps, null, null);
     }
     
-    private List<Book> queryBooks(String expression, 
+    protected List<Book> queryBooks(String expression, 
                                   Map<String, String> visitorProps,
                                   Map<String, String> parserBinProps) throws Exception {
         return queryBooks(expression, visitorProps, parserBinProps, null);
     }
     
-    private List<Book> queryBooks(String expression, 
+    protected List<Book> queryBooks(String expression, 
                                   Map<String, String> visitorProps,
                                   Map<String, String> parserBinProps,
                                   List<String> joinProps) throws Exception {
-        SearchCondition<Book> filter = 
-            new FiqlParser<Book>(Book.class,
-                                 visitorProps,
-                                 parserBinProps).parse(expression);
+        SearchCondition<Book> filter = getParser(visitorProps, parserBinProps)
+            .parse(expression);
         SearchConditionVisitor<Book, TypedQuery<Book>> jpa = 
             new JPATypedQueryVisitor<Book>(em, Book.class, visitorProps, joinProps);
         filter.accept(jpa);
@@ -501,9 +200,8 @@ public class JPATypedQueryVisitorTest ex
         return query.getResultList();
     }
     
-    private List<Tuple> criteriaQueryBooksTuple(String expression) throws Exception {
-        SearchCondition<Book> filter = 
-            new FiqlParser<Book>(Book.class).parse(expression);
+    protected List<Tuple> criteriaQueryBooksTuple(String expression) throws Exception {
+        SearchCondition<Book> filter = getParser().parse(expression);
         JPACriteriaQueryVisitor<Book, Tuple> jpa = 
             new JPACriteriaQueryVisitor<Book, Tuple>(em, Book.class, Tuple.class);
         filter.accept(jpa);
@@ -518,18 +216,16 @@ public class JPATypedQueryVisitorTest ex
         return em.createQuery(cquery).getResultList();
     }
     
-    private long criteriaQueryBooksCount(String expression) throws Exception {
-        SearchCondition<Book> filter = 
-            new FiqlParser<Book>(Book.class).parse(expression);
+    protected long criteriaQueryBooksCount(String expression) throws Exception {
+        SearchCondition<Book> filter = getParser().parse(expression);
         JPACriteriaQueryVisitor<Book, Long> jpa = 
             new JPACriteriaQueryVisitor<Book, Long>(em, Book.class, Long.class);
         filter.accept(jpa);
         return jpa.count();
     }
     
-    private List<Book> criteriaQueryBooksOrderBy(String expression, boolean asc) throws Exception {
-        SearchCondition<Book> filter = 
-            new FiqlParser<Book>(Book.class).parse(expression);
+    protected List<Book> criteriaQueryBooksOrderBy(String expression, boolean asc) throws Exception {
+        SearchCondition<Book> filter = getParser().parse(expression);
         JPACriteriaQueryVisitor<Book, Book> jpa = 
             new JPACriteriaQueryVisitor<Book, Book>(em, Book.class, Book.class);
         filter.accept(jpa);
@@ -541,9 +237,8 @@ public class JPATypedQueryVisitorTest ex
         return jpa.getOrderedTypedQuery(selections, asc).getResultList();
     }
     
-    private List<BookInfo> criteriaQueryBooksConstruct(String expression) throws Exception {
-        SearchCondition<Book> filter = 
-            new FiqlParser<Book>(Book.class).parse(expression);
+    protected List<BookInfo> criteriaQueryBooksConstruct(String expression) throws Exception {
+        SearchCondition<Book> filter = getParser().parse(expression);
         JPACriteriaQueryVisitor<Book, BookInfo> jpa = 
             new JPACriteriaQueryVisitor<Book, BookInfo>(em, Book.class, BookInfo.class);
         filter.accept(jpa);
@@ -559,9 +254,8 @@ public class JPATypedQueryVisitorTest ex
         return em.createQuery(cquery).getResultList();
     }
     
-    private List<Object[]> criteriaQueryBooksArray(String expression) throws Exception {
-        SearchCondition<Book> filter = 
-            new FiqlParser<Book>(Book.class).parse(expression);
+    protected List<Object[]> criteriaQueryBooksArray(String expression) throws Exception {
+        SearchCondition<Book> filter = getParser().parse(expression);
         JPACriteriaQueryVisitor<Book, Object[]> jpa = 
             new JPACriteriaQueryVisitor<Book, Object[]>(em, Book.class, Object[].class);
         filter.accept(jpa);
@@ -572,6 +266,10 @@ public class JPATypedQueryVisitorTest ex
         selections.add(Book_.bookTitle);
         
         return jpa.getArrayTypedQuery(selections).getResultList();
+    }    
+    
+    protected Date parseDate(String value) throws Exception {
+        return new SimpleDateFormat(SearchUtils.DEFAULT_DATE_FORMAT).parse(value);
     }
     
     public static class BookInfo {

Added: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java?rev=1567829&view=auto
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java (added)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorFiqlTest.java Thu Feb 13 02:04:30 2014
@@ -0,0 +1,343 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.ext.search.jpa;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Tuple;
+
+import org.apache.cxf.jaxrs.ext.search.SearchConditionParser;
+import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
+import org.junit.Test;
+
+public class JPATypedQueryVisitorFiqlTest extends AbstractJPATypedQueryVisitorTest {
+    
+    @Test
+    public void testOrQuery() throws Exception {
+        List<Book> books = queryBooks("id=lt=10,id=gt=10");
+        assertEquals(2, books.size());
+        assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId()
+            || 11 == books.get(0).getId() && 9 == books.get(1).getId());
+    }
+    
+    @Test
+    public void testOrQueryNoMatch() throws Exception {
+        List<Book> books = queryBooks("id==7,id==5");
+        assertEquals(0, books.size());
+    }
+    
+    @Test
+    public void testAndQuery() throws Exception {
+        List<Book> books = queryBooks("id==10;bookTitle==num10");
+        assertEquals(1, books.size());
+        assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle()));
+    }
+    
+    @Test
+    public void testQueryCollection() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.authors==Ted");
+        assertEquals(3, books.size());
+    }
+    
+    @Test
+    public void testQueryCollection2() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.book.id==10");
+        assertEquals(1, books.size());
+    }
+    
+    @Test
+    public void testQueryCollection3() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.book.ownerInfo.name==Barry");
+        assertEquals(1, books.size());
+    }
+    
+    @Test
+    public void testQueryElementCollection() throws Exception {
+        List<Book> books = 
+            queryBooks("authors==John");
+        assertEquals(2, books.size());
+    }
+    
+    @Test
+    public void testNumberOfReviews() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews=gt=0");
+        assertEquals(3, books.size());
+    }
+    
+    @Test
+    public void testNumberOfReviews2() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews=gt=3");
+        assertEquals(0, books.size());
+    }
+    
+    @Test
+    public void testNumberOfReviewAuthors() throws Exception {
+        List<Book> books = 
+            queryBooks("count(reviews.authors)=gt=0");
+        assertEquals(3, books.size());
+    }
+    
+    @Test
+    public void testNumberOfReviewAuthors2() throws Exception {
+        List<Book> books = 
+            queryBooks("count(reviews.authors)=gt=3");
+        assertEquals(0, books.size());
+    }
+    
+    @Test
+    public void testNumberOfAuthors() throws Exception {
+        List<Book> books = 
+            queryBooks("count(authors)=gt=0");
+        assertEquals(3, books.size());
+    }
+    
+    @Test
+    public void testNumberOfAuthors2() throws Exception {
+        List<Book> books = 
+            queryBooks("count(authors)=gt=3");
+        assertEquals(0, books.size());
+    }
+    
+    @Test
+    public void testQueryCollectionSize2() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.authors=gt=0");
+        assertEquals(3, books.size());
+    }
+    
+    @Test
+    public void testAndQueryCollection() throws Exception {
+        List<Book> books = 
+            queryBooks("id==10;authors==John;reviews.review==good;reviews.authors==Ted");
+        assertEquals(1, books.size());
+        assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle()));
+    }
+    
+    @Test
+    public void testAndQueryNoMatch() throws Exception {
+        List<Book> books = queryBooks("id==10;bookTitle==num9");
+        assertEquals(0, books.size());
+    }
+    
+    @Test
+    public void testEqualsQuery() throws Exception {
+        List<Book> books = queryBooks("id==10");
+        assertEquals(1, books.size());
+        assertTrue(10 == books.get(0).getId());
+    }
+    
+    @Test
+    public void testEqualsCriteriaQueryTuple() throws Exception {
+        List<Tuple> books = criteriaQueryBooksTuple("id==10");
+        assertEquals(1, books.size());
+        Tuple tuple = books.get(0);
+        int tupleId = tuple.get("id", Integer.class);
+        assertEquals(10, tupleId);
+    }
+    
+    @Test
+    public void testEqualsCriteriaQueryCount() throws Exception {
+        assertEquals(1L, criteriaQueryBooksCount("id==10"));
+    }
+    
+    
+    @Test
+    public void testEqualsCriteriaQueryConstruct() throws Exception {
+        List<BookInfo> books = criteriaQueryBooksConstruct("id==10");
+        assertEquals(1, books.size());
+        BookInfo info = books.get(0);
+        assertEquals(10, info.getId());
+        assertEquals("num10", info.getTitle());
+    }
+    
+    @Test
+    public void testOrderByAsc() throws Exception {
+        List<Book> books = criteriaQueryBooksOrderBy("reviews=gt=0", true);
+        assertEquals(3, books.size());
+        assertEquals(9, books.get(0).getId());
+        assertEquals(10, books.get(1).getId());
+        assertEquals(11, books.get(2).getId());
+    }
+    
+    @Test
+    public void testOrderByDesc() throws Exception {
+        List<Book> books = criteriaQueryBooksOrderBy("reviews=gt=0", false);
+        assertEquals(3, books.size());
+        assertEquals(11, books.get(0).getId());
+        assertEquals(10, books.get(1).getId());
+        assertEquals(9, books.get(2).getId());
+    }
+    
+    @Test
+    public void testEqualsCriteriaQueryArray() throws Exception {
+        List<Object[]> books = criteriaQueryBooksArray("id==10");
+        assertEquals(1, books.size());
+        Object[] info = books.get(0);
+        assertEquals(10, ((Integer)info[0]).intValue());
+        assertEquals("num10", (String)info[1]);
+    }
+    
+    @Test
+    public void testEqualsAddressQuery() throws Exception {
+        List<Book> books = queryBooks("address==Street1",
+            Collections.singletonMap("address", "address.street"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertTrue(9 == book.getId());
+        assertEquals("Street1", book.getAddress().getStreet());
+    }
+    
+    @Test
+    public void testEqualsAddressQuery2() throws Exception {
+        List<Book> books = queryBooks("street==Street1",
+            null,                          
+            Collections.singletonMap("street", "address.street"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertTrue(9 == book.getId());
+        assertEquals("Street1", book.getAddress().getStreet());
+    }
+    
+    @Test
+    public void testEqualsAddressQuery3() throws Exception {
+        Map<String, String> beanPropertiesMap = new HashMap<String, String>();
+        beanPropertiesMap.put("street", "address.street");
+        beanPropertiesMap.put("housenum", "address.houseNumber");
+        List<Book> books = 
+            queryBooks("street==Street2;housenum=lt=5", null, beanPropertiesMap);
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertTrue(10 == book.getId());
+        assertEquals("Street2", book.getAddress().getStreet());
+        
+    }
+
+    @Test
+    public void testEqualsOwnerNameQuery() throws Exception {
+        List<Book> books = queryBooks("ownerInfo.name.name==Fred");
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+    }
+    
+        
+    @Test
+    // "ownerInfo.name" maps to Name class and this 
+    // does not work in OpenJPA, as opposed to Hibernate
+    // "ownerInfo.name.name" will map to primitive type, see
+    // testEqualsOwnerNameQuery3(), which also works in OpenJPA
+    public void testEqualsOwnerNameQuery2() throws Exception {
+        List<Book> books = queryBooks("ownerInfo.name==Fred");
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+    }
+    
+    @Test
+    public void testEqualsOwnerNameQuery3() throws Exception {
+        List<Book> books = queryBooks("ownerName==Fred", null,
+            Collections.singletonMap("ownerName", "ownerInfo.name.name"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+    }
+    
+    @Test
+    public void testFindBookInTownLibrary() throws Exception {
+        List<Book> books = queryBooks("libAddress==town;bookTitle==num10", null,
+            Collections.singletonMap("libAddress", "library.address"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Barry", book.getOwnerInfo().getName().getName());
+    }
+    
+    @Test
+    public void testEqualsOwnerBirthDate() throws Exception {
+        List<Book> books = queryBooks("ownerbdate==2000-01-01", null,
+            Collections.singletonMap("ownerbdate", "ownerInfo.dateOfBirth"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+        
+        Date d = parseDate("2000-01-01");
+        
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+        assertEquals(d, book.getOwnerInfo().getDateOfBirth());
+    }
+
+    
+    @Test
+    public void testEqualsWildcard() throws Exception {
+        List<Book> books = queryBooks("bookTitle==num1*");
+        assertEquals(2, books.size());
+        assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId()
+            || 11 == books.get(0).getId() && 10 == books.get(1).getId());
+    }
+    
+    @Test
+    public void testGreaterQuery() throws Exception {
+        List<Book> books = queryBooks("id=gt=10");
+        assertEquals(1, books.size());
+        assertTrue(11 == books.get(0).getId());
+    }
+    
+    @Test
+    public void testGreaterEqualQuery() throws Exception {
+        List<Book> books = queryBooks("id=ge=10");
+        assertEquals(2, books.size());
+        assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId()
+            || 11 == books.get(0).getId() && 10 == books.get(1).getId());
+    }
+    
+    @Test
+    public void testLessEqualQuery() throws Exception {
+        List<Book> books = queryBooks("id=le=10");
+        assertEquals(2, books.size());
+        assertTrue(9 == books.get(0).getId() && 10 == books.get(1).getId()
+            || 9 == books.get(0).getId() && 10 == books.get(1).getId());
+    }
+    
+    @Test
+    public void testNotEqualsQuery() throws Exception {
+        List<Book> books = queryBooks("id!=10");
+        assertEquals(2, books.size());
+        assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId()
+            || 11 == books.get(0).getId() && 9 == books.get(1).getId());
+    }
+    
+    @Override
+    protected SearchConditionParser<Book> getParser(Map<String, String> visitorProps,
+            Map<String, String> parserBinProps) {
+        return new FiqlParser<Book>(Book.class, visitorProps, parserBinProps);
+    }
+    
+    @Override
+    public SearchConditionParser<Book> getParser() {
+        return new FiqlParser<Book>(Book.class);
+    }
+}

Added: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorODataTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorODataTest.java?rev=1567829&view=auto
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorODataTest.java (added)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorODataTest.java Thu Feb 13 02:04:30 2014
@@ -0,0 +1,315 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.jaxrs.ext.search.jpa;
+
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.Tuple;
+
+import org.apache.cxf.jaxrs.ext.search.SearchConditionParser;
+import org.apache.cxf.jaxrs.ext.search.odata.ODataParser;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JPATypedQueryVisitorODataTest extends AbstractJPATypedQueryVisitorTest {
+    @Test
+    public void testOrQuery() throws Exception {
+        List<Book> books = queryBooks("id lt 10 or id gt 10");
+        assertEquals(2, books.size());
+        assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId()
+            || 11 == books.get(0).getId() && 9 == books.get(1).getId());
+    }
+    
+    @Test
+    public void testOrQueryNoMatch() throws Exception {
+        List<Book> books = queryBooks("id eq 7 or id eq 5");
+        assertEquals(0, books.size());
+    }
+    
+    @Test
+    public void testAndQuery() throws Exception {
+        List<Book> books = queryBooks("id eq 10 and bookTitle eq 'num10'");
+        assertEquals(1, books.size());
+        assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle()));
+    }
+    
+    @Test @Ignore("Fixing, in progress") 
+    public void testQueryCollection() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.authors eq 'Ted'");
+        assertEquals(3, books.size());
+    }
+    
+    @Test @Ignore("Fixing, in progress")
+    public void testQueryCollection2() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.book.id eq 10");
+        assertEquals(1, books.size());
+    }
+    
+    @Test @Ignore("Fixing, in progress")
+    public void testQueryCollection3() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.book.ownerInfo.name eq 'Barry'");
+        assertEquals(1, books.size());
+    }
+    
+    @Test @Ignore("Fixing, in progress")
+    public void testQueryElementCollection() throws Exception {
+        List<Book> books = 
+            queryBooks("authors eq 'John'");
+        assertEquals(2, books.size());
+    }
+    
+    @Test
+    public void testNumberOfReviews() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews gt 0");
+        assertEquals(3, books.size());
+    }
+    
+    @Test
+    public void testNumberOfReviews2() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews gt 3");
+        assertEquals(0, books.size());
+    }    
+    
+    @Test @Ignore("Fixing, in progress")
+    public void testQueryCollectionSize2() throws Exception {
+        List<Book> books = 
+            queryBooks("reviews.authors gt 0");
+        assertEquals(3, books.size());
+    }
+    
+    @Test @Ignore("Fixing, in progress")
+    public void testAndQueryCollection() throws Exception {
+        List<Book> books = 
+            queryBooks("id eq 10 and authors eq 'John' and reviews.review eq 'good' and reviews.authors eq 'Ted'");
+        assertEquals(1, books.size());
+        assertTrue(10 == books.get(0).getId() && "num10".equals(books.get(0).getBookTitle()));
+    }
+    
+    @Test
+    public void testAndQueryNoMatch() throws Exception {
+        List<Book> books = queryBooks("id eq 10 and bookTitle eq 'num9'");
+        assertEquals(0, books.size());
+    }
+    
+    @Test
+    public void testEqualsQuery() throws Exception {
+        List<Book> books = queryBooks("id eq 10");
+        assertEquals(1, books.size());
+        assertTrue(10 == books.get(0).getId());
+    }
+    
+    @Test
+    public void testEqualsCriteriaQueryTuple() throws Exception {
+        List<Tuple> books = criteriaQueryBooksTuple("id eq 10");
+        assertEquals(1, books.size());
+        Tuple tuple = books.get(0);
+        int tupleId = tuple.get("id", Integer.class);
+        assertEquals(10, tupleId);
+    }
+    
+    @Test
+    public void testEqualsCriteriaQueryCount() throws Exception {
+        assertEquals(1L, criteriaQueryBooksCount("id eq 10"));
+    }
+    
+    
+    @Test
+    public void testEqualsCriteriaQueryConstruct() throws Exception {
+        List<BookInfo> books = criteriaQueryBooksConstruct("id eq 10");
+        assertEquals(1, books.size());
+        BookInfo info = books.get(0);
+        assertEquals(10, info.getId());
+        assertEquals("num10", info.getTitle());
+    }
+    
+    @Test
+    public void testOrderByAsc() throws Exception {
+        List<Book> books = criteriaQueryBooksOrderBy("reviews gt 0", true);
+        assertEquals(3, books.size());
+        assertEquals(9, books.get(0).getId());
+        assertEquals(10, books.get(1).getId());
+        assertEquals(11, books.get(2).getId());
+    }
+    
+    @Test
+    public void testOrderByDesc() throws Exception {
+        List<Book> books = criteriaQueryBooksOrderBy("reviews gt 0", false);
+        assertEquals(3, books.size());
+        assertEquals(11, books.get(0).getId());
+        assertEquals(10, books.get(1).getId());
+        assertEquals(9, books.get(2).getId());
+    }
+    
+    @Test
+    public void testEqualsCriteriaQueryArray() throws Exception {
+        List<Object[]> books = criteriaQueryBooksArray("id eq 10");
+        assertEquals(1, books.size());
+        Object[] info = books.get(0);
+        assertEquals(10, ((Integer)info[0]).intValue());
+        assertEquals("num10", (String)info[1]);
+    }
+    
+    @Test
+    public void testEqualsAddressQuery() throws Exception {
+        List<Book> books = queryBooks("address eq 'Street1'",
+            Collections.singletonMap("address", "address.street"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertTrue(9 == book.getId());
+        assertEquals("Street1", book.getAddress().getStreet());
+    }
+    
+    @Test
+    public void testEqualsAddressQuery2() throws Exception {
+        List<Book> books = queryBooks("street eq 'Street1'",
+            null,                          
+            Collections.singletonMap("street", "address.street"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertTrue(9 == book.getId());
+        assertEquals("Street1", book.getAddress().getStreet());
+    }
+    
+    @Test
+    public void testEqualsAddressQuery3() throws Exception {
+        Map<String, String> beanPropertiesMap = new HashMap<String, String>();
+        beanPropertiesMap.put("street", "address.street");
+        beanPropertiesMap.put("housenum", "address.houseNumber");
+        List<Book> books = 
+            queryBooks("street eq 'Street2' and housenum lt 5", null, beanPropertiesMap);
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertTrue(10 == book.getId());
+        assertEquals("Street2", book.getAddress().getStreet());
+        
+    }
+
+    @Test
+    public void testEqualsOwnerNameQuery() throws Exception {
+        List<Book> books = queryBooks("ownerInfo.name.name eq 'Fred'");
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+    }
+    
+        
+    @Test
+    // "ownerInfo.name" maps to Name class and this 
+    // does not work in OpenJPA, as opposed to Hibernate
+    // "ownerInfo.name.name" will map to primitive type, see
+    // testEqualsOwnerNameQuery3(), which also works in OpenJPA
+    public void testEqualsOwnerNameQuery2() throws Exception {
+        List<Book> books = queryBooks("ownerInfo.name eq 'Fred'");
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+    }
+    
+    @Test
+    public void testEqualsOwnerNameQuery3() throws Exception {
+        List<Book> books = queryBooks("ownerName eq 'Fred'", null,
+            Collections.singletonMap("ownerName", "ownerInfo.name.name"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+    }
+    
+    @Test
+    public void testFindBookInTownLibrary() throws Exception {
+        List<Book> books = queryBooks("libAddress eq 'town' and bookTitle eq 'num10'", null,
+            Collections.singletonMap("libAddress", "library.address"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Barry", book.getOwnerInfo().getName().getName());
+    }
+    
+    @Test
+    public void testEqualsOwnerBirthDate() throws Exception {
+        List<Book> books = queryBooks("ownerbdate eq '2000-01-01'", null,
+            Collections.singletonMap("ownerbdate", "ownerInfo.dateOfBirth"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+        
+        Date d = parseDate("2000-01-01");
+        
+        assertEquals("Fred", book.getOwnerInfo().getName().getName());
+        assertEquals(d, book.getOwnerInfo().getDateOfBirth());
+    }
+
+    
+    @Test
+    public void testEqualsWildcard() throws Exception {
+        List<Book> books = queryBooks("bookTitle eq 'num1*'");
+        assertEquals(2, books.size());
+        assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId()
+            || 11 == books.get(0).getId() && 10 == books.get(1).getId());
+    }
+    
+    @Test
+    public void testGreaterQuery() throws Exception {
+        List<Book> books = queryBooks("id gt 10");
+        assertEquals(1, books.size());
+        assertTrue(11 == books.get(0).getId());
+    }
+    
+    @Test
+    public void testGreaterEqualQuery() throws Exception {
+        List<Book> books = queryBooks("id ge 10");
+        assertEquals(2, books.size());
+        assertTrue(10 == books.get(0).getId() && 11 == books.get(1).getId()
+            || 11 == books.get(0).getId() && 10 == books.get(1).getId());
+    }
+    
+    @Test
+    public void testLessEqualQuery() throws Exception {
+        List<Book> books = queryBooks("id le 10");
+        assertEquals(2, books.size());
+        assertTrue(9 == books.get(0).getId() && 10 == books.get(1).getId()
+            || 9 == books.get(0).getId() && 10 == books.get(1).getId());
+    }
+    
+    @Test
+    public void testNotEqualsQuery() throws Exception {
+        List<Book> books = queryBooks("id ne 10");
+        assertEquals(2, books.size());
+        assertTrue(9 == books.get(0).getId() && 11 == books.get(1).getId()
+            || 11 == books.get(0).getId() && 9 == books.get(1).getId());
+    }
+    
+    @Override
+    protected SearchConditionParser<Book> getParser(Map<String, String> visitorProps,
+            Map<String, String> parserBinProps) {
+        return new ODataParser<Book>(Book.class, visitorProps, parserBinProps);
+    }
+    
+    @Override
+    protected SearchConditionParser<Book> getParser() {
+        return new ODataParser<Book>(Book.class);
+    }
+}



Mime
View raw message