Order { public void checkout(Cart cart, PaymentDetails paymentDetails, boolean notifyCustomer) { if (paymentDetails.paymentMethod == PaymentMethod.CreditCard) chargeCard(paymentDetails, cart); reserveInventory(cart); if (notifyCustomer) notifyCustomer(cart); }  void checkout(Cart cart, PaymentDetails paymentDetails, boolean notifyCustomer);  }
@Test public void checkoutProductsWithoutNotification() throws Exception { order.checkout(createCartWithSufficientInventory(), createPaymentDetails(), false); }
@Test(expected = OrderException.class) public void checkoutProductsWhenInsufficientInventoryWithoutNotification() throws Exception { order.checkout(createCartWithInsufficientInventory(), createPaymentDetails(), false); }
@Test(expected = OrderException.class) public void checkoutProductsWithNotification() throws Exception { order.checkout(createCartWithSufficientInventory(), createPaymentDetails(), true); }