@Test
public void runInTransactionWithRetriesShouldPropagateUserException() throws Exception {

  final Exception expectedException = new FooException();
  when(transactionFunction.apply(any())).thenThrow(expectedException);
  try {
    storage.runInTransactionWithRetries(transactionFunction);
    fail("Expected exception!");
  } catch (FooException e) {
    // Verify that we can throw a user defined checked exception type inside the transaction
    // body and catch it
    assertThat(e, is(expectedException));
  }
  verify(transactionFunction).apply(any());
}