Browse Source

Finalizing documentation and simplify admin object handling in AdministrationTest file

remotes/origin/fdai7780
fdai7921 11 months ago
parent
commit
90d518e61e
  1. 29
      src/test/java/org/example/AdministrationTest.java

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

@ -61,33 +61,34 @@ class AdministrationTest {
assertEquals(false, test03);
}
/**
* Test method for {@link Administration#deleteAdmin(String)}.
* Verifies the functionality of deleting an admin from the system.
*/
@Test
void deleteAdmin() {
// Create an instance of Administration
Administration administration = new Administration();
// Create some sample admins
Admin admin1 = new Admin("Saul Goodman", "A123456", "Admin");
Admin admin2 = new Admin("Mike Unknown", "A789012", "Admin");
// Add admins to the administration
administration.addAdmin(admin1);
administration.addAdmin(admin2);
admin.addAdmin(admin1);
admin.addAdmin(admin2);
// Attempt to delete an admin (admin1)
boolean deleted = administration.deleteAdmin("A123456");
boolean deleted = admin.deleteAdmin("A123456");
// Check if the admin is deleted successfully
assertTrue(deleted);
// Check if the admin is no longer in the system
assertNull(administration.findAdminById("A123456"));
assertNull(admin.findAdminById("A123456"));
// Check if the other admin (admin2) still exists in the system
assertNotNull(administration.findAdminById("A789012"));
assertNotNull(admin.findAdminById("A789012"));
// Attempt to delete a non-existing admin
boolean nonExistingAdminDeleted = administration.deleteAdmin("A999999");
boolean nonExistingAdminDeleted = admin.deleteAdmin("A999999");
// Check if the deletion of non-existing admin returns false
assertFalse(nonExistingAdminDeleted);
@ -104,10 +105,12 @@ class AdministrationTest {
assertEquals(student, student2);
}
/**
* Test method for {@link Administration#addStudents(Student)}.
* Verifies the functionality of adding a student to the system.
*/
@Test
void addStudents() {
Administration admin = new Administration();
// Creating a sample student
Student student = new Student("Walter White", "S123456", "Student");
@ -130,6 +133,10 @@ class AdministrationTest {
assertEquals("Student", retrievedStudent.getRole());
}
/**
* Test method for {@link Administration#deleteStudents(String)}.
* Verifies the functionality of deleting a student from the system.
*/
@Test
void deleteStudents() {
Student student1 = new Student("Walter White", "S123456", "Student");

Loading…
Cancel
Save