Browse Source

test: deleteAdmin method in Administration class

remotes/origin/fdai7780
fdai7921 11 months ago
parent
commit
946c76220d
  1. 33
      src/test/java/org/example/AdministrationTest.java

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

@ -60,6 +60,39 @@ class AdministrationTest {
assertEquals(false, test02); assertEquals(false, test02);
assertEquals(false, test03); assertEquals(false, test03);
} }
@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);
// Attempt to delete an admin (admin1)
boolean deleted = administration.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"));
// Check if the other admin (admin2) still exists in the system
assertNotNull(administration.findAdminById("A789012"));
// Attempt to delete a non-existing admin
boolean nonExistingAdminDeleted = administration.deleteAdmin("A999999");
// Check if the deletion of non-existing admin returns false
assertFalse(nonExistingAdminDeleted);
}
@org.junit.jupiter.api.Test @org.junit.jupiter.api.Test
void findStudentById(){ void findStudentById(){

Loading…
Cancel
Save