db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1845744 [2/9] - in /db/jdo/trunk: copyjdorijars/ tck/ tck/src/main/java/org/apache/jdo/tck/pc/company/ tck/src/main/java/org/apache/jdo/tck/pc/mylib/ tck/src/main/java/org/apache/jdo/tck/query/ tck/src/main/java/org/apache/jdo/tck/query/de...
Date Sun, 04 Nov 2018 18:37:24 GMT
Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/DenoteUniquenessInFilter.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/DenoteUniquenessInFilter.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/DenoteUniquenessInFilter.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/DenoteUniquenessInFilter.java Sun Nov  4 18:37:24 2018
@@ -20,10 +20,14 @@ package org.apache.jdo.tck.query.jdoql;
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.pc.company.CompanyModelReader;
 import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.QDepartment;
+import org.apache.jdo.tck.pc.company.QEmployee;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
+import javax.jdo.JDOQLTypedQuery;
+
 /**
  *<B>Title:</B> Element Returned in Query Result
  *<BR>
@@ -49,107 +53,128 @@ public class DenoteUniquenessInFilter ex
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.2-2 (DenoteUniquenessInFilter) failed: ";
-    
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     */
-    private static final QueryElementHolder[] VALID_QUERIES = {
-        // Uniqueness not specified.
-        // emp1 qualifies for both contains clause => result is dept1
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employees.contains(e1) && (e1.personid == 1 && " +
-                        "(employees.contains(e2) && (e2.weeklyhours == 40)))",
-        /*VARIABLES*/   "Employee e1; Employee e2",
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        // Uniqueness specified.
-        // Only emp3 qualifies for both contains clause.
-        // Condition e1 != e2 violated => result is empty
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employees.contains(e1) && (e1.personid == 3 && " +
-                        "(employees.contains(e2) && (e2.weeklyhours == 19 && " +
-                        "e1 != e2)))",
-        /*VARIABLES*/   "Employee e1; Employee e2",
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        // Uniqueness specified.
-        // Only emp1 matches the first contains clause.
-        // emp1 and emp2 match the second contains clause.
-        // Thus, there are two different values for e1 and e2
-        // satifying the entire filter => result is dept1
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employees.contains(e1) && (e1.personid == 1 && " +
-                        "(employees.contains(e2) && (e2.weeklyhours == 40 && " +
-                        "e1 != e2)))",
-        /*VARIABLES*/   "Employee e1; Employee e2",
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-        
-    /** 
-     * The expected results of valid queries.
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
      */
-    private Object[] expectedResult = {
+    public static void main(String[] args) {
+        BatchTestRunner.run(DenoteUniquenessInFilter.class);
+    }
+
+    /** */
+    public void testPositive0() {
         // Uniqueness not specified.
         // emp1 qualifies for both contains clause => result is dept1
-        getTransientCompanyModelInstancesAsList(new String[]{"dept1"}),
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"});
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        QEmployee e1 = QEmployee.variable("e1");
+        QEmployee e2 = QEmployee.variable("e2");
+        query.filter(cand.employees.contains(e1).and(e1.personid.eq(1l).and(
+                cand.employees.contains(e2).and(e2.weeklyhours.eq(40d)))));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employees.contains(e1) && (e1.personid == 1 && " +
+                "(employees.contains(e2) && (e2.weeklyhours == 40)))",
+                /*VARIABLES*/   "Employee e1; Employee e2",
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testPositive1() {
         // Uniqueness specified.
         // Only emp3 qualifies for both contains clause.
         // Condition e1 != e2 violated => result is empty
-        getTransientCompanyModelInstancesAsList(new String[]{}),
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{});
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        QEmployee e1 = QEmployee.variable("e1");
+        QEmployee e2 = QEmployee.variable("e2");
+        query.filter(cand.employees.contains(e1).and(e1.personid.eq(3l).and(
+                cand.employees.contains(e2).and(e2.weeklyhours.eq(19d).and(e1.ne(e2))))));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employees.contains(e1) && (e1.personid == 3 && " +
+                "(employees.contains(e2) && (e2.weeklyhours == 19 && " +
+                "e1 != e2)))",
+                /*VARIABLES*/   "Employee e1; Employee e2",
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testPositive2() {
         // Uniqueness specified.
         // Only emp1 matches the first contains clause.
         // emp1 and emp2 match the second contains clause.
         // Thus, there are two different values for e1 and e2
         // satifying the entire filter => result is dept1
-        getTransientCompanyModelInstancesAsList(new String[]{"dept1"})
-    };
-    
-    /**
-     * The <code>main</code> is called when the class
-     * is directly executed from the command line.
-     * @param args The arguments passed to the program.
-     */
-    public static void main(String[] args) {
-        BatchTestRunner.run(DenoteUniquenessInFilter.class);
-    }
-    
-    /** */
-    public void testPositive() {
-        for (int i = 0; i < VALID_QUERIES.length; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-        }
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"});
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        QEmployee e1 = QEmployee.variable("e1");
+        QEmployee e2 = QEmployee.variable("e2");
+        query.filter(cand.employees.contains(e1).and(e1.personid.eq(1l).and(
+                cand.employees.contains(e2).and(e2.weeklyhours.eq(40d).and(e1.ne(e2))))));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employees.contains(e1) && (e1.personid == 1 && " +
+                "(employees.contains(e2) && (e2.weeklyhours == 40 && " +
+                "e1 != e2)))",
+                /*VARIABLES*/   "Employee e1; Employee e2",
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
     
     /**

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Having.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Having.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Having.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/Having.java Sun Nov  4 18:37:24 2018
@@ -22,10 +22,13 @@ import java.util.Arrays;
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.pc.company.CompanyModelReader;
 import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.QEmployee;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
+import javax.jdo.JDOQLTypedQuery;
+
 /**
  *<B>Title:</B> Having.
  *<BR>
@@ -42,43 +45,7 @@ public class Having extends QueryTest {
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.10-2 (Having) failed: ";
-    
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     */
-    private static final QueryElementHolder[] VALID_QUERIES = {
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "department, AVG(weeklyhours)",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    "department HAVING COUNT(department) > 0",
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        // HAVING clause uses field that isn't contained in the SELECT clause.
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "department, AVG(weeklyhours)",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    "department HAVING COUNT(personid) > 1",
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-    
+
     /** 
      * The array of invalid queries which may be executed as 
      * single string queries and as API queries.
@@ -115,26 +82,6 @@ public class Having extends QueryTest {
         /*FROM*/        null,
         /*TO*/          null)
     };
-    
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        Arrays.asList(new Object[] {
-            new Object[] {
-                    getTransientCompanyModelInstance("dept1"),
-                    new Double(33.0)},
-            new Object[] {
-                    getTransientCompanyModelInstance("dept2"),
-                    new Double(0.0)}}),
-        Arrays.asList(new Object[] {
-            new Object[] {
-                    getTransientCompanyModelInstance("dept1"),
-                    new Double(33.0)},
-            new Object[] {
-                    getTransientCompanyModelInstance("dept2"),
-                    new Double(0.0)}})
-    };
         
     /**
      * The <code>main</code> is called when the class
@@ -144,18 +91,83 @@ public class Having extends QueryTest {
     public static void main(String[] args) {
         BatchTestRunner.run(Having.class);
     }
-    
+
     /** */
-    public void testPositive() {
-        for (int i = 0; i < VALID_QUERIES.length; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-        }
+    public void testPositive0() {
+        Object expected = Arrays.asList(new Object[] {
+                new Object[] {
+                        getTransientCompanyModelInstance("dept1"),
+                        new Double(33.0)},
+                new Object[] {
+                        getTransientCompanyModelInstance("dept2"),
+                        new Double(0.0)}});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.groupBy(cand.department).having(cand.department.count().gt(0L));
+        query.result(false, cand.department, cand.weeklyhours.avg());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "department, AVG(weeklyhours)",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    "department HAVING COUNT(department) > 0",
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Object[].class, expected);
     }
 
     /** */
+    public void testPositive1() {
+        // HAVING clause uses field that isn't contained in the SELECT clause.
+        Object expected = Arrays.asList(new Object[] {
+                new Object[] {
+                        getTransientCompanyModelInstance("dept1"),
+                        new Double(33.0)},
+                new Object[] {
+                        getTransientCompanyModelInstance("dept2"),
+                        new Double(0.0)}});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.groupBy(cand.department).having(cand.personid.count().gt(1L));
+        query.result(false, cand.department, cand.weeklyhours.avg());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "department, AVG(weeklyhours)",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    "department HAVING COUNT(personid) > 1",
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null ,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Object[].class, expected);
+    }
+    
+    /** */
     public void testNegative() {
         for (int i = 0; i < INVALID_QUERIES.length; i++) {
             compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false);

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java Sun Nov  4 18:37:24 2018
@@ -25,6 +25,11 @@ import org.apache.jdo.tck.query.QueryEle
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
+import org.apache.jdo.tck.pc.company.QDepartment;
+import org.apache.jdo.tck.pc.company.QPerson;
+
+import javax.jdo.JDOQLTypedQuery;
+
 /**
  *<B>Title:</B> Identifiers Equal Field Names.
  *<BR>
@@ -42,95 +47,6 @@ public class IdentifiersEqualFieldNames
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.2-43 (IdentifiersEqualFieldNames) failed: ";
-    
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     */
-    private static final QueryElementHolder[] VALID_QUERIES = {
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Person.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.firstname == 'emp1First'",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Person.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.personid < Byte.MAX_VALUE",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employees.size() > org.apache.jdo.tck.pc.company.Department.RECOMMENDED_NO_OF_EMPS",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employees.size() > Department.RECOMMENDED_NO_OF_EMPS",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employees.size() > RECOMMENDED_NO_OF_EMPS",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-    
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1"}),
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp2", "emp3", "emp4", "emp5"}),
-        getTransientCompanyModelInstancesAsList(new String[]{"dept1"}),
-        getTransientCompanyModelInstancesAsList(new String[]{"dept1"}),
-        getTransientCompanyModelInstancesAsList(new String[]{"dept1"})
-    };
             
     /**
      * The <code>main</code> is called when the class
@@ -142,18 +58,160 @@ public class IdentifiersEqualFieldNames
     }
     
     /** */
-    public void testPositive() {
-        for (int i = 0; i < VALID_QUERIES.length; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-        }
+    public void testPositive0() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.filter(cand.firstname.eq("emp1First"));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.firstname == 'emp1First'",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testPositive1() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.filter(cand.personid.lt((long)Byte.MAX_VALUE));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.personid < Byte.MAX_VALUE",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testPositive2() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"});
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        query.filter(cand.employees.size().gt(org.apache.jdo.tck.pc.company.Department.RECOMMENDED_NO_OF_EMPS));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employees.size() > org.apache.jdo.tck.pc.company.Department.RECOMMENDED_NO_OF_EMPS",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testPositive3() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"});
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        query.filter(cand.employees.size().gt(Department.RECOMMENDED_NO_OF_EMPS));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employees.size() > Department.RECOMMENDED_NO_OF_EMPS",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testPositive4() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"}) ;
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        query.filter(cand.employees.size().gt(Department.RECOMMENDED_NO_OF_EMPS));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employees.size() > RECOMMENDED_NO_OF_EMPS",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
      * @see JDO_Test#localSetUp()
      */
+    @Override
     protected void localSetUp() {
         addTearDownClass(CompanyModelReader.getTearDownClasses());
         loadAndPersistCompanyModel(getPM());

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java Sun Nov  4 18:37:24 2018
@@ -22,10 +22,17 @@ import org.apache.jdo.tck.pc.company.Com
 import org.apache.jdo.tck.pc.company.DentalInsurance;
 import org.apache.jdo.tck.pc.company.Employee;
 import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.QEmployee;
+import org.apache.jdo.tck.pc.company.QFullTimeEmployee;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
+import javax.jdo.JDOQLTypedQuery;
+import javax.jdo.query.BooleanExpression;
+import javax.jdo.query.IfThenElseExpression;
+import javax.jdo.query.NumericExpression;
+
 /**
  *<B>Title:</B> Use of If Else expression in filter
  *<BR>
@@ -41,73 +48,6 @@ public class IfElseInFilter extends Quer
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.x (IfElseInFilter) failed: ";
-    
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     */
-    private static final QueryElementHolder[] VALID_QUERIES = {
-        // simple If/Else using literals
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.salary > (IF (this.department.name == 'Development') 15000 ELSE 25000)",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.personid",
-        /*FROM*/        null,
-        /*TO*/          null),
-        // simple If/Else using relationships
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "(IF (this.manager == null) this.mentor.department.deptid ELSE this.manager.department.deptid) == this.department.deptid",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.personid",
-        /*FROM*/        null,
-        /*TO*/          null),
-        // multiple If/Else with distinct conditions
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "(IF (0.0 <= this.salary && this.salary < 10000.1) 1 ELSE IF (10000.1 <= this.salary && this.salary < 20000.1) 2 ELSE IF (20000.1 <= this.salary && this.salary < 30000.1) 3 ELSE 4) == 2",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.personid",
-        /*FROM*/        null,
-        /*TO*/          null),
-        // multiple If/Else with overlapping conditions
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "(IF (this.salary < 10000.1) 1 ELSE IF (this.salary < 20000.1) 2 ELSE IF (this.salary < 30000.1) 3 ELSE 4) == 2",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.personid",
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
 
    /** 
      * The array of invalid queries which may be executed as 
@@ -160,16 +100,6 @@ public class IfElseInFilter extends Quer
         /*FROM*/        null,
         /*TO*/          null)
     };
-        
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp5"}),
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"}),
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1"}),
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1"})
-    };
     
     /**
      * The <code>main</code> is called when the class
@@ -179,15 +109,143 @@ public class IfElseInFilter extends Quer
     public static void main(String[] args) {
         BatchTestRunner.run(IfElseInFilter.class);
     }
-    
+
+    /** */
+    public void testPositive0() {
+        // simple If/Else using literals
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp5"});
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        IfThenElseExpression<Double> ifExpr =
+                query.ifThenElse(cand.department.name.eq("Development"), 15000.0,25000.0);
+        query.filter(cand.salary.gt(ifExpr));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.salary > (IF (this.department.name == 'Development') 15000 ELSE 25000)",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.personid",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+    /** */
+    public void testPositive1() {
+        // simple If/Else using relationships
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        IfThenElseExpression<Long> ifExpr = query.ifThenElse(Long.class,
+                cand.manager.eq((Employee)null), cand.mentor.department.deptid, cand.manager.department.deptid);
+        query.filter(ifExpr.eq(cand.department.deptid));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "(IF (this.manager == null) this.mentor.department.deptid ELSE this.manager.department.deptid) == this.department.deptid",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.personid",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  null,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
     /** */
-    public void testPositive() {
-        for (int i = 0; i < VALID_QUERIES.length; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-        }
+    public void testPositive2() {
+        // multiple If/Else with distinct conditions
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        BooleanExpression cond1 = cand.salary.gt(0.0).and(cand.salary.lt(10000.1));
+        BooleanExpression cond2 = cand.salary.gt(10000.1).and(cand.salary.lt(20000.1));
+        BooleanExpression cond3 = cand.salary.gt(20000.1).and(cand.salary.lt(30000.1));
+        IfThenElseExpression<Integer> ifExpr =
+                query.ifThen(cond1, 1).ifThen(cond2, 2).ifThen(cond3, 3).elseEnd(4);
+        query.filter(ifExpr.eq(2));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "(IF (0.0 <= this.salary && this.salary < 10000.1) 1 ELSE " +
+                                 "IF (10000.1 <= this.salary && this.salary < 20000.1) 2 ELSE " +
+                                 "IF (20000.1 <= this.salary && this.salary < 30000.1) 3 ELSE 4) == 2",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.personid",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+    /** */
+    public void testPositive3() {
+        // multiple If/Else with overlapping conditions
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        BooleanExpression cond1 = cand.salary.lt(10000.1);
+        BooleanExpression cond2 = cand.salary.lt(20000.1);
+        BooleanExpression cond3 = cand.salary.lt(30000.1);
+        IfThenElseExpression<Integer> ifExpr =
+                query.ifThen(cond1, 1).ifThen(cond2, 2).ifThen(cond3, 3).elseEnd(4);
+        query.filter(ifExpr.eq(2));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "(IF (this.salary < 10000.1) 1 ELSE " +
+                                 "IF (this.salary < 20000.1) 2 ELSE IF (this.salary < 30000.1) 3 ELSE 4) == 2",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.personid",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /** */

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleIdenticalImports.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleIdenticalImports.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleIdenticalImports.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/MultipleIdenticalImports.java Sun Nov  4 18:37:24 2018
@@ -17,17 +17,17 @@
 
 package org.apache.jdo.tck.query.jdoql;
 
-import java.util.Collection;
-import java.util.HashSet;
+import java.util.HashMap;
+import java.util.Map;
 
-import javax.jdo.PersistenceManager;
-import javax.jdo.Query;
-import javax.jdo.Transaction;
+import javax.jdo.JDOQLTypedQuery;
+import javax.jdo.query.Expression;
 
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.pc.company.CompanyModelReader;
 import org.apache.jdo.tck.pc.company.Department;
 import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.QEmployee;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
@@ -58,136 +58,118 @@ public class MultipleIdenticalImports ex
         BatchTestRunner.run(MultipleIdenticalImports.class);
     }
 
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
+    /**
+     *
      */
-    private static final QueryElementHolder[] VALID_QUERIES = {
+    public void testImportDepartmentTwice() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        Expression<Department> empParam = query.parameter("d", Department.class);
+        query.filter(cand.department.eq(empParam));
+
+        Map<String, Object> paramValues = new HashMap<>();
+        paramValues.put("d", getPersistentCompanyModelInstance("dept1"));
+
         // Import Department twice
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "department == d",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  "Department d",
-        /*IMPORTS*/     "import org.apache.jdo.tck.pc.company.Department; " +
-                        "import org.apache.jdo.tck.pc.company.Department;",
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        // Import Department explictly and per type-import-on-demand
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "department == d",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  "Department d",
-        /*IMPORTS*/     "import org.apache.jdo.tck.pc.company.Department; " +
-                        "import org.apache.jdo.tck.pc.company.*",
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        // type-import-on-demand twice
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "department == d",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  "Department d",
-        /*IMPORTS*/     "import org.apache.jdo.tck.pc.company.*; " +
-                        "import org.apache.jdo.tck.pc.company.*",
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-    
-    /** 
-     * The expected results of valid queries.
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "department == d",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  "Department d",
+                /*IMPORTS*/     "import org.apache.jdo.tck.pc.company.Department; " +
+                "import org.apache.jdo.tck.pc.company.Department;",
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ paramValues);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /**
+     *
      */
-    private Object[] expectedResult = {
-        // Import Department twice
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"}),
-        // Import Department explictly and per type-import-on-demand
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"}),
-        // type-import-on-demand twice
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"})
-    };
-    
-    /** Parameters of valid queries. */
-    private Object[][] parameters = {
-        // Import Department twice
-        {getPersistentCompanyModelInstance("dept1")},
-        // Import Department explictly and per type-import-on-demand
-        {getPersistentCompanyModelInstance("dept1")},
-        // type-import-on-demand twice
-        {getPersistentCompanyModelInstance("dept1")}
-    };
-            
-    /** */
-    void runTest(PersistenceManager pm, CompanyModelReader reader) {
-        Query query;
-        Collection expected;
-        Object result;
-            
-        Transaction tx = pm.currentTransaction();
-        tx.begin();
-        Department dept1 = (Department)reader.getDepartment("dept1");
-        expected = new HashSet();
-        expected.add(reader.getFullTimeEmployee("emp1"));
-        expected.add(reader.getFullTimeEmployee("emp2"));
-        expected.add(reader.getPartTimeEmployee("emp3"));
-            
-        // Import Department twice
-        query = pm.newQuery(Employee.class);
-        query.declareImports("import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.Department;");
-        query.declareParameters("Department d");
-        query.setFilter("department == d");
-        result = query.execute(dept1);
-        checkQueryResultWithoutOrder(ASSERTION_FAILED, "department == d",
-                result, expected);
+    public void testImportDepartmentExplicitlyAndPerTypeImportOnDemand() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"});
 
-        // Import Department explictly and per type-import-on-demand
-        query = pm.newQuery(Employee.class);
-        query.declareImports("import org.apache.jdo.tck.pc.company.Department; import org.apache.jdo.tck.pc.company.*");
-        query.declareParameters("Department d");
-        query.setFilter("department == d");
-        result = query.execute(dept1);
-        checkQueryResultWithoutOrder(ASSERTION_FAILED, "department == d",
-                result, expected);
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        Expression<Department> empParam = query.parameter("d", Department.class);
+        query.filter(cand.department.eq(empParam));
 
-        // type-import-on-demand twice
-        query = pm.newQuery(Employee.class);
-        query.declareImports("import org.apache.jdo.tck.pc.company.*; import org.apache.jdo.tck.pc.company.*");
-        query.declareParameters("Department d");
-        query.setFilter("department == d");
-        result = query.execute(dept1);
-        checkQueryResultWithoutOrder(ASSERTION_FAILED, "department == d",
-                result, expected);
+        Map<String, Object> paramValues = new HashMap<>();
+        paramValues.put("d", getPersistentCompanyModelInstance("dept1"));
 
-        tx.commit();
-        tx = null;
+        // Import Department explictly and per type-import-on-demand
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "department == d",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  "Department d",
+                /*IMPORTS*/     "import org.apache.jdo.tck.pc.company.Department; " +
+                "import org.apache.jdo.tck.pc.company.*",
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ paramValues);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
-    
-    /** */
-    public void testPositive() {
-        for (int i = 0; i < VALID_QUERIES.length; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    parameters[i], expectedResult[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    parameters[i], expectedResult[i]);
-        }
+
+    /**
+     * 
+     */
+    public void testTypeImportOnDemandTwice() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp3"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        Expression<Department> empParam = query.parameter("d", Department.class);
+        query.filter(cand.department.eq(empParam));
+
+        Map<String, Object> paramValues = new HashMap<>();
+        paramValues.put("d", getPersistentCompanyModelInstance("dept1"));
+
+        // type-import-on-demand twice
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "department == d",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  "Department d",
+                /*IMPORTS*/     "import org.apache.jdo.tck.pc.company.*; " +
+                "import org.apache.jdo.tck.pc.company.*",
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ paramValues);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
     
     /**

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationComparisonWithNull.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationComparisonWithNull.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationComparisonWithNull.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationComparisonWithNull.java Sun Nov  4 18:37:24 2018
@@ -22,10 +22,13 @@ import org.apache.jdo.tck.pc.company.Com
 import org.apache.jdo.tck.pc.company.Employee;
 import org.apache.jdo.tck.pc.company.FullTimeEmployee;
 import org.apache.jdo.tck.pc.company.MedicalInsurance;
+import org.apache.jdo.tck.pc.company.QEmployee;
+import org.apache.jdo.tck.pc.company.QMedicalInsurance;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
+import javax.jdo.JDOQLTypedQuery;
 import javax.jdo.PersistenceManager;
 import javax.jdo.Transaction;
 import java.util.Calendar;
@@ -64,188 +67,6 @@ public class NavigationComparisonWithNul
         return NAVIGATION_TEST_COMPANY_TESTDATA;
     }
 
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     */
-    private static final QueryElementHolder[] VALID_QUERIES = {
-        // 0: simple manager check being nill
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.manager == null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 1: simple manager check being not null
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.manager != null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 2: simple manager check being not null using not operator
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "!(this.manager == null)",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 3: manager's manager check
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.manager.manager == null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 4: manager's manager check with extra check on first level manager
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.manager != null && this.manager.manager == null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 5 : manager's manager check not being null
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.manager.manager != null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 6 : manager's manager check not being null using not operator
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "!(this.manager.manager == null)",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 7 : multiple relationships 
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        MedicalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.employee.manager.manager == null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-
-        // 8 : multiple relationships 
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        MedicalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.employee != null && this.employee.manager != null && this.employee.manager.manager == null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 9 : multiple relationships 
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        MedicalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "this.employee.manager.manager != null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // 10 : multiple relationships 
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null,
-        /*FROM*/        MedicalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "!(this.employee.manager.manager == null)",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-
     /**
      * Manager relationship:
      * emp0
@@ -261,47 +82,6 @@ public class NavigationComparisonWithNul
      *   emp9
      */
     
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        // 0 : this.manager == null
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp0", "emp4", "emp7"}),
-        // 1 : this.manager != null
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp2", "emp3", "emp5", "emp6", "emp8", "emp9", "emp10"}),
-        // 2 : !(this.manager == null)
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp2", "emp3", "emp5", "emp6", "emp8", "emp9", "emp10"}),
-        
-        // 3 : this.manager.manager == null
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp0", "emp1", "emp4", "emp5", "emp6", "emp7", "emp8", "emp9"}),
-        // 4: this.manager != null && this.manager.manager == null
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp5", "emp6", "emp8", "emp9"}),
-        // 5 : this.manager.manager != null
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp2", "emp3", "emp10"}),
-        // 6 : !(this.manager.manager == null)
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp2", "emp3", "emp10"}),
-
-        // 7 : this.employee.manager.manager == null
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "medicalIns1", "medicalIns4", "medicalIns5", "medicalIns98"}),
-        // 8 : this.employee != null && this.employee.manager != null && this.employee.manager.manager == null
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "medicalIns1",  "medicalIns5"}),
-        // 9 : this.employee.manager.manager != null
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "medicalIns2", "medicalIns3"}),
-        // 10 : !(this.employee.manager.manager == null)
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "medicalIns2", "medicalIns3"})
-    };
-    
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -315,30 +95,100 @@ public class NavigationComparisonWithNul
      * this.manager == null
      */
     public void testPositive0() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[0], 
