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 [4/9] - in /db/jdo/trunk: copyjdorijars/ tck/ tck/src/main/java/org/apache/jdo/tck/pc/company/ tck/src/main/java/org/apache/jdo/tck/pc/mylib/ tck/src/main/java/org/apache/jdo/tck/query/ tck/src/main/java/org/apache/jdo/tck/query/de...
Date Sun, 04 Nov 2018 18:37:24 GMT
Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java Sun Nov  4 18:37:24 2018
@@ -18,18 +18,25 @@
 package org.apache.jdo.tck.query.jdoql.methods;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import javax.jdo.JDOHelper;
+import javax.jdo.JDOQLTypedQuery;
 import javax.jdo.PersistenceManager;
 import javax.jdo.Query;
 import javax.jdo.Transaction;
+import javax.jdo.query.Expression;
 
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.pc.company.CompanyModelReader;
 import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.pc.company.QPerson;
+import org.apache.jdo.tck.pc.mylib.QVersionedPCPoint;
 import org.apache.jdo.tck.pc.mylib.VersionedPCPoint;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
@@ -54,16 +61,29 @@ public class SupportedJDOHelperMethods e
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.2-49 (SupportedJDOHelperMethods) 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 = {
-        new QueryElementHolder(
+    public static void main(String[] args) {
+        BatchTestRunner.run(SupportedJDOHelperMethods.class);
+    }
+    
+    /** */
+    public void testGetObjectById1() {
+        Class oidClass = getPM().getObjectIdClass(Person.class);
+        List expectedResult = getExpectedResult(true, Person.class);
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.result(false, cand.jdoObjectId());
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      "JDOHelper.getObjectId(this)", 
-                /*INTO*/        null, 
+                /*RESULT*/      "JDOHelper.getObjectId(this)",
+                /*INTO*/        null,
                 /*FROM*/        Person.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       null,
@@ -73,11 +93,33 @@ public class SupportedJDOHelperMethods e
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expectedResult);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, oidClass, expectedResult);
+    }
+
+    /** */
+    public void testGetObjectById2() {
+        List expectedResult = getExpectedResult(false, Person.class, "personid == 1");
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        Expression<Object> oid = query.parameter("oid", Object.class);
+        query.filter(cand.jdoObjectId().eq(oid));
+
+        // The query above returns a collection of size 1. The collection element is a
+        // pc instance whose oid is the parameter of the query below.
+        Map<String, Object> paramValues = new HashMap<>();
+        paramValues.put("oid", JDOHelper.getObjectId(expectedResult.get(0)));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        Person.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "JDOHelper.getObjectId(this) == oid",
@@ -87,68 +129,13 @@ public class SupportedJDOHelperMethods e
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
-                /*UNIQUE*/      null,
-                /*RESULT*/      "JDOHelper.getVersion(this)", 
-                /*INTO*/        null, 
-                /*FROM*/        VersionedPCPoint.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*/      null, 
-                /*INTO*/        null, 
-                /*FROM*/        VersionedPCPoint.class,
-                /*EXCLUDE*/     null,
-                /*WHERE*/       "JDOHelper.getVersion(this) == ver",
-                /*VARIABLES*/   null,
-                /*PARAMETERS*/  "Long ver",
-                /*IMPORTS*/     null,
-                /*GROUP BY*/    null,
-                /*ORDER BY*/    null,
-                /*FROM*/        null,
-                /*TO*/          null),
-    };
-
-    /**
-     * 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(SupportedJDOHelperMethods.class);
-    }
-    
-    /** */
-    public void testGetObjectById() {
-        // query 1
-        int index = 0;
-        List expectedResult = getExpectedResult(true, Person.class);
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult);
-
-        // query 2
-        index = 1;
-        expectedResult = getExpectedResult(false, Person.class, "personid == 1");
-        // The query above returns a collection of size 1.
-        // The collection element is a pc instances 
-        // whose oid is the parameter of the query below.
-        Object[] parameters = new Object[]{
-                JDOHelper.getObjectId(expectedResult.get(0))};
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                parameters, expectedResult);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                parameters, expectedResult);
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ paramValues);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expectedResult);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult);
     }
 
     /** Test for JDOHelper.getVersion() in queries. */
