I've often had the problem that when checking for a working retry mechanism (btw. spring-retry works great) I wanted to first throw an exception and then return a value or whatever else is necessary.
Easy peasy, I thought. Just create an Answer and hold state within the answer i.e. a boolean that gets set to true after it has been called:
@Test
public void queryIsRetried() {
final Answer
And of course there is a much easier way, stupid me:
@Test
public void queryIsRetried() {
when(lexdbJdbcTemplate.query(anyString(), any(RowMapper.class)))
.thenThrow(new RuntimeException())
.thenReturn(null);
underTest.query("SELECT 1;");
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment