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 })
5151public 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}
0 commit comments