### Question:
CmsPsuPisController implements CmsPsuPisApi { @Override public ResponseEntity<CmsPsuAuthorisation> getAuthorisationByAuthorisationId(String authorisationId, String instanceId) { return cmsPsuPisService.getAuthorisationByAuthorisationId(authorisationId, instanceId) .map(payment -> new ResponseEntity<>(payment, HttpStatus.OK)) .orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); }  @Override ResponseEntity<Object> updatePsuInPayment(String authorisationId, String instanceId, PsuIdData psuIdData); @Override ResponseEntity<Object> getPaymentIdByRedirectId(String redirectId, String instanceId); @Override ResponseEntity<CmsPayment> getPaymentByPaymentId(String psuId, String psuIdType, String psuCorporateId, String psuCorporateIdType, String paymentId, String instanceId); @Override ResponseEntity<Object> getPaymentIdByRedirectIdForCancellation(String redirectId, String instanceId); @Override ResponseEntity<CmsPayment> getPaymentByPaymentIdForCancellation(String psuId, String psuIdType, String psuCorporateId, String psuCorporateIdType, String paymentId, String instanceId); @Override ResponseEntity<CmsPsuAuthorisation> getAuthorisationByAuthorisationId(String authorisationId, String instanceId); @Override ResponseEntity<Object> updateAuthorisationStatus(String psuId, String psuIdType, String psuCorporateId, String psuCorporateIdType, String paymentId, String authorisationId, String status, String instanceId, AuthenticationDataHolder authenticationDataHolder); @Override ResponseEntity<Void> updatePaymentStatus(String paymentId, String status, String instanceId); @Override ResponseEntity<List<CmsPisPsuDataAuthorisation>> psuAuthorisationStatuses(String paymentId, String instanceId);  }### Answer:
@Test void getAuthorisationByAuthorisationId_withValidRequest_shouldReturnAuthorisation() throws Exception { String cmsPsuAuthorisationJson = jsonReader.getStringFromFile("json/pis/response/cms-psu-authorisation.json"); CmsPsuAuthorisation cmsPsuAuthorisation = jsonReader.getObjectFromString(cmsPsuAuthorisationJson, CmsPsuAuthorisation.class); when(cmsPsuPisService.getAuthorisationByAuthorisationId(AUTHORISATION_ID, INSTANCE_ID)) .thenReturn(Optional.of(cmsPsuAuthorisation)); mockMvc.perform(get("/psu-api/v1/payment/authorisation/{authorisation-id}", AUTHORISATION_ID) .headers(INSTANCE_ID_HEADERS)) .andExpect(status().isOk()) .andExpect(content().json(cmsPsuAuthorisationJson)); }
@Test void getAuthorisationByAuthorisationId_withEmptyServiceResponse_shouldReturnBadRequest() throws Exception { when(cmsPsuPisService.getAuthorisationByAuthorisationId(AUTHORISATION_ID, INSTANCE_ID)) .thenReturn(Optional.empty()); mockMvc.perform(get("/psu-api/v1/payment/authorisation/{authorisation-id}", AUTHORISATION_ID) .headers(INSTANCE_ID_HEADERS)) .andExpect(status().isBadRequest()) .andExpect(content().bytes(EMPTY_BODY)); verify(cmsPsuPisService).getAuthorisationByAuthorisationId(AUTHORISATION_ID, INSTANCE_ID); }