From a723cedda1b6f61891a73c4bb0f0d9b7fcc7ff11 Mon Sep 17 00:00:00 2001 From: Roar Date: Wed, 4 Mar 2026 21:01:39 +0100 Subject: [PATCH] Updated APICharityDataTest Added tests for new logic regarding org_number. --- .../team6/models/APICharityDataTest.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) 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."); + } +