package com.blogspot.toomuchcoding.book.chapter3._4_CreatingPartialMock.answer.assertj; import com.blogspot.toomuchcoding.book.chapter3.common.TaxFactorProcessor; import com.blogspot.toomuchcoding.book.chapter3.common.TaxService; import com.blogspot.toomuchcoding.common.testng.MockitoTestNGListener; import com.blogspot.toomuchcoding.person.Person; import org.mockito.InjectMocks; import org.mockito.Mock; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import static org.assertj.core.api.BDDAssertions.then; import static org.mockito.Answers.CALLS_REAL_METHODS; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyDouble; import static org.mockito.Mockito.doNothing; @Listeners(MockitoTestNGListener.class) public class TaxFactorProcessorTestNgTest { @Mock(answer = CALLS_REAL_METHODS) TaxService taxService; @InjectMocks TaxFactorProcessor systemUnderTest; @Test public void should_return_default_tax_factor_for_person_from_undefined_country() { // given doNothing().when(taxService).updateTaxData(anyDouble(), any(Person.class)); // when double taxFactor = systemUnderTest.processTaxFactorFor(new Person()); // then then(taxFactor).isEqualTo(TaxService.DEFAULT_TAX_FACTOR); } }