Make it clear how to persist updated `AccountancyEntry`s
Closed this issue · 1 comments
martinmo commented
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.
odrotbohm commented
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 anIllegalArgumentException
(Spring'sAssert
class might be helpful here). - Add test case that tries to call
Accountancy.add(…)
with an already existingAccountancyEntry
and verify it's rejected inAccountancyTests
.