@@ -160,31 +147,71 @@ public class SupportedJDOHelperMethods e
         pm.currentTransaction().commit();
         Object id = pm.getObjectId(pt1);
 
-        try
-        {
-        	// query 1
-        	int index = 2;
-        	List expectedResult = new ArrayList();
-        	expectedResult.add((long) 1);
-        	executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-        			expectedResult);
-        	executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-        			expectedResult);
+        try {
+            // query 1
+            List expectedResult = Arrays.asList(Long.valueOf(1));
+
+            JDOQLTypedQuery<VersionedPCPoint> query = getPM().newJDOQLTypedQuery(VersionedPCPoint.class);
+            QVersionedPCPoint cand = QVersionedPCPoint.candidate();
+            query.result(false, cand.jdoVersion());
+
+            QueryElementHolder holder = new QueryElementHolder(
+                    /*UNIQUE*/      null,
+                    /*RESULT*/      "JDOHelper.getVersion(this)",
+                    /*INTO*/        null,
+                    /*FROM*/        VersionedPCPoint.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, expectedResult);
+            executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult);
+            //executeJDOQLTypedQuery(ASSERTION_FAILED, holder, Long.class, expectedResult);
 
             // query 2
-            index = 3;
             expectedResult = getExpectedResult(false, VersionedPCPoint.class, "x == 1");
-            Object[] parameters = new Object[]{new Long(1)};
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                    parameters, expectedResult);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                    parameters, expectedResult);
-        }
-        finally
-        {
-        	pm.currentTransaction().begin();
-        	pm.deletePersistent(pm.getObjectById(id));
-        	pm.currentTransaction().commit();
+
+            query = getPM().newJDOQLTypedQuery(VersionedPCPoint.class);
+            cand = QVersionedPCPoint.candidate();
+            Expression<Object> ver = query.parameter("ver", Object.class);
+            query.filter(cand.jdoVersion().eq(ver));
+
+            Map<String, Object> paramValues = new HashMap<>();
+            paramValues.put("ver", Long.valueOf(1));
+
+            holder = new QueryElementHolder(
+                    /*UNIQUE*/      null,
+                    /*RESULT*/      null,
+                    /*INTO*/        null,
+                    /*FROM*/        VersionedPCPoint.class,
+                    /*EXCLUDE*/     null,
+                    /*WHERE*/       "JDOHelper.getVersion(this) == ver",
+                    /*VARIABLES*/   null,
+                    /*PARAMETERS*/  "Long ver",
+                    /*IMPORTS*/     null,
+                    /*GROUP BY*/    null,
+                    /*ORDER BY*/    null,
+                    /*FROM*/        null,
+                    /*TO*/          null,
+                    /*JDOQLTyped*/  query,
+                    /*paramValues*/ paramValues);
+
+            executeAPIQuery(ASSERTION_FAILED, holder, expectedResult);
+            executeSingleStringQuery(ASSERTION_FAILED, holder, expectedResult);
+            executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expectedResult);
+
+        } finally {
+            pm.currentTransaction().begin();
+            pm.deletePersistent(pm.getObjectById(id));
+            pm.currentTransaction().commit();
         }
     }
     

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedListMethods.java Sun Nov  4 18:37:24 2018
@@ -17,18 +17,22 @@
 
 package org.apache.jdo.tck.query.jdoql.methods;
 
-import javax.jdo.PersistenceManager;
-import javax.jdo.Query;
-import javax.jdo.Transaction;
+import javax.jdo.JDOQLTypedQuery;
+import javax.jdo.query.Expression;
+import javax.jdo.query.NumericExpression;
 
 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.MeetingRoom;
