Things to notice in the project:
-
The UI tests in the AccountFragmentTest don't work due to mocking problems:
(E/TestRunner: java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null))
-
The tests of the
Repository
class could be better tested. -
The extension function or mapper from
AcountData
toAccount
takes a bit more than50ms
. I couldn't come up with a better solution, so I decided to go for this one. The way this mapping function works is:- From the transactions in an
AccountData
I map them to aTransaction
with abeforeBalance
andafterBalance
of 0. - Then, those transactions inside the list, they are sorted by date (the date in the
Transaction
model is aLocalDateTime
and it can easily compared and thus sorted). - And finally, I created a new extension function from a
List<Transaction>
calledmap
, which given aTransaction
from the list, an initial balance, and iterates through every transaction in the list, accumulating the initial balance in theaccumulator
property, thebalanceBefore
is assigned the value of theaccumulator
and thebalanceAfter
as the sum of theaccumulator
plus the amount of the transaction. Finally, once thebalanceBefore
andbalanceAfter
are initialized with the proper values, the current transaction is copied with the newbalanceBefore
andbalanceAfter
values.
- From the transactions in an