From c67d0e903e61687d7f39ad0f9b9961292c83bb51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Jun 2024 09:11:09 +0000 Subject: [PATCH 1/2] Bump com.amazonaws:aws-java-sdk-bom in /gp2gp-translator Bumps [com.amazonaws:aws-java-sdk-bom](https://github.com/aws/aws-sdk-java) from 1.11.1000 to 1.12.748. - [Changelog](https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-java/compare/1.11.1000...1.12.748) --- updated-dependencies: - dependency-name: com.amazonaws:aws-java-sdk-bom dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- gp2gp-translator/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gp2gp-translator/build.gradle b/gp2gp-translator/build.gradle index 34cbbba68..c9b268946 100644 --- a/gp2gp-translator/build.gradle +++ b/gp2gp-translator/build.gradle @@ -43,7 +43,7 @@ dependencies { implementation 'com.azure:azure-storage-blob:12.26.1' - implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.1000') + implementation platform('com.amazonaws:aws-java-sdk-bom:1.12.748') implementation 'com.amazonaws:aws-java-sdk-s3' } From dad2be85d7bf7a4b3809308a4658c193f1badf60 Mon Sep 17 00:00:00 2001 From: Adrian Clay Date: Fri, 21 Jun 2024 14:19:47 +0100 Subject: [PATCH 2/2] Replace amazon namespace Exception with IllegalArgumentException --- .../service/AttachmentHandlerService.java | 5 ++--- .../service/SkeletonProcessingService.java | 3 +-- .../service/SkeletonProcessingServiceTests.java | 16 ++++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/AttachmentHandlerService.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/AttachmentHandlerService.java index c6e76a280..da480efaa 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/AttachmentHandlerService.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/AttachmentHandlerService.java @@ -18,7 +18,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import software.amazon.ion.NullValueException; import uk.nhs.adaptors.connector.model.PatientAttachmentLog; import uk.nhs.adaptors.pss.translator.config.SupportedFileTypes; import uk.nhs.adaptors.pss.translator.exception.InlineAttachmentProcessingException; @@ -125,14 +124,14 @@ public void storeAttachmentWithoutProcessing(String fileName, String payload, St public byte[] getAttachment(String filename, String conversationId) { if (!StringUtils.hasText(filename)) { - throw new NullValueException(); + throw new IllegalArgumentException("filename must not be empty"); } return storageManagerService.downloadFile(filename, conversationId); } public void removeAttachment(String filename, String conversationId) { if (!StringUtils.hasText(filename)) { - throw new NullValueException(); + throw new IllegalArgumentException("filename must not be empty"); } storageManagerService.deleteFile(filename, conversationId); } diff --git a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/SkeletonProcessingService.java b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/SkeletonProcessingService.java index 22bbbf56b..48d5582c6 100644 --- a/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/SkeletonProcessingService.java +++ b/gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/SkeletonProcessingService.java @@ -11,7 +11,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import software.amazon.ion.NullValueException; import uk.nhs.adaptors.connector.model.PatientAttachmentLog; import uk.nhs.adaptors.pss.translator.mhs.model.InboundMessage; import uk.nhs.adaptors.pss.translator.model.EbxmlReference; @@ -73,7 +72,7 @@ private InboundMessage insertSkeletonIntoInboundMessagePayload(PatientAttachment .findFirst(); if (ebxmlSkeletonReference.isEmpty()) { - throw new NullValueException(); + throw new IllegalArgumentException("inboundMessage does not contain a skeleton attachment reference"); } var skeletonDocumentId = ebxmlSkeletonReference.get().getDocumentId(); diff --git a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/service/SkeletonProcessingServiceTests.java b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/service/SkeletonProcessingServiceTests.java index 47365c0dd..6b22b8354 100644 --- a/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/service/SkeletonProcessingServiceTests.java +++ b/gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/service/SkeletonProcessingServiceTests.java @@ -13,6 +13,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import javax.xml.bind.JAXBException; import javax.xml.transform.TransformerException; @@ -31,7 +32,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import lombok.SneakyThrows; -import software.amazon.ion.NullValueException; import uk.nhs.adaptors.connector.dao.PatientMigrationRequestDao; import uk.nhs.adaptors.connector.model.PatientAttachmentLog; import uk.nhs.adaptors.connector.model.PatientMigrationRequest; @@ -115,7 +115,7 @@ private void prepareSkeletonRCMRMocks(InboundMessage inboundMessage) throws SAXE } @Test - public void When_UpdateInboundMessageAttachmentHandlerServiceThrowsNullException_Expect_ThrowsNullValueException() + public void When_UpdateInboundMessageAttachmentHandlerServiceThrowsIllegalArgumentException_Expect_ThrowsException() throws JAXBException, JsonProcessingException, TransformerException, SAXException { var inboundMessage = new InboundMessage(); @@ -124,9 +124,9 @@ public void When_UpdateInboundMessageAttachmentHandlerServiceThrowsNullException inboundMessage.setPayload(readInboundMessagePayloadFromFile()); inboundMessage.setEbXML(readInboundMessageEbXmlFromFile()); - doThrow(NullValueException.class).when(attachmentHandlerService).getAttachment(any(), any()); + doThrow(IllegalArgumentException.class).when(attachmentHandlerService).getAttachment(any(), any()); - assertThrows(NullValueException.class, () -> + assertThrows(IllegalArgumentException.class, () -> skeletonProcessingService.updateInboundMessageWithSkeleton(attachmentLog, inboundMessage, migrationRequest.getConversationId())); } @@ -190,8 +190,8 @@ public void When_SkeletonAsSectionMessage_Expect_ThrowNoErrors() throws JAXBExce } @Test - public void When_SkeletonAsSectionMessageAndEBXMLSkeletonReferenceIsEmpty_Expect_NullValueException() - throws JAXBException, JsonProcessingException, TransformerException, SAXException { + public void When_SkeletonAsSectionMessageAndEBXMLSkeletonReferenceIsEmpty_Expect_IllegalArgumentException() + throws SAXException { var inboundMessage = new InboundMessage(); var attachmentLog = createSkeletonPatientAttachmentLog(); @@ -199,7 +199,7 @@ public void When_SkeletonAsSectionMessageAndEBXMLSkeletonReferenceIsEmpty_Expect inboundMessage.setEbXML(readInboundMessageEbXmlFromFile()); var reference = new EbxmlReference("First instance is always a payload", "mid:1", "docId"); - var ebXmlAttachments = Arrays.asList(reference); + var ebXmlAttachments = List.of(reference); var fileAsBytes = readInboundMessageSkeletonPayloadFromFile().getBytes(StandardCharsets.UTF_8); when(attachmentHandlerService.getAttachment(any(), any())).thenReturn(fileAsBytes); when(xmlParseUtilService.getEbxmlAttachmentsData(any())).thenReturn(ebXmlAttachments); @@ -210,7 +210,7 @@ public void When_SkeletonAsSectionMessageAndEBXMLSkeletonReferenceIsEmpty_Expect emptyAttachmentsData ); - assertThrows(NullValueException.class, () -> + assertThrows(IllegalArgumentException.class, () -> skeletonProcessingService.updateInboundMessageWithSkeleton(attachmentLog, inboundMessage, migrationRequest.getConversationId())); }