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 [7/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/result/DistinctQuery.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctQuery.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctQuery.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/DistinctQuery.java Sun Nov  4 18:37:24 2018
@@ -21,11 +21,15 @@ 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.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;
 
+import javax.jdo.JDOQLTypedQuery;
+
 /**
  *<B>Title:</B> Disctinct Query.
  *<BR>
@@ -44,88 +48,6 @@ public class DistinctQuery extends Query
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.9-1 (DistinctQuery) 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",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "DISTINCT department",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "department.deptid, department.name",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "DISTINCT department.deptid, department.name",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*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[]{
-                "dept1", "dept1", "dept1", "dept2", "dept2"}),
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "dept1", "dept2"}),
-        Arrays.asList(new Object[] {
-                new Object[]{new Long(1),"Development"},
-                new Object[]{new Long(1),"Development"},
-                new Object[]{new Long(1),"Development"},
-                new Object[]{new Long(2),"Human Resources"},
-                new Object[]{new Long(2),"Human Resources"}}),
-        Arrays.asList(new Object[] {
-                new Object[]{new Long(1),"Development"},
-                new Object[]{new Long(2),"Human Resources"}}) 
-    };
-            
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -136,15 +58,133 @@ public class DistinctQuery extends Query
     }
     
     /** */
-    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[]{
+                "dept1", "dept1", "dept1", "dept2", "dept2"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(false, cand.department);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "department",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Department.class, expected);
+    }
+
+    /** */
+    public void testPositive1() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{
+                "dept1", "dept2"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(true, cand.department);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "DISTINCT department",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Department.class, expected);
+    }
+
+    /** */
+    public void testPositive2() {
+        Object expected = Arrays.asList(new Object[] {
+                new Object[]{new Long(1),"Development"},
+                new Object[]{new Long(1),"Development"},
+                new Object[]{new Long(1),"Development"},
+                new Object[]{new Long(2),"Human Resources"},
+                new Object[]{new Long(2),"Human Resources"}});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(false, cand.department.deptid, cand.department.name);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "department.deptid, department.name",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Object[].class, expected);
     }
 
+    /** */
+    public void testPositive3() {
+        Object expected = Arrays.asList(new Object[] {
+                new Object[]{new Long(1),"Development"},
+                new Object[]{new Long(2),"Human Resources"}});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(true, cand.department.deptid, cand.department.name);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "DISTINCT department.deptid, department.name",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Object[].class, expected);
+    }
     /**
      * @see JDO_Test#localSetUp()
      */

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/Grouping.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/Grouping.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/Grouping.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/Grouping.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.FullTimeEmployee;
+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;
+
 /**
  *<B>Title:</B> Grouping.
  *<BR>
@@ -46,37 +49,16 @@ public class Grouping extends QueryTest
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.10-1 (Grouping) 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, SUM(salary)",
-        /*INTO*/        null, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    "department",
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-    
-    /** 
-     * The array of invalid queries which may be executed as 
+
+    /**
+     * The array of invalid queries which may be executed as
      * single string queries and as API queries.
      */
     private static final QueryElementHolder[] INVALID_QUERIES = {
         new QueryElementHolder(
         /*UNIQUE*/      null,
         /*RESULT*/      "department, salary",
-        /*INTO*/        null, 
+        /*INTO*/        null,
         /*FROM*/        FullTimeEmployee.class,
         /*EXCLUDE*/     null,
         /*WHERE*/       null,
@@ -88,15 +70,6 @@ public class Grouping 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(30000.0)},
-            new Object[] {getTransientCompanyModelInstance("dept2"), new Double(45000.0)}})
-    };
         
     /**
      * The <code>main</code> is called when the class
@@ -109,12 +82,35 @@ public class Grouping extends QueryTest
     
     /** */
     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 = Arrays.asList(new Object[] {
+                new Object[] {getTransientCompanyModelInstance("dept1"), new Double(30000.0)},
+                new Object[] {getTransientCompanyModelInstance("dept2"), new Double(45000.0)}});
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        query.result(false, cand.department, cand.salary.sum());
+        query.groupBy(cand.department);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "department, SUM(salary)",
+                /*INTO*/        null,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    "department",
+                /*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);
     }
 
     /** */

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/IfElseResult.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/IfElseResult.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/IfElseResult.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/IfElseResult.java Sun Nov  4 18:37:24 2018
@@ -25,10 +25,15 @@ 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.Project;
+import org.apache.jdo.tck.pc.company.QDentalInsurance;
+import org.apache.jdo.tck.pc.company.QProject;
 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.IfThenElseExpression;
