Skip to content

Commit

Permalink
feat: added tests to Organization classes
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheaGjerde committed Mar 24, 2026
1 parent 27aff0f commit 33484e3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void getTrustedOrganizations_OnlyReturnsTrustedOrganizations() {
@Test
void testFindByOrgNumberReturnsOrganization() {
assertEquals(new Organization(1, "Trusted Org1", true,
"org.com", true, "Information about Trusted Org1"),
"org.com", true, "Information about Trusted Org1", null),
repository.findByOrgNumber(1));
}

Expand All @@ -93,7 +93,7 @@ void testFindByOrgNumberIfOrgNumberNotFound() {
@Test
void testFindByOrgNameReturnsOrganization() {
assertEquals(new Organization(1, "Trusted Org1", true,
"org.com", true, "Information about Trusted Org1"),
"org.com", true, "Information about Trusted Org1", null),
repository.findByOrgName("Trusted Org1"));
}

Expand All @@ -116,7 +116,7 @@ void testFindByOrgNameIfNameNotFound() {
@Test
void testFindByOrgNameIsCaseInsensitive() {
assertEquals(new Organization(1, "Trusted Org1", true,
"org.com", true, "Information about Trusted Org1"),
"org.com", true, "Information about Trusted Org1", null),
repository.findByOrgName("trusted org1"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,19 @@ void testFindByOrgName() {
assertEquals(1, org.orgNumber());
assertEquals("Misjonsalliansen", org.name());
}

@Test
void fetchLogoUrlReturnsNullWhenUrlIsNull() {
assertNull(service.fetchLogoUrl(null));
}
@Test
void fetchLogoUrlReturnsNullWhenUrlIsBlank() {
assertNull(service.fetchLogoUrl(""));
}
@Test
void fetchLogoUrlCachesResultOnSecondCall() {
String result1 = service.fetchLogoUrl("https://");
String result2 = service.fetchLogoUrl("https://");
assertEquals(result1, result2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ void constructor_CreatesAnOrganizationWhenInputIsValid() {
true,
"org.com",
true,
"Org description"
"Org description",
null
);

assertAll(
Expand All @@ -35,7 +36,8 @@ void constructor_ThrowsWhenOrgNumberIsNegative() {
true,
"org.com",
true,
"Org description"
"Org description",
null
));
}

Expand All @@ -47,7 +49,8 @@ void constructor_ThrowsWhenNameIsNull() {
true,
"org.com",
true,
"Org description"
"Org description",
null
));
}

Expand All @@ -59,7 +62,8 @@ void constructor_ThrowsWhenNameIsBlank() {
true,
"org.com",
true,
"Org description"
"Org description",
null
));
}

Expand All @@ -71,7 +75,8 @@ void constructor_ThrowsWhenWebsiteURLIsNull() {
true,
null,
true,
"Org description"
"Org description",
null
));
}

Expand All @@ -83,7 +88,8 @@ void constructor_ThrowsWhenWebsiteURLIsBlank() {
true,
"",
true,
"Org description"
"Org description",
null
));
}

Expand All @@ -95,6 +101,20 @@ void constructor_ThrowsWhenDescriptionIsNull() {
true,
"org.com",
true,
null,
null
));
}

@Test
void constructor_AcceptsNullLogoUrl() {
assertDoesNotThrow(() -> new Organization(
1,
"Org",
true,
"org.com",
true,
"description",
null
));
}
Expand Down

0 comments on commit 33484e3

Please sign in to comment.