diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/Main.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/Main.java index e06a045..ead8b5c 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/Main.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/Main.java @@ -2,6 +2,7 @@ public class Main { + // Make sure you're connected to the NTNU network for this to work public static void main(String[] args) { HmHApplication.main(args); } diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/database/DatabaseConnection.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/database/DatabaseConnection.java index 018d229..1222288 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/database/DatabaseConnection.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/database/DatabaseConnection.java @@ -24,17 +24,6 @@ public DatabaseConnection() { this.username = "apbaluna"; this.password = "GYntUFPG"; - if (this.databaseURL == null || this.databaseURL.isBlank()) { - throw new IllegalStateException("Database environment variable URL has not been set"); - } - - if (this.username == null || this.username.isBlank()) { - throw new IllegalStateException("Username environment variable has not been set"); - } - - if (this.password == null || this.password.isBlank()) { - throw new IllegalStateException("Password environment variable has not been set"); - } } /** diff --git a/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/APICharityDataTest.java b/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/APICharityDataTest.java deleted file mode 100644 index fde6784..0000000 --- a/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/APICharityDataTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package ntnu.systemutvikling.team6.models; - -import org.junit.jupiter.api.Test; - -import ntnu.systemutvikling.team6.scraper.APICharityData; - -import static org.junit.jupiter.api.Assertions.*; - -class APICharityDataTest { - - @Test - void initialParametersShouldBeCorrect() { - APICharityData charity = new APICharityData( - "938419264", "Misjonsalliansen", "approved", - "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", false - ); - - assertEquals("938419264", charity.getOrg_number(), - "Org_number parameter of APICharityData should be correct."); - assertEquals("Misjonsalliansen", charity.getName(), - "Name parameter of APICharityData should be correct."); - assertEquals("approved", charity.getStatus(), - "Status parameter of APICharityData should be correct."); - assertEquals("https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", - charity.getUrl(), "Url parameter of APICharityData should be correct."); - assertFalse(charity.getIs_pre_approved(), "Is_pre_approved parameter of APICharityData should " + - "be correct."); - - } - - @Test - void org_numberWhiteSpaceShouldBeremoved() { - String org_number = "938 4192 64"; - APICharityData charity = new APICharityData( - org_number, "Misjonsalliansen", "approved", - "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", false - ); - - assertEquals(org_number.replaceAll("\\s",""), charity.getOrg_number(), - "Org_number should not contain whitespace."); - } - - @Test - void nullOrg_numberShouldThrowIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, () -> new APICharityData(null, "Misjonsalliansen", - "approved", "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", - false), "Null org_number should not be allowed."); - } - - @Test - void blankOrg_numberShouldThrowIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, () -> new APICharityData(" ", "Misjonsalliansen", - "approved", "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", - false), "Blank org_number should not be allowed."); - } - - @Test - void emptyOrg_numberShouldThrowIllegalArgumentException() { - assertThrows(IllegalArgumentException.class, () -> new APICharityData("", "Misjonsalliansen", - "approved", "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", - false), "Null org_number should not be allowed."); - } - - - - -} \ No newline at end of file diff --git a/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/OrganizationTest.java b/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/OrganizationTest.java deleted file mode 100644 index c713667..0000000 --- a/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/models/OrganizationTest.java +++ /dev/null @@ -1,26 +0,0 @@ -/* package ntnu.systemutvikling.team6.models; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -class OrganizationTest { - - @Test - void initialParametersShouldBeCorrect() { - String name = "Hjelpesenter"; - String telephone = "123456789"; - String location = "London"; - String status = "Approved"; - - var org = new Organization(name, telephone, location, status); - - assertEquals(name, org.getName(), "Name parameter should be correct."); - assertEquals(telephone, org.getTelephone(), "Telephone parameter should be correct."); - assertEquals(location, org.getLocation(), "Location parameter should be correct."); - assertEquals(status, org.getStatus(), "Status parameter should be correct."); - } - -} - -*/ \ No newline at end of file diff --git a/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/scraper/APICharityDataTest.java b/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/scraper/APICharityDataTest.java new file mode 100644 index 0000000..cd90feb --- /dev/null +++ b/helpmehelpapplication/src/test/java/ntnu/systemutvikling/team6/scraper/APICharityDataTest.java @@ -0,0 +1,96 @@ +package ntnu.systemutvikling.team6.scraper; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class APICharityDataTest { + + @Test + void initialParametersShouldBeCorrect() { + APICharityData charity = + new APICharityData( + "938419264", + "Misjonsalliansen", + "approved", + "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", + false); + + assertEquals( + "938419264", + charity.getOrg_number(), + "Org_number parameter of APICharityData should be correct."); + assertEquals( + "Misjonsalliansen", + charity.getName(), + "Name parameter of APICharityData should be correct."); + assertEquals( + "approved", charity.getStatus(), "Status parameter of APICharityData should be correct."); + assertEquals( + "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", + charity.getUrl(), + "Url parameter of APICharityData should be correct."); + assertFalse( + charity.getIs_pre_approved(), + "Is_pre_approved parameter of APICharityData should " + "be correct."); + } + + @Test + void org_numberWhiteSpaceShouldBeremoved() { + String org_number = "938 4192 64"; + APICharityData charity = + new APICharityData( + org_number, + "Misjonsalliansen", + "approved", + "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", + false); + + assertEquals( + org_number.replaceAll("\\s", ""), + charity.getOrg_number(), + "Org_number should not contain whitespace."); + } + + @Test + void nullOrg_numberShouldThrowIllegalArgumentException() { + assertThrows( + IllegalArgumentException.class, + () -> + new APICharityData( + null, + "Misjonsalliansen", + "approved", + "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", + false), + "Null org_number should not be allowed."); + } + + @Test + void blankOrg_numberShouldThrowIllegalArgumentException() { + assertThrows( + IllegalArgumentException.class, + () -> + new APICharityData( + " ", + "Misjonsalliansen", + "approved", + "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", + false), + "Blank org_number should not be allowed."); + } + + @Test + void emptyOrg_numberShouldThrowIllegalArgumentException() { + assertThrows( + IllegalArgumentException.class, + () -> + new APICharityData( + "", + "Misjonsalliansen", + "approved", + "https://www.innsamlingskontrollen.no/organisasjoner/misjonsalliansen/", + false), + "Null org_number should not be allowed."); + } +}