public void buyProduct(Product product) {
    LOGGER.info(
        String.format(
            "%s want to buy %s($%.2f)...",
            name, product.getName(), product.getSalePrice().getAmount()));
    try {
      withdraw(product.getSalePrice());
    } catch (IllegalArgumentException ex) {
      LOGGER.error(ex.getMessage());
      return;
    }
    try {
      customerDao.addProduct(product, this);
      purchases.add(product);
      LOGGER.info(String.format("%s bought %s!", name, product.getName()));
    } catch (SQLException exception) {
      receiveMoney(product.getSalePrice());
      LOGGER.error(exception.getMessage());
    }
  }
@Test
    void shouldAddProductToPurchases() {
        product.setPrice(Money.of(USD, 200.0));

        customer.buyProduct(product);

        assertEquals(customer.getPurchases(), new ArrayList<>());
        assertEquals(customer.getMoney(), Money.of(USD,100));

        product.setPrice(Money.of(USD, 100.0));

        customer.buyProduct(product);

        assertEquals(new ArrayList<>(Arrays.asList(product)), customer.getPurchases());
        assertEquals(Money.zero(USD), customer.getMoney());
    }