I am migrating from mockito-all:1.9.5 to mockito-core:2.28.2, and some of the tests that were passing are now failing.
For example, this test :
@ExtendWith(CdiUnitExtension.class)
@AdditionalClasses({
    XmlMockUnmarshaller.class
})
public class FeaturesTest
    @Produces
    @Mock
    private RefService refService;
    
    @Produces
    @Mock
    private PaymentService paymentService;
    
    @BeforeEach
    public void setUp() {
        this.cacheData = new CacheData();
        this.cacheData.setDateExecution("12/12/2015");
        when(refService.isDateAvailable(anyString()).thenReturn(true);
    }
    
    @Test
    public void shouldReturnErrorIfReasonHasInvalidChars() {
        // Given
        this.cacheData.setReason("qhsdlq$98%èd");
    
        // When
        List<Error> errors = paymentService.validatePayment(this.cacheData);
    
        // Then
        assertTrue(errors.size() == 1); // test fails : errors.size() = 2;
        assertEquals(errors.get(0).getField(), "reason");
    }
}
with the method validatePayment being like :
@Inject
RefService refService;
...
public List<Error> validatePayment(CacheData cacheData) {
    ...
    if (!refService.isDateAvailable(cacheData.getExecutionDate())) {
        errors.add(new Error("executionDate"));
    }
    ...
    return errors;
}
With mockito-core, this test fails because there are 2 errors in the list, as if the configuration of the mock in the setUp is ignored.
How can I rewrite my test to make it pass ?
 
     
    