diff --git a/src/main/java/gov/cabinetoffice/gap/adminbackend/entities/GrantExportEntity.java b/src/main/java/gov/cabinetoffice/gap/adminbackend/entities/GrantExportEntity.java index 058f7da5..d18cf9bd 100644 --- a/src/main/java/gov/cabinetoffice/gap/adminbackend/entities/GrantExportEntity.java +++ b/src/main/java/gov/cabinetoffice/gap/adminbackend/entities/GrantExportEntity.java @@ -45,6 +45,9 @@ public class GrantExportEntity { @Column(name = "location") private String location; + // Not a database column, needed to support SQS message for Submission Export + private Integer schemeId; + @Override public boolean equals(Object o) { if (this == o) { diff --git a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/SubmissionsService.java b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/SubmissionsService.java index 98ca9b2c..e0b57ea6 100644 --- a/src/main/java/gov/cabinetoffice/gap/adminbackend/services/SubmissionsService.java +++ b/src/main/java/gov/cabinetoffice/gap/adminbackend/services/SubmissionsService.java @@ -316,7 +316,8 @@ private List mapExportRecordListToBatchMessageRequest(Integer return list.stream() .map(submission -> GrantExportEntity.builder().id(new GrantExportId(exportId, submission.getId())) .status(GrantExportStatus.REQUESTED).applicationId(applicationId) - .emailAddress(adminSession.getEmailAddress()).createdBy(adminSession.getGrantAdminId()).build()) + .emailAddress(adminSession.getEmailAddress()).createdBy(adminSession.getGrantAdminId()) + .schemeId(submission.getScheme().getId()).build()) .toList(); } @@ -344,6 +345,9 @@ private SendMessageBatchRequest mapExportRecordListToBatchMessageRequest( return new SendMessageBatchRequestEntry().withId(randomUuid).withMessageBody(randomUuid) .withMessageDeduplicationId(randomUuid) .withMessageGroupId(exportRecord.getId().getExportBatchId().toString()) + .addMessageAttributesEntry("schemeId", + new MessageAttributeValue().withDataType("String") + .withStringValue(exportRecord.getSchemeId().toString())) .addMessageAttributesEntry("submissionId", new MessageAttributeValue().withDataType("String") .withStringValue(exportRecord.getId().getSubmissionId().toString())) diff --git a/src/test/java/gov/cabinetoffice/gap/adminbackend/services/SubmissionsServiceTest.java b/src/test/java/gov/cabinetoffice/gap/adminbackend/services/SubmissionsServiceTest.java index 898c2d6b..c3a0e871 100644 --- a/src/test/java/gov/cabinetoffice/gap/adminbackend/services/SubmissionsServiceTest.java +++ b/src/test/java/gov/cabinetoffice/gap/adminbackend/services/SubmissionsServiceTest.java @@ -373,8 +373,9 @@ class TriggerSubmissionsExportTests { @Test void happyPath_throwsNoException() { + SchemeEntity scheme = SchemeEntity.builder().id(1).build(); List submissions = Collections - .singletonList(randomSubmission().definition(SUBMISSION_DEFINITION).build()); + .singletonList(randomSubmission().definition(SUBMISSION_DEFINITION).scheme(scheme).build()); when(submissionRepository.findByApplicationGrantApplicationIdAndStatus(1, SubmissionStatus.SUBMITTED)) .thenReturn(submissions); @@ -408,8 +409,9 @@ void repoSaveFailure_throwsException() { @Test void sqsMessageFailure_throwsException() { + SchemeEntity scheme = SchemeEntity.builder().id(1).build(); List submissions = Collections - .singletonList(randomSubmission().definition(SUBMISSION_DEFINITION).build()); + .singletonList(randomSubmission().definition(SUBMISSION_DEFINITION).scheme(scheme).build()); when(submissionRepository.findByApplicationGrantApplicationIdAndStatus(1, SubmissionStatus.SUBMITTED)) .thenReturn(submissions); when(amazonSQS.sendMessageBatch(any())).thenThrow(new AmazonSQSException("Cannot send messages"));