st-tu-dresden/salespoint

Make it clear how to persist updated `AccountancyEntry`s

Closed this issue · 1 comments

In Accountancy, the add(…) method currently has two purposes: 1) adding a new entry and 2) updating/saving an existing entry. However, the latter purpose isn't clear to Salespoint framework users, neither from the method name (i.e., something like save(…) would be better) nor from the javadoc. The AccountancyEntryRepository, which has a save(…) method, is package private.

AccountancyEntry instances are supposed to be immutable (as that's how bookkeeping works), so I guess we need to make sure we don't write any non-new entries.

  • Add check for AccountancyEntry.isNew() and reject parameter with an IllegalArgumentException (Spring's Assert class might be helpful here).
  • Add test case that tries to call Accountancy.add(…) with an already existing AccountancyEntry and verify it's rejected in AccountancyTests.