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: queryService
test_class.modifier: @MockBean
  	private
test_class.original_string: @MockBean
  	private QueryService queryService;
test_class.type: QueryService
test_class.var_name: queryService
test_class.declarator: contextResolver
test_class.modifier: @Autowired
test_class.original_string: @Autowired
  	ContextResolverBasic contextResolver;
test_class.type: ContextResolverBasic
test_class.var_name: contextResolver
test_class.declarator: paramsResolver
test_class.modifier: @Autowired
test_class.original_string: @Autowired
  	ParamsResolver paramsResolver;
test_class.type: ParamsResolver
test_class.var_name: paramsResolver
test_class.declarator: entity
test_class.modifier: private
test_class.original_string: private String entity;
test_class.type: String
test_class.var_name: entity
test_class.declarator: response = ""
test_class.modifier: private
test_class.original_string: private String response = "";
test_class.type: String
test_class.var_name: response
test_class.declarator: linkHeader = "<<http://localhost:9090/ngsi-ld/contextes/urn:ngsi-ld:Vehicle:A100>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\">"
test_class.modifier: private
test_class.original_string: private String linkHeader = "<<http://localhost:9090/ngsi-ld/contextes/urn:ngsi-ld:Vehicle:A100>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\">";
test_class.type: String
test_class.var_name: linkHeader
test_class.declarator: entities
test_class.modifier: private
test_class.original_string: private List<String> entities;
test_class.type: List<String>
test_class.var_name: entities
test_class.file: Core/QueryManager/src/test/java/eu/neclab/ngsildbroker/queryhandler/controller/QueryControllerTest.java
test_class.identifier: QueryControllerTest
test_case.body: @Test
  	public void getEntityTest() throws Exception {
  		try {
  
  			ResponseEntity<Object> responseEntity = ResponseEntity.status(HttpStatus.OK).header("location",
  					"<<http://localhost:9090/ngsi-ld/contextes/urn:ngsi-ld:Vehicle:A100>; rel=\"http://www.w3.org/ns/json-ld#context\"; type=\"application/ld+json\">")
  					.body(response);
  
  			Mockito.doReturn(entity).when(queryService).retrieveEntity(any(String.class), any(List.class),
  					any(boolean.class), any(boolean.class));
  //			Mockito.doReturn(responseEntity).when(qc).generateReply(any(), any(), any());
  			QueryResult result = new QueryResult(entities, null, ErrorType.None, -1, true);
  			Mockito.doReturn(result).when(queryService).getData(any(), any(), any(), any(), any(), any(), any());
  			mockMvc.perform(get("/ngsi-ld/v1/entities/{entityId}", "urn:ngsi-ld:Vehicle:A100").accept(AppConstants.NGB_APPLICATION_JSON))
  					.andExpect(status().isOk()).andExpect(jsonPath("$.id").value("urn:ngsi-ld:Vehicle:A100"));
  //					.andExpect(redirectedUrl(linkHeader)).andDo(print());
  			verify(queryService, times(1)).getData(any(), any(), any(), any(), any(), any(), any());
  //			verify(qc, times(1)).generateReply(any(), any(), any());
  
  		} catch (Exception e) {
  			Assert.fail(e.getMessage());
  		}
  
  	}
