### Question:
TransactionGroup extends Observable implements Observer, HasProgressCollection<TransactionGroup, Transaction> { public synchronized void add(Transaction transaction) { transactions.add(transaction); long size = transaction.getSize(); long transferred = transaction.getTransferred(); this.size += size; this.transferred += transferred; transactionSize.put(transaction, size); transactionTransferred.put(transaction, transferred); progressListener = () -> { updateMetadata(transaction); notify(transaction); }; transaction.onProgress(progressListener); setChanged(); notify(transaction); }  boolean isEmpty(); synchronized void add(Transaction transaction); int size(); synchronized void clear(); @Override double getProgress(); @Override long totalSize(); @Override long currentSize(); @Override TransactionGroup onProgress(Runnable runnable); @Override void update(Observable o, Object arg); synchronized void cancel(); @Override TransactionGroup onProgress(Consumer<Transaction> consumer); @Override long totalElements(); @Override long finishedElements(); static final long METADATA_SIZE; }### Answer:
@Test public void givenANotStartedTransaction_progressIs0() { upload1.setSize(100L); group.add(upload1); assertProgress(0.0); }
@Test public void givenAStartedTransaction_progressDependsOnTransaction() { upload1.setSize(100); group.add(upload1); upload1.setTransferred(50); assertProgress(0.5); }
@Test public void givenMultipleTransactions_progressDependsOnSize() { upload1.setSize(100); upload2.setSize(300); upload1.setTransferred(100); upload2.setTransferred(0); group.add(upload1); group.add(upload2); assertProgress(0.25); }