Skip to content

Commit

Permalink
Change devnull transport accessUrl
Browse files Browse the repository at this point in the history
So pattern matching passes for e2e tests
  • Loading branch information
rpoet-jh committed Jul 19, 2024
1 parent 37f7c3e commit ec93b4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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());
}
Expand All @@ -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");

Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit ec93b4d

Please sign in to comment.