### Question:
SubscriptionController { @RequestMapping(method = RequestMethod.PATCH, value = "/{" + NGSIConstants.QUERY_PARAMETER_ID + "}") public ResponseEntity<byte[]> updateSubscription(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id, @RequestBody String payload) { logger.trace("call updateSubscription() ::"); try { HttpUtils.doPreflightCheck(request, payload); List<Object> context = HttpUtils.getAtContext(request); String resolved = contextResolver.expand(payload, context, true, AppConstants.SUBSCRIPTIONS_URL_ID); Subscription subscription = DataSerializer.getSubscription(resolved); if (subscription.getId() == null) { subscription.setId(id); } SubscriptionRequest subscriptionRequest = new SubscriptionRequest(subscription, context); if (resolved == null || subscription == null || !id.equals(subscription.getId())) { return badRequestResponse; } manager.updateSubscription(subscriptionRequest); } catch (ResponseException e) { logger.error("Exception ::", e); return ResponseEntity.status(e.getHttpStatus()).body(new RestResponse(e).toJsonBytes()); } return ResponseEntity.noContent().build(); }  @RequestMapping(method = RequestMethod.POST) @ResponseBody ResponseEntity<byte[]> subscribeRest(HttpServletRequest request, @RequestBody String payload); @RequestMapping(method = RequestMethod.GET, value = "/") ResponseEntity<byte[]> getAllSubscriptions(HttpServletRequest request,
			@RequestParam(required = false, name = "limit", defaultValue = "0") int limit); @RequestMapping(method = RequestMethod.GET, value = "/{id}") ResponseEntity<byte[]> getSubscriptions(HttpServletRequest request,
			@PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) String id,
			@RequestParam(required = false, name = "limit", defaultValue = "0") int limit); @RequestMapping(method = RequestMethod.DELETE, value = "/{id}") ResponseEntity<byte[]> deleteSubscription(HttpServletRequest request,
			@PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id); @RequestMapping(method = RequestMethod.PATCH, value = "/{" + NGSIConstants.QUERY_PARAMETER_ID + "}") ResponseEntity<byte[]> updateSubscription(HttpServletRequest request,
			@PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
			@RequestBody String payload);  }### Answer:
@Test public void updateSubscriptionTest() { try { mockMvc.perform(patch("/ngsi-ld/v1/subscriptions/urn:ngsi-ld:Subscription:211/") .contentType(AppConstants.NGB_APPLICATION_JSON).accept(AppConstants.NGB_APPLICATION_JSONLD) .content(subscriptionEntityPayload)) .andExpect(status().isNoContent()); } catch (Exception e) { Assert.fail(); e.printStackTrace(); } }
@Test public void updateSubscriptionNotFoundTest() { try { when(subscriptionService.updateSubscription(any())). thenThrow(new ResponseException(ErrorType.NotFound)); mockMvc.perform(patch("/ngsi-ld/v1/subscriptions/urn:ngsi-ld:Subscription:211/") .contentType(AppConstants.NGB_APPLICATION_JSON).accept(AppConstants.NGB_APPLICATION_JSONLD) .content(subscriptionEntityPayload)) .andExpect(status().isNotFound()); } catch (Exception e) { Assert.fail(); e.printStackTrace(); } }