Skip to content

Commit

Permalink
Fix: DonationRegistryTest is now valid
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianBalunan committed Apr 13, 2026
1 parent b56ba38 commit 6c44e69
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public UUID getCharityId() {
return charity.getUUID();
}

public UUID getDonationID() {
return donationID;
}

public double getAmount() {
return amount;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public Optional<Donation> findDonationById(UUID donationId) {
throw new IllegalArgumentException("DonationId can not be null.");
}
return donations.stream()
.filter(donations -> donationId.equals(donations.getCharityId()))
.filter(donations -> donationId.equals(donations.getDonationID()))
.findFirst();
}

Expand All @@ -34,6 +34,6 @@ public boolean removeDonation(UUID donationId) {
if (donationId == null) {
throw new IllegalArgumentException("DonationId can not be null.");
}
return donations.removeIf(donation -> donationId.equals(donation.getCharityId()));
return donations.removeIf(donation -> donationId.equals(donation.getDonationID()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void getAllDonations_shouldReturnUnmodifiableList() {
void findDonationById_shouldReturnDonationIfFound() {
registry.addDonation(donation);

Optional<Donation> result = registry.findDonationById(donation.getCharityId());
Optional<Donation> result = registry.findDonationById(donation.getDonationID());

assertTrue(result.isPresent());
assertEquals(donation, result.get());
Expand All @@ -87,7 +87,7 @@ void findDonationById_nullId_shouldThrowException() {
void removeDonation_shouldRemoveDonation() {
registry.addDonation(donation);

boolean removed = registry.removeDonation(donation.getCharityId());
boolean removed = registry.removeDonation(donation.getDonationID());

assertTrue(removed);
assertTrue(registry.getAllDonations().isEmpty());
Expand Down

0 comments on commit 6c44e69

Please sign in to comment.