From 73a429764b45523826ba404d48fe026f66e408d0 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 15:42:20 +0100 Subject: [PATCH] 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