From d0ad3ba87b4517d1991262bcf26492a3183140ff Mon Sep 17 00:00:00 2001 From: fdai7921 Date: Wed, 7 Feb 2024 16:18:41 +0100 Subject: [PATCH] test: addStudents method in Administration class --- .../java/org/example/AdministrationTest.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index eef7af4..6b2e3f7 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -71,6 +71,32 @@ class AdministrationTest { 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 void deleteStudents() { Student student1 = new Student("Walter White", "S123456", "Student"); @@ -140,5 +166,4 @@ class AdministrationTest { // Finding the added course assertEquals(course, admin.findCourseByID("M101")); } - } \ No newline at end of file