test_class.declarator: mockMvc
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private MockMvc mockMvc;
test_class.type: MockMvc
test_class.var_name: mockMvc
test_class.declarator: csourceSubsService
test_class.modifier: @MockBean
test_class.original_string: @MockBean
  	CSourceSubscriptionService csourceSubsService;
test_class.type: CSourceSubscriptionService
test_class.var_name: csourceSubsService
test_class.declarator: payload
test_class.modifier: private
test_class.original_string: private String payload;
test_class.type: String
test_class.var_name: payload
test_class.declarator: updatePayload
test_class.modifier: @SuppressWarnings("unused")
  	// TODO use or remove
  	private
test_class.original_string: @SuppressWarnings("unused")
  	// TODO use or remove
  	private String updatePayload;
test_class.type: String
test_class.var_name: updatePayload
test_class.file: Registry/RegistryManager/src/test/java/eu/neclab/ngsildbroker/registryhandler/controller/RegistrySubscriptionControllerTest.java
test_class.identifier: RegistrySubscriptionControllerTest
test_case.body: @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());
  			
  		}
  
  	}
test_case.class_method_signature: RegistrySubscriptionControllerTest.subscribeRestTest()
test_case.full_signature: @Test public void subscribeRestTest()
test_case.identifier: subscribeRestTest
test_case.invocations: thenReturn when subscribe any andDo andExpect andExpect perform content contentType post isCreated status redirectedUrl print subscribe verify times any printStackTrace fail getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void subscribeRestTest()
focal_class.declarator: logger = LogManager.getLogger(RegistrySubscriptionController.class)
focal_class.modifier: private final static
focal_class.original_string: private final static Logger logger = LogManager.getLogger(RegistrySubscriptionController.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: manager
focal_class.modifier: @Autowired
focal_class.original_string: @Autowired
  	CSourceSubscriptionService manager;
focal_class.type: CSourceSubscriptionService
focal_class.var_name: manager
focal_class.declarator: contextResolver
focal_class.modifier: @Autowired
  	@Qualifier("rmconRes")
focal_class.original_string: @Autowired
  	@Qualifier("rmconRes")
  	ContextResolverBasic contextResolver;
focal_class.type: ContextResolverBasic
focal_class.var_name: contextResolver
focal_class.declarator: kafkaOps
focal_class.modifier: @Autowired
  	@Qualifier("rmops")
focal_class.original_string: @Autowired
  	@Qualifier("rmops")
  	KafkaOps kafkaOps;
focal_class.type: KafkaOps
focal_class.var_name: kafkaOps
focal_class.declarator: eurekaClient
focal_class.modifier: @Autowired
focal_class.original_string: @Autowired
  	EurekaClient eurekaClient;
focal_class.type: EurekaClient
focal_class.var_name: eurekaClient
focal_class.declarator: httpUtils = HttpUtils.getInstance(contextResolver)
focal_class.original_string: HttpUtils httpUtils = HttpUtils.getInstance(contextResolver);
focal_class.type: HttpUtils
focal_class.var_name: httpUtils
focal_class.declarator: badRequest = new ResponseException(ErrorType.BadRequestData)
focal_class.original_string: ResponseException badRequest = new ResponseException(ErrorType.BadRequestData);
focal_class.type: ResponseException
focal_class.var_name: badRequest
focal_class.declarator: badRequestResponse = ResponseEntity.status(badRequest.getHttpStatus())
  			.body(new RestResponse(badRequest).toJsonBytes())
focal_class.original_string: ResponseEntity<byte[]> badRequestResponse = ResponseEntity.status(badRequest.getHttpStatus())
  			.body(new RestResponse(badRequest).toJsonBytes());
focal_class.type: ResponseEntity<byte[]>
focal_class.var_name: badRequestResponse
focal_class.file: Registry/RegistryManager/src/main/java/eu/neclab/ngsildbroker/registryhandler/controller/RegistrySubscriptionController.java
focal_class.identifier: RegistrySubscriptionController
focal_class.class_method_signature: RegistrySubscriptionController.subscribeRest(HttpServletRequest request,	@RequestBody String payload)
focal_class.full_signature: @PostMapping public ResponseEntity<byte[]> subscribeRest(HttpServletRequest request,	@RequestBody String payload)
focal_class.identifier: subscribeRest
focal_class.modifiers: @PostMapping public
focal_class.parameters: (HttpServletRequest request,	@RequestBody String payload)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> subscribeRest(HttpServletRequest request,	@RequestBody String payload)
focal_class.class_method_signature: RegistrySubscriptionController.getAllSubscriptions(HttpServletRequest request,  @RequestParam(required = false, name = "limit", defaultValue = "0") int limit)
focal_class.full_signature: @GetMapping public ResponseEntity<byte[]> getAllSubscriptions(HttpServletRequest request,  @RequestParam(required = false, name = "limit", defaultValue = "0") int limit)
focal_class.identifier: getAllSubscriptions
focal_class.modifiers: @GetMapping public
focal_class.parameters: (HttpServletRequest request,  @RequestParam(required = false, name = "limit", defaultValue = "0") int limit)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> getAllSubscriptions(HttpServletRequest request,  @RequestParam(required = false, name = "limit", defaultValue = "0") int limit)
focal_class.class_method_signature: RegistrySubscriptionController.getSubscriptions(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
  			@RequestParam(required = false, name = "limit", defaultValue = "0") int limit)
focal_class.full_signature: @GetMapping("{id}") //(method = RequestMethod.GET, value = "/{id}") public ResponseEntity<byte[]> getSubscriptions(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
  			@RequestParam(required = false, name = "limit", defaultValue = "0") int limit)
