Nobt { public void createPaymentFrom(PaymentDraft paymentDraft) { final Payment payment = Payment.fromDraft(getNextIdentifier(), currencyKey, paymentDraft); payments.add(payment); } Nobt(NobtId id, CurrencyKey currencyKey, String name, Set<Person> explicitParticipants, Set<Expense> expenses, Set<DeletedExpense> deletedExpenses, Set<Payment> payments, Instant createdOn, Optimizer optimizer); NobtId getId(); CurrencyKey getCurrencyKey(); String getName(); Optimizer getOptimizer(); Set<Expense> getExpenses(); Set<DeletedExpense> getDeletedExpenses(); Set<Payment> getPayments(); Set<Person> getParticipatingPersons(); List<Debt> getOptimizedDebts(); Instant getCreatedOn(); void createExpenseFrom(ExpenseDraft expenseDraft); void createPaymentFrom(PaymentDraft paymentDraft); void deleteExpense(long expenseId);  }
@Test public void shouldAddPaymentToTheListOfPayments() throws Exception { final Nobt nobt = aNobt().build(); final PaymentDraft paymentDraft = aPaymentDraft() .withSender(thomas) .withRecipient(david) .withAmount(amount(5)) .build(); nobt.createPaymentFrom(paymentDraft); assertThat(nobt, hasPayments( hasItem( allOf( hasSender(equalTo(thomas)), hasRecipient(equalTo(david)), hasAmount(equalTo(amount(5))) ) ) )); }
@Test public void shouldAssignIdToPayment() throws Exception { final Nobt nobt = aNobt().build(); nobt.createPaymentFrom(aPaymentDraft().build()); assertThat(nobt, hasPayments( allOf( iterableWithSize(greaterThan(0)), everyItem( PaymentMatchers.hasId(notNullValue(Long.class)) ) ) )); }