Open
Conversation
- Migrate TestBase, Proposal3ServiceBeanTest, Shipping3ServiceBeanTest, Container3ServiceBeanTest and BLSample3ServiceBeanTest from JUnit 4 annotations to JUnit 5 (Jupiter); BLSample3VOTest kept as JUnit 4 via vintage-engine - Add JUnit Jupiter 5.11.4, junit-vintage-engine and Surefire 3.2.5 to pom.xml - Enable Proposal3, Shipping3, Container3 and BLSample3 service tests; 12 tests now active (81 total, 0 failures) - Refactor BLSample3ServiceBean.getDiffractionPlan: move Ejb3ServiceLocator lookup inside the null-check and collapse duplicate if/else-if branches into a single ternary + one if, so the locator is never called when no diffractionPlanId is present Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tests no longer need a manually-started database. Running `mvn test` pulls a mariadb:11 image, starts it, and tears it down automatically. TestBase starts a single MariaDBContainer as a JVM-scoped static singleton and creates the EJBContainer only once for the whole test run, keeping the startup overhead minimal. The container is initialised from files in ispyb-database/schema/: 01-schema.sql ← pydb_empty.sql (canonical empty-schema dump) 02-proposals.sql ← test-data-proposals.sql (Person/Proposal data) 03-shipping.sql ← test-data-shipping.sql (Shipping/Dewar/Container) 04-blsample.sql ← test-data-blsample.sql (Protein/Crystal/BLSample) Keeping one SQL file per test class makes it straightforward to diagnose which fixture data is needed when a test fails. Files are bound from the host filesystem via withFileSystemBind so the canonical data scripts live alongside the schema in ispyb-database/, not buried in test resources. The project root is resolved through the maven.multiModuleProjectDirectory system property (falls back to ".." for IDE runs from the ispyb-ejb directory). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tier 2 — fix hardcoded production IDs, migrate from JUnit 4 @ignore to JUnit 5: - Protein3ServiceBeanTest: use fixture Protein id=1 (with crystal) / id=2 (no crystal) - Crystal3ServiceBeanTest: use fixture proteinId=1 - DewarRestWsServiceBeanTest: use session id=1 / proposal 8425; assert non-empty results Tier 3 — add session/beamline fixtures, enable two more tests: - test-data-sessions.sql: BeamLineSetup(1), BLSession(1, P11), ShippingHasSession, EnergyScan(1, Se) - BeamLineSetup3ServiceBeanTest: findByPk(1) and findByScreeningInputId(missing=null) - EnergyScanRestWsServiceTest: assert real rows via v_energyScan view Tier 4 — new test classes for core MX services: - Person3ServiceBeanTest: findByPk, findByLogin, findByFamilyAndGivenName - Session3ServiceBeanTest: findByPk, findByShippingId, hasDataCollectionGroups, getNbOfCollects - Dewar3ServiceBeanTest: findByPk (plain/with-containers), findByShippingId, countDewarSamples - DewarTransportHistory3ServiceBeanTest: findAll, findByDewarId Fixture data is now split into one SQL file per concern, stored in ispyb-database/schema/: test-data-proposals.sql, test-data-shipping.sql, test-data-proteins.sql (new), test-data-blsample.sql (Protein row moved to proteins file), test-data-sessions.sql (new) Result: 37 active tests (up from 12), 0 failures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add test-data-collections.sql: DataCollectionGroup(1) + DataCollection(1, 100 images)
- Mount 07-collections.sql in TestBase
- New DataCollectionGroup3ServiceBeanTest: findByPk, findByPkWithDataCollections,
findAll, findFiltered, findBySampleId
- New DataCollection3ServiceBeanTest: findByPk, findByProposalId, getNbOfCollects,
getNbOfTests (native-query quirks treated same as countDewarSamples: assert >= 0)
- Skip DataCollection3ServiceBean.findAll() — pre-existing invalid JPQL ("from VO")
103 tests, 0 failures.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
OpenJPA 4.0.0 strictly enforces the JPQL spec: queries must start with SELECT, UPDATE, or DELETE. Three service beans used Hibernate's shorthand "from Entity vo" which omits the SELECT clause and is not valid JPQL. - DataCollection3ServiceBean.findAll(): "from DataCollection3VO vo" - Proposal3ServiceBean.findAll(): "from Proposal3VO vo" - Person3ServiceBean.findBySiteId(): "from Person3VO vo where ..." All three rewritten to standard "SELECT vo FROM Entity vo [WHERE ...]". DataCollection3ServiceBeanTest.findAll() re-enabled now that the bug is fixed. 104 tests, 0 failures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Integrate testcontainers for unit testing