+import org.apache.jdo.tck.pc.company.QDepartment;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  *<B>Title:</B>Supported list methods
  *<BR>
@@ -48,14 +52,34 @@ public class SupportedListMethods extend
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.2-58 (SupportedListMethods) 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(SupportedListMethods.class);
+    }
+
+    /** */
+    public void testGetInFilter() {
         // get(PARAMETER) in filter
-        new QueryElementHolder(
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"dept1"});
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        Expression<MeetingRoom> roomParam = query.parameter("room1", MeetingRoom.class);
+        NumericExpression<?> posParam = query.numericParameter("pos");
+        query.filter(cand.meetingRooms.get(posParam).eq(roomParam));
+
+        getPM().currentTransaction().begin();
+        Map<String, Object> paramValues = new HashMap<>();
+        paramValues.put("pos", Integer.valueOf(1));
+        paramValues.put("room1", getPersistentCompanyModelInstance("room2"));
+        getPM().currentTransaction().commit();
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
                 /*RESULT*/      null,
                 /*INTO*/        null,
@@ -68,9 +92,26 @@ public class SupportedListMethods extend
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ paramValues);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testGetInResult() {
         // get(LITERAL) in result
-        new QueryElementHolder(
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"room2"});
+
+        JDOQLTypedQuery<Department> query = getPM().newJDOQLTypedQuery(Department.class);
+        QDepartment cand = QDepartment.candidate();
+        query.result(false, cand.meetingRooms.get(1));
+        query.filter(cand.deptid.eq(1L));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
                 /*RESULT*/      "meetingRooms.get(1)",
                 /*INTO*/        null,
