Skip to content

Commit

Permalink
Updated CharityRegistryTest
Browse files Browse the repository at this point in the history
100% coverage.
  • Loading branch information
roaraf committed Apr 23, 2026
1 parent 7f109f0 commit ed164d1
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ void testFindCharityByOrgNumber() {
assertEquals(charity, result.get());
}

@Test
void testFindCharityByOrgNumberNullThrowsException() {
registry.addCharity(charity);

assertThrows(
IllegalArgumentException.class,
() -> registry.findCharityByOrgnumber(null));
}

@Test
void testFindCharityByIdNotFound() {
Optional<Charity> result = registry.findCharityByUUID(UUID.randomUUID());
Expand All @@ -87,6 +96,16 @@ void testRemoveCharitySuccessfully() {
assertTrue(registry.getAllCharities().isEmpty());
}

@Test
void testRemoveCharitySuccessfullyOrgNumber() {
registry.addCharity(charity);

boolean removed = registry.removeCharity(charity.getOrg_number());

assertTrue(removed);
assertTrue(registry.getAllCharities().isEmpty());
}

@Test
void testRemoveCharityNotFound() {
boolean removed = registry.removeCharityUUID(UUID.randomUUID());
Expand All @@ -97,4 +116,11 @@ void testRemoveCharityNotFound() {
void testRemoveCharityNullThrowsException() {
assertThrows(IllegalArgumentException.class, () -> registry.removeCharity(null));
}

@Test
void testRemoveCharityUUIDNullThrowsException() {
UUID uuid = null;
assertThrows(IllegalArgumentException.class, () -> registry.removeCharityUUID(uuid));

}
}

0 comments on commit ed164d1

Please sign in to comment.