Skip to content

Commit 076b669

Browse files
FLAGSAPI-1046 reverted most of the the auto formatting changes to simplify PR
1 parent 5edfc5b commit 076b669

4 files changed

Lines changed: 146 additions & 139 deletions

File tree

docker/service/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,16 @@ dependencies {
5050
testImplementation "io.rest-assured:json-path:4.4.0"
5151
testImplementation "io.rest-assured:xml-path:4.4.0"
5252
testImplementation "com.github.tomakehurst:wiremock-jre8-standalone:2.31.0"
53+
testImplementation(platform('org.junit:junit-bom:5.13.0'))
54+
testImplementation('org.junit.jupiter:junit-jupiter')
55+
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
5356
}
5457

5558
test {
5659
useJUnitPlatform()
60+
testLogging {
61+
events "passed", "skipped", "failed"
62+
}
5763
}
5864

5965
sourceSets {

docker/service/src/integration-test/java/uk/nhs/adaptors/scr/uat/SetAcsUAT.java

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444

4545
@SpringBootTest
4646
@AutoConfigureMockMvc
47-
@ExtendWith({ SpringExtension.class })
47+
@ExtendWith({SpringExtension.class})
4848
@DirtiesContext
4949
@Slf4j
50-
@ContextConfiguration(initializers = { WireMockInitializer.class })
50+
@ContextConfiguration(initializers = {WireMockInitializer.class})
5151
public class SetAcsUAT {
5252
private static final String SPINE_ACS_ENDPOINT = "/sync-service";
5353
private static final String ACS_QUERY_HEADER = "urn:nhs:names:services:lrs/SET_RESOURCE_PERMISSIONS_INUK01";
@@ -87,7 +87,7 @@ public void testSetAcsPermissionViaSds(TestData testData) throws Exception {
8787
stubSdsService(practitionerRoleResponse);
8888

8989
performRequest(testData.getFhirRequest())
90-
.andExpect(status().isCreated());
90+
.andExpect(status().isCreated());
9191
}
9292

9393
@ParameterizedTest(name = "[{index}] - {0}")
@@ -97,7 +97,7 @@ public void testSetAcsPermissionViaUserInfo(TestData testData) throws Exception
9797
stubIdentityService(userInfoResponse);
9898

9999
performRequest(testData.getFhirRequest())
100-
.andExpect(status().isCreated());
100+
.andExpect(status().isCreated());
101101
}
102102

103103
@ParameterizedTest(name = "[{index}] - {0}")
@@ -107,8 +107,8 @@ public void testSetAcsPermissionSpineError(TestData testData) throws Exception {
107107
stubIdentityService(userInfoResponse);
108108

109109
performRequest(testData.getFhirRequest())
110-
.andExpect(status().isBadRequest())
111-
.andExpect(content().json(testData.getFhirResponse()));
110+
.andExpect(status().isBadRequest())
111+
.andExpect(content().json(testData.getFhirResponse()));
112112
}
113113

114114
@ParameterizedTest(name = "[{index}] - {0}")
@@ -117,8 +117,8 @@ public void testSetAcsPermissionBadRequest(TestData testData) throws Exception {
117117
stubIdentityService(userInfoResponse);
118118

119119
performRequest(testData.getFhirRequest())
120-
.andExpect(status().isBadRequest())
121-
.andExpect(content().json(testData.getFhirResponse()));
120+
.andExpect(status().isBadRequest())
121+
.andExpect(content().json(testData.getFhirResponse()));
122122
}
123123

124124
@ParameterizedTest(name = "[{index}] - {0}")
@@ -137,35 +137,34 @@ public void testSetAcsPermissionNoRoleCodeBadRequest(TestData testData) throws E
137137

138138
private ResultActions performRequest(String request) throws Exception {
139139
return mockMvc.perform(post(ACS_ENDPOINT)
140-
.contentType(APPLICATION_FHIR_JSON)
141-
.header(ScrHttpHeaders.NHSD_ASID, NHSD_ASID)
142-
.header(ScrHttpHeaders.CLIENT_IP, CLIENT_IP)
143-
.header(ScrHttpHeaders.NHSD_SESSION_URID, NHSD_SESSION_URID)
144-
.header(ScrHttpHeaders.NHSD_IDENTITY, NHSD_IDENTITY_UUID)
145-
.header(AUTHORIZATION, BEARER_TOKEN)
146-
.content(request));
140+
.contentType(APPLICATION_FHIR_JSON)
141+
.header(ScrHttpHeaders.NHSD_ASID, NHSD_ASID)
142+
.header(ScrHttpHeaders.CLIENT_IP, CLIENT_IP)
143+
.header(ScrHttpHeaders.NHSD_SESSION_URID, NHSD_SESSION_URID)
144+
.header(ScrHttpHeaders.NHSD_IDENTITY, NHSD_IDENTITY_UUID)
145+
.header(AUTHORIZATION, BEARER_TOKEN)
146+
.content(request));
147147

148148
}
149149

