### Question:
CmsConsentController implements CmsConsentApi { @Override public ResponseEntity<Object> createConsent(@RequestBody CmsConsent request) { CmsResponse<CmsCreateConsentResponse> cmsResponse; try { cmsResponse = consentServiceEncrypted.createConsent(request); } catch (WrongChecksumException e) { return new ResponseEntity<>(CmsError.CHECKSUM_ERROR, HttpStatus.BAD_REQUEST); } if (cmsResponse.hasError()) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); } return new ResponseEntity<>(cmsResponse.getPayload(), HttpStatus.CREATED); }  @Override ResponseEntity<Object> createConsent(@RequestBody CmsConsent request); @Override ResponseEntity<CmsConsent> getConsentById(String encryptedConsentId); @Override ResponseEntity<ConsentStatusResponse> getConsentStatusById(String encryptedConsentId); @Override ResponseEntity<Object> updateConsentStatus(String encryptedConsentId, String status); @Override ResponseEntity<Void> findAndTerminateOldConsentsByNewConsentId(String encryptedConsentId); @Override ResponseEntity<Object> updateMultilevelScaRequired(String encryptedConsentId, boolean multilevelSca);  }### Answer:
@Test void createConsent_Success() throws Exception { when(consentServiceEncrypted.createConsent(any())).thenReturn(CmsResponse.<CmsCreateConsentResponse>builder() .payload(jsonReader.getObjectFromFile(CMS_CREATE_CONSENT_RESPONSE_PATH, CmsCreateConsentResponse.class)) .build()); mockMvc.perform(MockMvcRequestBuilders.post(UriComponentsBuilder.fromPath("/api/v1/consent").build().toUriString()) .contentType(MediaType.APPLICATION_JSON_VALUE) .content(jsonReader.getStringFromFile(CMS_CONSENT_PATH))) .andExpect(status().is(HttpStatus.CREATED.value())); }
@Test void createConsent_throwsChecksumError() throws Exception { when(consentServiceEncrypted.createConsent(any())).thenThrow(WrongChecksumException.class); ResultActions resultActions = mockMvc.perform(MockMvcRequestBuilders.post(UriComponentsBuilder.fromPath("/api/v1/consent").build().toUriString()) .contentType(MediaType.APPLICATION_JSON_VALUE) .content(jsonReader.getStringFromFile(CMS_CONSENT_PATH))); resultActions .andExpect(status().is(HttpStatus.BAD_REQUEST.value())) .andExpect(content().string('"' + CmsError.CHECKSUM_ERROR.toString() + '"')); }
@Test void createConsent_returnsNoContentResponse() throws Exception { when(consentServiceEncrypted.createConsent(any())).thenReturn(CmsResponse.<CmsCreateConsentResponse>builder().error(CmsError.LOGICAL_ERROR).build()); mockMvc.perform(MockMvcRequestBuilders.post(UriComponentsBuilder.fromPath("/api/v1/consent").build().toUriString()) .contentType(MediaType.APPLICATION_JSON_VALUE) .content(jsonReader.getStringFromFile(CMS_CONSENT_PATH))) .andExpect(status().is(HttpStatus.NO_CONTENT.value())); }