From ec93b4d611deb6a64385736d442052708912a4ee Mon Sep 17 00:00:00 2001 From: Russ Poetker Date: Fri, 19 Jul 2024 10:30:25 -0400 Subject: [PATCH] Change devnull transport accessUrl So pattern matching passes for e2e tests --- .../transport/devnull/DevNullTransport.java | 2 +- .../service/SubmissionProcessorIT.java | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/transport/devnull/DevNullTransport.java b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/transport/devnull/DevNullTransport.java index 5d607760..5f5a1845 100644 --- a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/transport/devnull/DevNullTransport.java +++ b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/transport/devnull/DevNullTransport.java @@ -88,7 +88,7 @@ public void onSuccess(Submission submission, Deposit deposit, RepositoryCopy rep rc.getExternalIds().add("devnull-fake-extid-" + repositoryCopy.getId()); rc.setCopyStatus(CopyStatus.COMPLETE); rc.setAccessUrl( - URI.create("devnull-fake-url/" + repositoryCopy.getId()) + URI.create("https://devnull-fake-url/handle/" + repositoryCopy.getId()) ); return rc; }, true); diff --git a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/service/SubmissionProcessorIT.java b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/service/SubmissionProcessorIT.java index c47ed66d..dacd8d6e 100644 --- a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/service/SubmissionProcessorIT.java +++ b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/service/SubmissionProcessorIT.java @@ -81,7 +81,7 @@ void testSubmissionProcessing_Full() throws Exception { resetGrantProjectName(submission, null); // WHEN/THEN - testSubmissionProcessor(submission); + testSubmissionProcessor(submission, false); verify(filesystemTransport, times(3)).open(anyMap()); verify(devNullTransport, times(0)).open(anyMap()); } @@ -94,7 +94,7 @@ void testSubmissionProcessing_SkipTestSubmission() throws Exception { resetGrantProjectName(submission, DeploymentTestDataService.PASS_E2E_TEST_GRANT); // WHEN/THEN - testSubmissionProcessor(submission); + testSubmissionProcessor(submission, true); verify(devNullTransport, times(3)).open(anyMap()); verify(filesystemTransport, times(0)).open(anyMap()); } @@ -108,12 +108,12 @@ void testSubmissionProcessing_DontSkipTestSubmission() throws Exception { ReflectionTestUtils.setField(depositTaskHelper, "skipDeploymentTestDeposits", Boolean.FALSE); // WHEN/THEN - testSubmissionProcessor(submission); + testSubmissionProcessor(submission, false); verify(devNullTransport, times(0)).open(anyMap()); verify(filesystemTransport, times(3)).open(anyMap()); } - private void testSubmissionProcessor(Submission submission) throws IOException { + private void testSubmissionProcessor(Submission submission, boolean usingDevNull) throws IOException { triggerSubmission(submission); final Submission actualSubmission = passClient.getObject(Submission.class, submission.getId(), "grants"); @@ -185,16 +185,19 @@ private void testSubmissionProcessor(Submission submission) throws IOException { .findFirst().get(); assertTrue(pmcDeposit.getDepositStatusRef().startsWith("nihms-package:nihms-native-2022-05_")); assertEquals(DepositStatus.ACCEPTED, pmcDeposit.getDepositStatus()); + verifyAccessUrl(pmcDeposit, usingDevNull); Deposit j10pDeposit = resultDeposits.stream() .filter(deposit -> deposit.getRepository().getRepositoryKey().equals("JScholarship")) .findFirst().get(); assertNull(j10pDeposit.getDepositStatusRef()); assertEquals(DepositStatus.ACCEPTED, j10pDeposit.getDepositStatus()); + verifyAccessUrl(j10pDeposit, usingDevNull); Deposit bagItDeposit = resultDeposits.stream() .filter(deposit -> deposit.getRepository().getRepositoryKey().equals("BagIt")) .findFirst().get(); assertNull(bagItDeposit.getDepositStatusRef()); assertEquals(DepositStatus.ACCEPTED, bagItDeposit.getDepositStatus()); + verifyAccessUrl(bagItDeposit, usingDevNull); // WHEN submissionStatusUpdater.doUpdate(); @@ -212,6 +215,16 @@ private void testSubmissionProcessor(Submission submission) throws IOException { assertEquals(AggregatedDepositStatus.ACCEPTED, aggrStatusSubmission.getAggregatedDepositStatus()); } + private void verifyAccessUrl(Deposit deposit, boolean usingDevNull) throws IOException { + RepositoryCopy j10pRepoCopy = passClient.getObject(deposit.getRepositoryCopy()); + String accessUrl = j10pRepoCopy.getAccessUrl().toString(); + if (usingDevNull) { + assertEquals("https://devnull-fake-url/handle/" + j10pRepoCopy.getId(), accessUrl); + } else { + assertTrue(accessUrl.startsWith("file:")); + } + } + private void resetGrantProjectName(Submission submission, String grantProjectName) throws IOException { String resolvedProjectName = resolveProjectName(grantProjectName); Grant grant = submission.getGrants().get(0);