### Question:
CmsAspspPiisController implements CmsAspspPiisApi { @Override public ResponseEntity<CreatePiisConsentResponse> createConsent(CreatePiisConsentRequest request, String psuId, String psuIdType, String psuCorporateId, String psuCorporateIdType, String instanceId) { PsuIdData psuIdData = getPsuIdData(psuId, psuIdType, psuCorporateId, psuCorporateIdType); return cmsAspspPiisService.createConsent(psuIdData, request, instanceId) .map(consentId -> new ResponseEntity<>(new CreatePiisConsentResponse(consentId), HttpStatus.CREATED)) .orElseGet(() -> new ResponseEntity<>(HttpStatus.BAD_REQUEST)); }  @Override ResponseEntity<CreatePiisConsentResponse> createConsent(CreatePiisConsentRequest request, String psuId,
                                                                   String psuIdType, String psuCorporateId, String psuCorporateIdType,
                                                                   String instanceId); @Override ResponseEntity<List<CmsPiisConsent>> getConsentsForPsu(String psuId, String psuIdType, String psuCorporateId, String psuCorporateIdType, String instanceId); @Override ResponseEntity<Boolean> terminateConsent(String consentId, String instanceId);  }### Answer:
@Test void createConsent_Success() throws Exception { when(cmsAspspPiisService.createConsent(psuIdData, createPiisConsentRequest, INSTANCE_ID)) .thenReturn(Optional.of(CONSENT_ID)); mockMvc.perform(post(CREATE_PIIS_CONSENT_URL) .contentType(MediaType.APPLICATION_JSON_VALUE) .headers(httpHeaders) .content(jsonReader.getStringFromFile(CREATE_PIIS_CONSENT_REQUEST_PATH))) .andExpect(status().is(HttpStatus.CREATED.value())) .andExpect(content().json(jsonReader.getStringFromFile(CREATE_PIIS_CONSENT_RESPONSE_PATH))); verify(cmsAspspPiisService, times(1)).createConsent(psuIdData, createPiisConsentRequest, INSTANCE_ID); }
@Test void createConsent_BadRequest() throws Exception { when(cmsAspspPiisService.createConsent(psuIdData, createPiisConsentRequest, INSTANCE_ID)) .thenReturn(Optional.empty()); mockMvc.perform(post(CREATE_PIIS_CONSENT_URL) .contentType(MediaType.APPLICATION_JSON_VALUE) .headers(httpHeaders) .content(jsonReader.getStringFromFile(CREATE_PIIS_CONSENT_REQUEST_PATH))) .andExpect(status().is(HttpStatus.BAD_REQUEST.value())); verify(cmsAspspPiisService, times(1)).createConsent(psuIdData, createPiisConsentRequest, INSTANCE_ID); }