### Question:
RegistryController { @PostMapping public ResponseEntity<byte[]> registerCSource(HttpServletRequest request, @RequestBody(required = false) String payload) { try { HttpUtils.doPreflightCheck(request, payload); logger.debug("payload received :: " + payload); this.validate(payload); String resolved = httpUtils.expandPayload(request, payload, AppConstants.CSOURCE_URL_ID); logger.debug("Resolved payload::" + resolved); CSourceRegistration csourceRegistration = DataSerializer.getCSourceRegistration(resolved); logger.debug("Csource :: " + csourceRegistration); URI uri = csourceService.registerCSource(csourceRegistration); return ResponseEntity.status(HttpStatus.CREATED).header("location", AppConstants.CSOURCE_URL + uri).build(); } catch (ResponseException exception) { return ResponseEntity.status(exception.getHttpStatus()).body(new RestResponse(exception).toJsonBytes()); } catch (Exception e) { e.printStackTrace(); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new RestResponse(ErrorType.InternalError, e.getLocalizedMessage()).toJsonBytes()); } }  @GetMapping ResponseEntity<byte[]> discoverCSource(HttpServletRequest request,
			@RequestParam HashMap<String, String> queryMap); @PostMapping ResponseEntity<byte[]> registerCSource(HttpServletRequest request,
			@RequestBody(required = false) String payload); @GetMapping("{registrationId}") ResponseEntity<byte[]> getCSourceById(HttpServletRequest request,
			@PathVariable("registrationId") String registrationId); @PatchMapping("{registrationId}") ResponseEntity<byte[]> updateCSource(HttpServletRequest request,
			@PathVariable("registrationId") String registrationId, @RequestBody String payload); @DeleteMapping("{registrationId}") ResponseEntity<byte[]> deleteCSource(@PathVariable("registrationId") String registrationId);  }### Answer:
@Test public void registerCSourceTest() { try { when(csourceService.registerCSource(any())) .thenReturn(new URI("urn:ngsi-ld:ContextSourceRegistration:csr1a3458")); mockMvc.perform(post("/ngsi-ld/v1/csourceRegistrations/").contentType(AppConstants.NGB_APPLICATION_JSONLD).content(payload)) .andExpect(status().isCreated()) .andExpect(redirectedUrl("/ngsi-ld/v1/csourceRegistrations/urn:ngsi-ld:ContextSourceRegistration:csr1a3458")) .andDo(print()); verify(csourceService, times(1)).registerCSource(any()); } catch (Exception e) { Assert.fail(e.getMessage()); e.printStackTrace(); } }