From d62aa243f800a8ab372ad22562f9504bf9fc1540 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 15:32:27 +0100 Subject: [PATCH 1/3] Test: deleteProfessor Test Added --- src/test/java/org/example/AdministrationTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index 26b22f9..c8b7836 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -72,4 +72,14 @@ class AdministrationTest { assertEquals(student, student2); } + @Test + void deleteProfessor() { + Administration administration = new Administration(); + Professor professor = new Professor("P1002", "Diana", "Professor"); + + administration.addProfessor(professor); + assertTrue(administration.deleteProfessor("P1002")); + assertNull(administration.findProfessorById("P1002")); + } + } \ No newline at end of file From 73a429764b45523826ba404d48fe026f66e408d0 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 15:42:20 +0100 Subject: [PATCH 2/3] Test: AddProfessor Test added --- src/test/java/org/example/AdministrationTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index c8b7836..fdff1bb 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -17,8 +17,22 @@ class AdministrationTest { Professor foundProf1 = administration.findProfessorById("P1001"); assertEquals(prof1, foundProf1); + } + + @Test + void testAddProfessor() { + Administration administration = new Administration(); + + Professor newProfessor = new Professor("P2001", "Dr. Jane Smith", "Professor"); + + administration.addProfessor(newProfessor); + Professor retrievedProfessor = administration.findProfessorById("P2001"); + assertNotNull(retrievedProfessor, "Professor should be found in the administration."); + assertEquals(newProfessor.getProfessorID(), retrievedProfessor.getProfessorID(), "The retrieved professor's ID should match the original."); + assertEquals(newProfessor.getName(), retrievedProfessor.getName(), "The retrieved professor's name should match the original."); + assertEquals(newProfessor.getRole(), retrievedProfessor.getRole(), "The retrieved professor's role should match the original."); } @Test From ba5399d67502a26cab0837e57f8ea18f004a7fd7 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 15:58:46 +0100 Subject: [PATCH 3/3] Test: AddAdmin Test added --- .../java/org/example/AdministrationTest.java | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index fdff1bb..6ec59c3 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -19,6 +19,16 @@ class AdministrationTest { } + @Test + void deleteProfessor() { + Administration administration = new Administration(); + Professor professor = new Professor("P1002", "Diana", "Professor"); + + administration.addProfessor(professor); + assertTrue(administration.deleteProfessor("P1002")); + assertNull(administration.findProfessorById("P1002")); + } + @Test void testAddProfessor() { Administration administration = new Administration(); @@ -85,15 +95,19 @@ class AdministrationTest { Student student2 = administration.findStudentById("S1001"); assertEquals(student, student2); } - @Test - void deleteProfessor() { + void addAdminTest() { Administration administration = new Administration(); - Professor professor = new Professor("P1002", "Diana", "Professor"); - administration.addProfessor(professor); - assertTrue(administration.deleteProfessor("P1002")); - assertNull(administration.findProfessorById("P1002")); + Admin admin = new Admin("Jane Doe", "A2001", "Admin"); + administration.addAdmin(admin); + Admin result = administration.findAdminById("A2001"); + + assertNotNull(result, "Admin should be found after being added."); + assertEquals("A2001", result.getId(), "The ID of the found admin should match."); + assertEquals("Jane Doe", result.getName(), "The name of the found admin should match."); } + + } \ No newline at end of file