-                        expectedResult[0]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[0], 
-                                 expectedResult[0]);
+        // 0: simple manager check being null
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"emp0", "emp4", "emp7"});
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.filter(cand.manager.eq((Employee)null));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.manager == null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
      * this.manager != null
      */
     public void testPositive1() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[1], 
-                        expectedResult[1]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[1], 
-                                 expectedResult[1]);
+        // 1: simple manager check being not null
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"emp1", "emp2", "emp3", "emp5", "emp6", "emp8", "emp9", "emp10"});
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.filter(cand.manager.ne((Employee)null));
+        
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.manager != null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
      * !(this.manager == null)
      */
     public void testPositive2() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[2], 
-                        expectedResult[2]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[2], 
-                                 expectedResult[2]);
+        // 2: simple manager check being not null using not operator
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"emp1", "emp2", "emp3", "emp5", "emp6", "emp8", "emp9", "emp10"});
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.filter(cand.manager.eq((Employee)null).not());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "!(this.manager == null)",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        // DataNucleus: UnsupportedOperationException: Dont currently support operator NOT  in JDOQL conversion
+        //executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
@@ -346,40 +196,138 @@ public class NavigationComparisonWithNul
      * Disabled, because it currently fails on the RI.
      */
     public void testPositive3() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[3], 
