-
Notifications
You must be signed in to change notification settings - Fork 536
Closed
Labels
Description
I was trying @retryable with Spring-data and testing it out using Mockito @MockBean but the retry for the repository is not working and it was always called only once.
@Repository
public interface TestRepository extends CrudRepository<Test, String> {
@Retryable(value = { Exception.class }, maxAttempts = 4, backoff = @Backoff(delay = 2000))
List<Test> findAll();
}
when(testRepository.findAll())
.thenThrow(new RecoverableDataAccessException("test RecoverableDataAccessException 1"))
.thenThrow(new RecoverableDataAccessException("test RecoverableDataAccessException 2"))
.thenReturn(Lists.newArrayList(test));
verify(testRepository, times(3)).findAll(any());
org.mockito.exceptions.verification.TooFewActualInvocations:
testRepository bean.findAll(<any string>);
Wanted 3 times:
-> at com.*.findAllTest(TestIT.java:10)
But was 1 time:
Referring to this Stackoverflow answer
Spring-boot: 2.3.0.RELEASE
Spring-Retry: 1.2.5.RELEASE
Spring-data: 2.3.0.RELEASE
arsulegai