### Question:
TaxUpdater { public void transferTaxFor(Person person) { taxService.updateTaxFactor(person, calculateTaxFactor(1)); taxService.transferTaxFor(person); taxService.transferTaxFor(person); taxService.updateTaxFactor(person, calculateTaxFactor(2)); taxService.transferTaxFor(person); } TaxUpdater(TaxService taxService); void transferTaxFor(Person person); static final int TAX_FACTOR; }### Answer:
@Test public void should_update_tax_factor_and_transfer_tax_in_specified_order() { Person person = new Person(); systemUnderTest.transferTaxFor(person); InOrder inOrder = Mockito.inOrder(taxService); inOrder.verify(taxService).updateTaxFactor(eq(person), anyDouble()); inOrder.verify(taxService, times(2)).transferTaxFor(person); inOrder.verify(taxService).updateTaxFactor(eq(person), anyDouble()); inOrder.verify(taxService).transferTaxFor(person); }
@Test public void should_transfer_tax_in_specified_order() { Person person = new Person(); systemUnderTest.transferTaxFor(person); InOrder inOrder = Mockito.inOrder(taxService); inOrder.verify(taxService, times(2)).transferTaxFor(person); inOrder.verify(taxService).transferTaxFor(person); }
@Test public void should_update_tax_factor_and_transfer_tax_in_specified_order_with_less_calls() { Person person = new Person(); systemUnderTest.transferTaxFor(person); InOrder inOrder = Mockito.inOrder(taxService); inOrder.verify(taxService).updateTaxFactor(eq(person), anyDouble()); inOrder.verify(taxService, calls(1)).transferTaxFor(person); inOrder.verify(taxService).updateTaxFactor(eq(person), anyDouble()); inOrder.verify(taxService).transferTaxFor(person); }
@Test public void should_update_tax_factor_and_transfer_tax_in_specified_order_with_calls() { Person person = new Person(); systemUnderTest.transferTaxFor(person); InOrder inOrder = Mockito.inOrder(taxService); inOrder.verify(taxService).updateTaxFactor(eq(person), anyDouble()); inOrder.verify(taxService, calls(2)).transferTaxFor(person); inOrder.verify(taxService).updateTaxFactor(eq(person), anyDouble()); inOrder.verify(taxService).transferTaxFor(person); }