 1 class AccountTest {
 2
 3   @Test
 4   void withdrawalSucceeds() {
 5     AccountId accountId = new AccountId(1L);
 6     Account account = defaultAccount()
 7         .withAccountId(accountId)
 8         .withBaselineBalance (Money.of(555L))
 9         .withActivityWindow(new ActivityWindow(
10             defaultActivity()
11                 .withTargetAccount (accountId)
12                 .withMoney(Money.of(999L)).build(),
13             defaultActivity(
14                 .withTargetAccount(accountId)
15                 .withMoney(Money.of(1L)).build()))
16         .build();
17
18     AccountId randomTargetAccount = new AccountId(99L);
19     boolean success = account.withdraw(Money.of(555L), randomTargetAccount);
20
21     assertThat(success).isTrue();
22     assertThat(account
23             .getActivityWindow()
24             .getActivities())
25             .hasSize(3);
26     assertThat(account.calculateBalance() )
27             .isEqualTo(Money.of(1000L));
28   }
29 }
