@Test public void shouldRemoveInstancesOnlyOnce() throws Exception { final Remove sut = new Remove( debt(thomas, amount(2.5), simon) ); final ArrayList<Debt> existingTransactions = new ArrayList<>( Arrays.asList( debt(thomas, amount(2.5), simon), debt(thomas, amount(2.5), simon) ) ); sut.applyTo(existingTransactions); assertThat(existingTransactions, allOf( iterableWithSize(1), hasItem( debt(thomas, amount(2.5), simon) ) )); }
@Override public void applyTo(Collection<Debt> existingDebts) { for (Debt debtToBeRemoved : debtsToBeRemoved) { existingDebts.remove(debtToBeRemoved); } }
Remove implements CombinationResult { @Override public void applyTo(Collection<Debt> existingDebts) { for (Debt debtToBeRemoved : debtsToBeRemoved) { existingDebts.remove(debtToBeRemoved); } } }
Remove implements CombinationResult { @Override public void applyTo(Collection<Debt> existingDebts) { for (Debt debtToBeRemoved : debtsToBeRemoved) { existingDebts.remove(debtToBeRemoved); } } Remove(Debt... debtsToBeRemoved); }
Remove implements CombinationResult { @Override public void applyTo(Collection<Debt> existingDebts) { for (Debt debtToBeRemoved : debtsToBeRemoved) { existingDebts.remove(debtToBeRemoved); } } Remove(Debt... debtsToBeRemoved); @Override boolean hasChanges(); @Override void applyTo(Collection<Debt> existingDebts); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
Remove implements CombinationResult { @Override public void applyTo(Collection<Debt> existingDebts) { for (Debt debtToBeRemoved : debtsToBeRemoved) { existingDebts.remove(debtToBeRemoved); } } Remove(Debt... debtsToBeRemoved); @Override boolean hasChanges(); @Override void applyTo(Collection<Debt> existingDebts); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }