### Question:
EntityController { @PostMapping public ResponseEntity<byte[]> createEntity(HttpServletRequest request, @RequestBody(required = false) String payload) { String result = null; try { HttpUtils.doPreflightCheck(request, payload); logger.trace("create entity :: started"); String resolved = httpUtils.expandPayload(request, payload, AppConstants.ENTITIES_URL_ID); result = entityService.createMessage(resolved); logger.trace("create entity :: completed"); return ResponseEntity.status(HttpStatus.CREATED).header("location", AppConstants.ENTITES_URL + result) .build(); } catch (ResponseException exception) { logger.error("Exception :: ", exception); exception.printStackTrace(); return ResponseEntity.status(exception.getHttpStatus()).body(new RestResponse(exception).toJsonBytes()); } catch(DateTimeParseException exception) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(new RestResponse(ErrorType.BadRequestData, "Failed to parse provided datetime field.").toJsonBytes()); } catch(JsonParseException exception) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(new RestResponse(ErrorType.BadRequestData, "There is an error in the provided json document").toJsonBytes()); } catch (Exception exception) { logger.error("Exception :: ", exception); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new RestResponse(ErrorType.InternalError, exception.getLocalizedMessage()).toJsonBytes()); } } @Autowired  EntityController(EntityProducerChannel producerChannel);  EntityController(); @PostMapping ResponseEntity<byte[]> createEntity(HttpServletRequest request,
			@RequestBody(required = false) String payload); @PatchMapping("/{entityId}/attrs") ResponseEntity<byte[]> updateEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
			@RequestBody String payload); @PostMapping("/{entityId}/attrs") ResponseEntity<byte[]> appendEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
			@RequestBody String payload, @RequestParam(required = false, name = "options") String options); @PatchMapping("/{entityId}/attrs/{attrId}") ResponseEntity<byte[]> partialUpdateEntity(HttpServletRequest request,
			@PathVariable("entityId") String entityId, @PathVariable("attrId") String attrId,
			@RequestBody String payload); @DeleteMapping("/{entityId}/attrs/{attrId}") ResponseEntity<byte[]> deleteAttribute(HttpServletRequest request, @PathVariable("entityId") String entityId,
			@PathVariable("attrId") String attrId,@RequestParam(value = "datasetId", required = false) String datasetId,
			@RequestParam(value = "deleteAll", required = false) String deleteAll); @DeleteMapping("/{entityId}") ResponseEntity<byte[]> deleteEntity(@PathVariable("entityId") String entityId);  }### Answer:
@Test public void createEntityTest() { try { when(entityService.createMessage(any())).thenReturn("urn:ngsi-ld:Vehicle:A101"); mockMvc.perform(post("/ngsi-ld/v1/entities/").contentType(AppConstants.NGB_APPLICATION_JSON) .accept(AppConstants.NGB_APPLICATION_JSONLD).content(entityPayload)).andExpect(status().isCreated()) .andExpect(redirectedUrl("/ngsi-ld/v1/entities/urn:ngsi-ld:Vehicle:A101")); verify(entityService, times(1)).createMessage(any()); } catch (Exception e) { Assert.fail(); e.printStackTrace(); } }