diff --git a/.gradle/8.14/checksums/checksums.lock b/.gradle/8.14/checksums/checksums.lock index d7e7c606..11da43c9 100644 Binary files a/.gradle/8.14/checksums/checksums.lock and b/.gradle/8.14/checksums/checksums.lock differ diff --git a/.gradle/8.14/checksums/md5-checksums.bin b/.gradle/8.14/checksums/md5-checksums.bin index d18866f8..4a50efda 100644 Binary files a/.gradle/8.14/checksums/md5-checksums.bin and b/.gradle/8.14/checksums/md5-checksums.bin differ diff --git a/.gradle/8.14/checksums/sha1-checksums.bin b/.gradle/8.14/checksums/sha1-checksums.bin index 4f2514b4..4b7ac0b0 100644 Binary files a/.gradle/8.14/checksums/sha1-checksums.bin and b/.gradle/8.14/checksums/sha1-checksums.bin differ diff --git a/.gradle/8.14/executionHistory/executionHistory.bin b/.gradle/8.14/executionHistory/executionHistory.bin index 1822e65e..a4fe63d6 100644 Binary files a/.gradle/8.14/executionHistory/executionHistory.bin and b/.gradle/8.14/executionHistory/executionHistory.bin differ diff --git a/.gradle/8.14/executionHistory/executionHistory.lock b/.gradle/8.14/executionHistory/executionHistory.lock index 7ce4ac52..06029f9a 100644 Binary files a/.gradle/8.14/executionHistory/executionHistory.lock and b/.gradle/8.14/executionHistory/executionHistory.lock differ diff --git a/.gradle/8.14/fileHashes/fileHashes.bin b/.gradle/8.14/fileHashes/fileHashes.bin index e5f38381..701d2de4 100644 Binary files a/.gradle/8.14/fileHashes/fileHashes.bin and b/.gradle/8.14/fileHashes/fileHashes.bin differ diff --git a/.gradle/8.14/fileHashes/fileHashes.lock b/.gradle/8.14/fileHashes/fileHashes.lock index f44e5128..abe2b18e 100644 Binary files a/.gradle/8.14/fileHashes/fileHashes.lock and b/.gradle/8.14/fileHashes/fileHashes.lock differ diff --git a/.gradle/8.14/fileHashes/resourceHashesCache.bin b/.gradle/8.14/fileHashes/resourceHashesCache.bin index 77cc7861..2b554be4 100644 Binary files a/.gradle/8.14/fileHashes/resourceHashesCache.bin and b/.gradle/8.14/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index ec28e392..aae586f5 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/.gradle/file-system.probe b/.gradle/file-system.probe index c1eb5ca4..8809f1bd 100644 Binary files a/.gradle/file-system.probe and b/.gradle/file-system.probe differ diff --git a/build/classes/java/main/hhn/temp/project/AssignmentManager.class b/build/classes/java/main/hhn/temp/project/AssignmentManager.class index 4749de0a..02dca47d 100644 Binary files a/build/classes/java/main/hhn/temp/project/AssignmentManager.class and b/build/classes/java/main/hhn/temp/project/AssignmentManager.class differ diff --git a/build/classes/java/test/hhn/temp/project/GoodCasesTest.class b/build/classes/java/test/hhn/temp/project/GoodCasesTest.class index 1b0eb457..1a14beb6 100644 Binary files a/build/classes/java/test/hhn/temp/project/GoodCasesTest.class and b/build/classes/java/test/hhn/temp/project/GoodCasesTest.class differ diff --git a/build/jacoco/test.exec b/build/jacoco/test.exec index 44afc237..f1ab0a3b 100644 Binary files a/build/jacoco/test.exec and b/build/jacoco/test.exec differ diff --git a/build/reports/tests/test/classes/hhn.temp.project.BadCasesTest.html b/build/reports/tests/test/classes/hhn.temp.project.BadCasesTest.html index 2e827fd4..103c5272 100644 --- a/build/reports/tests/test/classes/hhn.temp.project.BadCasesTest.html +++ b/build/reports/tests/test/classes/hhn.temp.project.BadCasesTest.html @@ -41,7 +41,7 @@
-
0.016s
+
0.036s

duration

