In this recipe, we will perform the verification of the interaction with a mock, but at the same time, we will ignore the stubbed methods from this verification.
For this recipe, our system under test will be a TaxTransferer
class that will transfer tax through the web service for the given person if this person is not null. It will send a statistics report regardless of the fact whether the transfer took place or not:
public class TaxTransferer { private final TaxService taxService; public TaxTransferer(TaxService taxService) { this.taxService = taxService; } public boolean transferTaxFor(Person person) { if(person != null) { taxService.transferTaxFor(person); } return taxService.sendStatisticsReport(); } }