PostgresConnection implements IStorageConnection { public void rollback() throws StorageException { try { connection.rollback(); } catch (SQLException e) { throw new StorageException("Error rolling back SQL transaction: ", e); } } PostgresConnection(final ConnectionOptions options); ICompiledQuery compileQuery(final IPreparedQuery preparedQuery); boolean validate(); void close(); void commit(); void rollback();  }
@Test public void MustCorrectCommitRollback() throws StorageException, SQLException { testPostgresConnection.rollback(); verify(connection).rollback(); }
@Test public void MustInCorrectRollbackConnectionWhenRollbackThrowException() throws StorageException, SQLException { doThrow(new SQLException()).when(connection).rollback(); try { testPostgresConnection.rollback(); } catch (StorageException e) { verify(connection).rollback(); return; } assertTrue("Must throw exception", false); }