@Test public void shouldReturnParticipantsOfExpense() throws Exception { final Expense expense = anExpense() .withDebtee(thomas) .withShares( randomShare(thomas), randomShare(david), randomShare(lukas) ) .build(); final Set<Person> participants = expense.getParticipants(); assertThat(participants, containsInAnyOrder(thomas, david, lukas)); }
@Override public Set<Person> getParticipants() { final Set<Person> debtors = shares.stream().map(Share::getDebtor).collect(toSet()); final HashSet<Person> copyOfDebtors = new HashSet<>(debtors); copyOfDebtors.add(debtee); return copyOfDebtors; }
Expense implements CashFlow { @Override public Set<Person> getParticipants() { final Set<Person> debtors = shares.stream().map(Share::getDebtor).collect(toSet()); final HashSet<Person> copyOfDebtors = new HashSet<>(debtors); copyOfDebtors.add(debtee); return copyOfDebtors; } }
Expense implements CashFlow { @Override public Set<Person> getParticipants() { final Set<Person> debtors = shares.stream().map(Share::getDebtor).collect(toSet()); final HashSet<Person> copyOfDebtors = new HashSet<>(debtors); copyOfDebtors.add(debtee); return copyOfDebtors; } Expense(long id, String name, String splitStrategy, Person debtee, ConversionInformation conversionInformation, Set<Share> shares, LocalDate date, Instant createdOn); private  Expense(long id, ExpenseDraft draft, ConversionInformation conversionInformation); }
Expense implements CashFlow { @Override public Set<Person> getParticipants() { final Set<Person> debtors = shares.stream().map(Share::getDebtor).collect(toSet()); final HashSet<Person> copyOfDebtors = new HashSet<>(debtors); copyOfDebtors.add(debtee); return copyOfDebtors; } Expense(long id, String name, String splitStrategy, Person debtee, ConversionInformation conversionInformation, Set<Share> shares, LocalDate date, Instant createdOn); private  Expense(long id, ExpenseDraft draft, ConversionInformation conversionInformation); static Expense fromDraft(long id, CurrencyKey nobtCurrency, ExpenseDraft draft); @Override long getId(); String getName(); String getSplitStrategy(); Person getDebtee(); Set<Share> getShares(); LocalDate getDate(); @Override Set<Debt> calculateAccruingDebts(); Instant getCreatedOn(); ConversionInformation getConversionInformation(); @Override Set<Person> getParticipants(); }
Expense implements CashFlow { @Override public Set<Person> getParticipants() { final Set<Person> debtors = shares.stream().map(Share::getDebtor).collect(toSet()); final HashSet<Person> copyOfDebtors = new HashSet<>(debtors); copyOfDebtors.add(debtee); return copyOfDebtors; } Expense(long id, String name, String splitStrategy, Person debtee, ConversionInformation conversionInformation, Set<Share> shares, LocalDate date, Instant createdOn); private  Expense(long id, ExpenseDraft draft, ConversionInformation conversionInformation); static Expense fromDraft(long id, CurrencyKey nobtCurrency, ExpenseDraft draft); @Override long getId(); String getName(); String getSplitStrategy(); Person getDebtee(); Set<Share> getShares(); LocalDate getDate(); @Override Set<Debt> calculateAccruingDebts(); Instant getCreatedOn(); ConversionInformation getConversionInformation(); @Override Set<Person> getParticipants();  }