Java, Unit Testing, Legacy Code, Programming, Technology.
this.paymentProcessor = paymentProcessor; } public void processOrder(Order order) { paymentProcessor.process(order); } } Now, you can easily test OrderService by injecting a mock PaymentProcessor: public class OrderServiceTest { @Test public void testProcessOrder() { PaymentProcessor mockProcessor