OnlineOrder extends Order { public void checkout() { if (paymentProcessor.chargeCard(paymentDetails, cart)) { reservationService.reserveInventory(cart); notificationService.notifyCustomer(cart); } super.checkout(); } OnlineOrder(Cart cart, PaymentDetails paymentDetails, PaymentProcessor paymentProcessor, NotificationService notificationService, ReservationService reservationService); void checkout();  }
@Test public void checkoutOnlineOrder() { Cart cart = createCart(); PaymentDetails paymentDetails = createPaymentDetails(); Order order = new OnlineOrder(cart, paymentDetails, setupPaymentProcessor(), setupNotificationService(), setupReservationService()); order.checkout(); InOrder inOrder = inOrder(paymentProcessor, reservationService, notificationService); inOrder.verify(paymentProcessor, times(1)).chargeCard(paymentDetails, cart); inOrder.verify(reservationService, times(1)).reserveInventory(cart); inOrder.verify(reservationService, never()).isOnStock(anyString(), anyInt()); inOrder.verify(notificationService, times(1)).notifyCustomer(cart); }