@@ -81,7 +81,7 @@ Assert Add Task is programmed defensively assertAddTaskOnlyAcceptsValidParameters() -0.002s +0.003s passed @@ -93,31 +93,31 @@ Assert non-existent commands are recognized as such assertInvalidCommandsDontCrash() -0.001s +0.004s passed Assert List isn't empty after adding a task assertListNowEmptyAfterAdd() -0.002s +0.015s passed Assert that added tasks can't be Null assertNewTasksAreNotNull() -0.002s +0.001s passed Assert that Remove Task is programmed defensively assertRemoveTaskOnlyAcceptsValidParameters() -0.001s +0.006s passed Assert that removing a non-existent worker throws an Exception assertRemovingNonExistentWorkerFails() -0.002s +0.001s passed @@ -143,7 +143,7 @@ Generated by -Gradle 8.14 at 06.01.2026, 19:34:44

+Gradle 8.14 at 06.01.2026, 20:04:07

diff --git a/build/reports/tests/test/classes/hhn.temp.project.GoodCasesTest.html b/build/reports/tests/test/classes/hhn.temp.project.GoodCasesTest.html index 853b19ce..8477a2f1 100644 --- a/build/reports/tests/test/classes/hhn.temp.project.GoodCasesTest.html +++ b/build/reports/tests/test/classes/hhn.temp.project.GoodCasesTest.html @@ -29,7 +29,7 @@
-
1
+
0

failures

@@ -41,7 +41,7 @@
-
0.085s
+
0.047s

duration

@@ -50,8 +50,8 @@ -
-
92%
+
+
100%

successful

@@ -61,9 +61,6 @@
-

Failed tests

-
- -

Assert that removing a worker removes the worker from the worker list

- -
org.opentest4j.AssertionFailedError: Expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown.
-	at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:152)
-	at app//org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:73)
-	at app//org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:35)
-	at app//org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3111)
-	at app//hhn.temp.project.GoodCasesTest.assertRemoveWorkerActuallyRemoves(GoodCasesTest.java:153)
-	at java.base@17.0.2/java.lang.reflect.Method.invoke(Method.java:568)
-	at java.base@17.0.2/java.util.ArrayList.forEach(ArrayList.java:1511)
-	at java.base@17.0.2/java.util.ArrayList.forEach(ArrayList.java:1511)
-
-
-
-
-

Tests

@@ -103,19 +81,19 @@ - + - + - + @@ -127,25 +105,25 @@ - + - + - - - - + + + + - + @@ -175,7 +153,7 @@ - +
Check that every required surface command actually works assertCommandsAreRecognized()0.017s0.015s passed
Assert deleted Tasks no longer show up in the List assertDeletedTasksDisappear()0.001s0.003s passed
Check that editing is possible through UI assertEditingTasksIsPossibleThroughUi()0.014s0.008s passed
Check that every task command works assertFinishingTasksIsPossibleThroughUi()0.008s0.004s passed
Check Getters assertGettersWorkCorrectly()0.019s0.004s passed
Assert that removing a worker removes the worker from the worker listassertRemoveWorkerActuallyRemoves()0.012sfailedAssert that removing a worker removes the worker from the worker listassertRemoveWorkerActuallyRemoves()0.002spassed
Assert that removing Workers is possible through the UI assertRemovingWorkersIsPossibleThroughUI()0.005s0.003s passed
Assert that Worker can remove Task assertWorkerCanRemoveOwnTask()0.001s0s passed
@@ -192,13 +170,13 @@ Task edited General: help, ? - Show this help exit - Exit the program - listworkers - List all workers and select one - selecttask - Select a task by ID - createtask - Create a new task createworker - Create a new worker - listtasks - List all tasks - listunfinished - List unfinished tasks - listfinished - List finished tasks + createtask - Create a new task + selecttask - Select a task to work with + listworkers - List all workers + listtasks - List all tasks with status + listfinished - List only finished tasks + listunfinished - List only unfinished tasks When a task is selected: finish - Mark task as finished @@ -214,13 +192,13 @@ When a worker is selected: General: help, ? - Show this help exit - Exit the program - listworkers - List all workers and select one - selecttask - Select a task by ID - createtask - Create a new task createworker - Create a new worker - listtasks - List all tasks - listunfinished - List unfinished tasks - listfinished - List finished tasks + createtask - Create a new task + selecttask - Select a task to work with + listworkers - List all workers + listtasks - List all tasks with status + listfinished - List only finished tasks + listunfinished - List only unfinished tasks When a task is selected: finish - Mark task as finished @@ -233,7 +211,7 @@ When a worker is selected: remove - Remove the worker back - Return to main menu Enter worker name: -Created worker with ID: 1 +Created worker with ID: 1001 Enter task ID: Invalid input. Please enter a task ID or 'back': Invalid input. Please enter a task ID or 'back': @@ -245,13 +223,13 @@ Task marked as unfinished Task removed Unknown command. Type 'help' for available commands. Unknown command. Type 'help' for available commands. + Available workers: - 1: Alfred - 2: Balfred -Enter worker ID to select (or 'back'): -Worker 1 (Alfred) selected -Commands: remove, back -Worker removed + 1001: Alfred + 1002: Balfred + +Unknown command. Type 'help' for available commands. +Unknown command. Type 'help' for available commands. Unknown command. Type 'help' for available commands. Unknown command. Type 'help' for available commands. @@ -265,7 +243,7 @@ Unknown command. Type 'help' for available commands.
Generated by -Gradle 8.14 at 06.01.2026, 19:34:44

+Gradle 8.14 at 06.01.2026, 20:04:07

diff --git a/build/reports/tests/test/index.html b/build/reports/tests/test/index.html index f5786cff..1c5a0a0d 100644 --- a/build/reports/tests/test/index.html +++ b/build/reports/tests/test/index.html @@ -26,7 +26,7 @@
-
4
+
3

failures

@@ -38,7 +38,7 @@
-
1.063s
+
1.048s

duration

@@ -48,7 +48,7 @@
-
84%
+
88%

successful

@@ -82,10 +82,6 @@ DatabaseGoodCasesTest. Assert that the TestClass could be inserted into the database -
  • -GoodCasesTest. -Assert that removing a worker removes the worker from the worker list -
  • @@ -107,10 +103,10 @@ hhn.temp.project 25 -4 +3 0 -1.063s -84% +1.048s +88% @@ -136,7 +132,7 @@ 8 0 0 -0.016s +0.036s 100% @@ -146,7 +142,7 @@ 1 0 0 -0.070s +0.051s 100% @@ -156,18 +152,18 @@ 3 3 0 -0.892s +0.914s 0% - + hhn.temp.project.GoodCasesTest 13 -1 0 -0.085s -92% +0 +0.047s +100% @@ -180,7 +176,7 @@
    Generated by -Gradle 8.14 at 06.01.2026, 19:34:44

    +Gradle 8.14 at 06.01.2026, 20:04:07

    diff --git a/build/reports/tests/test/packages/hhn.temp.project.html b/build/reports/tests/test/packages/hhn.temp.project.html index b3490be6..fdde584e 100644 --- a/build/reports/tests/test/packages/hhn.temp.project.html +++ b/build/reports/tests/test/packages/hhn.temp.project.html @@ -28,7 +28,7 @@
    -
    4
    +
    3

    failures

    @@ -40,7 +40,7 @@
    -
    1.063s
    +
    1.048s

    duration

    @@ -50,7 +50,7 @@
    -
    84%
    +
    88%

    successful

    @@ -81,10 +81,6 @@ DatabaseGoodCasesTest. Assert that the TestClass could be inserted into the database -
  • -GoodCasesTest. -Assert that removing a worker removes the worker from the worker list -
  • @@ -107,7 +103,7 @@ 8 0 0 -0.016s +0.036s 100% @@ -117,7 +113,7 @@ 1 0 0 -0.070s +0.051s 100% @@ -127,18 +123,18 @@ 3 3 0 -0.892s +0.914s 0% - + GoodCasesTest 13 -1 0 -0.085s -92% +0 +0.047s +100%
    @@ -150,7 +146,7 @@ Generated by -Gradle 8.14 at 06.01.2026, 19:34:44

    +Gradle 8.14 at 06.01.2026, 20:04:07

    diff --git a/build/test-results/test/TEST-hhn.temp.project.BadCasesTest.xml b/build/test-results/test/TEST-hhn.temp.project.BadCasesTest.xml index 9f98525e..e73a1ac6 100644 --- a/build/test-results/test/TEST-hhn.temp.project.BadCasesTest.xml +++ b/build/test-results/test/TEST-hhn.temp.project.BadCasesTest.xml @@ -1,14 +1,14 @@ - + - - - - - + + + + + - + diff --git a/build/test-results/test/TEST-hhn.temp.project.GoodCasesTest.xml b/build/test-results/test/TEST-hhn.temp.project.GoodCasesTest.xml index 68e169e9..7a8b06b4 100644 --- a/build/test-results/test/TEST-hhn.temp.project.GoodCasesTest.xml +++ b/build/test-results/test/TEST-hhn.temp.project.GoodCasesTest.xml @@ -1,30 +1,19 @@ - + - - - + + + - - + + - + - - org.opentest4j.AssertionFailedError: Expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown. - at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:152) - at app//org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:73) - at app//org.junit.jupiter.api.AssertThrows.assertThrows(AssertThrows.java:35) - at app//org.junit.jupiter.api.Assertions.assertThrows(Assertions.java:3111) - at app//hhn.temp.project.GoodCasesTest.assertRemoveWorkerActuallyRemoves(GoodCasesTest.java:153) - at java.base@17.0.2/java.lang.reflect.Method.invoke(Method.java:568) - at java.base@17.0.2/java.util.ArrayList.forEach(ArrayList.java:1511) - at java.base@17.0.2/java.util.ArrayList.forEach(ArrayList.java:1511) - - + - + diff --git a/build/test-results/test/binary/results.bin b/build/test-results/test/binary/results.bin index 838d69a9..496ad193 100644 Binary files a/build/test-results/test/binary/results.bin and b/build/test-results/test/binary/results.bin differ diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin index f0c18350..3f9b3a80 100644 Binary files a/build/tmp/compileJava/previous-compilation-data.bin and b/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/build/tmp/compileTestJava/compileTransaction/stash-dir/GoodCasesTest.class.uniqueId0 b/build/tmp/compileTestJava/compileTransaction/stash-dir/GoodCasesTest.class.uniqueId0 index 9a36c568..1b0eb457 100644 Binary files a/build/tmp/compileTestJava/compileTransaction/stash-dir/GoodCasesTest.class.uniqueId0 and b/build/tmp/compileTestJava/compileTransaction/stash-dir/GoodCasesTest.class.uniqueId0 differ diff --git a/build/tmp/compileTestJava/previous-compilation-data.bin b/build/tmp/compileTestJava/previous-compilation-data.bin index 58f36158..a7c2eae7 100644 Binary files a/build/tmp/compileTestJava/previous-compilation-data.bin and b/build/tmp/compileTestJava/previous-compilation-data.bin differ diff --git a/src/main/java/hhn/temp/project/AssignmentManager.java b/src/main/java/hhn/temp/project/AssignmentManager.java index 7bca3274..9698a956 100644 --- a/src/main/java/hhn/temp/project/AssignmentManager.java +++ b/src/main/java/hhn/temp/project/AssignmentManager.java @@ -15,8 +15,8 @@ public class AssignmentManager { public AssignmentManager() { workerMap = new HashMap<>(); taskMap = new HashMap<>(); - int workerIdCounter = 1000; - int taskIdCounter = 0; + workerIdCounter = 1000; + taskIdCounter = 0; userInterface = new UserCommands(this); } public Map getTaskMap() { diff --git a/src/main/java/hhn/temp/project/Main.java b/src/main/java/hhn/temp/project/Main.java index e944ddbc..eedcea83 100644 --- a/src/main/java/hhn/temp/project/Main.java +++ b/src/main/java/hhn/temp/project/Main.java @@ -5,5 +5,6 @@ import java.util.Scanner; public class Main { public static void main(String[] args) { AssignmentManager manager = new AssignmentManager(); + manager.startCLI(); } } diff --git a/src/main/java/hhn/temp/project/UserCommands.java b/src/main/java/hhn/temp/project/UserCommands.java index 8bf59c63..3c034764 100644 --- a/src/main/java/hhn/temp/project/UserCommands.java +++ b/src/main/java/hhn/temp/project/UserCommands.java @@ -151,13 +151,13 @@ public class UserCommands implements Runnable { System.out.println("General:"); System.out.println(" help, ? - Show this help"); System.out.println(" exit - Exit the program"); - System.out.println(" listworkers - List all workers and select one"); - System.out.println(" selecttask - Select a task by ID"); - System.out.println(" createtask - Create a new task"); System.out.println(" createworker - Create a new worker"); - System.out.println(" listtasks - List all tasks"); - System.out.println(" listunfinished - List unfinished tasks"); - System.out.println(" listfinished - List finished tasks"); + System.out.println(" createtask - Create a new task"); + System.out.println(" selecttask - Select a task to work with"); + System.out.println(" listworkers - List all workers"); + System.out.println(" listtasks - List all tasks with status"); + System.out.println(" listfinished - List only finished tasks"); + System.out.println(" listunfinished - List only unfinished tasks"); System.out.println("\nWhen a task is selected:"); System.out.println(" finish - Mark task as finished"); @@ -185,16 +185,23 @@ public class UserCommands implements Runnable { case "selecttask": System.out.println("Enter task ID:"); - currentState = InputState.AWAITING_TASK_SELECTION; // Change to new state + currentState = InputState.AWAITING_TASK_SELECTION; break; case "listworkers": - System.out.println("Available workers:"); - for (Worker w : manager.getWorkerMap().values()) { - System.out.println(" " + w.getId() + ": " + w.getName()); - } - System.out.println("Enter worker ID to select (or 'back'):"); - currentState = InputState.WORKER_SELECTED; + listWorkers(); + break; + + case "listtasks": + listAllTasks(); + break; + + case "listfinished": + listTasksByStatus(TaskState.FINISHED); + break; + + case "listunfinished": + listTasksByStatus(TaskState.IN_PROGRESS); break; default: @@ -202,6 +209,54 @@ public class UserCommands implements Runnable { } } + private void listWorkers() { + System.out.println("\nAvailable workers:"); + if (manager.getWorkerMap().isEmpty()) { + System.out.println(" No workers found."); + } else { + for (Worker w : manager.getWorkerMap().values()) { + System.out.println(" " + w.getId() + ": " + w.getName()); + } + } + System.out.println(); + } + + private void listAllTasks() { + System.out.println("\nAll tasks:"); + if (manager.getTaskMap().isEmpty()) { + System.out.println(" No tasks found."); + } else { + for (Task task : manager.getTaskMap().values()) { + Worker worker = manager.getWorker(task.getWorkerId()); + String status = task.getTaskState() == TaskState.FINISHED ? "[FINISHED]" : "[IN PROGRESS]"; + System.out.println(String.format(" %d: %s - %s (Worker: %d - %s)", + task.getTaskId(), status, task.getName(), + worker.getId(), worker.getName())); + } + } + System.out.println(); + } + + private void listTasksByStatus(TaskState status) { + System.out.println("\nTasks with status: " + status); + boolean found = false; + + for (Task task : manager.getTaskMap().values()) { + if (task.getTaskState() == status) { + Worker worker = manager.getWorker(task.getWorkerId()); + System.out.println(String.format(" %d: %s (Worker: %d - %s)", + task.getTaskId(), task.getName(), + worker.getId(), worker.getName())); + found = true; + } + } + + if (!found) { + System.out.println(" No tasks found with this status."); + } + System.out.println(); + } + private void handleWorkerSelectionInput(String input) { if ("back".equalsIgnoreCase(input)) { resetToMainMenu(); diff --git a/test/hhn/temp/project/GoodCasesTest.java b/test/hhn/temp/project/GoodCasesTest.java index 6f9cd642..1b69f248 100644 --- a/test/hhn/temp/project/GoodCasesTest.java +++ b/test/hhn/temp/project/GoodCasesTest.java @@ -150,6 +150,6 @@ public class GoodCasesTest { public void assertRemoveWorkerActuallyRemoves() { int workerId = manager.createWorker("Alfred"); manager.removeWorker(workerId); - assertThrows(IllegalArgumentException.class, () -> manager.getWorkerMap().containsKey(workerId)); + assertThrows(IllegalArgumentException.class, () -> manager.getWorker(workerId)); // Use getWorker } }