150150
private void stubSpineAcsEndpoint(Resource response) throws IOException {
151151
wireMockServer.stubFor(
152-
WireMock.post(SPINE_ACS_ENDPOINT)
153-
.withHeader(SOAP_ACTION, equalTo(ACS_QUERY_HEADER))
154-
.withHeader(CONTENT_TYPE, equalTo(TEXT_XML_VALUE))
155-
.willReturn(aResponse()
156-
.withStatus(OK.value())
157-
.withBody(readString(response.getFile().toPath(), UTF_8))));
152+
WireMock.post(SPINE_ACS_ENDPOINT)
153+
.withHeader(SOAP_ACTION, equalTo(ACS_QUERY_HEADER))
154+
.withHeader(CONTENT_TYPE, equalTo(TEXT_XML_VALUE))
155+
.willReturn(aResponse()
156+
.withStatus(OK.value())
157+
.withBody(readString(response.getFile().toPath(), UTF_8))));
158158
}
159159

160-
private void stubSdsService(Resource response) throws IOException {
160+
private void stubSpineAcsEndpoint(Resource response) throws IOException {
161161
wireMockServer.stubFor(
162-
WireMock.get(WireMock.urlPathEqualTo(PRACTITIONER_ROLE_ENDPOINT))
163-
.withQueryParam(USER_ID_QUERY_PARAM,
164-
containing(NHSD_SESSION_URID))
165-
.willReturn(aResponse()
166-
.withStatus(OK.value())
167-
.withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)
168-
.withBody(readString(response.getFile().toPath(), UTF_8))));
162+
WireMock.post(SPINE_ACS_ENDPOINT)
163+
.withHeader(SOAP_ACTION, equalTo(ACS_QUERY_HEADER))
164+
.withHeader(CONTENT_TYPE, equalTo(TEXT_XML_VALUE))
165+
.willReturn(aResponse()
166+
.withStatus(OK.value())
167+
.withBody(readString(response.getFile().toPath(), UTF_8))));
169168
}
170169

171170
private void stubFailedSdsService() {
@@ -181,20 +180,20 @@ private void stubFailedSdsService() {
181180

182181
private void stubIdentityService(Resource response) throws IOException {
183182
wireMockServer.stubFor(
184-
WireMock.get(USER_INFO_ENDPOINT)
185-
.withHeader(AUTHORIZATION, equalTo(BEARER_TOKEN))
186-
.willReturn(aResponse()
187-
.withStatus(OK.value())
188-
.withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)
189-
.withBody(readString(response.getFile().toPath(), UTF_8))));
183+
WireMock.get(USER_INFO_ENDPOINT)
184+
.withHeader(AUTHORIZATION, equalTo(BEARER_TOKEN))
185+
.willReturn(aResponse()
186+
.withStatus(OK.value())
187+
.withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)
188+
.withBody(readString(response.getFile().toPath(), UTF_8))));
190189
}
191190

192191
private void stubFailedIdentityService() {
193192
wireMockServer.stubFor(
194-
WireMock.get(USER_INFO_ENDPOINT)
195-
.withHeader(AUTHORIZATION, equalTo(BEARER_TOKEN))
196-
.willReturn(aResponse()
197-
.withStatus(BAD_REQUEST.value())
198-
.withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)));
193+
WireMock.get(USER_INFO_ENDPOINT)
194+
.withHeader(AUTHORIZATION, equalTo(BEARER_TOKEN))
195+
.willReturn(aResponse()
196+
.withStatus(BAD_REQUEST.value())
197+
.withHeader(CONTENT_TYPE, APPLICATION_JSON_VALUE)));
199198
}
200199
}