-                        expectedResult[3]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[3], 
-                                 expectedResult[3]);
+        // 3: manager's manager check
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"emp0", "emp1", "emp4", "emp5", "emp6", "emp7", "emp8", "emp9"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.filter(cand.manager.manager.eq((Employee)null));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.manager.manager == null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
     
     /**
      * this.manager != null && this.manager.manager == null
      */
     public void testPositive4() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[4], 
-                        expectedResult[4]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[4], 
-                                 expectedResult[4]);
+       // 4: manager's manager check with extra check on first level manager
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"emp1", "emp5", "emp6", "emp8", "emp9"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.filter(cand.manager.ne((Employee)null).and(cand.manager.manager.eq((Employee)null)));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.manager != null && this.manager.manager == null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
      * this.manager.manager != null
      */
     public void testPositive5() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[5], 
-                        expectedResult[5]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[5], 
-                                 expectedResult[5]);
+        // 5 : manager's manager check not being null
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"emp2", "emp3", "emp10"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.filter(cand.manager.manager.ne((Employee)null));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.manager.manager != null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
      * !(this.manager.manager == null)
      */
     public void testPositive6() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[6], 
-                        expectedResult[6]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[6], 
-                                 expectedResult[6]);
+        // 6 : manager's manager check not being null using not operator
+        Object expected = getTransientCompanyModelInstancesAsList(
+            new String[]{"emp2", "emp3", "emp10"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        QEmployee e = QEmployee.variable("e");
+        query.filter(cand.manager.manager.eq((Employee)null).not());
+
+        QueryElementHolder holder  =new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "!(this.manager.manager == null)",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        // DataNucleus: UnsupportedOperationException: Dont currently support operator NOT  in JDOQL conversion
+        //executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
@@ -387,40 +335,137 @@ public class NavigationComparisonWithNul
      * Disabled, because it currently fails on the RI.
      */
     public void testPositive7() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[7], 
-                        expectedResult[7]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[7], 
-                                 expectedResult[7]);
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"medicalIns1", "medicalIns4", "medicalIns5", "medicalIns98"});
+
+        JDOQLTypedQuery<MedicalInsurance> query = getPM().newJDOQLTypedQuery(MedicalInsurance.class);
+        QMedicalInsurance cand = QMedicalInsurance.candidate();
+        query.filter(cand.employee.manager.manager.eq((Employee)null));
+
+        QueryElementHolder holder  = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        MedicalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.employee.manager.manager == null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
      * this.employee != null && this.employee.manager != null && this.employee.manager.manager == null
      */
     public void testPositive8() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[8], 
