### Question:
CmsPsuAisController implements CmsPsuAisApi { @Override public ResponseEntity<CmsPsuAuthorisation> getAuthorisationByAuthorisationId(String authorisationId, String instanceId) { return cmsPsuAisService.getAuthorisationByAuthorisationId(authorisationId, instanceId) .map(payment -> new ResponseEntity<>(payment, HttpStatus.OK)) .orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); }  @Override ResponseEntity<Object> updatePsuDataInConsent(String consentId, String authorisationId, String instanceId, PsuIdData psuIdData); @Override ResponseEntity<Object> updateAuthorisationStatus(String consentId, String status, String authorisationId, String psuId, String psuIdType, String psuCorporateId, String psuCorporateIdType, String instanceId, AuthenticationDataHolder authenticationDataHolder); @Override ResponseEntity<Boolean> confirmConsent(String consentId, String instanceId); @Override ResponseEntity<Boolean> rejectConsent(String consentId, String instanceId); @Override ResponseEntity<List<CmsAisAccountConsent>> getConsentsForPsu(String psuId, String psuIdType, String psuCorporateId, String psuCorporateIdType, String instanceId); @Override ResponseEntity<Boolean> revokeConsent(String consentId, String instanceId); @Override ResponseEntity<Boolean> authorisePartiallyConsent(String consentId, String instanceId); @Override ResponseEntity<CmsAisConsentResponse> getConsentIdByRedirectId(String redirectId, String instanceId); @Override ResponseEntity<CmsAisAccountConsent> getConsentByConsentId(String consentId, String psuId, String psuIdType, String psuCorporateId, String psuCorporateIdType, String instanceId); @Override ResponseEntity<CmsPsuAuthorisation> getAuthorisationByAuthorisationId(String authorisationId, String instanceId); @Override ResponseEntity<Void> putAccountAccessInConsent(String consentId, CmsAisConsentAccessRequest accountAccessRequest, String instanceId); @Override ResponseEntity<List<CmsAisPsuDataAuthorisation>> psuDataAuthorisations(String consentId, String instanceId);  }### Answer:
@Test void getAuthorisationByAuthorisationId_withValidRequest_shouldReturnOk() throws Exception { String cmsPsuAuthorisationJson = jsonReader.getStringFromFile("json/ais/response/cms-psu-authorisation.json"); CmsPsuAuthorisation cmsPsuAuthorisation = jsonReader.getObjectFromString(cmsPsuAuthorisationJson, CmsPsuAuthorisation.class); when(cmsPsuAisService.getAuthorisationByAuthorisationId(AUTHORISATION_ID, INSTANCE_ID)) .thenReturn(Optional.of(cmsPsuAuthorisation)); mockMvc.perform(get("/psu-api/v1/ais/consent/authorisation/{authorisation-id}", AUTHORISATION_ID) .headers(INSTANCE_ID_HEADERS)) .andExpect(status().isOk()) .andExpect(content().json(cmsPsuAuthorisationJson)); verify(cmsPsuAisService).getAuthorisationByAuthorisationId(AUTHORISATION_ID, INSTANCE_ID); }
@Test void getAuthorisationByAuthorisationId_withEmptyServiceResponse_shouldReturnBadRequest() throws Exception { when(cmsPsuAisService.getAuthorisationByAuthorisationId(AUTHORISATION_ID, INSTANCE_ID)) .thenReturn(Optional.empty()); mockMvc.perform(get("/psu-api/v1/ais/consent/authorisation/{authorisation-id}", AUTHORISATION_ID) .headers(INSTANCE_ID_HEADERS)) .andExpect(status().isBadRequest()) .andExpect(content().bytes(EMPTY_BODY)); verify(cmsPsuAisService).getAuthorisationByAuthorisationId(AUTHORISATION_ID, INSTANCE_ID); }