@Test @Ignore public void anOrderCanBeShipped() throws Exception { Order order = new Order("x", "y", "z"); assertEquals(false, order.isShipped()); order.ship(); assertEquals("order should be shipped", true, order.isShipped()); }
@Test @Ignore public void shippedOrdersAreNotShown() throws Exception { Order shipped = new Order("X"); Order notShipped = new Order("Y"); orders.addAll(asList(shipped, notShipped)); shipped.ship(); when(request.getMethod()).thenReturn("GET"); when(request.getRequestURI()).thenReturn("/orders"); ordersController.service(); verify(ordersView).show(asList(notShipped)); }
@Test @Ignore public void theControllerWillShipAnOrder() throws Exception { Order order = new Order("5555", "_", "_"); orders.add(order); when(request.getMethod()).thenReturn("POST"); when(request.getRequestURI()).thenReturn("/orders/shipped"); when(request.getParameter("order_code")).thenReturn("5555"); ordersController.service(); assertEquals("controller should set shipped", true, order.isShipped()); verify(ordersView).refresh(); }
@Test public void createOrder() { order = new Order(561, "customer"); final OrderItem orderItem = new OrderItem(order, "Prod", "Some product", 3, new BigDecimal("5.20")); order.getItems().add(orderItem); new Expectations() { { Database.executeInsertUpdateOrDelete( withPrefix("insert into order "), order.getNumber(), order.getCustomerId()); Database.executeInsertUpdateOrDelete( withPrefix("insert into order_item "), order.getNumber(), orderItem.getProductId(), orderItem.getProductDescription(), orderItem.getQuantity(), orderItem.getUnitPrice()); } }; new OrderRepository().create(order); }