From 4b91590ea71e71ba05ed41299b10e82fc9669008 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 16:07:46 +0100 Subject: [PATCH 1/3] Test: findAdminByIdTest Test added --- src/test/java/org/example/AdministrationTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index 6ec59c3..1eb2203 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -108,6 +108,15 @@ class AdministrationTest { assertEquals("Jane Doe", result.getName(), "The name of the found admin should match."); } + @Test + void findAdminByIdTest() { + Administration administration = new Administration(); + Admin admin = new Admin("John Doe", "A2002", "Admin"); + administration.addAdmin(admin); + Admin result = administration.findAdminById("A2002"); + assertNotNull(result, "Admin should be found by ID."); + assertEquals("A2002", result.getId(), "The ID should match the one searched for."); + } } \ No newline at end of file From 1c02ddb4eef10692a94c8894f07b1a2b76cb2949 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 16:12:32 +0100 Subject: [PATCH 2/3] Test: addStudentTest Test added --- .../java/org/example/AdministrationTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index 1eb2203..9e2fe17 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -119,4 +119,20 @@ class AdministrationTest { assertEquals("A2002", result.getId(), "The ID should match the one searched for."); } + @Test + void addStudentTest() { + Administration administration = new Administration(); + Student student = new Student("Alice", "S1001", "Student"); + + // Initially, no student should be found + assertNull(administration.findStudentById("S1001")); + + // Add the student + administration.addStudents(student); + + // Now, the student should be found + assertNotNull(administration.findStudentById("S1001")); + assertEquals("Alice", administration.findStudentById("S1001").getName()); + } + } \ No newline at end of file From 84826cfa7dbc649d4e48656274267740e6dcb971 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 16:13:15 +0100 Subject: [PATCH 3/3] Test: deleteStudentTest Test added --- .../java/org/example/AdministrationTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index 9e2fe17..2f744e2 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -135,4 +135,20 @@ class AdministrationTest { assertEquals("Alice", administration.findStudentById("S1001").getName()); } + @Test + void deleteStudentTest() { + Administration administration = new Administration(); + Student student = new Student("Bob", "S1002", "Student"); + + // Add the student and verify they're added + administration.addStudents(student); + assertNotNull(administration.findStudentById("S1002")); + + // Delete the student + assertTrue(administration.deleteStudents("S1002")); + + // Verify the student is no longer found + assertNull(administration.findStudentById("S1002")); + } + } \ No newline at end of file