@Test public void getPortfolio() throws Exception { when(service.getPortfolio(ServiceTestConfiguration.USER_ID)) .thenReturn(ServiceTestConfiguration.portfolio()); mockMvc.perform( get("/portfolio/" + ServiceTestConfiguration.USER_ID) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andDo(print()) .andExpect( content().contentTypeCompatibleWith( MediaType.APPLICATION_JSON)) .andExpect( jsonPath("$.userName").value( ServiceTestConfiguration.USER_ID)) .andExpect(jsonPath("$.holdings.*").value(hasSize(1))) .andDo(print()); }
@RequestMapping(value = "/portfolio/{id}", method = RequestMethod.GET) public ResponseEntity<Portfolio> getPortfolio(@PathVariable("id") final String userId) { logger.debug("PortfolioController: Retrieving portfolio with user id:" + userId); Portfolio folio = service.getPortfolio(userId); logger.debug("PortfolioController: Retrieved portfolio:" + folio); return new ResponseEntity<Portfolio>(folio, getNoCacheHeaders(), HttpStatus.OK); }
PortfolioController { @RequestMapping(value = "/portfolio/{id}", method = RequestMethod.GET) public ResponseEntity<Portfolio> getPortfolio(@PathVariable("id") final String userId) { logger.debug("PortfolioController: Retrieving portfolio with user id:" + userId); Portfolio folio = service.getPortfolio(userId); logger.debug("PortfolioController: Retrieved portfolio:" + folio); return new ResponseEntity<Portfolio>(folio, getNoCacheHeaders(), HttpStatus.OK); } }
PortfolioController { @RequestMapping(value = "/portfolio/{id}", method = RequestMethod.GET) public ResponseEntity<Portfolio> getPortfolio(@PathVariable("id") final String userId) { logger.debug("PortfolioController: Retrieving portfolio with user id:" + userId); Portfolio folio = service.getPortfolio(userId); logger.debug("PortfolioController: Retrieved portfolio:" + folio); return new ResponseEntity<Portfolio>(folio, getNoCacheHeaders(), HttpStatus.OK); }  }
PortfolioController { @RequestMapping(value = "/portfolio/{id}", method = RequestMethod.GET) public ResponseEntity<Portfolio> getPortfolio(@PathVariable("id") final String userId) { logger.debug("PortfolioController: Retrieving portfolio with user id:" + userId); Portfolio folio = service.getPortfolio(userId); logger.debug("PortfolioController: Retrieved portfolio:" + folio); return new ResponseEntity<Portfolio>(folio, getNoCacheHeaders(), HttpStatus.OK); }  @RequestMapping(value = "/portfolio/{id}", method = RequestMethod.GET) ResponseEntity<Portfolio> getPortfolio(@PathVariable("id") final String userId); @RequestMapping(value = "/portfolio", method = RequestMethod.POST) ResponseEntity<Order> addOrder(@RequestBody final Order order); }
PortfolioController { @RequestMapping(value = "/portfolio/{id}", method = RequestMethod.GET) public ResponseEntity<Portfolio> getPortfolio(@PathVariable("id") final String userId) { logger.debug("PortfolioController: Retrieving portfolio with user id:" + userId); Portfolio folio = service.getPortfolio(userId); logger.debug("PortfolioController: Retrieved portfolio:" + folio); return new ResponseEntity<Portfolio>(folio, getNoCacheHeaders(), HttpStatus.OK); }  @RequestMapping(value = "/portfolio/{id}", method = RequestMethod.GET) ResponseEntity<Portfolio> getPortfolio(@PathVariable("id") final String userId); @RequestMapping(value = "/portfolio", method = RequestMethod.POST) ResponseEntity<Order> addOrder(@RequestBody final Order order);  }