Browse Source

test: addStudents method in Administration class

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

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

@ -71,6 +71,32 @@ class AdministrationTest {
assertEquals(student, student2); assertEquals(student, student2);
} }
@Test
void addStudents() {
Administration admin = new Administration();
// Creating a sample student
Student student = new Student("Walter White", "S123456", "Student");
// Adding the student to the system
admin.addStudents(student);
// Retrieving the added student by ID
Student retrievedStudent = admin.findStudentById("S123456");
// Asserting that the retrieved student is not null
assertNotNull(retrievedStudent);
// Asserting that the retrieved student's name matches the expected name
assertEquals("Walter White", retrievedStudent.getName());
// Asserting that the retrieved student's ID matches the expected ID
assertEquals("S123456", retrievedStudent.getId());
// Asserting that the retrieved student's role matches the expected role
assertEquals("Student", retrievedStudent.getRole());
}
@Test @Test
void deleteStudents() { void deleteStudents() {
Student student1 = new Student("Walter White", "S123456", "Student"); Student student1 = new Student("Walter White", "S123456", "Student");
@ -140,5 +166,4 @@ class AdministrationTest {
// Finding the added course // Finding the added course
assertEquals(course, admin.findCourseByID("M101")); assertEquals(course, admin.findCourseByID("M101"));
} }
} }
Loading…
Cancel
Save