From 89fb0a57b312fdb40e165a9025276407fec34412 Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Wed, 10 Jan 2024 15:50:44 +0000 Subject: [PATCH 1/9] [PRMT-4356] Updated Dojofile and Dojofile-itest to use latest OpenJDK image --- Dojofile | 2 +- Dojofile-itest | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dojofile b/Dojofile index 1627e8d..fc4087d 100644 --- a/Dojofile +++ b/Dojofile @@ -1 +1 @@ -DOJO_DOCKER_IMAGE="nhsdev/openjdk-dojo:d186138d2093aeb801dcf7a331b5fda82082584d" \ No newline at end of file +DOJO_DOCKER_IMAGE="nhsdev/openjdk-dojo:d802c6970c76fe02798b24e07a2084f5d434bcda" \ No newline at end of file diff --git a/Dojofile-itest b/Dojofile-itest index d452173..ae0228d 100644 --- a/Dojofile-itest +++ b/Dojofile-itest @@ -1,3 +1,3 @@ -DOJO_DOCKER_IMAGE="nhsdev/openjdk-dojo:d186138d2093aeb801dcf7a331b5fda82082584d" +DOJO_DOCKER_IMAGE="nhsdev/openjdk-dojo:d802c6970c76fe02798b24e07a2084f5d434bcda" DOJO_DRIVER=docker-compose DOJO_DOCKER_COMPOSE_FILE=docker-compose.yaml \ No newline at end of file From 451d3085f5a0c36ac09ca32ba60e0a72d9f05d67 Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Wed, 10 Jan 2024 15:51:20 +0000 Subject: [PATCH 2/9] [PRMT-4356] Updated gradle-wrapper.properties to use version 8.5 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb87..a595206 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 843ae4a38e17added21c4028765b8a3cb25c85c9 Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Wed, 10 Jan 2024 15:51:59 +0000 Subject: [PATCH 3/9] [PRMT-4356] Renamed javax.annotation.PostConstruct to jakarta.annotation.PostConstruct --- .../nhs/prm/repo/re_registration/infra/LocalStackAwsConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/integration/java/uk/nhs/prm/repo/re_registration/infra/LocalStackAwsConfig.java b/src/integration/java/uk/nhs/prm/repo/re_registration/infra/LocalStackAwsConfig.java index 400c1a8..4c1fb57 100644 --- a/src/integration/java/uk/nhs/prm/repo/re_registration/infra/LocalStackAwsConfig.java +++ b/src/integration/java/uk/nhs/prm/repo/re_registration/infra/LocalStackAwsConfig.java @@ -8,6 +8,7 @@ import com.amazonaws.services.sqs.model.CreateQueueRequest; import com.amazonaws.services.sqs.model.GetQueueAttributesResult; import com.amazonaws.services.sqs.model.QueueDoesNotExistException; +import jakarta.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.TestConfiguration; @@ -32,7 +33,6 @@ import software.amazon.awssdk.services.sns.model.SubscribeRequest; import software.amazon.awssdk.services.sqs.SqsClient; -import javax.annotation.PostConstruct; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; From 58967a9b6117f83e5d70140d370af7c3e84a0a87 Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Wed, 10 Jan 2024 15:52:48 +0000 Subject: [PATCH 4/9] [PRMT-4356] Updated Dockerfile from eclipse-temurin:11.0.17_8-jre-alpine to eclipse-temurin:21.0.1_12-jre-alpine --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1d768c9..a57fc3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM eclipse-temurin:11.0.17_8-jre-alpine +FROM eclipse-temurin:21.0.1_12-jre-alpine RUN apk add --no-cache bash From a14aa8e0daa9043b4b3a624dac75d25e55c58255 Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Wed, 10 Jan 2024 15:53:59 +0000 Subject: [PATCH 5/9] [PRMT-4356] Updated Spring Boot plugin to 3.2.1 and the sourceCompatibility to 21 --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index d7d65c7..8959047 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'org.springframework.boot' version '2.7.18' + id 'org.springframework.boot' version '3.2.1' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id 'jacoco' @@ -9,7 +9,7 @@ plugins { group = 'uk.nhs.prm.repo' version = '0.0.1-SNAPSHOT' -sourceCompatibility = '11' +sourceCompatibility = '21' configurations { compileOnly { From 7d494c002208167a1cd0e250494e4d255244cf3d Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Fri, 12 Jan 2024 11:19:40 +0000 Subject: [PATCH 6/9] [PRMT-4356] Moved to using WireMock on a standalone build, otherwise Jetty issues occur https://github.com/wiremock/wiremock/issues/2317 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8959047..ba1d73a 100644 --- a/build.gradle +++ b/build.gradle @@ -70,7 +70,7 @@ dependencies { testImplementation 'org.springframework.boot:spring-boot-test' testImplementation "org.mockito:mockito-core:3.+" - testImplementation 'com.github.tomakehurst:wiremock-jre8:2.35.1' + testImplementation 'com.github.tomakehurst:wiremock-standalone:3.0.1' testImplementation 'org.awaitility:awaitility:4.2.0' } From 5d1a36bdeacaefd579fe477048cf11ee5be2b8c9 Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Fri, 12 Jan 2024 11:20:30 +0000 Subject: [PATCH 7/9] [PRMT-4356] Refactored some logic within DeleteEhrIntegrationTest.java --- .../delete_ehr/DeleteEhrIntegrationTest.java | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/integration/java/uk/nhs/prm/repo/re_registration/delete_ehr/DeleteEhrIntegrationTest.java b/src/integration/java/uk/nhs/prm/repo/re_registration/delete_ehr/DeleteEhrIntegrationTest.java index 8e9a03d..1d9afe7 100644 --- a/src/integration/java/uk/nhs/prm/repo/re_registration/delete_ehr/DeleteEhrIntegrationTest.java +++ b/src/integration/java/uk/nhs/prm/repo/re_registration/delete_ehr/DeleteEhrIntegrationTest.java @@ -5,6 +5,8 @@ import com.amazonaws.services.sqs.model.PurgeQueueRequest; import com.amazonaws.services.sqs.model.ReceiveMessageRequest; import com.github.tomakehurst.wiremock.WireMockServer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -26,7 +28,12 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import static com.github.tomakehurst.wiremock.client.WireMock.*; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.delete; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.matching; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; import static org.assertj.core.api.Assertions.assertThat; import static org.awaitility.Awaitility.await; @@ -37,6 +44,7 @@ @DirtiesContext public class DeleteEhrIntegrationTest { + private static final Logger LOGGER = LogManager.getLogger(DeleteEhrIntegrationTest.class); public static final String NHS_NUMBER = "9999567890"; @Autowired @@ -80,16 +88,15 @@ private WireMockServer initializeWebServer() { return wireMockServer; } - @Test void shouldPutTheEHRDeleteAuditMessageOntoTheAuditQueueWhenActiveSuspensionExistsInDBAndPDSReturnsAStatusCode200() { activeSuspensionsDb.save(getActiveSuspensionsMessage()); - - sqs.sendMessage(reRegistrationsQueueUrl,getReRegistrationEvent().toJsonString()); + sqs.sendMessage(reRegistrationsQueueUrl, getReRegistrationEvent().toJsonString()); await().atMost(20, TimeUnit.SECONDS).untilAsserted(()-> { String messageBody = checkMessageInRelatedQueue(reRegistrationsAuditUrl).get(0).getBody(); System.out.println("Found message - " + messageBody); + assertThat(messageBody).contains("\"status\":\"ACTION:RE_REGISTRATION_EHR_DELETED\""); assertThat(messageBody).contains("\"nemsMessageId\":\"someNemsId\""); assertThat(messageBody).contains("\"conversationIds\":[\"2431d4ff-f760-4ab9-8cd8-a3fc47846762\",\"c184cc19-86e9-4a95-b5b5-2f156900bb3c\"]"); @@ -110,7 +117,7 @@ void shouldPutTheUnknownReRegistrationsAuditMessageOntoTheAuditQueueWhenActiveSu private void stubResponses() { setPds200SuccessState(); - ehrRepo200Response(); + ehrRepository200Response(); } private void setPds200SuccessState() { @@ -123,7 +130,7 @@ private void setPds200SuccessState() { .withBody(getPdsResponseString().getBody()))); } - private void ehrRepo200Response() { + private void ehrRepository200Response() { stubFor(delete(urlMatching("/patients/" + NHS_NUMBER)) .withHeader("Authorization", matching(authKey)) .willReturn(aResponse() @@ -136,27 +143,30 @@ private void ehrRepo200Response() { .withHeader("Content-Type", "application/json"))); } - private ReRegistrationEvent getReRegistrationEvent() { String nemsMessageId = "someNemsId"; return new ReRegistrationEvent(NHS_NUMBER, "ABC123", nemsMessageId, "2017-11-01T15:00:33+00:00"); } private List checkMessageInRelatedQueue(String queueUrl) { - System.out.println("checking sqs queue: " + queueUrl); + LOGGER.info("Checking SQS Queue: {}", queueUrl); - var requestForMessagesWithAttributes - = new ReceiveMessageRequest().withQueueUrl(queueUrl) + ReceiveMessageRequest requestForMessagesWithAttributes = new ReceiveMessageRequest() + .withQueueUrl(queueUrl) .withMessageAttributeNames("traceId"); - List messages = sqs.receiveMessage(requestForMessagesWithAttributes).getMessages(); - System.out.printf("Found %s messages on queue: %s%n", messages.size(), queueUrl); + + final List messages = sqs + .receiveMessage(requestForMessagesWithAttributes) + .getMessages(); + + LOGGER.info("Found {} messages on queue: {}", messages.size(), queueUrl); assertThat(messages).hasSize(1); return messages; } private ResponseEntity getPdsResponseString() { - var pdsResponseString = "{\"nhsNumber\":\"" + NHS_NUMBER + "\",\"isSuspended\":false,\"currentOdsCode\":\"currentOdsCode\",\"managingOrganisation\":\"managingOrganisation\",\"recordETag\":\"etag\",\"isDeceased\":false}"; - return new ResponseEntity<>(pdsResponseString, HttpStatus.OK); + String pdsAdaptorResponseString = "{\"nhsNumber\":\"" + NHS_NUMBER + "\",\"isSuspended\":false,\"currentOdsCode\":\"currentOdsCode\",\"managingOrganisation\":\"managingOrganisation\",\"recordETag\":\"etag\",\"isDeceased\":false}"; + return new ResponseEntity<>(pdsAdaptorResponseString, HttpStatus.OK); } private ActiveSuspensionsMessage getActiveSuspensionsMessage() { From 0a2e534c496d894e1b8332d4a3e494ec51814814 Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Fri, 12 Jan 2024 11:30:26 +0000 Subject: [PATCH 8/9] [PRMT-4356] Refactored submit-dependency-graph.yml workflow to use JDK 21. --- .github/workflows/submit-dependency-graph.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/submit-dependency-graph.yml b/.github/workflows/submit-dependency-graph.yml index a3d7cfa..09fee77 100644 --- a/.github/workflows/submit-dependency-graph.yml +++ b/.github/workflows/submit-dependency-graph.yml @@ -10,6 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: '21' - name: Setup Gradle to generate and submit dependency graphs uses: gradle/gradle-build-action@v2 with: From 4ebf702a91fb10d80ed8dc9e96e1e5ef9a68d15b Mon Sep 17 00:00:00 2001 From: martin-nhs Date: Fri, 12 Jan 2024 11:32:59 +0000 Subject: [PATCH 9/9] [PRMT-4356] Refactored submit-dependency-graph.yml workflow to only run when a PR is merged into main --- .github/workflows/submit-dependency-graph.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/submit-dependency-graph.yml b/.github/workflows/submit-dependency-graph.yml index 09fee77..b9d9c24 100644 --- a/.github/workflows/submit-dependency-graph.yml +++ b/.github/workflows/submit-dependency-graph.yml @@ -1,6 +1,8 @@ name: Submit dependency graph on: - push: + pull_request: + types: [closed] + branches: [main] permissions: contents: write