When calculateAverage() was called, the result computed obviously was wrong and inconsistent with the expected result from test case. After some investigation, it was discovered that the denominator i.e. number of days, was given a wrong value from getDuration() function. May consider studying the implementation of that first.
Created attachment 49 [details] Bug reproduced and located in Plan class as suggested The result after unit testing was indeed caused by the aforementioned function getDuration(). It is suspected that the fault arose from the use of Period class to calculate date difference. As discussion from online forum revealed, Period class returns date difference separately in terms of [year, month, day]. Suppose dateDifference = 93 days. Period.getDays() will return 3 days since it is [0 year, 3 months, 3 days]. Alternative method is suggested to replace such erroneous function.
After switching to DAYS.between(startDate, endDate) from ChronoUnit Class. The computation was corrected.