You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2025/01/27 15:51:56 UTC
(db-jdo) branch JDO-849 updated: JDO-849: formatting changes
This is an automated email from the ASF dual-hosted git repository.
mbo pushed a commit to branch JDO-849
in repository https://gitbox.apache.org/repos/asf/db-jdo.git
The following commit(s) were added to refs/heads/JDO-849 by this push:
new faea154d JDO-849: formatting changes
faea154d is described below
commit faea154d72efa85cfd35b46ad49f9284b36d837e
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Mon Jan 27 16:47:43 2025 +0100
JDO-849: formatting changes
---
.../jdo/tck/query/api/SampleReadQueries.java | 25 +-
.../tck/query/jdoql/variables/StringVariables.java | 600 +++++++++++----------
2 files changed, 314 insertions(+), 311 deletions(-)
diff --git a/tck/src/main/java/org/apache/jdo/tck/query/api/SampleReadQueries.java b/tck/src/main/java/org/apache/jdo/tck/query/api/SampleReadQueries.java
index 67975dd3..a533a415 100644
--- a/tck/src/main/java/org/apache/jdo/tck/query/api/SampleReadQueries.java
+++ b/tck/src/main/java/org/apache/jdo/tck/query/api/SampleReadQueries.java
@@ -27,7 +27,6 @@ import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import javax.jdo.query.CollectionExpression;
-import javax.jdo.query.Expression;
import javax.jdo.query.NumericExpression;
import javax.jdo.query.StringExpression;
import org.apache.jdo.tck.pc.company.CompanyModelReader;
@@ -99,9 +98,9 @@ public class SampleReadQueries extends QueryTest {
"select from org.apache.jdo.tck.pc.company.Department where :depts.contains(name)";
private static final String SINGLE_STRING_QUERY_07 =
- "select from org.apache.jdo.tck.pc.company.FullTimeEmployee "
- + "where languages.contains(:lang)";
-
+ "select from org.apache.jdo.tck.pc.company.FullTimeEmployee "
+ + "where languages.contains(:lang)";
+
private static final String SINGLE_STRING_QUERY_08 =
"select firstname from org.apache.jdo.tck.pc.company.Employee where department.name == :deptName";
@@ -154,7 +153,7 @@ public class SampleReadQueries extends QueryTest {
"select firstname from org.apache.jdo.tck.pc.company.Employee "
+ "where this.weeklyhours > "
+ " (select AVG(e.weeklyhours) from this.department.employees e where e.manager == this.manager)";
-
+
/**
* Basic query.
*
@@ -1094,9 +1093,9 @@ public class SampleReadQueries extends QueryTest {
try {
tx.begin();
List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
try (Query<FullTimeEmployee> q =
- pm.newQuery(FullTimeEmployee.class, "languages.contains(:lang)")) {
+ pm.newQuery(FullTimeEmployee.class, "languages.contains(:lang)")) {
List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute("German");
checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, emps, expected);
} catch (Exception ex) {
@@ -1122,9 +1121,9 @@ public class SampleReadQueries extends QueryTest {
try {
tx.begin();
List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
try (Query<FullTimeEmployee> q =
- pm.newQuery(FullTimeEmployee.class, "languages.contains(:lang)")) {
+ pm.newQuery(FullTimeEmployee.class, "languages.contains(:lang)")) {
Map<String, Object> paramValues = new HashMap<>();
paramValues.put("lang", "German");
q.setNamedParameters(paramValues);
@@ -1153,9 +1152,9 @@ public class SampleReadQueries extends QueryTest {
try {
tx.begin();
List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
try (Query<FullTimeEmployee> q =
- pm.newQuery(FullTimeEmployee.class, "languages.contains(:lang)")) {
+ pm.newQuery(FullTimeEmployee.class, "languages.contains(:lang)")) {
q.setParameters("German");
List<FullTimeEmployee> emps = q.executeList();
checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, emps, expected);
@@ -1183,7 +1182,7 @@ public class SampleReadQueries extends QueryTest {
try {
tx.begin();
List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
try (Query<FullTimeEmployee> q = pm.newQuery(SINGLE_STRING_QUERY_07)) {
List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute("German");
checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_07, emps, expected);
@@ -1211,7 +1210,7 @@ public class SampleReadQueries extends QueryTest {
try {
tx.begin();
List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
try (JDOQLTypedQuery<FullTimeEmployee> q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) {
QFullTimeEmployee cand = QFullTimeEmployee.candidate("this");
StringExpression lang = q.stringParameter("lang");
diff --git a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/StringVariables.java b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/StringVariables.java
index 87ecb032..be48e185 100644
--- a/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/StringVariables.java
+++ b/tck/src/main/java/org/apache/jdo/tck/query/jdoql/variables/StringVariables.java
@@ -17,6 +17,12 @@
package org.apache.jdo.tck.query.jdoql.variables;
+import java.util.List;
+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.pc.company.CompanyModelReader;
import org.apache.jdo.tck.pc.company.FullTimeEmployee;
import org.apache.jdo.tck.pc.company.QFullTimeEmployee;
@@ -28,336 +34,334 @@ import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;
-import javax.jdo.JDOQLTypedQuery;
-import javax.jdo.PersistenceManager;
-import javax.jdo.Query;
-import javax.jdo.Transaction;
-import javax.jdo.query.Expression;
-import java.util.List;
-
/**
* <B>Title:</B> Variables of type String. <br>
* <B>Keywords:</B> query <br>
* <B>Assertion ID:</B> A14.6.2-2<br>
- * <B>Assertion Description: An element of the candidate collection is returned in the result if: ...
- * for all variables there exists a value for which the filter expression evaluates to true.</B>
+ * <B>Assertion Description: An element of the candidate collection is returned in the result if:
+ * ... for all variables there exists a value for which the filter expression evaluates to true.</B>
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class StringVariables extends QueryTest {
- /** */
- private static final String ASSERTION_FAILED = "Assertion A14.6.2-2 (StringVariables) failed: ";
-
- /** */
- private static final String SAMPLE_QUERIES_TEST_COMPANY_TESTDATA =
- "org/apache/jdo/tck/pc/company/companyForSampleQueriesTest.xml";
+ /** */
+ private static final String ASSERTION_FAILED = "Assertion A14.6.2-2 (StringVariables) failed: ";
- private static final String COLLECTION_STRING_VARIABLE_SSQ =
- "select from org.apache.jdo.tck.pc.company.FullTimeEmployee "
- + "where languages.contains(lang) && lang == 'German' variables String lang";
+ /** */
+ private static final String SAMPLE_QUERIES_TEST_COMPANY_TESTDATA =
+ "org/apache/jdo/tck/pc/company/companyForSampleQueriesTest.xml";
- private static final String MAP_KEY_STRING_VARIABLE_SSQ =
- "select from org.apache.jdo.tck.pc.company.FullTimeEmployee "
- + "where phoneNumbers.containsKey(key) && key == 'home' variables String key";
+ private static final String COLLECTION_STRING_VARIABLE_SSQ =
+ "select from org.apache.jdo.tck.pc.company.FullTimeEmployee "
+ + "where languages.contains(lang) && lang == 'German' variables String lang";
- private static final String MAP_VALUE_STRING_VARIABLE_SSQ =
- "select from org.apache.jdo.tck.pc.company.FullTimeEmployee "
- + "where phoneNumbers.containsValue(value) && value == '1111' variables String value";
+ private static final String MAP_KEY_STRING_VARIABLE_SSQ =
+ "select from org.apache.jdo.tck.pc.company.FullTimeEmployee "
+ + "where phoneNumbers.containsKey(key) && key == 'home' variables String key";
+ private static final String MAP_VALUE_STRING_VARIABLE_SSQ =
+ "select from org.apache.jdo.tck.pc.company.FullTimeEmployee "
+ + "where phoneNumbers.containsValue(value) && value == '1111' variables String value";
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection speaking
- * German (i.e. the language set includes the string "German").
- */
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void collectionStringVariable() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
- try (Query<FullTimeEmployee> q =
- pm.newQuery(FullTimeEmployee.class, "languages.contains(lang) && lang == 'German'")) {
- q.declareVariables("String lang");
- List<FullTimeEmployee> emps = q.executeList();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, COLLECTION_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection speaking
+ * German (i.e. the language set includes the string "German").
+ */
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void collectionStringVariable() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
+ try (Query<FullTimeEmployee> q =
+ pm.newQuery(FullTimeEmployee.class, "languages.contains(lang) && lang == 'German'")) {
+ q.declareVariables("String lang");
+ List<FullTimeEmployee> emps = q.executeList();
+ checkQueryResultWithoutOrder(
+ ASSERTION_FAILED, COLLECTION_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection speaking
- * German (i.e. the language set includes the string "German").
- */
- @SuppressWarnings("unchecked")
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void collectionStringVariableSSQ() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
- try (Query<FullTimeEmployee> q = pm.newQuery(COLLECTION_STRING_VARIABLE_SSQ)) {
- List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, COLLECTION_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection speaking
+ * German (i.e. the language set includes the string "German").
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void collectionStringVariableSSQ() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
+ try (Query<FullTimeEmployee> q = pm.newQuery(COLLECTION_STRING_VARIABLE_SSQ)) {
+ List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(
+ ASSERTION_FAILED, COLLECTION_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection speaking
- * German (i.e. the language set includes the string "German").
- */
- @SuppressWarnings("unchecked")
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void collectionStringVariableTypedQuery() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
- try (JDOQLTypedQuery<FullTimeEmployee> q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) {
- QFullTimeEmployee cand = QFullTimeEmployee.candidate("this");
- Expression<String> lang = q.variable("lang", String.class);
- q.filter(cand.languages.contains(lang).and(lang.eq("German")));
- List<FullTimeEmployee> emps = q.executeList();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, COLLECTION_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection speaking
+ * German (i.e. the language set includes the string "German").
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void collectionStringVariableTypedQuery() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp5");
+ try (JDOQLTypedQuery<FullTimeEmployee> q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) {
+ QFullTimeEmployee cand = QFullTimeEmployee.candidate("this");
+ Expression<String> lang = q.variable("lang", String.class);
+ q.filter(cand.languages.contains(lang).and(lang.eq("German")));
+ List<FullTimeEmployee> emps = q.executeList();
+ checkQueryResultWithoutOrder(
+ ASSERTION_FAILED, COLLECTION_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
- * home phone number (i.e. the phoneNumbers map includes an entry with key "home").
- */
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void mapKeyStringVariable() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp2", "emp5");
- try (Query<FullTimeEmployee> q =
- pm.newQuery(FullTimeEmployee.class, "phoneNumbers.containsKey(key) && key == 'home'")) {
- q.declareVariables("String key");
- List<FullTimeEmployee> emps = q.executeList();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_KEY_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
+ * home phone number (i.e. the phoneNumbers map includes an entry with key "home").
+ */
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void mapKeyStringVariable() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp2", "emp5");
+ try (Query<FullTimeEmployee> q =
+ pm.newQuery(FullTimeEmployee.class, "phoneNumbers.containsKey(key) && key == 'home'")) {
+ q.declareVariables("String key");
+ List<FullTimeEmployee> emps = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_KEY_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
- * home phone number (i.e. the phoneNumbers map includes an entry with key "home").
- */
- @SuppressWarnings("unchecked")
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void mapKeyStringVariableSSQ() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp2", "emp5");
- try (Query<FullTimeEmployee> q = pm.newQuery(MAP_KEY_STRING_VARIABLE_SSQ)) {
- List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_KEY_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
+ * home phone number (i.e. the phoneNumbers map includes an entry with key "home").
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void mapKeyStringVariableSSQ() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp2", "emp5");
+ try (Query<FullTimeEmployee> q = pm.newQuery(MAP_KEY_STRING_VARIABLE_SSQ)) {
+ List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_KEY_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
- * home phone number (i.e. the phoneNumbers map includes an entry with key "home").
- */
- @SuppressWarnings("unchecked")
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void mapKeyStringVariableTypedQuery() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp2", "emp5");
- try (JDOQLTypedQuery<FullTimeEmployee> q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) {
- QFullTimeEmployee cand = QFullTimeEmployee.candidate("this");
- Expression<String> key = q.variable("key", String.class);
- q.filter(cand.phoneNumbers.containsKey(key).and(key.eq("home")));
- List<FullTimeEmployee> emps = q.executeList();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_KEY_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
+ * home phone number (i.e. the phoneNumbers map includes an entry with key "home").
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void mapKeyStringVariableTypedQuery() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1", "emp2", "emp5");
+ try (JDOQLTypedQuery<FullTimeEmployee> q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) {
+ QFullTimeEmployee cand = QFullTimeEmployee.candidate("this");
+ Expression<String> key = q.variable("key", String.class);
+ q.filter(cand.phoneNumbers.containsKey(key).and(key.eq("home")));
+ List<FullTimeEmployee> emps = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_KEY_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
- * phone number "1111" (i.e. the phoneNumbers map includes an entry with value "1111").
- */
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void mapValueStringVariable() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1");
- try (Query<FullTimeEmployee> q =
- pm.newQuery(
- FullTimeEmployee.class, "phoneNumbers.containsValue(value) && value == '1111'")) {
- q.declareVariables("String value");
- List<FullTimeEmployee> emps = q.executeList();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_VALUE_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
+ * phone number "1111" (i.e. the phoneNumbers map includes an entry with value "1111").
+ */
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void mapValueStringVariable() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1");
+ try (Query<FullTimeEmployee> q =
+ pm.newQuery(
+ FullTimeEmployee.class, "phoneNumbers.containsValue(value) && value == '1111'")) {
+ q.declareVariables("String value");
+ List<FullTimeEmployee> emps = q.executeList();
+ checkQueryResultWithoutOrder(
+ ASSERTION_FAILED, MAP_VALUE_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
- * phone number "1111" (i.e. the phoneNumbers map includes an entry with value "1111").
- */
- @SuppressWarnings("unchecked")
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void mapValueStringVariableSSQ() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1");
- try (Query<FullTimeEmployee> q = pm.newQuery(MAP_VALUE_STRING_VARIABLE_SSQ)) {
- List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_VALUE_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
+ * phone number "1111" (i.e. the phoneNumbers map includes an entry with value "1111").
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void mapValueStringVariableSSQ() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1");
+ try (Query<FullTimeEmployee> q = pm.newQuery(MAP_VALUE_STRING_VARIABLE_SSQ)) {
+ List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(
+ ASSERTION_FAILED, MAP_VALUE_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- /**
- * Navigation through multi-valued field.
- *
- * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
- * phone number "1111" (i.e. the phoneNumbers map includes an entry with value "1111").
- */
- @SuppressWarnings("unchecked")
- @Test
- @Execution(ExecutionMode.CONCURRENT)
- public void mapValueStringVariableTypedQuery() {
- PersistenceManager pm = getPMF().getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- try {
- tx.begin();
- List<FullTimeEmployee> expected =
- getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1");
- try (JDOQLTypedQuery<FullTimeEmployee> q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) {
- QFullTimeEmployee cand = QFullTimeEmployee.candidate("this");
- Expression<String> value = q.variable("value", String.class);
- q.filter(cand.phoneNumbers.containsValue(value).and(value.eq("1111")));
- List<FullTimeEmployee> emps = q.executeList();
- checkQueryResultWithoutOrder(ASSERTION_FAILED, MAP_VALUE_STRING_VARIABLE_SSQ, emps, expected);
- } catch (Exception ex) {
- fail(ASSERTION_FAILED, ex.getLocalizedMessage());
- }
- tx.commit();
- } finally {
- cleanupPM(pm);
- }
+ /**
+ * Navigation through multi-valued field.
+ *
+ * <p>This query selects all FullTimeEmployee instances from the candidate collection having a
+ * phone number "1111" (i.e. the phoneNumbers map includes an entry with value "1111").
+ */
+ @SuppressWarnings("unchecked")
+ @Test
+ @Execution(ExecutionMode.CONCURRENT)
+ public void mapValueStringVariableTypedQuery() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class, "emp1");
+ try (JDOQLTypedQuery<FullTimeEmployee> q = pm.newJDOQLTypedQuery(FullTimeEmployee.class)) {
+ QFullTimeEmployee cand = QFullTimeEmployee.candidate("this");
+ Expression<String> value = q.variable("value", String.class);
+ q.filter(cand.phoneNumbers.containsValue(value).and(value.eq("1111")));
+ List<FullTimeEmployee> emps = q.executeList();
+ checkQueryResultWithoutOrder(
+ ASSERTION_FAILED, MAP_VALUE_STRING_VARIABLE_SSQ, emps, expected);
+ } catch (Exception ex) {
+ fail(ASSERTION_FAILED, ex.getLocalizedMessage());
+ }
+ tx.commit();
+ } finally {
+ cleanupPM(pm);
}
+ }
- @BeforeAll
- @Override
- protected void setUp() {
- super.setUp();
- }
+ @BeforeAll
+ @Override
+ protected void setUp() {
+ super.setUp();
+ }
- @AfterAll
- @Override
- protected void tearDown() {
- super.tearDown();
- }
+ @AfterAll
+ @Override
+ protected void tearDown() {
+ super.tearDown();
+ }
- /**
- * @see org.apache.jdo.tck.JDO_Test#localSetUp()
- */
- @Override
- protected void localSetUp() {
- addTearDownClass(CompanyModelReader.getTearDownClasses());
- loadAndPersistCompanyModel(getPM());
- }
+ /**
+ * @see org.apache.jdo.tck.JDO_Test#localSetUp()
+ */
+ @Override
+ protected void localSetUp() {
+ addTearDownClass(CompanyModelReader.getTearDownClasses());
+ loadAndPersistCompanyModel(getPM());
+ }
- /**
- * Returns the name of the company test data resource.
- *
- * @return name of the company test data resource.
- */
- @Override
- protected String getCompanyTestDataResource() {
- return SAMPLE_QUERIES_TEST_COMPANY_TESTDATA;
- }
+ /**
+ * Returns the name of the company test data resource.
+ *
+ * @return name of the company test data resource.
+ */
+ @Override
+ protected String getCompanyTestDataResource() {
+ return SAMPLE_QUERIES_TEST_COMPANY_TESTDATA;
+ }
}