tzaeschke commented on code in PR #97: URL: https://github.com/apache/db-jdo/pull/97#discussion_r1835486027
########## tck/src/main/java/org/apache/jdo/tck/lifecycle/PMsCanSharePCClassesButNotPCInstances.java: ########## @@ -110,15 +110,15 @@ protected void insertObjects(boolean sharedPC) { while (!attemptsComplete()) { try { - Thread.sleep(100); + Thread.sleep(200); Review Comment: Why the increase to 200? Seems quite long... ########## 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() { Review Comment: Rename to `testQuery20e()`? ########## tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCDSPerson.java: ########## @@ -297,6 +305,24 @@ public void setPhoneNumbers(Map<String, String> phoneNumbers) { this.phoneNumbers = (phoneNumbers != null) ? new HashMap<>(phoneNumbers) : null; } + /** + * Get the map of languages as an unmodifiable Set. + * + * @return The set of languages, as an unmodifiable set. + */ + public Set<String> getLanguages() { + return Collections.unmodifiableSet(languages); + } + + /** + * Set the languages set to be in this person. + * + * @param languages The map of phoneNumbers for this person. + */ + public void setLanguages(Set<String> languages) { + this.languages = languages; Review Comment: `this.languages = new HashSet(languages);` ? ########## tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedFC/FCAppPerson.java: ########## @@ -301,6 +309,24 @@ public void setPhoneNumbers(Map<String, String> phoneNumbers) { this.phoneNumbers = (phoneNumbers != null) ? new HashMap<>(phoneNumbers) : null; } + /** + * Get the map of languages as an unmodifiable Set. + * + * @return The set of languages, as an unmodifiable set. + */ + public Set<String> getLanguages() { + return Collections.unmodifiableSet(languages); + } + + /** + * Set the languages set to be in this person. + * + * @param languages The map of phoneNumbers for this person. + */ + public void setLanguages(Set<String> languages) { + this.languages = languages; Review Comment: `this.languages = new HashSet(languages);` ? ########## tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCDSPerson.java: ########## @@ -294,6 +298,24 @@ public void setPhoneNumbers(Map<String, String> phoneNumbers) { this._phoneNumbers = (phoneNumbers != null) ? new HashMap<>(phoneNumbers) : null; } + /** + * Get the map of languages as an unmodifiable Set. + * + * @return The set of languages, as an unmodifiable set. + */ + public Set<String> getLanguages() { + return Collections.unmodifiableSet(_languages); + } + + /** + * Set the languages set to be in this person. + * + * @param languages The map of phoneNumbers for this person. + */ + public void setLanguages(Set<String> languages) { + this._languages = languages; Review Comment: `this._languages = new HashSet(languages);` ? ########## tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedJPA/JPAAppPerson.java: ########## @@ -305,6 +315,24 @@ public void setPhoneNumbers(Map<String, String> phoneNumbers) { this.phoneNumbers = (phoneNumbers != null) ? convertString2Phone(phoneNumbers) : null; } + /** + * Get the map of languages as an unmodifiable Set. + * + * @return The set of languages, as an unmodifiable set. + */ + public Set<String> getLanguages() { + return Collections.unmodifiableSet(languages); + } + + /** + * Set the languages set to be in this person. + * + * @param languages The map of phoneNumbers for this person. + */ + public void setLanguages(Set<String> languages) { + this.languages = languages; Review Comment: `this.languages = new HashSet(languages);` ? ########## 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() { Review Comment: Rename to `testQuery21e()`? ########## tck/src/main/java/org/apache/jdo/tck/pc/companyAnnotatedPC/PCAppPerson.java: ########## @@ -294,6 +298,24 @@ public void setPhoneNumbers(Map<String, String> phoneNumbers) { this._phoneNumbers = (phoneNumbers != null) ? new HashMap<>(phoneNumbers) : null; } + /** + * Get the map of languages as an unmodifiable Set. + * + * @return The set of languages, as an unmodifiable set. + */ + public Set<String> getLanguages() { + return Collections.unmodifiableSet(_languages); + } + + /** + * Set the languages set to be in this person. + * + * @param languages The set of languages for this person. + */ + public void setLanguages(Set<String> languages) { + this._languages = languages; Review Comment: `this._languages = new HashSet(languages);` ? ########## tck/src/main/java/org/apache/jdo/tck/pc/company/Person.java: ########## @@ -261,6 +265,24 @@ public void setPhoneNumbers(Map<String, String> phoneNumbers) { this.phoneNumbers = (phoneNumbers != null) ? new HashMap<>(phoneNumbers) : null; } + /** + * Get the set of languages as an unmodifiable set. + * + * @return The set of languages, as an unmodifiable set. + */ + public Set<String> getLanguages() { + return Collections.unmodifiableSet(languages); + } + + /** + * Set the languages set to be in this person. + * + * @param languages The set of languages for this person. + */ + public void setLanguages(Set<String> languages) { + this.languages = languages; Review Comment: I would suggest copying the Set here, instead of internalizing an external variable? ########## tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/package.jdo: ########## @@ -241,6 +244,9 @@ has datastore identity. <property name="phoneNumbers" persistence-modifier="persistent"> <map key-type="String" value-type="String"/> </property> + <property name="languages" persistence-modifier="persistent"> + <collection type="String"/> Review Comment: Shouldn't that be `<collection element-type="String"/>`? ########## tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/company/package.jdo: ########## @@ -131,6 +131,9 @@ has application identity. <field name="phoneNumbers" persistence-modifier="persistent"> <map key-type="String" value-type="String"/> </field> + <field name="languages" persistence-modifier="persistent"> + <collection type="String"/> Review Comment: Shouldn't that be `<collection element-type="String"/>`? ########## tck/src/main/resources/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/package.jdo: ########## @@ -106,6 +106,9 @@ has datastore identity. <field name="phoneNumbers" persistence-modifier="persistent"> <map key-type="String" value-type="String"/> </field> + <field name="languages" persistence-modifier="persistent"> + <collection type="String"/> Review Comment: Shouldn't that be `<collection element-type="String"/>`? ########## tck/src/main/resources/jdo/applicationidentity/org/apache/jdo/tck/pc/company/package.jdo: ########## @@ -275,6 +278,9 @@ has application identity. <property name="phoneNumbers" persistence-modifier="persistent"> <map key-type="String" value-type="String"/> </property> + <property name="languages" persistence-modifier="persistent"> + <collection type="String"/> Review Comment: Shouldn't that be `<collection element-type="String"/>`? ########## tck/src/main/resources/sql/derby/applicationidentity/schema.sql: ########## @@ -407,6 +408,11 @@ CREATE TABLE employee_phoneno_type ( TYPE VARCHAR(16) NOT NULL ); +CREATE TABLE employee_language ( Review Comment: Use plural? 'employee_languages`? ########## 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: Rename to `testQuery22e()`? -- 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: jdo-dev-unsubscr...@db.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org