From 49c073ba0cc03224fa3d949a61d772052c2b7bf2 Mon Sep 17 00:00:00 2001 From: Matus Kasak Date: Fri, 3 Jul 2026 09:35:24 +0200 Subject: [PATCH 1/2] VSB-TUO/Fix EmbargoImportIT time-bomb: compute embargo dates dynamically testStandardEmbargoImport and testMultipleBitstreamsEmbargo started failing on 2026-06-30 because the test hardcoded EMBARGOEND_DATE_FUTURE = 2026-06-30 as a future embargo end date. Once real time passed that date, ItemImportServiceImpl.processEmbargoMetadata correctly skipped the embargo (a policy whose end date is past must not be applied - the same behaviour this suite itself asserts in testPastEmbargoDateNoPolicy), so the policy start date was null and both assertNotNull checks failed. The import logic is NOT broken: the branch head is unchanged since 2026-06-08, CI was green through 2026-06-29 and turned red on every run from 2026-06-30 00:57 UTC onward - the exact moment the hardcoded date rolled into the past. The bug is the test encoding the assumption that a fixed calendar date stays in the future. Fix: derive the embargo end date from LocalDate.now().plusYears(1) and the expected policy start date from it (+1 day), preserving the exact assertions (policy start = embargoend + 1 day, formatted yyyy-MM-dd). Verified locally: EmbargoImportIT 5/5 pass (was 3/5). Co-Authored-By: Claude Fable 5 --- .../java/org/dspace/app/itemimport/EmbargoImportIT.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dspace-api/src/test/java/org/dspace/app/itemimport/EmbargoImportIT.java b/dspace-api/src/test/java/org/dspace/app/itemimport/EmbargoImportIT.java index 2200b84334cf..337352c2c646 100644 --- a/dspace-api/src/test/java/org/dspace/app/itemimport/EmbargoImportIT.java +++ b/dspace-api/src/test/java/org/dspace/app/itemimport/EmbargoImportIT.java @@ -15,6 +15,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.List; import java.util.stream.Collectors; @@ -52,9 +53,13 @@ */ public class EmbargoImportIT extends AbstractIntegrationTestWithDatabase { - private static final String EMBARGOEND_DATE_FUTURE = "2026-06-30"; + // Embargo end date must be in the future at test run time, so compute it relative to "now". + // A hardcoded date here becomes a time bomb: the import logic correctly refuses to apply + // an embargo whose end date has already passed (see testPastEmbargoDateNoPolicy). + private static final LocalDate EMBARGO_END_FUTURE = LocalDate.now().plusYears(1); + private static final String EMBARGOEND_DATE_FUTURE = EMBARGO_END_FUTURE.toString(); // The resource policy start date should be embargoend + 1 day - private static final String EXPECTED_POLICY_START_DATE = "2026-07-01"; + private static final String EXPECTED_POLICY_START_DATE = EMBARGO_END_FUTURE.plusDays(1).toString(); private static final String EMBARGOEND_DATE_PAST = "2020-01-01"; private static final String ITEM_TITLE = "Test Embargo Item"; From cd3103845cfc09e94c66d2370328f87d6c084511 Mon Sep 17 00:00:00 2001 From: Matus Kasak Date: Fri, 3 Jul 2026 10:55:07 +0200 Subject: [PATCH 2/2] Update comment --- .../test/java/org/dspace/app/itemimport/EmbargoImportIT.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/dspace-api/src/test/java/org/dspace/app/itemimport/EmbargoImportIT.java b/dspace-api/src/test/java/org/dspace/app/itemimport/EmbargoImportIT.java index 337352c2c646..9f536bc27b2d 100644 --- a/dspace-api/src/test/java/org/dspace/app/itemimport/EmbargoImportIT.java +++ b/dspace-api/src/test/java/org/dspace/app/itemimport/EmbargoImportIT.java @@ -54,8 +54,6 @@ public class EmbargoImportIT extends AbstractIntegrationTestWithDatabase { // Embargo end date must be in the future at test run time, so compute it relative to "now". - // A hardcoded date here becomes a time bomb: the import logic correctly refuses to apply - // an embargo whose end date has already passed (see testPastEmbargoDateNoPolicy). private static final LocalDate EMBARGO_END_FUTURE = LocalDate.now().plusYears(1); private static final String EMBARGOEND_DATE_FUTURE = EMBARGO_END_FUTURE.toString(); // The resource policy start date should be embargoend + 1 day