focal_class.identifier: getSubscriptions
focal_class.modifiers: @GetMapping("{id}") //(method = RequestMethod.GET, value = "/{id}") public
focal_class.parameters: (HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
  			@RequestParam(required = false, name = "limit", defaultValue = "0") int limit)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> getSubscriptions(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
  			@RequestParam(required = false, name = "limit", defaultValue = "0") int limit)
focal_class.class_method_signature: RegistrySubscriptionController.deleteSubscription(@PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id)
focal_class.full_signature: @DeleteMapping("{id}") @RequestMapping(method = RequestMethod.DELETE, value = "/{id}") public ResponseEntity<byte[]> deleteSubscription(@PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id)
focal_class.identifier: deleteSubscription
focal_class.modifiers: @DeleteMapping("{id}") @RequestMapping(method = RequestMethod.DELETE, value = "/{id}") public
focal_class.parameters: (@PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> deleteSubscription(@PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id)
focal_class.class_method_signature: RegistrySubscriptionController.updateSubscription(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
  			@RequestBody String payload)
focal_class.full_signature: @PatchMapping("{id}") public ResponseEntity<byte[]> updateSubscription(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
  			@RequestBody String payload)
focal_class.identifier: updateSubscription
focal_class.modifiers: @PatchMapping("{id}") public
focal_class.parameters: (HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
  			@RequestBody String payload)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> updateSubscription(HttpServletRequest request, @PathVariable(name = NGSIConstants.QUERY_PARAMETER_ID, required = true) URI id,
  			@RequestBody String payload)
focal_method.body: @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");
  			//no absolute url only relative url
  			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());
  		}
  	}
focal_method.class_method_signature: RegistrySubscriptionController.subscribeRest(HttpServletRequest request,	@RequestBody String payload)
focal_method.full_signature: @PostMapping public ResponseEntity<byte[]> subscribeRest(HttpServletRequest request,	@RequestBody String payload)
focal_method.identifier: subscribeRest
focal_method.invocations: trace getAtContext expand getSubscription subscribe trace body created toString getBytes toString error body status getHttpStatus toJsonBytes error body status getBytes toString getId
focal_method.modifiers: @PostMapping public
focal_method.parameters: (HttpServletRequest request,	@RequestBody String payload)
focal_method.return: ResponseEntity<byte[]>
focal_method.signature: ResponseEntity<byte[]> subscribeRest(HttpServletRequest request,	@RequestBody String payload)