-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: created tests for the OrganizationRepository
- Loading branch information
Showing
2 changed files
with
57 additions
and
4 deletions.
There are no files selected for viewing
4 changes: 0 additions & 4 deletions
4
src/test/java/edu/group5/app/model/organization/OrganizationRepoTest.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
src/test/java/edu/group5/app/model/organization/OrganizationRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package edu.group5.app.model.organization; | ||
|
|
||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.*; | ||
|
|
||
| class OrganizationRepositoryTest { | ||
|
|
||
| private Map<Integer, Organization> content; | ||
| private Organization trustedOrganization1; | ||
| private Organization trustedOrganization2; | ||
| private Organization untrustedOrganization1; | ||
| private Organization untrustedOrganization2; | ||
| private OrganizationRepository repository; | ||
|
|
||
| @BeforeEach | ||
| void setUp() { | ||
| content = new HashMap<>(); | ||
|
|
||
| trustedOrganization1 = | ||
| new Organization(1, "Trusted Org1", true, "org.com", true, "description"); | ||
| trustedOrganization2 = | ||
| new Organization(2, "Trusted Org2", true, "org.com", true, "description"); | ||
| untrustedOrganization1 = | ||
| new Organization(3, "Untrusted Org1", false, "org.com", true, "description"); | ||
| untrustedOrganization2 = | ||
| new Organization(4, "Untrusted Org2", false, "org.com", true, "description"); | ||
|
|
||
| content.put(1, trustedOrganization1); | ||
| content.put(2, trustedOrganization2); | ||
| content.put(3, untrustedOrganization1); | ||
| content.put(4, untrustedOrganization2); | ||
|
|
||
| repository = new OrganizationRepository(content); | ||
| } | ||
|
|
||
| @Test | ||
| void constructor_ThrowsWhenContentIsNull() { | ||
| assertThrows(NullPointerException.class, () -> new OrganizationRepository(null)); | ||
| } | ||
|
|
||
| @Test | ||
| void getTrustedOrganizations_OnlyReturnsTrustedOrganizations() { | ||
| Map<Integer, Organization> trusted = repository.getTrustedOrganizations(); | ||
|
|
||
| assertEquals(2, trusted.size()); | ||
| assertTrue(trusted.containsKey(1)); | ||
| assertTrue(trusted.containsKey(2)); | ||
| assertFalse(trusted.containsKey(3)); | ||
| assertFalse(trusted.containsKey(4)); | ||
| assertTrue(trusted.values().stream().allMatch(Organization::trusted)); | ||
| } | ||
| } |