Browse Source

test: deleteStudent method in Administration class

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

28
src/test/java/org/example/AdministrationTest.java

@ -71,6 +71,34 @@ class AdministrationTest {
assertEquals(student, student2); assertEquals(student, student2);
} }
@Test
void deleteStudents() {
Student student1 = new Student("Walter White", "S123456", "Student");
Student student2 = new Student("Jesse Pinkmann", "S789012", "Student");
// Add students to the administration
admin.addStudents(student1);
admin.addStudents(student2);
// Delete a student (student1)
boolean deleted = admin.deleteStudents("S123456");
// Check if the student is deleted successfully
assertTrue(deleted);
// Check if the student is no longer in the system
assertNull(admin.findStudentById("S123456"));
// Check if the other student (student2) still exists in the system
assertNotNull(admin.findStudentById("S789012"));
// Attempt to delete a non-existing student
boolean nonExistingStudentDeleted = admin.deleteStudents("S999999");
// Check if the deletion of non-existing student returns false
assertFalse(nonExistingStudentDeleted);
}
/** /**
* Test case for the addCourse method. * Test case for the addCourse method.
* Adds a course to the Administration instance and checks if it can be found by its ID. * Adds a course to the Administration instance and checks if it can be found by its ID.

Loading…
Cancel
Save