@@ -83,47 +124,13 @@ public class SupportedListMethods extend
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null)
-    };
-
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        // get(PARAMETER) in filter
-        getTransientCompanyModelInstancesAsList(new String[]{"dept1"}),
-        // get(LITERAL) in result
-        getTransientCompanyModelInstancesAsList(new String[]{"room2"})
-    };
-
-    /**
-     * 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(SupportedListMethods.class);
-    }
-
-    /** */
-    public void testGetInFilter() {
-        int index = 0;
-        getPM().currentTransaction().begin();
-        Object[] parameters = new Object[]{1, getPersistentCompanyModelInstance("room2")};
-        getPM().currentTransaction().commit(); 
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                parameters, expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                parameters, expectedResult[index]);
-    }
-
-    /** */
-    public void testGetInResult() {
-        int index = 1;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, MeetingRoom.class, expected);
     }
 
     /**

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java Sun Nov  4 18:37:24 2018
@@ -22,10 +22,13 @@ import java.util.ArrayList;
 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> Supported Map methods.
  *<BR>
@@ -48,17 +51,28 @@ public class SupportedMapMethods extends
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.2-46 (SupportedMapMethods) 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 = {
-        // get
-        new QueryElementHolder(
+    public static void main(String[] args) {
+        BatchTestRunner.run(SupportedMapMethods.class);
+    }
+    
+    /** */
+    public void testGet() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.filter(cand.phoneNumbers.get("home").eq("1111"));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        Person.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "phoneNumbers.get('home') == '1111'",
@@ -68,12 +82,28 @@ public class SupportedMapMethods extends
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        // containsKey
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+    
+    /** */
+    public void testContainsKey() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.filter(cand.phoneNumbers.containsKey("home"));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        Person.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "phoneNumbers.containsKey('home')",
@@ -83,12 +113,27 @@ public class SupportedMapMethods extends
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        // containsValue
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testContainsValue() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.filter(cand.phoneNumbers.containsValue("1111"));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        Person.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "phoneNumbers.containsValue('1111')",
@@ -98,12 +143,27 @@ public class SupportedMapMethods extends
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        // isEmpty
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testIsEmpty() {
+        Object expected = new ArrayList();
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.filter(cand.phoneNumbers.isEmpty());
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        Person.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "phoneNumbers.isEmpty()",
@@ -113,12 +173,28 @@ public class SupportedMapMethods extends
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        // size
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testSize() {
+        Object expected = getTransientCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"});
+
+        JDOQLTypedQuery<Person> query = getPM().newJDOQLTypedQuery(Person.class);
+        QPerson cand = QPerson.candidate();
+        query.filter(cand.phoneNumbers.size().eq(2));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        Person.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "phoneNumbers.size() == 2",
@@ -128,79 +204,13 @@ public class SupportedMapMethods extends
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null)
-    };
-
-    /** 
-     * The expected results of valid queries.
-     */
-    private Object[] expectedResult = {
-        // get
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1"}),
-        // containsKey
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp2", "emp3", "emp4", "emp5"}),
-        // containsValue
-        getTransientCompanyModelInstancesAsList(new String[]{"emp1"}),
-        // isEmpty
-        new ArrayList(),
-        // size
-        getTransientCompanyModelInstancesAsList(new String[]{
-                "emp1", "emp2", "emp3", "emp4", "emp5"})
-    };
-            
-    /**
-     * 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(SupportedMapMethods.class);
-    }
-    
-    /** */
-    public void testGet() {
-        int index = 0;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-    
-    /** */
-    public void testContainsKey() {
-        int index = 1;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
-    /** */
-    public void testContainsValue() {
-        int index = 2;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
-    /** */
-    public void testIsEmpty() {
-        int index = 3;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-    }
-
-    /** */
-    public void testSize() {
-        int index = 4;
-        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
-        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
-                expectedResult[index]);
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /**

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java Sun Nov  4 18:37:24 2018
@@ -21,6 +21,7 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import javax.jdo.JDOQLTypedQuery;
 import javax.jdo.PersistenceManager;
 import javax.jdo.Query;
 import javax.jdo.Transaction;
@@ -28,6 +29,7 @@ import javax.jdo.Transaction;
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.pc.mylib.MylibReader;
 import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.pc.mylib.QPrimitiveTypes;
 import org.apache.jdo.tck.pc.query.MathSample;
 import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
@@ -58,17 +60,38 @@ public class SupportedMathMethods extend
     /** */
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.2-48 (SupportedMathMethods) failed: ";
-    
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     * These queries are used to test Math.abs.
+
+    /** */
+    private Object oidOfMath1;
+
+    /** */
+    private Object oidOfMath2;
+
+    /** */
+    private Object oidOfMath3;
+     
+    /**
+     * 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_ABS = {
-        new QueryElementHolder(
+    public static void main(String[] args) {
+        BatchTestRunner.run(SupportedMathMethods.class);
+    }
+
+    /** */
+    public void testAbs0() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", "primitiveTypesNegative"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.intNotNull.abs().eq(4));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "Math.abs(intNotNull) == 4",
@@ -78,11 +101,28 @@ public class SupportedMathMethods extend
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAbs1() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", "primitiveTypesNegative"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.intNull.abs().eq(4));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "Math.abs(intNull) == 4",
@@ -92,11 +132,28 @@ public class SupportedMathMethods extend
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAbs2() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", "primitiveTypesNegative"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.longNotNull.abs().eq(4L));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "Math.abs(longNotNull) == 4",
@@ -106,11 +163,28 @@ public class SupportedMathMethods extend
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAbs3() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", "primitiveTypesNegative"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.longNull.abs().eq(4L));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "Math.abs(longNull) == 4",
@@ -120,219 +194,277 @@ public class SupportedMathMethods extend
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAbs4() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", "primitiveTypesNegative"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.floatNotNull.abs().lt(4.1f).
+                and(cand.floatNotNull.abs().gt(3.9f)));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "Math.abs(floatNotNull) < 4.1 &&" +
-                                "Math.abs(floatNotNull) > 3.9",
+                "Math.abs(floatNotNull) > 3.9",
                 /*VARIABLES*/   null,
                 /*PARAMETERS*/  null,
                 /*IMPORTS*/     null,
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAbs5() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", "primitiveTypesNegative"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.floatNull.abs().lt(4.1f).
+                and(cand.floatNull.abs().gt(3.9f)));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "Math.abs(floatNull) < 4.1 &&" +
-                                "Math.abs(floatNull) > 3.9",
+                "Math.abs(floatNull) > 3.9",
                 /*VARIABLES*/   null,
                 /*PARAMETERS*/  null,
                 /*IMPORTS*/     null,
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAbs6() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", "primitiveTypesNegative"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.doubleNotNull.abs().lt(4.1).
+                and(cand.doubleNotNull.abs().gt(3.9)));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "Math.abs(doubleNotNull) < 4.1 &&" +
-                                "Math.abs(doubleNotNull) > 3.9",
+                "Math.abs(doubleNotNull) > 3.9",
                 /*VARIABLES*/   null,
                 /*PARAMETERS*/  null,
                 /*IMPORTS*/     null,
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testAbs7() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", "primitiveTypesNegative"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.doubleNull.abs().lt(4.1).
+                and(cand.doubleNull.abs().gt(3.9)));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "Math.abs(doubleNull) < 4.1 &&" +
-                                "Math.abs(doubleNull) > 3.9",
+                "Math.abs(doubleNull) > 3.9",
                 /*VARIABLES*/   null,
                 /*PARAMETERS*/  null,
                 /*IMPORTS*/     null,
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null)
-    };
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
 
