PortfolioController { @RequestMapping(value = "/portfolio", method = RequestMethod.POST) public ResponseEntity<Order> addOrder(@RequestBody final Order order) { logger.debug("Adding Order: " + order); Order savedOrder = service.addOrder(order); logger.debug("Order added: " + savedOrder); if (savedOrder != null && savedOrder.getOrderId() != null) { return new ResponseEntity<Order>(savedOrder, getNoCacheHeaders(), HttpStatus.CREATED); } else { logger.warn("Order not saved: " + order); return new ResponseEntity<Order>(savedOrder, getNoCacheHeaders(), HttpStatus.INTERNAL_SERVER_ERROR); } }  @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);  }
@Test public void addOrder() throws Exception { when(service.addOrder(ServiceTestConfiguration.order())) .thenReturn(ServiceTestConfiguration.order2()); mockMvc.perform( post("/portfolio") .contentType(MediaType.APPLICATION_JSON) .content( convertObjectToJson(ServiceTestConfiguration.order()))) .andExpect(status().isCreated()).andDo(print()); }