### Question:
RegistrySubscriptionController { @PostMapping public ResponseEntity<byte[]> subscribeRest(HttpServletRequest request, @RequestBody String payload) throws ResponseException { logger.trace("subscribeRest() :: started"); Subscription subscription; List<Object> context = HttpUtils.getAtContext(request); String resolved = contextResolver.expand(payload, context, true, AppConstants.CSOURCE_URL_ID); subscription = DataSerializer.getSubscription(resolved); if (resolved == null || subscription == null) { return badRequestResponse; } try { SubscriptionRequest subscriptionRequest = new SubscriptionRequest(subscription, context); URI subId = manager.subscribe(subscriptionRequest); logger.trace("subscribeRest() :: completed"); return ResponseEntity.created(new URI("/ngsi-ld/v1/csourceSubscriptions/" + subId.toString())).body(subId.toString().getBytes()); } catch (ResponseException e) { logger.error("Exception ::",e); return ResponseEntity.status(e.getHttpStatus()).body(new RestResponse(e).toJsonBytes()); } catch (URISyntaxException e) { logger.error("Exception ::",e); return ResponseEntity.status(HttpStatus.CONFLICT).body(subscription.getId().toString().getBytes()); } }  @PostMapping ResponseEntity<byte[]> subscribeRest(HttpServletRequest request,	@RequestBody String payload); @GetMapping ResponseEntity<byte[]> getAllSubscriptions(HttpServletRequest request,  @RequestParam(required = false, name = "limit", defaultValue = "0") int limit); @GetMapping("{id}") //(method = RequestMethod.GET, value = "/{id}") ResponseEntity<byte[]> getSubscriptions(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
			@RequestParam(required = false, name = "limit", defaultValue = "0") int limit); @DeleteMapping("{id}") @RequestMapping(method = RequestMethod.DELETE, value = "/{id}") ResponseEntity<byte[]> deleteSubscription(@PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id); @PatchMapping("{id}") ResponseEntity<byte[]> updateSubscription(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
			@RequestBody String payload);  }### Answer:
@Test public void subscribeRestTest() { try { when(csourceSubsService.subscribe(any())).thenReturn(new URI("urn:ngsi-ld:Subscription:7")); mockMvc.perform(post("/ngsi-ld/v1/csourceSubscriptions/").contentType(AppConstants.NGB_APPLICATION_JSONLD) .content(payload)).andExpect(status().isCreated()) .andExpect(redirectedUrl("/ngsi-ld/v1/csourceSubscriptions/urn:ngsi-ld:Subscription:7")).andDo(print()); verify(csourceSubsService, times(1)).subscribe(any()); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }