From 326fd032bb85c8f0963af4353240e29862b982f1 Mon Sep 17 00:00:00 2001 From: Tobias Herbert Date: Tue, 6 Feb 2024 22:13:54 +0100 Subject: [PATCH 1/2] Add AdministrationTest Class and added test for findProfessorByID Method --- .../java/org/example/AdministrationTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/java/org/example/AdministrationTest.java diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java new file mode 100644 index 0000000..3b78a4a --- /dev/null +++ b/src/test/java/org/example/AdministrationTest.java @@ -0,0 +1,22 @@ +package org.example; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class AdministrationTest { + + @Test + void findProfessorById() { + Administration administration = new Administration(); + Professor prof1 = new Professor("P1001", "Aaron", "Professor"); + + administration.addProfessor(prof1); + + Professor foundProf1 = administration.findProfessorById("P1001"); + assertEquals(prof1, foundProf1); + + + + } +} \ No newline at end of file From d2146298c6b10e7b6ff72b54d6d09c0d9a60b32a Mon Sep 17 00:00:00 2001 From: Tobias Herbert Date: Tue, 6 Feb 2024 22:16:13 +0100 Subject: [PATCH 2/2] documentation: AdministrationTest and AdminTest --- src/test/java/org/example/AdminTest.java | 6 +++--- src/test/java/org/example/AdministrationTest.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/example/AdminTest.java b/src/test/java/org/example/AdminTest.java index e8fa2fa..a863a79 100644 --- a/src/test/java/org/example/AdminTest.java +++ b/src/test/java/org/example/AdminTest.java @@ -10,7 +10,7 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.*; class AdminTest { - + //Tests printAdminInfo Method @org.junit.jupiter.api.Test void printAdminInfo() { Admin admin = new Admin("Aaron", "A1001", "Admin"); @@ -27,7 +27,7 @@ class AdminTest { assertTrue(printedOutput.contains("Admin")); } - + //Tests writeToFile Method @Test void writeToFile() throws IOException { Admin admin = new Admin("Simon", "A1001", "Admin") ; @@ -43,7 +43,7 @@ class AdminTest { Files.delete(path); } - + //Tests readFromFile Method @Test void readFromFile() throws IOException { diff --git a/src/test/java/org/example/AdministrationTest.java b/src/test/java/org/example/AdministrationTest.java index 3b78a4a..8edf5c7 100644 --- a/src/test/java/org/example/AdministrationTest.java +++ b/src/test/java/org/example/AdministrationTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.*; class AdministrationTest { + // Test the findProfessorById Method @Test void findProfessorById() { Administration administration = new Administration();