-    /** 
-     * The array of valid queries which may be executed as 
-     * single string queries and as API queries.
-     * These queries are used to test Math.sqrt.
-     */
-    private static final QueryElementHolder[] VALID_QUERIES_SQRT = {
-        new QueryElementHolder(
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testSqrt0() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{"primitiveTypesPositive"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.doubleNotNull.gt(0d).and(cand.doubleNotNull.sqrt().lt(2.1).
+                and(cand.doubleNotNull.sqrt().gt(1.9))));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "doubleNotNull > 0 && " +
-                                "Math.sqrt(doubleNotNull) < 2.1 && " +
-                                "Math.sqrt(doubleNotNull) > 1.9",
+                "Math.sqrt(doubleNotNull) < 2.1 && " +
+                "Math.sqrt(doubleNotNull) > 1.9",
                 /*VARIABLES*/   null,
                 /*PARAMETERS*/  null,
                 /*IMPORTS*/     null,
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testSqrt1() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{"primitiveTypesPositive"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.doubleNull.gt(0d).and(cand.doubleNull.sqrt().lt(2.1).
+                and(cand.doubleNull.sqrt().gt(1.9))));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "doubleNull > 0 && " +
-                                "Math.sqrt(doubleNull) < 2.1 && " +
-                                "Math.sqrt(doubleNull) > 1.9",
+                "Math.sqrt(doubleNull) < 2.1 && " +
+                "Math.sqrt(doubleNull) > 1.9",
                 /*VARIABLES*/   null,
                 /*PARAMETERS*/  null,
                 /*IMPORTS*/     null,
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testSqrt2() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{"primitiveTypesPositive"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.intNotNull.gt(0).and(cand.intNotNull.sqrt().lt(2.1).
+                and(cand.intNotNull.sqrt().gt(1.9))));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "intNotNull > 0 && " +
-                                "Math.sqrt(intNotNull) < 2.1 && " +
-                                "Math.sqrt(intNotNull) > 1.9",
+                "Math.sqrt(intNotNull) < 2.1 && " +
+                "Math.sqrt(intNotNull) > 1.9",
                 /*VARIABLES*/   null,
                 /*PARAMETERS*/  null,
                 /*IMPORTS*/     null,
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-        new QueryElementHolder(
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
+
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
+    }
+
+    /** */
+    public void testSqrt3() {
+        Object expected = getTransientMylibInstancesAsList(new String[]{"primitiveTypesPositive"});
+
+        JDOQLTypedQuery<PrimitiveTypes> query = getPM().newJDOQLTypedQuery(PrimitiveTypes.class);
+        QPrimitiveTypes cand = QPrimitiveTypes.candidate();
+        query.filter(cand.intNull.gt(0).and(cand.intNull.sqrt().lt(2.1).
+                and(cand.intNull.sqrt().gt(1.9))));
+
+        QueryElementHolder holder = new QueryElementHolder(
                 /*UNIQUE*/      null,
-                /*RESULT*/      null, 
-                /*INTO*/        null, 
+                /*RESULT*/      null,
+                /*INTO*/        null,
                 /*FROM*/        PrimitiveTypes.class,
                 /*EXCLUDE*/     null,
                 /*WHERE*/       "intNull > 0 && " +
-                                "Math.sqrt(intNull) < 2.1 && " +
-                                "Math.sqrt(intNull) > 1.9",
+                "Math.sqrt(intNull) < 2.1 && " +
+                "Math.sqrt(intNull) > 1.9",
                 /*VARIABLES*/   null,
                 /*PARAMETERS*/  null,
                 /*IMPORTS*/     null,
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null),
-    };
-
-    /** */
-    private Object oidOfMath1;
-
-    /** */
-    private Object oidOfMath2;
+                /*TO*/          null,
+                /*JDOQLTyped*/  query,
+                /*paramValues*/ null);
 
-    /** */
-    private Object oidOfMath3;
-
-    /** 
-     * The expected results of valid queries testing Math.abs.
-     */
-    private Object[] expectedResultABS = {
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive", "primitiveTypesNegative"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive", "primitiveTypesNegative"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive", "primitiveTypesNegative"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive", "primitiveTypesNegative"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive", "primitiveTypesNegative"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive", "primitiveTypesNegative"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive", "primitiveTypesNegative"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive", "primitiveTypesNegative"})
-    };
-        
-    /** The expected results of valid queries testing Math.sqrt. */
-    private Object[] expectedResultSQRT = {
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive"}),
-            getTransientMylibInstancesAsList(new String[]{
-                    "primitiveTypesPositive"})
-    };
-            
-    /**
-     * 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(SupportedMathMethods.class);
-    }
-
-    /** */
-    public void testAbs() {
-        for (int i = 0; i < VALID_QUERIES_ABS.length; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES_ABS[i], 
-                    expectedResultABS[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES_ABS[i], 
-                    expectedResultABS[i]);
-        }
-    }
-
-    /** */
-    public void testSqrt() {
-        for (int i = 0; i < VALID_QUERIES_SQRT.length; i++) {
-            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES_SQRT[i], 
-                    expectedResultSQRT[i]);
-            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES_SQRT[i], 
-                    expectedResultSQRT[i]);
-        }
+        executeAPIQuery(ASSERTION_FAILED, holder, expected);
+        executeSingleStringQuery(ASSERTION_FAILED, holder, expected);
+        executeJDOQLTypedQuery(ASSERTION_FAILED, holder, expected);
     }
 
     /** 

Modified: db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedOptionalMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedOptionalMethods.java?rev=1845744&r1=1845743&r2=1845744&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedOptionalMethods.java (original)
+++ db/jdo/trunk/tck/src/main/java/org/apache/jdo/tck/query/jdoql/methods/SupportedOptionalMethods.java Sun Nov  4 18:37:24 2018
@@ -20,6 +20,8 @@ package org.apache.jdo.tck.query.jdoql.m
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Optional;
 
 import javax.jdo.PersistenceManager;
@@ -156,7 +158,9 @@ public class SupportedOptionalMethods ex
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null);
+                /*TO*/          null,
+                /*JDOQLTyped*/  null,
+                /*paramValues*/ null);
 
         ArrayList<Object> expectedResults = new ArrayList<>();
         Transaction tx = pm.currentTransaction();