test_case.class_method_signature: QueryControllerTest.getEntityTest()
test_case.full_signature: @Test public void getEntityTest()
test_case.identifier: getEntityTest
test_case.invocations: body header status retrieveEntity when doReturn any any any any getData when doReturn any any any any any any any andExpect andExpect perform accept get isOk status value jsonPath getData verify times any any any any any any any fail getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void getEntityTest()
focal_class.declarator: logger = LogManager.getLogger(QueryController.class)
focal_class.modifier: private final static
focal_class.original_string: private final static Logger logger = LogManager.getLogger(QueryController.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: MY_REQUEST_URL = "/ngsi-ld/v1/entities"
focal_class.modifier: private final static
focal_class.original_string: private final static String MY_REQUEST_URL = "/ngsi-ld/v1/entities";
focal_class.type: String
focal_class.var_name: MY_REQUEST_URL
focal_class.declarator: MY_REQUEST_URL_ALT = "/ngsi-ld/v1/entities/"
focal_class.modifier: private final static
focal_class.original_string: private final static String MY_REQUEST_URL_ALT = "/ngsi-ld/v1/entities/";
focal_class.type: String
focal_class.var_name: MY_REQUEST_URL_ALT
focal_class.declarator: queryService
focal_class.modifier: @Autowired
focal_class.original_string: @Autowired
  	QueryService queryService;
focal_class.type: QueryService
focal_class.var_name: queryService
focal_class.declarator: paramsResolver
focal_class.modifier: @Autowired
  	@Qualifier("qmparamsResolver")
focal_class.original_string: @Autowired
  	@Qualifier("qmparamsResolver")
  	ParamsResolver paramsResolver;
focal_class.type: ParamsResolver
focal_class.var_name: paramsResolver
focal_class.declarator: contextResolver
focal_class.modifier: @Autowired
  	@Qualifier("qmconRes")
focal_class.original_string: @Autowired
  	@Qualifier("qmconRes")
  	ContextResolverBasic contextResolver;
focal_class.type: ContextResolverBasic
focal_class.var_name: contextResolver
focal_class.declarator: atContextServerUrl
focal_class.modifier: @Value("${atcontext.url}")
focal_class.original_string: @Value("${atcontext.url}")
  	String atContextServerUrl;
focal_class.type: String
focal_class.var_name: atContextServerUrl
focal_class.declarator: defaultLimit = 50
focal_class.modifier: @Value("${defaultLimit}")
focal_class.original_string: @Value("${defaultLimit}")
  	int defaultLimit = 50;
focal_class.type: int
focal_class.var_name: defaultLimit
focal_class.declarator: maxLimit = 1000
focal_class.modifier: @Value("${maxLimit}")
focal_class.original_string: @Value("${maxLimit}")
  	int maxLimit = 1000;
focal_class.type: int
focal_class.var_name: maxLimit
focal_class.declarator: debug = false
focal_class.modifier: @Value("${ngb.debugmode}")
focal_class.original_string: @Value("${ngb.debugmode}")
  	boolean debug = false;
focal_class.type: boolean
focal_class.var_name: debug
focal_class.declarator: httpUtils
focal_class.modifier: private
focal_class.original_string: private HttpUtils httpUtils;
focal_class.type: HttpUtils
focal_class.var_name: httpUtils
focal_class.declarator: emptyResult1 = { '{', ' ', '}' }
focal_class.modifier: private final
focal_class.original_string: private final byte[] emptyResult1 = { '{', ' ', '}' };
focal_class.type: byte[]
focal_class.var_name: emptyResult1
focal_class.declarator: emptyResult2 = { '{', '}' }
focal_class.modifier: private final
focal_class.original_string: private final byte[] emptyResult2 = { '{', '}' };
focal_class.type: byte[]
focal_class.var_name: emptyResult2
focal_class.file: Core/QueryManager/src/main/java/eu/neclab/ngsildbroker/queryhandler/controller/QueryController.java
focal_class.identifier: QueryController
focal_class.class_method_signature: QueryController.setup()
focal_class.full_signature: @PostConstruct private void setup()
focal_class.identifier: setup
focal_class.modifiers: @PostConstruct private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void setup()
focal_class.class_method_signature: QueryController.getEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options)
focal_class.full_signature: @GetMapping(path = "/{entityId}") public ResponseEntity<byte[]> getEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options)
focal_class.identifier: getEntity
focal_class.modifiers: @GetMapping(path = "/{entityId}") public
focal_class.parameters: (HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> getEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options)
focal_class.class_method_signature: QueryController.getAllEntity(HttpServletRequest request,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "limit", required = false) Integer limit,
  			@RequestParam(value = "offset", required = false) Integer offset,
  			@RequestParam(value = "qtoken", required = false) String qToken,
  			@RequestParam(name = "options", required = false) List<String> options,
  			@RequestParam(name = "services", required = false) Boolean showServices)
focal_class.full_signature: @GetMapping() public ResponseEntity<byte[]> getAllEntity(HttpServletRequest request,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "limit", required = false) Integer limit,
  			@RequestParam(value = "offset", required = false) Integer offset,
  			@RequestParam(value = "qtoken", required = false) String qToken,
  			@RequestParam(name = "options", required = false) List<String> options,
  			@RequestParam(name = "services", required = false) Boolean showServices)
