 1 class SendMoneyServiceTest {
 2
 5   // Pominięto deklaracje pól
 4
 5   @Test
 6   void transactionSucceeds() {
 7
 8     // Jeśli
 9     Account sourceAccount = givenSourceAccount();
10     Account targetAccount = givenTargetAccount();
11
12     givenWithdrawalWillSucceed(sourceAccount);
13     givenDepositWillSucceed(targetAccount);
14
15     Money money = Money.of(500L);
16
17     SendMoneyCommand command = new SendMoneyCommand(
18         sourceAccount.getId(),
19         targetAccount.getId(),
20         money);
21
22     // Gdy
23     boolean success = sendMoneyService.sendMoney(command);
24
25     // Wtedy
26     assertThat(success).isTrue();
27
28     AccountId sourceAccountId = sourceAccount.getId();
29     AccountId targetAccountId = targetAccount.getId();
30
31     then(sourceAccount).should().withdraw(eq(money), eq(targetAccountId));
32     then(targetAccount).should().deposit(eq(money), eq(sourceAccountId));
33     thenAccountsHaveBeenUpdated(sourceAccountId, targetAccountId) ;
34   }
35
36   // Pominięto metody pomocnicze
37 }
