Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses failing backend tests (Issue: dataquest-dev/dspace-customers#524) by making integration tests less brittle and aligning Spring Boot cache configuration with DSpace kernel-managed caching.
Changes:
- Update
MetadataBitstreamControllerITto validate the ZIP response by parsing/extracting it instead of byte-for-byte ZIP generation. - Make
BitstreamFormatRestRepositoryITcompute the baseline number of bitstream formats dynamically rather than relying on a hardcoded constant. - Adjust Spring Boot configuration to avoid creating a competing CacheManager (cache is managed by the DSpace kernel).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| dspace-server-webapp/src/test/java/org/dspace/app/rest/MetadataBitstreamControllerIT.java | Switches ZIP verification to extract-and-compare approach. |
| dspace-server-webapp/src/test/java/org/dspace/app/rest/BitstreamFormatRestRepositoryIT.java | Removes hardcoded baseline count; initializes it from the DB per test. |
| dspace-server-webapp/src/main/resources/application.properties | Disables Boot cache autoconfig to prevent competing CacheManager vs kernel cache. |
| dspace-api/src/test/java/org/dspace/ctask/general/CreateMissingIdentifiersIT.java | Restores modified config after test to avoid cross-test pollution. |
| dspace-api/src/test/java/org/dspace/builder/ItemBuilder.java | Fixes indentation in test builder cleanup. |
| try (ZipArchiveInputStream zipIn = new ZipArchiveInputStream(new ByteArrayInputStream(responseBytes))) { | ||
| ZipArchiveEntry entry = zipIn.getNextZipEntry(); | ||
| // Verify entry name matches bitstream name | ||
| assertEquals(bts.getName(), entry.getName()); | ||
| // Verify uncompressed content matches the original bitstream content |
There was a problem hiding this comment.
After calling getNextZipEntry(), the test assumes an entry exists. If the response is not a valid ZIP or is empty, entry will be null and the test will NPE on entry.getName(), which makes failures harder to diagnose. Add an assertion that the entry is non-null (and optionally assert there are no unexpected additional entries).
| String bitstreamContent = "ThisIsSomeDummyText"; | ||
|
|
There was a problem hiding this comment.
bitstreamContent is hardcoded again in this test method, duplicating the value used when creating the Bitstream in setUp(). To avoid future divergence (e.g., setUp changes but the assertion doesn’t), store the content in a shared constant/field or derive expected bytes by retrieving the bitstream content from bts.
| private int DEFAULT_AMOUNT_FORMATS; | ||
|
|
||
| @Before | ||
| public void init() throws SQLException { | ||
| DEFAULT_AMOUNT_FORMATS = bitstreamFormatService.findAll(context).size(); | ||
| } |
There was a problem hiding this comment.
DEFAULT_AMOUNT_FORMATS is no longer a constant (it’s assigned in @before), but it’s still named like a constant (ALL_CAPS). Rename it to a regular field name (e.g., defaultAmountFormats/initialAmountFormats) to match Java conventions and reduce confusion.
|
Current state: |
|
See the fixes made in ufal/clarin-dspace repository, particularly: |
Problem description
Issue: https://github.com/dataquest-dev/dspace-customers/issues/524
Manual Testing (if applicable)
Copilot review