focal_class.identifier: getAllEntity
focal_class.modifiers: @GetMapping() public
focal_class.parameters: (HttpServletRequest request,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "limit", required = false) Integer limit,
  			@RequestParam(value = "offset", required = false) Integer offset,
  			@RequestParam(value = "qtoken", required = false) String qToken,
  			@RequestParam(name = "options", required = false) List<String> options,
  			@RequestParam(name = "services", required = false) Boolean showServices)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> getAllEntity(HttpServletRequest request,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "limit", required = false) Integer limit,
  			@RequestParam(value = "offset", required = false) Integer offset,
  			@RequestParam(value = "qtoken", required = false) String qToken,
  			@RequestParam(name = "options", required = false) List<String> options,
  			@RequestParam(name = "services", required = false) Boolean showServices)
focal_class.class_method_signature: QueryController.getQueryData(HttpServletRequest request, String originalQueryParams,
  			Map<String, String[]> paramMap, List<String> attrs, Integer limit, Integer offset, String qToken,
  			List<String> options, Boolean showServices, boolean retrieve)
focal_class.full_signature: private ResponseEntity<byte[]> getQueryData(HttpServletRequest request, String originalQueryParams,
  			Map<String, String[]> paramMap, List<String> attrs, Integer limit, Integer offset, String qToken,
  			List<String> options, Boolean showServices, boolean retrieve)
focal_class.identifier: getQueryData
focal_class.modifiers: private
focal_class.parameters: (HttpServletRequest request, String originalQueryParams,
  			Map<String, String[]> paramMap, List<String> attrs, Integer limit, Integer offset, String qToken,
  			List<String> options, Boolean showServices, boolean retrieve)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> getQueryData(HttpServletRequest request, String originalQueryParams,
  			Map<String, String[]> paramMap, List<String> attrs, Integer limit, Integer offset, String qToken,
  			List<String> options, Boolean showServices, boolean retrieve)
focal_class.class_method_signature: QueryController.checkParamsForValidity(QueryParams qp)
focal_class.full_signature: private void checkParamsForValidity(QueryParams qp)
focal_class.identifier: checkParamsForValidity
focal_class.modifiers: private
focal_class.parameters: (QueryParams qp)
focal_class.return: void
focal_class.signature: void checkParamsForValidity(QueryParams qp)
focal_class.class_method_signature: QueryController.generateReply(HttpServletRequest request, QueryResult qResult, boolean forceArray)
focal_class.full_signature: public ResponseEntity<byte[]> generateReply(HttpServletRequest request, QueryResult qResult, boolean forceArray)
focal_class.identifier: generateReply
focal_class.modifiers: public
focal_class.parameters: (HttpServletRequest request, QueryResult qResult, boolean forceArray)
focal_class.return: ResponseEntity<byte[]>
focal_class.signature: ResponseEntity<byte[]> generateReply(HttpServletRequest request, QueryResult qResult, boolean forceArray)
focal_class.class_method_signature: QueryController.generateNextLink(HttpServletRequest request, QueryResult qResult)
focal_class.full_signature: private String generateNextLink(HttpServletRequest request, QueryResult qResult)
focal_class.identifier: generateNextLink
focal_class.modifiers: private
focal_class.parameters: (HttpServletRequest request, QueryResult qResult)
focal_class.return: String
focal_class.signature: String generateNextLink(HttpServletRequest request, QueryResult qResult)
focal_class.class_method_signature: QueryController.generateFollowUpLinkHeader(HttpServletRequest request, int offset, int limit, String token,
  			String rel)
focal_class.full_signature: private String generateFollowUpLinkHeader(HttpServletRequest request, int offset, int limit, String token,
  			String rel)
focal_class.identifier: generateFollowUpLinkHeader
focal_class.modifiers: private
focal_class.parameters: (HttpServletRequest request, int offset, int limit, String token,
  			String rel)
focal_class.return: String
focal_class.signature: String generateFollowUpLinkHeader(HttpServletRequest request, int offset, int limit, String token,
  			String rel)
