@Test public void givenAStartedTransaction_progressDependsOnTransaction() { upload1.setSize(100); group.add(upload1); upload1.setTransferred(50); assertProgress(0.5); }
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); }
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); } }
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); }  }
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(); }
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; }