Testing a Domain Entity with Unit Tests
We will start by looking at a domain entity at the center of our architecture. Let's recall the Account entity from Chapter 4, Implementing a Use Case. The state of an Account consists of a balance the account had at a certain point in the past (the baseline balance) and a list of deposits and withdrawals (activities) since then. We now want to verify that the withdraw() method works as expected:
class AccountTest {
  @Test
  void withdrawalSucceeds() {
    AccountId accountId = new AccountId(1L);
    Account account = defaultAccount()
        .withAccountId(accountId)
        .withBaselineBalance(Money.of(555L))
        .withActivityWindow(new ActivityWindow(
            defaultActivity()
     ...