+
 /**
  *<B>Title:</B> IfElseResult.
  *<BR>
@@ -43,55 +48,6 @@ public class IfElseResult extends QueryT
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion (IfElseResult) 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*/      "IF (this.employee == null) 'No employee' ELSE this.employee.lastname",
-        /*INTO*/        null, 
-        /*FROM*/        DentalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.insid ascending",
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "IF (this.members.size() > 2) this.budget * 1.2 ELSE this.budget * 1.1",
-        /*INTO*/        null, 
-        /*FROM*/        Project.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.projid ascending",
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "IF (this.reviewers.isEmpty()) 'No reviewer' ELSE IF (this.reviewers.size() == 1) 'Single reviewer' ELSE 'Reviewer team'",
-        /*INTO*/        null, 
-        /*FROM*/        Project.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.projid ascending",
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
 
     /** 
      * The array of invalid queries which may be executed as 
@@ -145,15 +101,6 @@ public class IfElseResult extends QueryT
         /*TO*/          null)
     };
     
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        Arrays.asList(new Object[] { "emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last", "No employee" }),
-        Arrays.asList(new Object[] { new BigDecimal("3000001.188"), new BigDecimal("55000"), new BigDecimal("2201.089") }),
-        Arrays.asList(new Object[] { "No reviewer", "Reviewer team", "Single reviewer" })
-    };
-            
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -164,13 +111,103 @@ public class IfElseResult extends QueryT
     }
     
     /** */