@@ -181,18 +185,23 @@ public class SupportedOptionalMethods ex
     public void testParameterOptional() {
         OptionalSample osReferencedPC1 = getOptionalSampleById(oidReferencedPC1);
         String paramDecl = "java.util.Optional op";
+        Map<String, Object> paramValues = new HashMap<>();
+
+        paramValues.put("op", Optional.of(osReferencedPC1));
         checkQuery("this.optionalPC == op", paramDecl, 
-                new Object[]{Optional.of(osReferencedPC1)}, 
-                new Object[]{oidPC});
-        checkQuery("this.optionalDate == op", paramDecl,  
-                new Object[]{Optional.of(DATE)}, 
-                new Object[]{oidPC});
-        checkQuery("this.optionalInteger == op", paramDecl,  
-                new Object[]{Optional.of(INTEGER)}, 
-                new Object[]{oidPC});
-        checkQuery("this.optionalString == op", paramDecl,  
-                new Object[]{Optional.of(STRING)}, 
-                new Object[]{oidPC});
+                paramValues, new Object[]{oidPC});
+
+        paramValues.put("op", Optional.of(DATE));
+        checkQuery("this.optionalDate == op", paramDecl,
+                paramValues, new Object[]{oidPC});
+
+        paramValues.put("op", Optional.of(INTEGER));
+        checkQuery("this.optionalInteger == op", paramDecl,
+                paramValues, new Object[]{oidPC});
+
+        paramValues.put("op", Optional.of(STRING));
+        checkQuery("this.optionalString == op", paramDecl,
+                paramValues, new Object[]{oidPC});
     }
 
     /**
@@ -201,18 +210,27 @@ public class SupportedOptionalMethods ex
      */
     public void testParameterOptionalAutoDeref() {
         OptionalSample osReferencedPC1 = getOptionalSampleById(oidReferencedPC1);
-        checkQuery("this.optionalPC == op", 
+        Map<String, Object> paramValues = new HashMap<>();
+
+        paramValues.put("op", osReferencedPC1);
+        checkQuery("this.optionalPC == op",
                 OptionalSample.class.getName() + " op", 
-                new Object[]{osReferencedPC1}, new Object[]{oidPC});
-        checkQuery("this.optionalDate == op", 
+                paramValues, new Object[]{oidPC});
+
+        paramValues.put("op", DATE);
+        checkQuery("this.optionalDate == op",
                 "java.util.Date op",  
-                new Object[]{DATE}, new Object[]{oidPC});
-        checkQuery("this.optionalInteger == op", 
-                "Integer op",  
-                new Object[]{INTEGER}, new Object[]{oidPC});
-        checkQuery("this.optionalString == op", 
+                paramValues, new Object[]{oidPC});
+
+        paramValues.put("op", INTEGER);
+        checkQuery("this.optionalInteger == op",
+                "Integer op",
+                paramValues, new Object[]{oidPC});
+
+        paramValues.put("op", STRING);
+        checkQuery("this.optionalString == op",
                 "String op",  
-                new Object[]{STRING}, new Object[]{oidPC});
+                paramValues, new Object[]{oidPC});
     }
 
     private OptionalSample getOptionalSampleById(Object id) {
@@ -233,14 +251,15 @@ public class SupportedOptionalMethods ex
      */
     public void testParameterOptionalWithEmptyFields() {
         String paramDecl = "java.util.Optional op";
-        Object[] params = new Object[]{Optional.empty()}; 
-        checkQuery("this.optionalPC == op", paramDecl, params, 
+        Map<String, Object> paramValues = new HashMap<>();
+        paramValues.put("op", Optional.empty());
+        checkQuery("this.optionalPC == op", paramDecl, paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC2});
-        checkQuery("this.optionalDate == op", paramDecl, params, 
+        checkQuery("this.optionalDate == op", paramDecl, paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
-        checkQuery("this.optionalInteger == op", paramDecl, params, 
+        checkQuery("this.optionalInteger == op", paramDecl, paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
-        checkQuery("this.optionalString == op", paramDecl, params, 
+        checkQuery("this.optionalString == op", paramDecl, paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
     }
 
@@ -250,14 +269,15 @@ public class SupportedOptionalMethods ex
      */
     public void testParameterOptionalWithNull() {
         String paramDecl = "java.util.Optional op";
-        Object[] params = new Object[]{null}; 
-        checkQuery("this.optionalPC == op", paramDecl, params, 
+        Map<String, Object> paramValues = new HashMap<>();
+        paramValues.put("op", null);
+        checkQuery("this.optionalPC == op", paramDecl, paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC2});
-        checkQuery("this.optionalDate == op", paramDecl, params, 
+        checkQuery("this.optionalDate == op", paramDecl, paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
-        checkQuery("this.optionalInteger == op", paramDecl, params, 
+        checkQuery("this.optionalInteger == op", paramDecl, paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
-        checkQuery("this.optionalString == op", paramDecl, params, 
+        checkQuery("this.optionalString == op", paramDecl, paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
     }
 
@@ -266,14 +286,15 @@ public class SupportedOptionalMethods ex
      * (Object)null.
      */
     public void testParameterOptionalNull() {
-        Object[] params = new Object[]{null}; 
-        checkQuery("this.optionalPC == op", OptionalSample.class.getName() + " op", params, 
+        Map<String, Object> paramValues = new HashMap<>();
+        paramValues.put("op", null);
+        checkQuery("this.optionalPC == op", OptionalSample.class.getName() + " op", paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC2});
-        checkQuery("this.optionalDate == op", "java.util.Date op", params, 
+        checkQuery("this.optionalDate == op", "java.util.Date op", paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
-        checkQuery("this.optionalInteger == op", "java.lang.Integer op", params, 
+        checkQuery("this.optionalInteger == op", "java.lang.Integer op", paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
-        checkQuery("this.optionalString == op", "java.lang.String op", params, 
+        checkQuery("this.optionalString == op", "java.lang.String op", paramValues,
                 new Object[]{oidEmpty, oidNull, oidReferencedPC1, oidReferencedPC2});
 
     }
@@ -352,7 +373,7 @@ public class SupportedOptionalMethods ex
                             false, null, expectedResults, true);
     }
 
-    private void checkQuery(String filter, String paramDecl, Object[] params, Object[] result) {
+    private void checkQuery(String filter, String paramDecl, Map<String, ?> paramValues, Object[] result) {
         QueryElementHolder qeh = new QueryElementHolder(
                 /*UNIQUE*/      null,
                 /*RESULT*/      null, 
@@ -366,7 +387,9 @@ public class SupportedOptionalMethods ex
                 /*GROUP BY*/    null,
                 /*ORDER BY*/    null,
                 /*FROM*/        null,
-                /*TO*/          null);
+                /*TO*/          null,
+                /*JDOQLTyped*/   null,
+                /*paramValues*/  paramValues);
 
         ArrayList<Object> expectedResults = new ArrayList<>();
         PersistenceManager pm  = getPM();
@@ -387,8 +410,8 @@ public class SupportedOptionalMethods ex
             }
         }
 
-        executeAPIQuery(ASSERTION_FAILED, qeh, params, expectedResults);
-        executeSingleStringQuery(ASSERTION_FAILED, qeh, params, expectedResults);
+        executeAPIQuery(ASSERTION_FAILED, qeh, expectedResults);
+        executeSingleStringQuery(ASSERTION_FAILED, qeh, expectedResults);
     }
 
 



Mime
View raw message