@Test public void shouldMapEveryShareToADebt() throws Exception { final Expense expense = anExpense() .withDebtee(thomas) .withShares( new Share(david, amount(30)), new Share(thomas, amount(10)), new Share(lukas, amount(20)) ) .build(); final Set<Debt> debts = expense.calculateAccruingDebts(); assertThat(debts, containsInAnyOrder( debt(david, amount(30), thomas), debt(thomas, amount(10), thomas), debt(lukas, amount(20), thomas) )); }
@Override public Set<Debt> calculateAccruingDebts() { return shares .stream() .map(share -> Debt.debt(share.getDebtor(), share.getAmount(), debtee)) .collect(toSet()); }
Expense implements CashFlow { @Override public Set<Debt> calculateAccruingDebts() { return shares .stream() .map(share -> Debt.debt(share.getDebtor(), share.getAmount(), debtee)) .collect(toSet()); } }
Expense implements CashFlow { @Override public Set<Debt> calculateAccruingDebts() { return shares .stream() .map(share -> Debt.debt(share.getDebtor(), share.getAmount(), debtee)) .collect(toSet()); } 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<Debt> calculateAccruingDebts() { return shares .stream() .map(share -> Debt.debt(share.getDebtor(), share.getAmount(), debtee)) .collect(toSet()); } 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<Debt> calculateAccruingDebts() { return shares .stream() .map(share -> Debt.debt(share.getDebtor(), share.getAmount(), debtee)) .collect(toSet()); } 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();  }