-    public void testPositive() {
-        for (int index = 0; index < VALID_QUERIES.length; index++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                            expectedResult[index]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                                     expectedResult[index]);
-        }
+    public void testPositive0() {
+        Object expected = Arrays.asList("emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last", "No employee");
+
+        JDOQLTypedQuery<DentalInsurance> query = getPM().newJDOQLTypedQuery(DentalInsurance.class);
+        QDentalInsurance cand = QDentalInsurance.candidate();
+        query.result(false,
+                query.ifThenElse(cand.employee.eq((Employee)null), "No employee", cand.employee.lastname));
+        query.orderBy(cand.insid.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "IF (this.employee == null) 'No employee' ELSE this.employee.lastname",
+                /*INTO*/        null,
+                /*FROM*/        DentalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.insid ascending",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, String.class, expected);
+    }
+
+    /** */
+    public void testPositive1() {
+        Object expected = Arrays.asList(
+                new BigDecimal("3000001.188"), new BigDecimal("55000"), new BigDecimal("2201.089"));
+
+        JDOQLTypedQuery<Project> query = getPM().newJDOQLTypedQuery(Project.class);
+        QProject cand = QProject.candidate();
+        query.result(false,
+                query.ifThenElse(BigDecimal.class, cand.members.size().gt(2),
+                        cand.budget.mul(new BigDecimal(1.2)), cand.budget.mul(new BigDecimal(1.1))));
+        query.orderBy(cand.projid.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "IF (this.members.size() > 2) this.budget * 1.2 ELSE this.budget * 1.1",
+                /*INTO*/        null,
+                /*FROM*/        Project.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.projid ascending",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, BigDecimal.class, expected);
+    }
+
+    /** */
+    public void testPositive2() {
+        Object expected = Arrays.asList("No reviewer", "Reviewer team", "Single reviewer");
+
+        JDOQLTypedQuery<Project> query = getPM().newJDOQLTypedQuery(Project.class);
+        QProject cand = QProject.candidate();
+        IfThenElseExpression<String> ifThenElse = query.ifThen(cand.reviewers.isEmpty(), "No Reviewer").
+                ifThen(cand.reviewers.size().eq(1), "Single reviewer").elseEnd("Reviewer team");
+        query.result(false, ifThenElse);
+        query.orderBy(cand.projid.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "IF (this.reviewers.isEmpty()) 'No reviewer' " +
+                "ELSE IF (this.reviewers.size() == 1) 'Single reviewer' ELSE 'Reviewer team'",
+                /*INTO*/        null,
+                /*FROM*/        Project.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.projid ascending",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, String.class, expected);
     }
 
     /** */

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/MethodsInResult.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/MethodsInResult.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/MethodsInResult.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/MethodsInResult.java Sun Nov  4 18:37:24 2018
@@ -17,15 +17,16 @@
  
 package org.apache.jdo.tck.query.result;
 
-import java.math.BigInteger;
 import java.util.Arrays;
 
-import javax.jdo.PersistenceManager;
-import javax.jdo.Query;
+import javax.jdo.JDOQLTypedQuery;
 
+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.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;
@@ -48,182 +49,200 @@ public class MethodsInResult extends Que
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.9-5 (MethodsInResult) failed: ";
     
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API 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 static final QueryElementHolder[] VALID_QUERIES = {
+    public static void main(String[] args) {
+        BatchTestRunner.run(MethodsInResult.class);
+    }
+
+    public void testCollectionSizeInResult() {
         // collection.size()
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "this.employees.size()",
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.name ascending",
-        /*FROM*/        null,
-        /*TO*/          null),
-        
+        Object expected = Arrays.asList(new Integer(3), new Integer(2));
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        query.result(false, cand.employees.size());
+        query.orderBy(cand.name.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "this.employees.size()",
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.name ascending",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Integer.class, expected);
+    }
+
+    public void testMapSizeInResult() {
         // map.size()
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "this.phoneNumbers.size()",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.lastname ascending, this.firstname ascending",
-        /*FROM*/        null,
-        /*TO*/          null),
+        Object expected = Arrays.asList(
+                new Integer(2), new Integer(2), new Integer(2), new Integer(2), new Integer(2));
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(false, cand.phoneNumbers.size());
+        query.orderBy(cand.lastname.asc(), cand.firstname.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "this.phoneNumbers.size()",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.lastname ascending, this.firstname ascending",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Integer.class, expected);
+    }
 
+    public void testMaxAndSizeInResult() {
         // MAX(collection.size())
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "MAX(this.employees.size())",
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
+        Object expected = new Integer(3);
 
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        query.result(false, cand.employees.size().max());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      Boolean.TRUE,
+                /*RESULT*/      "MAX(this.employees.size())",
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Integer.class, expected);
+    }
+
+    public void testMapGetInResult() {
         // map.get()
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "this.phoneNumbers.get('home')",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.lastname ascending, this.firstname ascending",
-        /*FROM*/        null,
-        /*TO*/          null),
+        Object expected = Arrays.asList("1111", "2222", "3333", "3343", "3363");
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(false, cand.phoneNumbers.get("home"));
+        query.orderBy(cand.lastname.asc(), cand.firstname.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "this.phoneNumbers.get('home')",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.lastname ascending, this.firstname ascending",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, String.class, expected);
+    }
 
+    public void testSubstringInResult()  {
         // String.substring()
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "this.firstname.substring(1,4)",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.lastname ascending, this.firstname ascending",
-        /*FROM*/        null,
-        /*TO*/          null),
+        Object expected = Arrays.asList("mp1", "mp2", "mp3", "mp4", "mp5");
 
-        // String.indexOf()
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "this.firstname.indexOf('First')",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "this.lastname ascending, this.firstname ascending",
-        /*FROM*/        null,
-        /*TO*/          null)    
-    };
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(false, cand.firstname.substring(1, 4));
+        query.orderBy(cand.lastname.asc(), cand.firstname.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "this.firstname.substring(1,4)",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.lastname ascending, this.firstname ascending",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, String.class, expected);
+    }
 
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        // collection.size()
-        Arrays.asList(new Object[] { new Integer(3), new Integer(2) }),
-        // map.size()
-        Arrays.asList(new Object[] { new Integer(2), new Integer(2), new Integer(2), new Integer(2), new Integer(2) }),
-        // MAX(collection.size())
-        new Integer(3),
-        // map.get()
-        Arrays.asList(new Object[] { "1111", "2222", "3333", "3343", "3363" }),
-        // String.substring()
-        Arrays.asList(new Object[] { "mp1", "mp2", "mp3", "mp4", "mp5" }),
+    public void testIndexOfInResult() {
         // String.indexOf()
-        //Arrays.asList(new Object[] { new BigInteger("4"), new BigInteger("4"), new BigInteger("4"), new BigInteger("4"), new BigInteger("4") }),
-        Arrays.asList(new Object[] { new Integer(4), new Integer(4), new Integer(4), new Integer(4), new Integer(4) }),
-    };
-    
-    /**
-     * 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(MethodsInResult.class);
-    }
+        Object expected =
+                Arrays.asList(new Integer(4), new Integer(4), new Integer(4), new Integer(4), new Integer(4));
 
-    public void testCollectionSizeInResult() throws Exception {
-        int index = 0;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
-    public void testMapSizeInResult() throws Exception {
-        int index = 1;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
-    public void testMaxAndSizeInResult() throws Exception {
-        int index = 2;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
-    public void testMapGetInResult() throws Exception {
-        int index = 3;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
-    public void testSubstringInResult() throws Exception {
-        int index = 4;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
-    public void testIndexOfInResult() throws Exception {
-        int index = 5;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(false, cand.firstname.indexOf("First"));
+        query.orderBy(cand.lastname.asc(), cand.firstname.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "this.firstname.indexOf('First')",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "this.lastname ascending, this.firstname ascending",
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Integer.class, expected);
     }
 
     /**

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java Sun Nov  4 18:37:24 2018
@@ -23,10 +23,14 @@ 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.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> NullPointerException in Result Expression.
  *<BR>
@@ -45,52 +49,6 @@ public class NPEInResultExpr extends Que
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.9-4 (NPEInResultExpr) 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*/      "manager.lastname",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "e.manager.lastname",
-        /*INTO*/        null, 
-        /*FROM*/        Department.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employees.contains(e)",
-        /*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 = {
-        //Note: None of the entries below are bean names!
-        Arrays.asList(new Object[]{
-                "emp2Last", null, "emp2Last", "emp2Last", "emp2Last"}),
-        Arrays.asList(new Object[]{
-                "emp2Last", null, "emp2Last", "emp2Last", "emp2Last"})
-    };
             
     /**
      * The <code>main</code> is called when the class
@@ -102,13 +60,65 @@ public class NPEInResultExpr extends Que
     }
     
     /** */
-    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("emp2Last", null, "emp2Last", "emp2Last", "emp2Last");
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(false, cand.manager.lastname);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "manager.lastname",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, String.class, expected);
+    }
+
+    /** */
+    public void testPositive1() {
+        Object expected = Arrays.asList("emp2Last", null, "emp2Last", "emp2Last", "emp2Last");
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        QEmployee e = QEmployee.variable("e");
+        query.filter(cand.employees.contains(e));
+        query.result(false, e.manager.lastname);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "e.manager.lastname",
+                /*INTO*/        null,
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employees.contains(e)",
+                /*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, String.class, expected);
     }
 
     /**

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/NullResults.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/NullResults.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/NullResults.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/NullResults.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> Null Results.
  *<BR>
@@ -42,64 +45,6 @@ public class NullResults extends QueryTe
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.9-7 (NullResults) 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*/      Boolean.TRUE,
-        /*RESULT*/      "manager",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "lastname == 'emp2Last'",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "manager",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "lastname == 'emp2Last'",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "DISTINCT manager",
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*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 = {
-        null,
-        Arrays.asList(new Object[]{null}),
-        getTransientCompanyModelInstancesAsList(new String[]{"emp2", null}) 
-    };
             
     /**
      * The <code>main</code> is called when the class
@@ -112,29 +57,94 @@ public class NullResults extends QueryTe
     
     /** */
     public void testUnique() {
-        int index = 0;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
+        Object expected = null;
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.filter(cand.lastname.eq("emp2Last"));
+        query.result(false, cand.manager);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      Boolean.TRUE,
+                /*RESULT*/      "manager",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "lastname == 'emp2Last'",
+                /*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, Employee.class, expected);
     }
 
     /** */
     public void testNavigation() {
-        int index = 1;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
+        Object expected = Arrays.asList(new Object[]{null});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.filter(cand.lastname.eq("emp2Last"));
+        query.result(false, cand.manager);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "manager",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "lastname == 'emp2Last'",
+                /*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, Employee.class, expected);
     }
 
     /** */
     public void testDistinctNavigation() {
-        int index = 2;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp2", null});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(true, cand.manager);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "DISTINCT manager",
+                /*INTO*/        null,
+                /*FROM*/        Employee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Employee.class, expected);
     }
 
     /**

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java Sun Nov  4 18:37:24 2018
@@ -25,6 +25,8 @@ import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.pc.company.CompanyModelReader;
 import org.apache.jdo.tck.pc.company.FullTimeEmployee;
 import org.apache.jdo.tck.pc.company.Project;
+import org.apache.jdo.tck.pc.company.QFullTimeEmployee;
+import org.apache.jdo.tck.pc.company.QProject;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.query.result.classes.LongString;
@@ -35,6 +37,8 @@ import org.apache.jdo.tck.query.result.c
 import org.apache.jdo.tck.util.BatchTestRunner;
 import org.apache.jdo.tck.util.ConversionHelper;
 
+import javax.jdo.JDOQLTypedQuery;
+
 /**
  *<B>Title:</B> Result Class Requirements.
  *<BR>
@@ -52,172 +56,6 @@ public class ResultClassRequirements ext
         "Assertion A14.6.12-1 (ResultClassRequirements) failed: ";
     
     /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     */
-    private static final QueryElementHolder[] VALID_QUERIES = {
-        // Long
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "personid",
-        /*INTO*/        Long.class, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // Double
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "salary",
-        /*INTO*/        Double.class, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // BigDecimal
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "budget",
-        /*INTO*/        BigDecimal.class, 
-        /*FROM*/        Project.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // java.util.Date
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "hiredate",
-        /*INTO*/        java.util.Date.class, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // Map
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "personid AS id, lastname AS name",
-        /*INTO*/        Map.class, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // user defined result class
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "personid AS l, lastname AS s",
-        /*INTO*/        LongString.class, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // constructor
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "new LongString(personid, lastname)",
-        /*INTO*/        null, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     "import org.apache.jdo.tck.query.result.classes.LongString;",
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // constructor without constructor call
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "personid, lastname",
-        /*INTO*/        LongString.class, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // public fields
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "personid AS l",
-        /*INTO*/        PublicLongField.class, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        
-        // public put method
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "personid, lastname",
-        /*INTO*/        PublicPutMethod.class, 
-        /*FROM*/        FullTimeEmployee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-    
-    /** 
      * The array of invalid queries which may be executed as 
      * single string queries and as API queries.
      */
@@ -337,55 +175,6 @@ public class ResultClassRequirements ext
     private static Object[][] publicPutMethod5 =
         {{"personid", new Long(5)}, {"lastname", "emp5Last"}};
     
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        // Long
-        Arrays.asList(new Object[]{new Long(1), new Long(2), new Long(5)}),
-        // Double
-        Arrays.asList(new Object[]{
-                new Double(20000.0), new Double(10000.0), new Double(45000.0)}),
-        // BigDecimal
-        Arrays.asList(new Object[]{new BigDecimal("2500000.99"), 
-                new BigDecimal("50000.00"), new BigDecimal("2000.99")}),
-        // java.util.Date
-        Arrays.asList(new Object[]{
-                CompanyModelReader.stringToUtilDate("1/Jan/1999"), 
-                CompanyModelReader.stringToUtilDate("1/Jul/2003"), 
-                CompanyModelReader.stringToUtilDate("15/Aug/1998")}),
-        // Map
-        Arrays.asList(new Object[]{
-                ConversionHelper.arrayToMap(emp1Map),
-                ConversionHelper.arrayToMap(emp2Map),
-                ConversionHelper.arrayToMap(emp5Map)}),
-        // user defined result class
-        Arrays.asList(new Object[]{
-                new LongString(1, "emp1Last"), 
-                new LongString(2, "emp2Last"), 
-                new LongString(5, "emp5Last")}),
-        // constructor
-        Arrays.asList(new Object[]{
-                new LongString(1, "emp1Last"), 
-                new LongString(2, "emp2Last"), 
-                new LongString(5, "emp5Last")}),
-        // constructor without constructor call
-        Arrays.asList(new Object[]{
-                new LongString(1, "emp1Last"), 
-                new LongString(2, "emp2Last"), 
-                new LongString(5, "emp5Last")}),
-        // public fields
-        Arrays.asList(new Object[]{
-                new PublicLongField(1), 
-                new PublicLongField(2), 
-                new PublicLongField(5)}),
-        // public put method
-        Arrays.asList(new Object[]{
-                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod1)),
-                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod2)),
-                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod5))})
-    };
-            
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -397,58 +186,330 @@ public class ResultClassRequirements ext
     
     /** */
     public void testLong() {
-        int index = 0;
-        executeQuery(index);
+        Object expected = Arrays.asList(new Long(1), new Long(2), new Long(5));
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        query.result(false, cand.personid);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "personid",
+                /*INTO*/        Long.class,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Long.class, expected);
     }
 
     /** */
     public void testDouble() {
-        int index = 1;
-        executeQuery(index);
+        Object expected = Arrays.asList(new Double(20000.0), new Double(10000.0), new Double(45000.0));
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        query.result(false, cand.salary);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "salary",
+                /*INTO*/        Double.class,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Double.class, expected);
     }
 
     /** */
     public void testBigDecimal() {
-        int index = 2;
-        executeQuery(index);
+        Object expected = Arrays.asList(
+                new BigDecimal("2500000.99"), new BigDecimal("50000.00"), new BigDecimal("2000.99"));
+
+        JDOQLTypedQuery<Project> query = getPM().newJDOQLTypedQuery(Project.class);
+        QProject cand = QProject.candidate();
+        query.result(false, cand.budget);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "budget",
+                /*INTO*/        BigDecimal.class,
+                /*FROM*/        Project.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, BigDecimal.class, expected);
     }
 
     /** */
     public void testDate() {
-        int index = 3;
-        executeQuery(index);
+        Object expected = Arrays.asList(
+                CompanyModelReader.stringToUtilDate("1/Jan/1999"),
+                CompanyModelReader.stringToUtilDate("1/Jul/2003"),
+                CompanyModelReader.stringToUtilDate("15/Aug/1998"));
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        query.result(false, cand.hiredate);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "hiredate",
+                /*INTO*/        java.util.Date.class,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, java.util.Date.class, expected);
     }
 
     /** */
     public void testMap() {
-        int index = 4;
-        executeQuery(index);
+        Object expected = Arrays.asList(
+                ConversionHelper.arrayToMap(emp1Map),
+                ConversionHelper.arrayToMap(emp2Map),
+                ConversionHelper.arrayToMap(emp5Map));
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        // JDOQLTypedQuery API: Map Result
+        query.result(false, cand.personid, cand.lastname);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "personid AS id, lastname AS name",
+                /*INTO*/        Map.class,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, Map.class, expected);
     }
 
     /** */
     public void testUserDefinedResultClass() {
-        int index = 5;
-        executeQuery(index);
+        Object expected = Arrays.asList(
+                new LongString(1, "emp1Last"),
+                new LongString(2, "emp2Last"),
+                new LongString(5, "emp5Last"));
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        // JDOQLTypedQuery API: user defined class
+        query.result(false, cand.personid, cand.lastname);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "personid AS l, lastname AS s",
+                /*INTO*/        LongString.class,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, LongString.class, expected);
     }
 
     /** */
     public void testConstructor() {
-        int index = 6;
-        executeQuery(index);
-        index++;
-        executeQuery(index);
+        Object expected = Arrays.asList(new Object[]{
+                new LongString(1, "emp1Last"),
+                new LongString(2, "emp2Last"),
+                new LongString(5, "emp5Last")});
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        // JDOQLTypedQuery API: constructor
+        query.result(false, cand.personid, cand.lastname);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "new LongString(personid, lastname)",
+                /*INTO*/        null,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     "import org.apache.jdo.tck.query.result.classes.LongString;",
+                /*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, LongString.class, expected);
+    }
+
+    /** */
+    public void testConstructorWithoutConstructorCall() {
+        Object expected = Arrays.asList(new Object[]{
+                new LongString(1, "emp1Last"),
+                new LongString(2, "emp2Last"),
+                new LongString(5, "emp5Last")});
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        // JDOQLTypedQuery API: constructor
+        query.result(false, cand.personid, cand.lastname);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "personid, lastname",
+                /*INTO*/        LongString.class,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, LongString.class, expected);
     }
 
     /** */
     public void testFields() {
-        int index = 8;
-        executeQuery(index);
+        Object expected = Arrays.asList(new Object[]{
+                new PublicLongField(1),
+                new PublicLongField(2),
+                new PublicLongField(5)});
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        // JDOQLTypedQuery API:
+        query.result(false, cand.personid);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "personid AS l",
+                /*INTO*/        PublicLongField.class,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, PublicLongField.class, expected);
     }
 
     /** */
     public void testPut() {
-        int index = 9;
-        executeQuery(index);
+        Object expected = Arrays.asList(new Object[]{
+                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod1)),
+                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod2)),
+                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod5))});
+
+        JDOQLTypedQuery<FullTimeEmployee> query = getPM().newJDOQLTypedQuery(FullTimeEmployee.class);
+        QFullTimeEmployee cand = QFullTimeEmployee.candidate();
+        // JDOQLTypedQuery API: constructor
+        query.result(false, cand.personid, cand.lastname);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "personid, lastname",
+                /*INTO*/        PublicPutMethod.class,
+                /*FROM*/        FullTimeEmployee.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       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, PublicPutMethod.class, expected);
     }
 
     /** */
@@ -460,14 +521,6 @@ public class ResultClassRequirements ext
         }
     }
 
-    /** */
-    private void executeQuery(int index) {
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
     /**
      * @see JDO_Test#localSetUp()
      */



Mime
View raw message