Skip to content

Unit testing and others #41

Merged
merged 29 commits into from
Mar 5, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0a4721e
Added getHashPassword to PasswordHasher
robinsp Mar 3, 2026
eed6f98
Added isValidPassword to PasswordHasher
robinsp Mar 3, 2026
9b9d8ea
Added password hashing to User
robinsp Mar 3, 2026
ab2de3d
Added Junit tests to PasswordHasher
robinsp Mar 3, 2026
ab584ac
Feat: Added file (CharityTest) and repo structure for UnitTesting
Mar 3, 2026
5ed46ad
Added exeption handling in User
robinsp Mar 3, 2026
7e62703
Feat: Added UnitTest for Charity class with JavaDoc
Mar 3, 2026
1bb6914
Added Junit tests to User
robinsp Mar 3, 2026
db8bb74
Merge pull request #34 from cathrkri/feature/password-hashing
robinsp Mar 3, 2026
8a43cfa
Wrote javadoc to User
robinsp Mar 3, 2026
654e852
Merge pull request #35 from cathrkri/feature/password-hashing
robinsp Mar 3, 2026
30c5e48
Feat: Added UnitTest for CharityRegistry class
Mar 4, 2026
0baccdd
Feat: Added JavaDoc for when necessary in CharityRegistry in Test class
Mar 4, 2026
7d6fe90
Attempt Feat: DonationTest but User is fully developed
Mar 4, 2026
7fa8603
Feat: Added SettingsTest
Mar 4, 2026
d3565a3
Fix: Better naming conventions
Mar 4, 2026
9b40a55
feat: added workflow
robinsp Mar 5, 2026
4ef68e8
Fix: Simpler definisjon of Anonymous
Mar 5, 2026
b13d42d
Fix: Added FeedbackTest
Mar 5, 2026
9c68af3
Merge branch 'main' of git.ntnu.no:cathrkri/systemutviklingTeam6 into…
Mar 5, 2026
b2c1072
Merge: Clean up before merge
Mar 5, 2026
e2161b7
Merge: Merge with feat/workflow
Mar 5, 2026
40c5bed
Fix: Package Placement
Mar 5, 2026
98feae9
Fix: Package Placement
Mar 5, 2026
6c3f7eb
Fix: Fixed tests based on User being able to create their own id on c…
Mar 5, 2026
2408d90
Fix: Anonymous has correct contructor
Mar 5, 2026
3ab00df
Fixes: All current Tests are valid
Mar 5, 2026
afa366b
Feature: gitignore for better workflow
Mar 5, 2026
23110a0
Fix: Hotfixes and better Anonymous handling
Mar 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions helpmehelpapplication/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: ci

on:
push:
branches: main
pull_request:
branches: main

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribition: temurin
java-version: "25"
cache: maven
- run:
mvn -B test
2 changes: 2 additions & 0 deletions helpmehelpapplication/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
target/
6 changes: 6 additions & 0 deletions helpmehelpapplication/helpmehelpapplication.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="CheckStyle-IDEA-Module" serialisationVersion="2">
<option name="activeLocationsIds" />
</component>
</module>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ntnu.sytemutvikling.team6;

public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
Original file line number Diff line number Diff line change
@@ -1,98 +1,95 @@
/**
* This class represents a charity organization. It contains information about the charity such as its name, description, total donations, verification status, and category.
*
* This class represents a charity organization. It contains information about the charity such as
* its name, description, total donations, verification status, and category.
*
* @author Adrian Balunan
*/
package ntnu.sytemutvikling.team6.models;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.ArrayList;

abstract class Charity {
/* UUID for uniquely identifying each charity */
private UUID id;

/* Name of the charity */
private String name;

/* Description of the charity's mission and activities */
private String description;

/* Total Donations received */
private int totalDonations;

/* Is the charity verified? */
private boolean isVerified;

/* Category for the charity */
private String category;

/* List that contains the charity's Feedbacks */
private List<Feedback> feedbacks;

/**
* Konstructor for creating a new charity.
* The ID is generated automatically using UUID.
* Total donations are initialized to 0.
* The charity is unverified by default.
*
* @param name
* @param description
* @param category
*/
public Charity(String name, String description, String category) {
this.id = UUID.randomUUID();
this.name = name;
this.description = description;
this.totalDonations = 0;
this.isVerified = false;
this.feedbacks = new ArrayList<>();
this.category = category;
}

/**
* Getters for the charity's attributes.
*/
public UUID getId() {
return id;
}
public String getCategory() {
return category;
}
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public int getTotalDonations() {
return totalDonations;
}
public boolean isVerified() {
return isVerified;
}

/**
* Setter for verification status.
* This one sets the charity as verified.
*/
public void setVerified() {
this.isVerified = true;
}

/**
* Setter for verification status.
* This one sets the charity as unverified.
*/
public void setUnverified() {
this.isVerified = false;
}

/**
* Setter for total donations. This method is used to update the total donations when a new donation is made.
*/
public void setTotalDonations(int amount) {
this.totalDonations += amount;
}
public class Charity {
/* UUID for uniquely identifying each charity */
private UUID id;

/* Name of the charity */
private String name;

/* Description of the charity's mission and activities */
private String description;

/* Total Donations received */
private int totalDonations;

/* Is the charity verified? */
private boolean isVerified;

/* Category for the charity */
private String category;

/* List that contains the charity's Feedbacks */
private List<Feedback> feedbacks;

/**
* Konstructor for creating a new charity. The ID is generated automatically using UUID. Total
* donations are initialized to 0. The charity is unverified by default.
*
* @param name
* @param description
* @param category
*/
public Charity(String name, String description, String category) {
this.id = UUID.randomUUID();
this.name = name;
this.description = description;
this.totalDonations = 0;
this.isVerified = false;
this.feedbacks = new ArrayList<>();
this.category = category;
}

/** Getters for the charity's attributes. */
public UUID getId() {
return id;
}

public String getCategory() {
return category;
}

public String getName() {
return name;
}

public String getDescription() {
return description;
}

public int getTotalDonations() {
return totalDonations;
}

public boolean isVerified() {
return isVerified;
}

/** Setter for verification status. This one sets the charity as verified. */
public void setVerified() {
this.isVerified = true;
}

/** Setter for verification status. This one sets the charity as unverified. */
public void setUnverified() {
this.isVerified = false;
}

/**
* Setter for total donations. This method is used to update the total donations when a new
* donation is made.
*/
public void setTotalDonations(int amount) {
this.totalDonations += amount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,35 @@

import java.util.*;

public class CharityRegistry{
private final List<Charity> charities;
public class CharityRegistry {
private final List<Charity> charities;

public CharityRegistry(){
this.charities = new ArrayList<>();
}
public CharityRegistry() {
this.charities = new ArrayList<>();
}

public List<Charity> getAllCharities(){
return Collections.unmodifiableList(charities);
}
public List<Charity> getAllCharities() {
return Collections.unmodifiableList(charities);
}

public Optional<Charity> findCharityById(UUID charityId){
if(charityId == null){
throw new IllegalArgumentException("CharityId can not be null.");
}
return charities.stream()
.filter(charity -> charityId.equals(charity.getId()))
.findFirst();
public Optional<Charity> findCharityById(UUID charityId) {
if (charityId == null) {
throw new IllegalArgumentException("CharityId can not be null.");
}
return charities.stream().filter(charity -> charityId.equals(charity.getId())).findFirst();
}

public void addCharity(Charity charity){
if(charity == null){
throw new IllegalArgumentException("Charity can not be null.");
public void addCharity(Charity charity) {
if (charity == null) {
throw new IllegalArgumentException("Charity can not be null.");
}
charities.add(charity);
}
}

public boolean removeCharity(UUID charityId){
if(charityId == null){
throw new IllegalArgumentException("CharityId can not be null.");
}
return charities.removeIf(charity -> charityId.equals(charity.getId()));
public boolean removeCharity(UUID charityId) {
if (charityId == null) {
throw new IllegalArgumentException("CharityId can not be null.");
}
}
return charities.removeIf(charity -> charityId.equals(charity.getId()));
}
}
Loading
Loading