-                        expectedResult[8]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[8], 
-                                 expectedResult[8]);
+        // 8 : multiple relationships 
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"medicalIns1", "medicalIns5"});
+
+        JDOQLTypedQuery<MedicalInsurance> query = getPM().newJDOQLTypedQuery(MedicalInsurance.class);
+        QMedicalInsurance cand = QMedicalInsurance.candidate();
+        query.filter(cand.employee.ne((Employee)null).and(cand.employee.manager.ne((Employee)null))
+                .and(cand.employee.manager.manager.eq((Employee)null)));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        MedicalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.employee != null && this.employee.manager != null && " +
+                                 "this.employee.manager.manager == null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
      * this.employee.manager.manager != null
      */
     public void testPositive9() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[9], 
-                        expectedResult[9]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[9], 
-                                 expectedResult[9]);
+        // 9 : multiple relationships 
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"medicalIns2", "medicalIns3"});
+
+        JDOQLTypedQuery<MedicalInsurance> query = getPM().newJDOQLTypedQuery(MedicalInsurance.class);
+        QMedicalInsurance cand = QMedicalInsurance.candidate();
+        query.filter(cand.employee.manager.manager.ne((Employee)null));
+
+        QueryElementHolder holder  = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        MedicalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "this.employee.manager.manager != null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**
      * !(this.employee.manager.manager == null)
      */
     public void testPositive10() {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[10], 
-                        expectedResult[10]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[10], 
-                                 expectedResult[10]);
+        Object expected = getTransientCompanyModelInstancesAsList(
+                new String[]{"medicalIns2", "medicalIns3"});
+
+        JDOQLTypedQuery<MedicalInsurance> query = getPM().newJDOQLTypedQuery(MedicalInsurance.class);
+        QMedicalInsurance cand = QMedicalInsurance.candidate();
+        query.filter(cand.employee.manager.manager.eq((Employee)null).not());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        MedicalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "!(this.employee.manager.manager == null)",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        // DataNucleus: UnsupportedOperationException: Dont currently support operator NOT  in JDOQL conversion
+        //executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
     
     /**

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughACollectionField.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughACollectionField.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughACollectionField.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NavigationThroughACollectionField.java Sun Nov  4 18:37:24 2018
@@ -20,10 +20,14 @@ package org.apache.jdo.tck.query.jdoql;
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.pc.company.CompanyModelReader;
 import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.QDepartment;
+import org.apache.jdo.tck.pc.company.QEmployee;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
+import javax.jdo.JDOQLTypedQuery;
+
 /**
  *<B>Title:</B> Navigation Through a Collection Field
  *<BR>
@@ -54,34 +58,6 @@ public class NavigationThroughACollectio
     protected String getCompanyTestDataResource() {
         return NAVIGATION_TEST_COMPANY_TESTDATA;
     }
-
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     */
-    private static final QueryElementHolder[] VALID_QUERIES = {
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null,
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employees.contains(e) && e.firstname == \"emp1First\"",
-        /*VARIABLES*/   "Employee e",
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-        
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        getTransientCompanyModelInstancesAsList(new String[]{"dept1"})
-    };
     
     /**
      * The <code>main</code> is called when the class
@@ -94,12 +70,33 @@ public class NavigationThroughACollectio
     
     /** */
     public void testPositive() {
-        for (int i = 0; i < VALID_QUERIES.length; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-        }
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"});
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        QEmployee e = QEmployee.variable("e");
+        query.filter(cand.employees.contains(e).and(e.firstname.eq("emp1First")));
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employees.contains(e) && e.firstname == \"emp1First\"",
+                /*VARIABLES*/   "Employee e",
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/   query,
+                /*paramValues*/  null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
     
     /**



Mime
View raw message