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