Skip to content

Commit

Permalink
TMI2-602: Add schemeId to submission export SQS message (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
iaincooper-tco authored Mar 5, 2024
1 parent 46db7a1 commit db41803
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ private List<GrantExportEntity> 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();
}

Expand Down Expand Up @@ -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()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,9 @@ class TriggerSubmissionsExportTests {

@Test
void happyPath_throwsNoException() {
SchemeEntity scheme = SchemeEntity.builder().id(1).build();
List<Submission> submissions = Collections
.singletonList(randomSubmission().definition(SUBMISSION_DEFINITION).build());
.singletonList(randomSubmission().definition(SUBMISSION_DEFINITION).scheme(scheme).build());
when(submissionRepository.findByApplicationGrantApplicationIdAndStatus(1, SubmissionStatus.SUBMITTED))
.thenReturn(submissions);

Expand Down Expand Up @@ -408,8 +409,9 @@ void repoSaveFailure_throwsException() {

@Test
void sqsMessageFailure_throwsException() {
SchemeEntity scheme = SchemeEntity.builder().id(1).build();
List<Submission> 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"));
Expand Down

0 comments on commit db41803

Please sign in to comment.