diff --git a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/DeploymentTestDataService.java b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/DeploymentTestDataService.java index 04c8166e..bbacb1a7 100644 --- a/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/DeploymentTestDataService.java +++ b/pass-deposit-services/deposit-core/src/main/java/org/eclipse/pass/deposit/service/DeploymentTestDataService.java @@ -32,6 +32,7 @@ import org.eclipse.pass.support.client.model.PassEntity; import org.eclipse.pass.support.client.model.Policy; import org.eclipse.pass.support.client.model.Submission; +import org.eclipse.pass.support.client.model.SubmissionEvent; import org.eclipse.pass.support.client.model.User; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,6 +93,10 @@ private void deleteTestSubmissions(Grant testGrant) throws IOException { testFileSelector.setFilter(RSQL.equals("submission.id", testSubmission.getId())); List testFiles = passClient.streamObjects(testFileSelector).toList(); testFiles.forEach(this::deleteFile); + PassClientSelector subEventSelector = new PassClientSelector<>(SubmissionEvent.class); + subEventSelector.setFilter(RSQL.equals("submission.id", testSubmission.getId())); + List testSubmissionEvents = passClient.streamObjects(subEventSelector).toList(); + testSubmissionEvents.forEach(this::deleteObject); deleteObject(testSubmission); deleteObject(testSubmission.getPublication()); } catch (IOException e) { diff --git a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/service/DeploymentTestDataServiceIT.java b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/service/DeploymentTestDataServiceIT.java index 10371194..0ff08236 100644 --- a/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/service/DeploymentTestDataServiceIT.java +++ b/pass-deposit-services/deposit-core/src/test/java/org/eclipse/pass/deposit/service/DeploymentTestDataServiceIT.java @@ -34,6 +34,7 @@ import org.eclipse.pass.support.client.model.AwardStatus; import org.eclipse.pass.support.client.model.Deposit; import org.eclipse.pass.support.client.model.DepositStatus; +import org.eclipse.pass.support.client.model.EventType; import org.eclipse.pass.support.client.model.File; import org.eclipse.pass.support.client.model.Grant; import org.eclipse.pass.support.client.model.PassEntity; @@ -42,6 +43,7 @@ import org.eclipse.pass.support.client.model.Repository; import org.eclipse.pass.support.client.model.RepositoryCopy; import org.eclipse.pass.support.client.model.Submission; +import org.eclipse.pass.support.client.model.SubmissionEvent; import org.eclipse.pass.support.client.model.User; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -93,6 +95,9 @@ public void cleanUp() throws IOException { PassClientSelector fileSelector = new PassClientSelector<>(File.class); List testFiles = passClient.streamObjects(fileSelector).toList(); testFiles.forEach(this::deleteFile); + PassClientSelector subEventSelector = new PassClientSelector<>(SubmissionEvent.class); + List testSubEvents = passClient.streamObjects(subEventSelector).toList(); + testSubEvents.forEach(this::deleteObject); PassClientSelector submissionSelector = new PassClientSelector<>(Submission.class); List testSubmissions = passClient.streamObjects(submissionSelector).toList(); testSubmissions.forEach(this::deleteObject); @@ -195,6 +200,9 @@ public void testProcessData_DeleteTestSubmissionsForTestGrant() throws Exception PassClientSelector fileSelector = new PassClientSelector<>(File.class); List testFiles = passClient.streamObjects(fileSelector).toList(); assertTrue(testFiles.isEmpty()); + PassClientSelector subEventSelector = new PassClientSelector<>(SubmissionEvent.class); + List testSubEvents = passClient.streamObjects(subEventSelector).toList(); + assertTrue(testSubEvents.isEmpty()); } @Test @@ -255,6 +263,12 @@ public void testProcessData_DoesNotDeleteTestSubmissionsForOtherGrant() throws E assertEquals(1, testFiles.size()); File actualFile = testFiles.get(0); assertEquals(actualSubmission.getId(), actualFile.getSubmission().getId()); + + PassClientSelector subEventSelector = new PassClientSelector<>(SubmissionEvent.class); + List testSubEvents = passClient.streamObjects(subEventSelector).toList(); + assertEquals(1, testSubEvents.size()); + SubmissionEvent actualSubEvent = testSubEvents.get(0); + assertEquals(actualSubmission.getId(), actualSubEvent.getSubmission().getId()); } private Submission initSubmissionAndDeposits(Grant testGrant) throws Exception { @@ -294,6 +308,16 @@ private Submission initSubmissionAndDeposits(Grant testGrant) throws Exception { file.setSubmission(submission); passClient.createObject(file); + PassClientSelector selectorUser = new PassClientSelector<>(User.class); + selectorUser.setFilter(RSQL.equals("email", "test-user-email@foo")); + User testUser = passClient.streamObjects(selectorUser).toList().get(0); + + SubmissionEvent submissionEvent = new SubmissionEvent(); + submissionEvent.setSubmission(submission); + submissionEvent.setEventType(EventType.SUBMITTED); + submissionEvent.setPerformedBy(testUser); + passClient.createObject(submissionEvent); + return submission; }