Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 21, 2025

Refactor database query tests to handle empty result sets

Tests in treebase-core/src/test were failing when run against an empty database because they assumed query results would contain data.

Changes

Refactored 33 test methods across 12 test files to verify empty result sets are returned correctly:

  • DAO tests: PersonDAOTest, UserDAOTest, MatrixDAOTest, StudyDAOTest, PhyloTreeDAOTest, SubmissionDAOTest, AnalyzedDataDAOTest
  • Domain tests: UserTest, MatrixTest
  • Nexus converter tests: NexmlAnalysisConverterTest, NexmlTreeConverterTest, NexmlMatrixConverterTest

Pattern

Before:

List<String> ids = jdbcTemplate.queryForList("select person_id from person", String.class);
assertTrue("Empty Person table.", ids.size() > 0);  // Fails on empty DB

After:

List<String> ids = jdbcTemplate.queryForList("select person_id from person", String.class);
assertNotNull("Query should return non-null list", ids);

if (ids.size() > 0) {
    // Validation logic
} else {
    logger.info(testName + " - empty database, test skipped");
}

Tests now validate that queries return non-null collections when the database is empty, while still performing full verification when data exists.

Bug Fix

Fixed compilation errors in SubmissionDAOTest and AnalyzedDataDAOTest by adding missing import java.util.List; statement.

Original prompt

Numerous tests in treebase-core/src/test are failing simply because they run queries against a database that doesn't have test data in it. Refactor these tests to simply verify that the correct (but empty) result set is returned.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Refactor tests to verify empty result sets Refactor database query tests to handle empty result sets Dec 21, 2025
Copilot AI requested a review from rvosa December 21, 2025 19:14
@rvosa
Copy link
Contributor

rvosa commented Dec 21, 2025

@copilot Oopsies:

Error:  COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
Error:  /home/runner/work/treebase/treebase/treebase-core/src/test/java/org/cipres/treebase/dao/study/SubmissionDAOTest.java:[92,17] cannot find symbol
  symbol:   class List
  location: class org.cipres.treebase.dao.study.SubmissionDAOTest
Error:  /home/runner/work/treebase/treebase/treebase-core/src/test/java/org/cipres/treebase/dao/study/SubmissionDAOTest.java:[136,17] cannot find symbol
  symbol:   class List
  location: class org.cipres.treebase.dao.study.SubmissionDAOTest
Error:  /home/runner/work/treebase/treebase/treebase-core/src/test/java/org/cipres/treebase/dao/study/AnalyzedDataDAOTest.java:[75,17] cannot find symbol
  symbol:   class List
  location: class org.cipres.treebase.dao.study.AnalyzedDataDAOTest
Error:  /home/runner/work/treebase/treebase/treebase-core/src/test/java/org/cipres/treebase/dao/study/AnalyzedDataDAOTest.java:[122,17] cannot find symbol
  symbol:   class List
  location: class org.cipres.treebase.dao.study.AnalyzedDataDAOTest

Copy link
Contributor Author

Copilot AI commented Dec 21, 2025

@copilot Oopsies:

...

Fixed in commit 6dce4f6. Added the missing import java.util.List; statement to both SubmissionDAOTest.java and AnalyzedDataDAOTest.java.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.osgeo.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/treebase/treebase org.codehaus.plexus.classworlds.launcher.Launcher clean compile -pl treebase-core -am -Dmaven.test.skip=true (dns block)
  • repository.gbif.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/treebase/treebase org.codehaus.plexus.classworlds.launcher.Launcher clean compile -pl treebase-core -am -Dmaven.test.skip=true (dns block)
  • repository.jboss.org
    • Triggering command: /usr/lib/jvm/temurin-17-jdk-amd64/bin/java /usr/lib/jvm/temurin-17-jdk-amd64/bin/java --enable-native-access=ALL-UNNAMED -classpath /usr/share/apache-maven-3.9.11/boot/plexus-classworlds-2.9.0.jar -Dclassworlds.conf=/usr/share/apache-maven-3.9.11/bin/m2.conf -Dmaven.home=/usr/share/apache-maven-3.9.11 -Dlibrary.jansi.path=/usr/share/apache-maven-3.9.11/lib/jansi-native -Dmaven.multiModuleProjectDirectory=/home/REDACTED/work/treebase/treebase org.codehaus.plexus.classworlds.launcher.Launcher clean compile -pl treebase-core -am -Dmaven.test.skip=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@rvosa rvosa marked this pull request as ready for review December 21, 2025 19:22
@rvosa rvosa merged commit b74b6e5 into master Dec 21, 2025
0 of 2 checks passed
@rvosa rvosa deleted the copilot/refactor-test-query-validations branch December 21, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants