Skip to content

Commit

Permalink
Fix: reinlisted tests and now should be working. Coverage will be don…
Browse files Browse the repository at this point in the history
…e on a later date
  • Loading branch information
AdrianBalunan committed Mar 15, 2026
1 parent f5912d9 commit 25b8580
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ PRIMARY KEY (`UUID_Donations`),
CONSTRAINT `fk_Donations_Charities`
FOREIGN KEY (`Charities_UUID_charities`)
REFERENCES Charities (`UUID_charities`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public String getDescription() {

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

/** Setter for verification status. This one sets the charity as unverified. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public Optional<Charity> findCharityByOrgnumber(String org_number) {

public Optional<Charity> findCharityByUUID(UUID uuid) {
if (uuid == null) {
throw new IllegalArgumentException("CharityId can not be null.");
throw new IllegalArgumentException("Uuid can not be null.");
}
return charities.stream().filter(charity -> uuid.equals(charity.getOrg_number())).findFirst();
return charities.stream().filter(charity -> uuid.equals(charity.getUUID())).findFirst();
}

public void addCharity(Charity charity) {
Expand Down
34 changes: 23 additions & 11 deletions helpmehelpapplication/src/main/resources/fxml/frontPage.fxml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.Cursor?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.effect.Blend?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>

<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="900.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/17.0.12" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ntnu.systemutvikling.team6.controller.FrontpageController">
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="1200.0" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ntnu.systemutvikling.team6.controller.FrontpageController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
Expand Down Expand Up @@ -211,7 +223,7 @@
</HBox>
</children>
</StackPane>
<HBox layoutX="10.0" layoutY="10.0" prefWidth="1000.0">
<HBox prefWidth="1000.0">
<children>
<VBox prefHeight="300.0" prefWidth="150.0" style="-fx-background-color: transparent; -fx-border-color: #2F8F8B; -fx-background-radius: 10; -fx-border-radius: 10; -fx-border-width: 2;">
<HBox.margin>
Expand Down Expand Up @@ -274,7 +286,7 @@
</VBox>
<ScrollPane fitToWidth="true" prefWidth="900.0" HBox.hgrow="ALWAYS">
<content>
<FlowPane fx:id="cardsContainer" hgap="20.0" prefHeight="200.0" prefWidth="200.0" vgap="20.0">
<FlowPane fx:id="cardsContainer" hgap="20.0" vgap="20.0">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* package ntnu.systemutvikling.team6.models;
package ntnu.systemutvikling.team6.models;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -13,80 +13,89 @@
*
* @author Adrian Balunan
*/
/*

public class CharityRegistryTest {
private CharityRegistry registry;
private Charity charity;

/* Setting up variables */
/*
@BeforeEach
public void setup() {
registry = new CharityRegistry();
//charity = new Charity("Charity1", "Something Somewhere Somehow", "Cancer");
}
@Test
void testAddCharitySuccessfully() {
registry.addCharity(charity);
assertEquals(1, registry.getAllCharities().size());
assertTrue(registry.getAllCharities().contains(charity));
}
@Test
void testAddCharityNullThrowsException() {
assertThrows(IllegalArgumentException.class, () -> registry.addCharity(null));
}
@Test
void testGetAllCharitiesReturnsUnmodifiableList() {
registry.addCharity(charity);
List<Charity> charities = registry.getAllCharities();
assertThrows(UnsupportedOperationException.class, () -> charities.add(charity));
}
@Test
void testFindCharityByIdFound() {
registry.addCharity(charity);
Optional<Charity> result = registry.findCharityByUUID(charity.getUUID());
assertTrue(result.isPresent());
assertEquals(charity, result.get());
}
@Test
void testFindCharityByIdNotFound() {
Optional<Charity> result = registry.findCharityByUUID(UUID.randomUUID());
assertTrue(result.isEmpty());
}
@Test
void testFindCharityByIdNullThrowsException() {
assertThrows(IllegalArgumentException.class, () -> registry.findCharityByUUID(null));
}
@Test
void testRemoveCharitySuccessfully() {
registry.addCharity(charity);
boolean removed = registry.removeCharityUUID(charity.getUUID());
assertTrue(removed);
assertTrue(registry.getAllCharities().isEmpty());
@BeforeEach
public void setup() {
registry = new CharityRegistry();
charity = new Charity("1239813", "www.aaaa.com", "Charity1", false, "unverified");

}

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

assertEquals(1, registry.getAllCharities().size());
assertTrue(registry.getAllCharities().contains(charity));
}

@Test
void testAddCharityNullThrowsException() {
assertThrows(IllegalArgumentException.class, () -> registry.addCharity(null));
}

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

List<Charity> charities = registry.getAllCharities();
assertThrows(UnsupportedOperationException.class, () -> charities.add(charity));
}

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

Optional<Charity> result = registry.findCharityByUUID(charity.getUUID());

assertTrue(result.isPresent());
assertEquals(charity, result.get());
}
@Test
void testFindCharityByOrgNumber() {
registry.addCharity(charity);

Optional<Charity> result = registry.findCharityByOrgnumber(charity.getOrg_number());

assertTrue(result.isPresent());
assertEquals(charity, result.get());
}

@Test
void testFindCharityByIdNotFound() {
Optional<Charity> result = registry.findCharityByUUID(UUID.randomUUID());
assertTrue(result.isEmpty());
}

@Test
void testFindCharityByIdNullThrowsException() {
assertThrows(IllegalArgumentException.class, () -> registry.findCharityByUUID(null));
}

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

boolean removed = registry.removeCharityUUID(charity.getUUID());

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

@Test
void testRemoveCharityNotFound() {
boolean removed = registry.removeCharityUUID(UUID.randomUUID());
assertFalse(removed);
}

@Test
void testRemoveCharityNullThrowsException() {
assertThrows(IllegalArgumentException.class, () -> registry.removeCharity(null));
}
}

@Test
void testRemoveCharityNotFound() {
boolean removed = registry.removeCharityUUID(UUID.randomUUID());
assertFalse(removed);
}
@Test
void testRemoveCharityNullThrowsException() {
assertThrows(IllegalArgumentException.class, () -> registry.removeCharity(null));
}
}
*/
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* package ntnu.systemutvikling.team6.models;
package ntnu.systemutvikling.team6.models;

import static org.junit.jupiter.api.Assertions.*;

Expand All @@ -11,25 +11,24 @@
*
* @author Adrian Balunan
*/
/*

public class CharityTest {
private Charity charity;

@BeforeEach
public void setup() {
charity = new Charity("1212", "Charity1", "Something Somewhere Somehow", "Cancer", false, "unverified");
charity = new Charity("1239813", "www.aaaa.com", "Charity1", false, "unverified");
}

/** Getters should work: */
/*
@Test
public void testGettingIdShouldWork() {
assertInstanceOf(UUID.class, charity.getUUID());
}

@Test
public void testGettingCategoryShouldWork() {
assertEquals("Cancer", charity.getCategory());
assertEquals("", charity.getCategory());
}

@Test
Expand All @@ -39,18 +38,17 @@ public void testGettingNameShouldWork() {

@Test
public void testGettingDescriptionShouldWork() {
assertEquals("Something Somewhere Somehow", charity.getDescription());
assertEquals("Les mer her: www.aaaa.com", charity.getDescription());
}

/** Getter and setter for IsVerified should be able to switch between true and false */
/*
@Test
public void testIsVerifiedReturnsCorrectly() {
assertFalse(charity.getPreApproved());
charity.setVerified();
assertTrue(charity.getPreApproved());
charity.setUnverified();
assertFalse(charity.getPreApproved());
@Test
public void testIsVerifiedReturnsCorrectly() {
assertEquals("approved", charity.getStatus());
charity.setUnverified();
assertEquals("Veto", charity.getStatus());
charity.setVerified();
assertEquals("approved", charity.getStatus());
}
}
}
*/

0 comments on commit 25b8580

Please sign in to comment.