focal_class.class_method_signature: QueryController.generatePrevLink(HttpServletRequest request, QueryResult qResult)
focal_class.full_signature: private String generatePrevLink(HttpServletRequest request, QueryResult qResult)
focal_class.identifier: generatePrevLink
focal_class.modifiers: private
focal_class.parameters: (HttpServletRequest request, QueryResult qResult)
focal_class.return: String
focal_class.signature: String generatePrevLink(HttpServletRequest request, QueryResult qResult)
focal_method.body: @GetMapping(path = "/{entityId}")
  	public ResponseEntity<byte[]> getEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options) {
  		String originalQuery = NGSIConstants.QUERY_PARAMETER_ID + "=" + entityId;
  		HashMap<String, String[]> paramMap = new HashMap<String, String[]>();
  		paramMap.put(NGSIConstants.QUERY_PARAMETER_ID, new String[] { entityId });
  		ResponseEntity<byte[]> result = getQueryData(request, originalQuery, paramMap, attrs, null, null, null, options,
  				false, true);
  		if (Arrays.equals(emptyResult1, result.getBody()) || Arrays.equals(emptyResult2, result.getBody())) {
  			return ResponseEntity.status(HttpStatus.NOT_FOUND)
  					.body(new RestResponse(ErrorType.NotFound, "Resource not found.").toJsonBytes());
  		}
  		return result;
  		/*
  		 * String result = null; try {
  		 * logger.trace("getEntity() ::query operation by kafka ::");
  		 * 
  		 * if (!request.getParameterMap().isEmpty() && attrs == null && options == null)
  		 * { throw new ResponseException(ErrorType.InvalidRequest); }
  		 * 
  		 * boolean includeSysAttrs = (options != null &&
  		 * options.contains(NGSIConstants.QUERY_PARAMETER_OPTIONS_SYSATTRS)); boolean
  		 * keyValues = (options != null &&
  		 * options.contains(NGSIConstants.QUERY_PARAMETER_OPTIONS_KEYVALUES));
  		 * ArrayList<String> expandedAttrs = new ArrayList<String>();
  		 * 
  		 * if (attrs != null) {
  		 * 
  		 * List<Object> linkHeaders = HttpUtils.parseLinkHeader(request,
  		 * NGSIConstants.HEADER_REL_LDCONTEXT);
  		 * 
  		 * for (String attrib : attrs) { try {
  		 * expandedAttrs.add(paramsResolver.expandAttribute(attrib, linkHeaders)); }
  		 * catch (ResponseException exception) { continue; } } // TODO valid this. spec
  		 * doesn't say what to do here!!! if (expandedAttrs.isEmpty()) { return
  		 * ResponseEntity.status(HttpStatus.ACCEPTED).body("{}".getBytes()); } }
  		 * 
  		 * result = queryService.retrieveEntity(entityId, expandedAttrs, keyValues,
  		 * includeSysAttrs); if (result != "null" && !result.isEmpty()) { return
  		 * httpUtils.generateReply(request, result); } else { return
  		 * ResponseEntity.status(HttpStatus.NOT_FOUND) .body(new
  		 * RestResponse(ErrorType.NotFound, "Resource not found.").toJsonBytes()); }
  		 * 
  		 * } catch (ResponseException exception) { logger.error("Exception ::",
  		 * exception); return ResponseEntity.status(exception.getHttpStatus()).body(new
  		 * RestResponse(exception).toJsonBytes()); } catch (Exception exception) {
  		 * logger.error("Exception ::", exception); return
  		 * ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(new
  		 * RestResponse(ErrorType.InternalError, "Internal error").toJsonBytes()); }
  		 */ }
focal_method.class_method_signature: QueryController.getEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options)
focal_method.full_signature: @GetMapping(path = "/{entityId}") public ResponseEntity<byte[]> getEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options)
focal_method.identifier: getEntity
focal_method.invocations: put getQueryData equals getBody equals getBody body status toJsonBytes
focal_method.modifiers: @GetMapping(path = "/{entityId}") public
focal_method.parameters: (HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options)
focal_method.return: ResponseEntity<byte[]>
focal_method.signature: ResponseEntity<byte[]> getEntity(HttpServletRequest request, @PathVariable("entityId") String entityId,
  			@RequestParam(value = "attrs", required = false) List<String> attrs,
  			@RequestParam(value = "options", required = false) List<String> options)