db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1847421 - in /db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query: QueryElementHolder.java jdoql/NegativeRange.java jdoql/PositiveRange.java result/DefaultUnique.java
Date Sun, 25 Nov 2018 17:16:48 GMT
Author: mbo
Date: Sun Nov 25 17:16:48 2018
New Revision: 1847421

URL: http://svn.apache.org/viewvc?rev=1847421&view=rev
Log:
JDO-652: more JDOQLTypedQuery test cases

Modified:
    db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java
    db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java
    db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java
    db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultUnique.java

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java?rev=1847421&r1=1847420&r2=1847421&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/QueryElementHolder.java Sun Nov
25 17:16:48 2018
@@ -161,48 +161,6 @@ public class QueryElementHolder {
 
     /**
      * Returns an instance of this class holding the given arguments
-     * such as the candidate class, the filter, etc. 
-     * The given arguments represent JDOQL query elements. 
-     * It is valid to pass <code>null</code> as a value
-     * for JDOQL querys elements. Such elements are not transfered into a 
-     * JDO {@link javax.jdo.Query} instance.
-     * Instead, the default of JDO {@link javax.jdo.Query} instance is taken.
-     * @param unique the JDOQL unique query element
-     * @param result the JDOQL result query element
-     * @param resultClass the JDOQL result class query element
-     * @param candidateClass the JDOQL candidate class query element
-     * @param excludeSubClasses the JDOQL exclude subclasses query element
-     * @param filter the JDOQL filter query element
-     * @param variables the JDOQL variables query element
-     * @param parameters the JDOQL parameters query element
-     * @param imports the JDOQL imports query element
-     * @param grouping the JDOQL grouping query element
-     * @param ordering the JDOQL ordering query element
-     * @param from the JDOQL from query element
-     * @param to the JDOQL to query element
-     */
-    public QueryElementHolder(Boolean unique, String result, 
-            Class resultClass, Class candidateClass, 
-            Boolean excludeSubClasses, String filter,
-            String variables, String parameters, String imports, 
-            String grouping, String ordering, long from, long to) {
-        this.unique = unique;
-        this.result = result;
-        this.resultClass = resultClass;
-        this.candidateClass = candidateClass;
-        this.excludeSubClasses = excludeSubClasses;
-        this.filter = filter;
-        this.variables = variables;
-        this.parameters = parameters;
-        this.imports = imports;
-        this.grouping = grouping;
-        this.ordering = ordering;
-        this.fromLong = new Long(from);
-        this.toLong = new Long(to);
-    }
-
-    /**
-     * Returns an instance of this class holding the given arguments
      * such as the candidate class, the filter, etc.
      * The given arguments represent JDOQL query elements.
      * It is valid to pass <code>null</code> as a value

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java?rev=1847421&r1=1847420&r2=1847421&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java Sun Nov
25 17:16:48 2018
@@ -26,6 +26,8 @@ import org.apache.jdo.tck.query.QueryEle
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
+import javax.jdo.JDOQLTypedQuery;
+
 /**
  *<B>Title:</B> Negative Range.
  *<BR>
@@ -45,79 +47,6 @@ public class NegativeRange extends Query
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.8-2 (NegativeRange) 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*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        4,
-        /*TO*/          4),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Person.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        4,
-        /*TO*/          3),
-        new QueryElementHolder(
-        /*UNIQUE*/      Boolean.TRUE,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Person.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        4,
-        /*TO*/          4),
-        new QueryElementHolder(
-        /*UNIQUE*/      Boolean.TRUE,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Person.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        4,
-        /*TO*/          3)
-    };
-
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        Arrays.asList(new Object[]{}),
-        Arrays.asList(new Object[]{}),
-        null,
-        null
-    };
             
     /**
      * The <code>main</code> is called when the class
@@ -127,30 +56,119 @@ public class NegativeRange extends Query
     public static void main(String[] args) {
         BatchTestRunner.run(NegativeRange.class);
     }
-    
-    /** */
-    public void testNonUnique() {
-        for (int i = 0; i < 2; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-        }
+
+    public void testNonUnique0() {
+        Object expected = Arrays.asList();
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        4,
+                /*TO*/          4,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
-    /** */
-    public void testUnique() {
-        for (int i = 2; i < 4; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
-                    expectedResult[i]);
-        }
+    public void testNonUnique1() {
+        Object expected = Arrays.asList();
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        4,
+                /*TO*/          3,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    public void testUnique0() {
+        Object expected = null;
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      Boolean.TRUE,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        4,
+                /*TO*/          4,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    public void testUnique1() {
+        Object expected = null;
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      Boolean.TRUE,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        4,
+                /*TO*/          3,
+                /*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/PositiveRange.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java?rev=1847421&r1=1847420&r2=1847421&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java Sun Nov
25 17:16:48 2018
@@ -20,10 +20,13 @@ 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.Person;
+import org.apache.jdo.tck.pc.company.QPerson;
 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> Positive Range.
  *<BR>
@@ -39,83 +42,6 @@ public class PositiveRange extends Query
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.8-1 (PositiveRange) 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*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "personid ASCENDING",
-        /*FROM*/        0,
-        /*TO*/          5),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Person.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "personid ASCENDING",
-        /*FROM*/        0,
-        /*TO*/          4),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Person.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "personid ASCENDING",
-        /*FROM*/        1,
-        /*TO*/          5),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      null, 
-        /*INTO*/        null, 
-        /*FROM*/        Person.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    "personid ASCENDING",
-        /*FROM*/        1,
-        /*TO*/          4)
-    };
-
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp2", "emp3", "emp4", "emp5"}),
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp2", "emp3", "emp4"}),
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp2", "emp3", "emp4", "emp5"}),
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp2", "emp3", "emp4"})
-    };
             
     /**
      * The <code>main</code> is called when the class
@@ -125,20 +51,131 @@ public class PositiveRange extends Query
     public static void main(String[] args) {
         BatchTestRunner.run(PositiveRange.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 = getTransientCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.orderBy(cand.personid.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "personid ASCENDING",
+                /*FROM*/        0,
+                /*TO*/          5,
+                /*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"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.orderBy(cand.personid.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "personid ASCENDING",
+                /*FROM*/        0,
+                /*TO*/          4,
+                /*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[]{
+                "emp2", "emp3", "emp4", "emp5"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.orderBy(cand.personid.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "personid ASCENDING",
+                /*FROM*/        1,
+                /*TO*/          5,
+                /*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[]{
+                "emp2", "emp3", "emp4"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.orderBy(cand.personid.asc());
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*INTO*/        null,
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    "personid ASCENDING",
+                /*FROM*/        1,
+                /*TO*/          4,
+                /*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/result/DefaultUnique.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultUnique.java?rev=1847421&r1=1847420&r2=1847421&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultUnique.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/result/DefaultUnique.java Sun
Nov 25 17:16:48 2018
@@ -25,10 +25,14 @@ 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.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> Default Unique.
  *<BR>
@@ -45,193 +49,6 @@ public class DefaultUnique extends Query
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.11-2 (DefaultUnique) 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*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-
-        // aggregate queries
-
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "COUNT(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*/      "avg(lifetimeOrthoBenefit)", 
-        /*INTO*/        null, 
-        /*FROM*/        DentalInsurance.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*/      "MIN(budget)", 
-        /*INTO*/        null, 
-        /*FROM*/        Project.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*/      "max (budget)", 
-        /*INTO*/        null, 
-        /*FROM*/        Project.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*/      "SUM (budget)", 
-        /*INTO*/        null, 
-        /*FROM*/        Project.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    null,
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-
-        // aggregate queries with grouping
-
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "count(department)", 
-        /*INTO*/        null, 
-        /*FROM*/        Employee.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       null,
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    "department",
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "AVG(lifetimeOrthoBenefit)", 
-        /*INTO*/        null, 
-        /*FROM*/        DentalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employee != null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    "employee.department",
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "min(lifetimeOrthoBenefit)", 
-        /*INTO*/        null, 
-        /*FROM*/        DentalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employee != null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    "employee.department",
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "MAX(lifetimeOrthoBenefit)", 
-        /*INTO*/        null, 
-        /*FROM*/        DentalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employee != null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    "employee.department",
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null),
-        new QueryElementHolder(
-        /*UNIQUE*/      null,
-        /*RESULT*/      "sum(lifetimeOrthoBenefit)", 
-        /*INTO*/        null, 
-        /*FROM*/        DentalInsurance.class,
-        /*EXCLUDE*/     null,
-        /*WHERE*/       "employee != null",
-        /*VARIABLES*/   null,
-        /*PARAMETERS*/  null,
-        /*IMPORTS*/     null,
-        /*GROUP BY*/    "employee.department",
-        /*ORDER BY*/    null,
-        /*FROM*/        null,
-        /*TO*/          null)
-    };
-    
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp2", "emp3", "emp4", "emp5"}),
-        // results for aggregate queries
-        new Long(5),
-        new Double("99.997"),
-        new BigDecimal("2000.99"),
-        new BigDecimal("2500000.99"),
-        new BigDecimal("2552001.98"),
-        // results for aggregate queries with grouping
-        Arrays.asList(new Object[]{new Long(3), new Long(2)}),
-        Arrays.asList(new Object[]{new Double("99.996"), new Double("99.9985")}),
-        Arrays.asList(new Object[]{new BigDecimal("99.995"), new BigDecimal("99.998")}),
-        Arrays.asList(new Object[]{new BigDecimal("99.997"), new BigDecimal("99.999")}),
-        Arrays.asList(new Object[]{new BigDecimal("299.988"), new BigDecimal("199.997")})
-    };
             
     /**
      * The <code>main</code> is called when the class
@@ -244,40 +61,321 @@ public class DefaultUnique extends Query
 
     /** */
     public void testThis() {
-        int index = 0;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"});
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null,
+                /*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, expected);
+    }
+
+    /** */
+    public void testAggregateNoGrouping0() {
+        Object expected = Long.valueOf(5);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "COUNT(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*/  null,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAggregateNoGrouping1() {
+        Object expected = new Double("99.997");
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "avg(lifetimeOrthoBenefit)",
+                /*INTO*/        null,
+                /*FROM*/        DentalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  null,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAggregateNoGrouping2() {
+        Object expected = new BigDecimal("2000.99");
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "MIN(budget)",
+                /*INTO*/        null,
+                /*FROM*/        Project.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  null,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /** */
-    public void testAggregateNoGrouping() {
-        final int firstIndex = 1;
-        final int lastIndex = 5;
-        for (int index = firstIndex; index <= lastIndex; index++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                            expectedResult[index]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                                     expectedResult[index]);
-        }
+    public void testAggregateNoGrouping3() {
+        Object expected = new BigDecimal("2500000.99");
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "MAX(budget)",
+                /*INTO*/        null,
+                /*FROM*/        Project.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  null,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAggregateNoGrouping4() {
+        Object expected = new BigDecimal("2552001.98");
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "SUM (budget)",
+                /*INTO*/        null,
+                /*FROM*/        Project.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null,
+                /*JDOQLTyped*/  null,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /** */
-    public void testAggregateGrouping() {
-        final int firstIndex = 6;
-        final int lastIndex = 10;
-        for (int index = firstIndex; index <= lastIndex; index++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                            expectedResult[index]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                                     expectedResult[index]);
-        }
+    public void testAggregateGrouping0() {
+        Object expected = Arrays.asList(Long.valueOf(3), Long.valueOf(2));
+
+        JDOQLTypedQuery<Employee> query = getPM().newJDOQLTypedQuery(Employee.class);
+        QEmployee cand = QEmployee.candidate();
+        query.result(false, cand.department.count());
+        query.groupBy(cand.department);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "count(department)",
+                /*INTO*/        null,
+                /*FROM*/        Employee.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, null, true, expected);
+    }
+
+    /** */
+    public void testAggregateGrouping1() {
+        Object expected = Arrays.asList(new Double("99.996"), new Double("99.9985"));
+
+        JDOQLTypedQuery<DentalInsurance> query = getPM().newJDOQLTypedQuery(DentalInsurance.class);
+        QDentalInsurance cand = QDentalInsurance.candidate();
+        query.filter(cand.employee.ne((Employee)null));
+        query.result(false, cand.lifetimeOrthoBenefit.avg());
+        query.groupBy(cand.employee.department);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "AVG(lifetimeOrthoBenefit)",
+                /*INTO*/        null,
+                /*FROM*/        DentalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employee != null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    "employee.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, null, true, expected);
+    }
+
+    /** */
+    public void testAggregateGrouping2() {
+        Object expected = Arrays.asList(new BigDecimal("99.995"), new BigDecimal("99.998"));
+
+        JDOQLTypedQuery<DentalInsurance> query = getPM().newJDOQLTypedQuery(DentalInsurance.class);
+        QDentalInsurance cand = QDentalInsurance.candidate();
+        query.filter(cand.employee.ne((Employee)null));
+        query.result(false, cand.lifetimeOrthoBenefit.min());
+        query.groupBy(cand.employee.department);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "min(lifetimeOrthoBenefit)",
+                /*INTO*/        null,
+                /*FROM*/        DentalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employee != null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    "employee.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, null, true, expected);
+    }
+
+    /** */
+    public void testAggregateGrouping3() {
+        Object expected = Arrays.asList(new BigDecimal("99.997"), new BigDecimal("99.999"));
+
+        JDOQLTypedQuery<DentalInsurance> query = getPM().newJDOQLTypedQuery(DentalInsurance.class);
+        QDentalInsurance cand = QDentalInsurance.candidate();
+        query.filter(cand.employee.ne((Employee)null));
+        query.result(false, cand.lifetimeOrthoBenefit.max());
+        query.groupBy(cand.employee.department);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "MAX(lifetimeOrthoBenefit)",
+                /*INTO*/        null,
+                /*FROM*/        DentalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employee != null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    "employee.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, null, true, expected);
+    }
+
+    /** */
+    public void testAggregateGrouping4() {
+        Object expected = Arrays.asList(new BigDecimal("299.988"), new BigDecimal("199.997"));
+
+        JDOQLTypedQuery<DentalInsurance> query = getPM().newJDOQLTypedQuery(DentalInsurance.class);
+        QDentalInsurance cand = QDentalInsurance.candidate();
+        query.filter(cand.employee.ne((Employee)null));
+        query.result(false, cand.lifetimeOrthoBenefit.sum());
+        query.groupBy(cand.employee.department);
+
+        QueryElementHolder holder = new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "sum(lifetimeOrthoBenefit)",
+                /*INTO*/        null,
+                /*FROM*/        DentalInsurance.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "employee != null",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    "employee.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, null, true, expected);
     }
 
     /**
      * @see JDO_Test#localSetUp()
      */
+    @Override
     protected void localSetUp() {
         addTearDownClass(CompanyModelReader.getTearDownClasses());
         loadAndPersistCompanyModel(getPM());



Mime
View raw message