Beyond Mock Objects - The Code Whisperer

You can apply the same idea on your Service. Your service for example can have tow methods, one with no date parameter and another with a date parameter. You can test the one with the date parameter. Your controller will then call the methods without parameter.

RecentOpenOrdersController {
....OrderService orderService;

....handleRequest() {
............orderService.getRecentOpenOrders();
....}
}

OrderService {

....getRecentOpenOrders() {
............this.getRecentOpenOrdersOrderedBefore(now());
....}

....getRecentOpenOrdersOrderedBefore(Date instant) {
............// the method easy to test
....}

}

It's not as generic as for the controller. But the idea is the same : Extract what you *can't* test (nothing more) and test the rest.