Browse Source

refactoring: extracting sampleProfs in AdministrationTest file

remotes/origin/fdai7780
fdai7921 11 months ago
parent
commit
a3c4884f5e
  1. 10
      src/test/java/org/example/AdministrationTest.java

10
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.");

Loading…
Cancel
Save