CheckedDatastoreTransaction extends CheckedDatastoreReaderWriter { Response commit() throws DatastoreIOException { try { return tx.commit(); } catch (DatastoreException e) { throw new DatastoreIOException(e); } } CheckedDatastoreTransaction(CheckedDatastore datastore, Transaction tx);   }
@Test public void commit() throws DatastoreIOException { when(transaction.commit()).thenReturn(response); assertThat(sut.commit(), is(response)); verify(transaction).commit(); }
@Test public void commitShouldThrowCheckedException() throws DatastoreIOException { doThrow(CAUSE).when(transaction).commit(); exception.expect(DatastoreIOException.class); exception.expectCause(is(CAUSE)); sut.commit(); }