diff --git a/helpmehelpapplication/src/test/java/ntnu/sytemutvikling/team6/models/APICharityDataTest.java b/helpmehelpapplication/src/test/java/ntnu/sytemutvikling/team6/models/APICharityDataTest.java index c863686..a015ac1 100644 --- a/helpmehelpapplication/src/test/java/ntnu/sytemutvikling/team6/models/APICharityDataTest.java +++ b/helpmehelpapplication/src/test/java/ntnu/sytemutvikling/team6/models/APICharityDataTest.java @@ -26,6 +26,39 @@ void initialParametersShouldBeCorrect() { } + @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."); + } +