Skip to content

Commit

Permalink
Merge branch 'feat/organizationRepo' into feat/organisation
Browse files Browse the repository at this point in the history
  • Loading branch information
emilfa authored Mar 3, 2026
2 parents 81a0a43 + 662c4ce commit f97f5ee
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 27 deletions.
24 changes: 2 additions & 22 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- main
- release/*
workflow_dispatch: # Allows manual triggering of the workflow


Expand Down Expand Up @@ -33,16 +34,6 @@ jobs:
java-version: '25'
- name: Run Tests
run: mvn clean test
- name: Upload Test Results
uses: actions/upload-artifact@v3
with:
name: surefire-reports
path: target/surefire-reports/
- name: Upload Coverage Report
uses: actions/upload-artifact@v3
with:
name: jacoco-report
path: target/jacoco/coverage-reports/jacoco.xml

package:
name: Package
Expand All @@ -62,15 +53,4 @@ jobs:
name: packaged-app
path: target/Help-Me-Help-1.0-SNAPSHOT-jar-with-dependencies.jar

deployPages:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '25'

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.war
*.ear
*.nar
target/

##############################
## Maven
Expand Down Expand Up @@ -37,3 +38,8 @@ out/
##############################
*.db
*.DS_Store

##############################
## VSCode
##############################
.vscode/
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-crypto -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>7.0.2</version>
</dependency>
</dependencies>

<build>
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/edu/group5/app/model/Repository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package edu.group5.app.model;

import java.util.Map;

/**
* Represents a repository
*/
public abstract class Repository<K, V> {
protected final Map<K, V> content;

public Repository(Map<K, V> content) {
this.content = content;
}

/**
* Gets the content of the repo
* @return content of the repo
*/
public Map<K, V> getContent() {
return content;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package edu.group5.app.model.organization;

import edu.group5.app.model.Repository;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
* Handles the business logic associated with organizations
*/
public class OrganizationRepository extends Repository<Integer, Organization> {
/**
* Creates a new Organization Repository
*
* @param content holds all current organizations in the repository; must not be null
* @throws NullPointerException if content is null
*/
public OrganizationRepository(Map<Integer, Organization> content) {
super(Objects.requireNonNull(content, "content cannot be null"));
}

/**
* Gets all trusted organizations in the repository
* @return all organizations with trusted = true
*/
public Map<Integer, Organization> getTrustedOrganizations() {
Map<Integer, Organization> trustedOrganizations = new HashMap<>();

content.forEach((orgNr, org) -> {
if (org.trusted()) {
trustedOrganizations.put(orgNr, org);
}
});

return trustedOrganizations;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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 OrganizationRepository repository;

@BeforeEach
void setUp() {
Map<Integer, Organization> content = new HashMap<>();

Organization trustedOrganization1 = new Organization(1, "Trusted Org1", true, "org.com", true, "description");
Organization trustedOrganization2 = new Organization(2, "Trusted Org2", true, "org.com", true, "description");
Organization untrustedOrganization1 = new Organization(3, "Untrusted Org1", false, "org.com", true, "description");
Organization 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));
}
}
Binary file removed target/classes/edu/group5/app/App.class
Binary file not shown.
Binary file removed target/classes/edu/group5/app/control/Wrapper.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed target/classes/edu/group5/app/model/user/User.class
Binary file not shown.
Binary file removed target/classes/edu/group5/app/utils/Utilities.class
Binary file not shown.
Binary file removed target/classes/edu/group5/app/view/View.class
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file removed target/test-classes/edu/group5/app/AppTest.class
Binary file not shown.

0 comments on commit f97f5ee

Please sign in to comment.