From a3c4884f5ec4774dd0d92b0517662c8bb4048a30 Mon Sep 17 00:00:00 2001 From: fdai7921 Date: Wed, 7 Feb 2024 16:49:20 +0100 Subject: [PATCH] refactoring: extracting sampleProfs in AdministrationTest file --- src/test/java/org/example/AdministrationTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index e0f1c10..17f65b3 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -10,11 +10,13 @@ class AdministrationTest { private static final Course sampleCourse = new Course("Math", "M101", 4); private static final Student sampleStudent = new Student("Walter White", "S123456", "Student"); private static final Student sampleStudent2 = new Student("Jesse Pinkman", "S789012", "Student"); + private static final Professor sampleProf = new Professor("P1001", "Aaron Levi", "Professor"); + private static final Professor sampleProf2 = new Professor("P1002", "Diana Richter", "Professor"); // Test the findProfessorById Method @Test void findProfessorById() { - Professor prof1 = new Professor("P1001", "Aaron", "Professor"); + Professor prof1 = sampleProf; admin.addProfessor(prof1); @@ -26,7 +28,7 @@ class AdministrationTest { @Test void deleteProfessor() { Administration administration = new Administration(); - Professor professor = new Professor("P1002", "Diana", "Professor"); + Professor professor = sampleProf2; administration.addProfessor(professor); assertTrue(administration.deleteProfessor("P1002")); @@ -37,11 +39,11 @@ class AdministrationTest { void testAddProfessor() { Administration administration = new Administration(); - Professor newProfessor = new Professor("P2001", "Dr. Jane Smith", "Professor"); + Professor newProfessor = sampleProf2; administration.addProfessor(newProfessor); - Professor retrievedProfessor = administration.findProfessorById("P2001"); + Professor retrievedProfessor = administration.findProfessorById("P1002"); assertNotNull(retrievedProfessor, "Professor should be found in the administration."); assertEquals(newProfessor.getProfessorID(), retrievedProfessor.getProfessorID(), "The retrieved professor's ID should match the original.");