docker/service/src/main/java/uk/nhs/adaptors/scr/services/GetScrService.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ public Bundle getScrId(String nhsNumber, String nhsdAsid, String clientIp) {
133133
bundle.addEntry(new BundleEntryComponent()
134134
.setFullUrl(getScrUrl() + "/DocumentReference/" + documentReference.getId())
135135
.setResource(documentReference)
136-
.setSearch(new Bundle.BundleEntrySearchComponent().setMode(MATCH)));
136+
.setSearch(new Bundle.BundleEntrySearchComponent().setMode(MATCH))
137+
);
137138

138139
bundle.addEntry(new BundleEntryComponent()
139140
.setFullUrl(patient.getId())
140-
.setResource(patient));
141+
.setResource(patient)
142+
);
141143
} else {
142144
bundle.setTotal(0);
143145
}
@@ -233,8 +235,8 @@ private void checkDetectedIssues(Document document) {
233235
}
234236

235237
private DocumentReference buildDocumentReference(String nhsNumber,
236-
EventListQueryResponse response,
237-
Patient patient) {
238+
EventListQueryResponse response,
239+
Patient patient) {
238240
DocumentReference documentReference = new DocumentReference();
239241
documentReference.setId(randomUUID());
240242

@@ -246,7 +248,8 @@ private DocumentReference buildDocumentReference(String nhsNumber,
246248
documentReference.setType(GP_SUMMARY_SNOMED);
247249
documentReference.setSubject(new Reference(patient));
248250

249-
DocumentReferenceContentComponent content = buildDocumentReferenceContent(nhsNumber, response.getLatestScrId());
251+
DocumentReferenceContentComponent content =
252+
buildDocumentReferenceContent(nhsNumber, response.getLatestScrId());
250253
documentReference.addContent(content);
251254

252255
documentReference.setMasterIdentifier(new Identifier()
@@ -267,6 +270,7 @@ private DocumentReferenceContentComponent buildDocumentReferenceContent(String n
267270
return content;
268271
}
269272

273+
270274
private Patient buildPatientResource(String nhsNumber) {
271275
Patient patient = new Patient();
272276
String patientResourceId = randomUUID();
@@ -281,8 +285,7 @@ private Patient buildPatientResource(String nhsNumber) {
281285
private String prepareEventListQueryRequest(String nhsNumber, String nhsdAsid, String clientIp) {
282286
EventListQueryParams eventListQueryParams = new EventListQueryParams()
283287
.setGeneratedMessageId(MDC.get(CORRELATION_ID_MDC_KEY))
284-
.setMessageCreationTime(
285-
DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(now(ZoneId.of("Europe/London"))))
288+
.setMessageCreationTime(DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(now(ZoneId.of("Europe/London"))))
286289
.setNhsNumber(nhsNumber)
287290
.setSenderFromASID(nhsdAsid)
288291
.setSpineToASID(scrConfiguration.getNhsdAsidTo())
@@ -294,8 +297,7 @@ private String prepareEventListQueryRequest(String nhsNumber, String nhsdAsid, S
294297
private String prepareEventQueryRequest(String psisEventId, String nhsNumber, String nhsdAsid, String clientIp) {
295298
var eventListQueryParams = new EventQueryParams()
296299
.setGeneratedMessageId(MDC.get(CORRELATION_ID_MDC_KEY))
297-
.setMessageCreationTime(
298-
DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(now(ZoneId.of("Europe/London"))))
300+
.setMessageCreationTime(DateTimeFormatter.ofPattern("yyyyMMddHHmmss").format(now(ZoneId.of("Europe/London"))))
299301
.setNhsNumber(nhsNumber)
300302
.setSenderFromASID(nhsdAsid)
301303
.setSpineToASID(scrConfiguration.getNhsdAsidTo())

0 commit comments

Comments
 (0)