public void save() {
    try {
      Optional<Customer> customer = customerDao.findByName(name);
      if (customer.isPresent()) {
        customerDao.update(this);
      } else {
        customerDao.save(this);
      }
    } catch (SQLException ex) {
      LOGGER.error(ex.getMessage());
    }
  }
@Test
    void shouldSaveCustomer() throws SQLException {
        when(customerDao.findByName("customer")).thenReturn(Optional.empty());

        customer.save();

        verify(customerDao, times(1)).save(customer);

        when(customerDao.findByName("customer")).thenReturn(Optional.of(customer));

        customer.save();

        verify(customerDao, times(1)).update(customer);
    }