Skip to content

Commit

Permalink
Merge pull request #211 from marcus-ny/branch-fix-dashboard-data-asse…
Browse files Browse the repository at this point in the history
…rtions

Fix incorrect assertions in DashboardData
  • Loading branch information
Joseph31416 authored Apr 14, 2024
2 parents 36c639e + 8c48cbe commit 5d7907f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
11 changes: 3 additions & 8 deletions src/main/java/seedu/address/model/analytics/DashboardData.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
* - Earliest return date
*/
public class DashboardData {
private Analytics analytics;
private BigDecimal maxLoanValue;
private Date earliestReturnDate;
private final Analytics analytics;
private final BigDecimal maxLoanValue;
private final Date earliestReturnDate;

/**
* Creates a DashboardData object with the given analytics, max loan value and earliest return date
Expand All @@ -31,13 +31,8 @@ public class DashboardData {
*/
public DashboardData(Analytics analytics, BigDecimal maxLoanValue, Date earliestReturnDate) {
requireNonNull(analytics);
requireNonNull(maxLoanValue);
this.analytics = analytics;
this.maxLoanValue = maxLoanValue;
// Should never be over the current date since overdue loans are not included
if (earliestReturnDate.before(new Date())) {
throw new IllegalArgumentException("Earliest return date should be in the future");
}
this.earliestReturnDate = earliestReturnDate;
}

Expand Down
10 changes: 0 additions & 10 deletions src/test/java/seedu/address/model/analytics/DashboardDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ public void constructor_null_throwsNullPointerException() {
new BigDecimal("100"), new Date()));
}

@Test
public void constructor_overdueReturnDate_throwsIllegalArgumentException() {
Analytics analytics = Analytics.getAnalytics(new UniqueLoanList().asUnmodifiableObservableList());
// Earliest return date in whole database is earlier than now
// Loan is overdue and should not be considered
Date oneDayBeforeNow = new Date(new Date().getTime() - 86400000);
assertThrows(IllegalArgumentException.class, () -> new DashboardData(analytics,
new BigDecimal("100"), oneDayBeforeNow));
}

@Test
public void urgencyTest() {
Date oneWeekAfterNow = new Date(new Date().getTime() + 604800000);
Expand Down

0 comments on commit 5d7907f

Please sign in to comment.