@Ignore @Test public void testCreateDb() { { Item item = new Item(); item.setName("Java in 21 days"); item.setDescription("EBook"); item.setPrice(500); itemService.save(item); } { Item item = new Item(); item.setName("Java cup"); item.setDescription("Coffee cup"); item.setPrice(100); itemService.save(item); } { Item item = new Item(); item.setName("Java t-shirt"); item.setDescription("T-shirts for all Java programmers"); item.setPrice(500); itemService.save(item); } { Item item = new Item(); item.setName("Professional Java consulting"); item.setDescription("per manhour"); item.setPrice(1000); itemService.save(item); } { Item item = new Item(); item.setName("Professional Java training"); item.setDescription("per manday"); item.setPrice(13000); itemService.save(item); } { UserOrder userOrder = new UserOrder(); userOrder.setName("Michal Knihomol"); userOrder.setCity("Praha"); userOrder.setOrderDate(new Date()); userOrder.setStreet("Knihovni 1"); userOrder.setZip("110 00"); userOrderService.save(userOrder); OrderedItem orderedItem = new OrderedItem(); orderedItem.setItem(itemService.findOne(1)); orderedItem.setUserOrder(userOrder); orderedItem.setQuantity(5); orderedItemService.save(orderedItem); } }
@RequestMapping(params = "id") public String showOne(Model model, @RequestParam int id) { model.addAttribute("item", itemService.findOne(id)); return "item"; }
@RequestMapping public String showAll(Model model) { model.addAttribute("items", itemService.findAll()); return "items"; }