@Test public void getQuotes() throws Exception { when(service.getQuotes(TestConfiguration.QUOTE_SYMBOLS)).thenReturn( TestConfiguration.quotes()); mockMvc.perform( get("/v1/quotes?q=" + TestConfiguration.QUOTE_SYMBOLS).contentType( MediaType.APPLICATION_JSON)).andExpect(status().isOk()) .andExpect(jsonPath("$", hasSize(2))) .andDo(print()); }
@RequestMapping(value = "/quotes", method = RequestMethod.GET) public ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query) throws SymbolNotFoundException{ logger.debug("received Quote query for: "+ query); if (query == null) { return new ResponseEntity<List<Quote>>(new ArrayList<Quote>(), getNoCacheHeaders(), HttpStatus.OK); } List<Quote> quotes; String[] splitQuery = query.split(","); if (splitQuery.length > 1) { quotes = service.getQuotes(query); } else { quotes = new ArrayList<>(); quotes.add(service.getQuote(splitQuery[0])); } logger.info(String.format("Retrieved symbols: %s with quotes {}", query, quotes)); return new ResponseEntity<List<Quote>>(quotes, getNoCacheHeaders(), HttpStatus.OK); }
QuoteV1Controller { @RequestMapping(value = "/quotes", method = RequestMethod.GET) public ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query) throws SymbolNotFoundException{ logger.debug("received Quote query for: "+ query); if (query == null) { return new ResponseEntity<List<Quote>>(new ArrayList<Quote>(), getNoCacheHeaders(), HttpStatus.OK); } List<Quote> quotes; String[] splitQuery = query.split(","); if (splitQuery.length > 1) { quotes = service.getQuotes(query); } else { quotes = new ArrayList<>(); quotes.add(service.getQuote(splitQuery[0])); } logger.info(String.format("Retrieved symbols: %s with quotes {}", query, quotes)); return new ResponseEntity<List<Quote>>(quotes, getNoCacheHeaders(), HttpStatus.OK); } }
QuoteV1Controller { @RequestMapping(value = "/quotes", method = RequestMethod.GET) public ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query) throws SymbolNotFoundException{ logger.debug("received Quote query for: "+ query); if (query == null) { return new ResponseEntity<List<Quote>>(new ArrayList<Quote>(), getNoCacheHeaders(), HttpStatus.OK); } List<Quote> quotes; String[] splitQuery = query.split(","); if (splitQuery.length > 1) { quotes = service.getQuotes(query); } else { quotes = new ArrayList<>(); quotes.add(service.getQuote(splitQuery[0])); } logger.info(String.format("Retrieved symbols: %s with quotes {}", query, quotes)); return new ResponseEntity<List<Quote>>(quotes, getNoCacheHeaders(), HttpStatus.OK); }  }
QuoteV1Controller { @RequestMapping(value = "/quotes", method = RequestMethod.GET) public ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query) throws SymbolNotFoundException{ logger.debug("received Quote query for: "+ query); if (query == null) { return new ResponseEntity<List<Quote>>(new ArrayList<Quote>(), getNoCacheHeaders(), HttpStatus.OK); } List<Quote> quotes; String[] splitQuery = query.split(","); if (splitQuery.length > 1) { quotes = service.getQuotes(query); } else { quotes = new ArrayList<>(); quotes.add(service.getQuote(splitQuery[0])); } logger.info(String.format("Retrieved symbols: %s with quotes {}", query, quotes)); return new ResponseEntity<List<Quote>>(quotes, getNoCacheHeaders(), HttpStatus.OK); }  @RequestMapping(value = "/quotes", method = RequestMethod.GET) ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query); @RequestMapping(value = "/company/{name}", method = RequestMethod.GET) ResponseEntity<List<CompanyInfo>> getCompanies(@PathVariable("name") final String name); @ExceptionHandler({ Exception.class }) void handleException(Exception e, HttpServletResponse response); }
QuoteV1Controller { @RequestMapping(value = "/quotes", method = RequestMethod.GET) public ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query) throws SymbolNotFoundException{ logger.debug("received Quote query for: "+ query); if (query == null) { return new ResponseEntity<List<Quote>>(new ArrayList<Quote>(), getNoCacheHeaders(), HttpStatus.OK); } List<Quote> quotes; String[] splitQuery = query.split(","); if (splitQuery.length > 1) { quotes = service.getQuotes(query); } else { quotes = new ArrayList<>(); quotes.add(service.getQuote(splitQuery[0])); } logger.info(String.format("Retrieved symbols: %s with quotes {}", query, quotes)); return new ResponseEntity<List<Quote>>(quotes, getNoCacheHeaders(), HttpStatus.OK); }  @RequestMapping(value = "/quotes", method = RequestMethod.GET) ResponseEntity<List<Quote>> getQuotes(@RequestParam(value="q", required=false) String query); @RequestMapping(value = "/company/{name}", method = RequestMethod.GET) ResponseEntity<List<CompanyInfo>> getCompanies(@PathVariable("name") final String name); @ExceptionHandler({ Exception.class }) void handleException(Exception e, HttpServletResponse response);  }