mboapache commented on code in PR #97:
URL: https://github.com/apache/db-jdo/pull/97#discussion_r1835755756
##########
tck/src/main/java/org/apache/jdo/tck/query/api/SampleReadQueries.java:
##########
@@ -3031,6 +3048,450 @@ public void testQuery19f() {
}
}
+ /**
+ * 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 testQuery20a() {
+ 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 = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_20,
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 testQuery20b() {
+ 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, SINGLE_STRING_QUERY_20,
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 testQuery20c() {
+ 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, SINGLE_STRING_QUERY_20,
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 testQuery20d() {
+ 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(SINGLE_STRING_QUERY_20)) {
+ List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_20,
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 testQuery20f() {
+ 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, SINGLE_STRING_QUERY_20,
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 testQuery21a() {
+ 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 = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_21,
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 testQuery21b() {
+ 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, SINGLE_STRING_QUERY_21,
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 testQuery21c() {
+ 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, SINGLE_STRING_QUERY_21,
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 testQuery21d() {
+ 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(SINGLE_STRING_QUERY_21)) {
+ List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_21,
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 testQuery21f() {
+ 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, SINGLE_STRING_QUERY_21,
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 testQuery22a() {
+ 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 = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_22,
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 testQuery22b() {
+ 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, SINGLE_STRING_QUERY_22,
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 testQuery22c() {
+ 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, SINGLE_STRING_QUERY_22,
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 testQuery22d() {
+ PersistenceManager pm = getPMF().getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<FullTimeEmployee> expected =
+ getTransientCompanyModelInstancesAsList(FullTimeEmployee.class,
"emp1");
+ try (Query<FullTimeEmployee> q = pm.newQuery(SINGLE_STRING_QUERY_22)) {
+ List<FullTimeEmployee> emps = (List<FullTimeEmployee>) q.execute();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, SINGLE_STRING_QUERY_22,
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 testQuery22f() {
Review Comment:
See above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]