ScannerImplementation #5

Merged
KevinSchoenmayer merged 11 commits from ScannerImplementation into main 2026-01-06 21:24:37 +01:00
22 changed files with 368 additions and 68 deletions
Showing only changes of commit c85d55ce7d - Show all commits

Binary file not shown.

Binary file not shown.

View File

@@ -650,7 +650,7 @@ code + .copy-button {
<script type="text/javascript"> <script type="text/javascript">
function configurationCacheProblems() { return ( function configurationCacheProblems() { return (
// begin-report-data // begin-report-data
{"diagnostics":[{"locations":[{}],"problem":[{"text":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated.","documentationLink":"https://docs.gradle.org/8.14/userguide/upgrading_version_8.html#groovy_space_assignment_syntax","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"properties-should-be-assigned-using-the-propname-value-syntax-setting-a-property-via-the-gradle-generated-propname-value-or-propname-value-syntax-in-groovy-dsl","displayName":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"solutions":[[{"text":"Use assignment ('exceptionFormat = <value>') instead."}]]}],"problemsReport":{"totalProblemCount":1,"buildName":"Template","requestedTasks":"check","documentationLink":"https://docs.gradle.org/8.14/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}} {"diagnostics":[{"locations":[{}],"problem":[{"text":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"severity":"WARNING","problemDetails":[{"text":"This is scheduled to be removed in Gradle 10.0."}],"contextualLabel":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated.","documentationLink":"https://docs.gradle.org/8.14/userguide/upgrading_version_8.html#groovy_space_assignment_syntax","problemId":[{"name":"deprecation","displayName":"Deprecation"},{"name":"properties-should-be-assigned-using-the-propname-value-syntax-setting-a-property-via-the-gradle-generated-propname-value-or-propname-value-syntax-in-groovy-dsl","displayName":"Properties should be assigned using the 'propName = value' syntax. Setting a property via the Gradle-generated 'propName value' or 'propName(value)' syntax in Groovy DSL has been deprecated."}],"solutions":[[{"text":"Use assignment ('exceptionFormat = <value>') instead."}]]}],"problemsReport":{"totalProblemCount":1,"buildName":"Template","requestedTasks":"test","documentationLink":"https://docs.gradle.org/8.14/userguide/reporting_problems.html","documentationLinkCaption":"Problem report","summaries":[]}}
// end-report-data // end-report-data
);} );}
</script> </script>

View File

@@ -41,7 +41,7 @@
</td> </td>
<td> <td>
<div class="infoBox" id="duration"> <div class="infoBox" id="duration">
<div class="counter">0.017s</div> <div class="counter">0.096s</div>
<p>duration</p> <p>duration</p>
</div> </div>
</td> </td>
@@ -63,6 +63,9 @@
<li> <li>
<a href="#">Tests</a> <a href="#">Tests</a>
</li> </li>
<li>
<a href="#">Standard output</a>
</li>
</ul> </ul>
<div class="tab"> <div class="tab">
<h2>Tests</h2> <h2>Tests</h2>
@@ -78,7 +81,7 @@
<tr> <tr>
<td class="success">Assert Add Task is programmed defensively</td> <td class="success">Assert Add Task is programmed defensively</td>
<td class="success">assertAddTaskOnlyAcceptsValidParameters()</td> <td class="success">assertAddTaskOnlyAcceptsValidParameters()</td>
<td class="success">0.003s</td> <td class="success">0.007s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
@@ -90,31 +93,31 @@
<tr> <tr>
<td class="success">Assert non-existent commands are recognized as such</td> <td class="success">Assert non-existent commands are recognized as such</td>
<td class="success">assertInvalidCommandsDontCrash()</td> <td class="success">assertInvalidCommandsDontCrash()</td>
<td class="success">0s</td> <td class="success">0.015s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Assert List isn't empty after adding a task</td> <td class="success">Assert List isn't empty after adding a task</td>
<td class="success">assertListNowEmptyAfterAdd()</td> <td class="success">assertListNowEmptyAfterAdd()</td>
<td class="success">0.002s</td> <td class="success">0.045s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Assert that added tasks can't be Null</td> <td class="success">Assert that added tasks can't be Null</td>
<td class="success">assertNewTasksAreNotNull()</td> <td class="success">assertNewTasksAreNotNull()</td>
<td class="success">0.002s</td> <td class="success">0.003s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Assert that Remove Task is programmed defensively</td> <td class="success">Assert that Remove Task is programmed defensively</td>
<td class="success">assertRemoveTaskOnlyAcceptsValidParameters()</td> <td class="success">assertRemoveTaskOnlyAcceptsValidParameters()</td>
<td class="success">0.002s</td> <td class="success">0.014s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Assert that removing a non-existent worker throws an Exception</td> <td class="success">Assert that removing a non-existent worker throws an Exception</td>
<td class="success">assertRemovingNonExistentWorkerFails()</td> <td class="success">assertRemovingNonExistentWorkerFails()</td>
<td class="success">0.002s</td> <td class="success">0.006s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
@@ -125,6 +128,13 @@
</tr> </tr>
</table> </table>
</div> </div>
<div class="tab">
<h2>Standard output</h2>
<span class="code">
<pre>Unknown command. Type 'help' for available commands.
</pre>
</span>
</div>
</div> </div>
<div id="footer"> <div id="footer">
<p> <p>
@@ -133,7 +143,7 @@
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label> </label>
</div>Generated by </div>Generated by
<a href="https://www.gradle.org">Gradle 8.14</a> at 04.01.2026, 15:20:17</p> <a href="https://www.gradle.org">Gradle 8.14</a> at 04.01.2026, 16:08:46</p>
</div> </div>
</div> </div>
</body> </body>

View File

@@ -41,7 +41,7 @@
</td> </td>
<td> <td>
<div class="infoBox" id="duration"> <div class="infoBox" id="duration">
<div class="counter">0.133s</div> <div class="counter">0.083s</div>
<p>duration</p> <p>duration</p>
</div> </div>
</td> </td>
@@ -66,6 +66,9 @@
<li> <li>
<a href="#">Tests</a> <a href="#">Tests</a>
</li> </li>
<li>
<a href="#">Standard output</a>
</li>
</ul> </ul>
<div class="tab"> <div class="tab">
<h2>Failed tests</h2> <h2>Failed tests</h2>
@@ -118,7 +121,7 @@
<tr> <tr>
<td class="success">Check that every required surface command actually works</td> <td class="success">Check that every required surface command actually works</td>
<td class="success">assertCommandsAreRecognized()</td> <td class="success">assertCommandsAreRecognized()</td>
<td class="success">0.014s</td> <td class="success">0.012s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
@@ -130,7 +133,7 @@
<tr> <tr>
<td class="failures">Check that editing is possible through UI</td> <td class="failures">Check that editing is possible through UI</td>
<td class="failures">assertEditingTasksIsPossibleThroughUi()</td> <td class="failures">assertEditingTasksIsPossibleThroughUi()</td>
<td class="failures">0.067s</td> <td class="failures">0.026s</td>
<td class="failures">failed</td> <td class="failures">failed</td>
</tr> </tr>
<tr> <tr>
@@ -142,43 +145,43 @@
<tr> <tr>
<td class="success">Check that every task command works</td> <td class="success">Check that every task command works</td>
<td class="success">assertFinishingTasksIsPossibleThroughUi()</td> <td class="success">assertFinishingTasksIsPossibleThroughUi()</td>
<td class="success">0.005s</td> <td class="success">0.006s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Check Getters</td> <td class="success">Check Getters</td>
<td class="success">assertGettersWorkCorrectly()</td> <td class="success">assertGettersWorkCorrectly()</td>
<td class="success">0.026s</td> <td class="success">0.007s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="failures">Assert that removing a worker removes the worker from the worker list</td> <td class="failures">Assert that removing a worker removes the worker from the worker list</td>
<td class="failures">assertRemoveWorkerActuallyRemoves()</td> <td class="failures">assertRemoveWorkerActuallyRemoves()</td>
<td class="failures">0.004s</td> <td class="failures">0.003s</td>
<td class="failures">failed</td> <td class="failures">failed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Assert that removing Workers is possible through the UI</td> <td class="success">Assert that removing Workers is possible through the UI</td>
<td class="success">assertRemovingWorkersIsPossibleThroughUI()</td> <td class="success">assertRemovingWorkersIsPossibleThroughUI()</td>
<td class="success">0.003s</td> <td class="success">0.005s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Assert that the Scanner is actually started when AM calls start</td> <td class="success">Assert that the Scanner is actually started when AM calls start</td>
<td class="success">assertScannerExists()</td> <td class="success">assertScannerExists()</td>
<td class="success">0.001s</td> <td class="success">0.002s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Assert that Task State is actually changed when submitted as finished</td> <td class="success">Assert that Task State is actually changed when submitted as finished</td>
<td class="success">assertTaskStateChanges()</td> <td class="success">assertTaskStateChanges()</td>
<td class="success">0.002s</td> <td class="success">0.011s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
<td class="success">Assert that added Tasks are added to the List</td> <td class="success">Assert that added Tasks are added to the List</td>
<td class="success">assertTasksShowInList()</td> <td class="success">assertTasksShowInList()</td>
<td class="success">0.003s</td> <td class="success">0.002s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
<tr> <tr>
@@ -190,11 +193,49 @@
<tr> <tr>
<td class="success">Assert that Worker can remove Task</td> <td class="success">Assert that Worker can remove Task</td>
<td class="success">assertWorkerCanRemoveOwnTask()</td> <td class="success">assertWorkerCanRemoveOwnTask()</td>
<td class="success">0.001s</td> <td class="success">0.002s</td>
<td class="success">passed</td> <td class="success">passed</td>
</tr> </tr>
</table> </table>
</div> </div>
<div class="tab">
<h2>Standard output</h2>
<span class="code">
<pre>Enter task ID: Error: Cannot invoke &quot;java.util.Scanner.nextLine()&quot; because &quot;this.scanner&quot; is null
Enter new name;description: Error: Cannot invoke &quot;java.util.Scanner.nextLine()&quot; because &quot;this.scanner&quot; is null
Unknown command. Type 'help' for available commands.
Available commands:
createWorker - Create a new worker
createTask - Create a new task
selectTask - Select a task to work with
listWorkers - List all workers
help/? - Show this help
exit - Exit the program
Available commands:
createWorker - Create a new worker
createTask - Create a new task
selectTask - Select a task to work with
listWorkers - List all workers
help/? - Show this help
exit - Exit the program
Enter worker name: Error: Cannot invoke &quot;java.util.Scanner.nextLine()&quot; because &quot;this.scanner&quot; is null
Enter worker ID: Error: Cannot invoke &quot;java.util.Scanner.nextLine()&quot; because &quot;this.scanner&quot; is null
Enter task ID: Error: Cannot invoke &quot;java.util.Scanner.nextLine()&quot; because &quot;this.scanner&quot; is null
Unknown command. Type 'help' for available commands.
Unknown command. Type 'help' for available commands.
Enter task ID: Error: Cannot invoke &quot;java.util.Scanner.nextLine()&quot; because &quot;this.scanner&quot; is null
Task marked as finished
Task marked as unfinished
Task removed
Unknown command. Type 'help' for available commands.
Unknown command. Type 'help' for available commands.
Enter worker ID: Error: Cannot invoke &quot;java.util.Scanner.nextLine()&quot; because &quot;this.scanner&quot; is null
Worker removed
Unknown command. Type 'help' for available commands.
Unknown command. Type 'help' for available commands.
</pre>
</span>
</div>
</div> </div>
<div id="footer"> <div id="footer">
<p> <p>
@@ -203,7 +244,7 @@
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label> </label>
</div>Generated by </div>Generated by
<a href="https://www.gradle.org">Gradle 8.14</a> at 04.01.2026, 15:20:17</p> <a href="https://www.gradle.org">Gradle 8.14</a> at 04.01.2026, 16:08:46</p>
</div> </div>
</div> </div>
</body> </body>

View File

@@ -38,7 +38,7 @@
</td> </td>
<td> <td>
<div class="infoBox" id="duration"> <div class="infoBox" id="duration">
<div class="counter">0.988s</div> <div class="counter">0.911s</div>
<p>duration</p> <p>duration</p>
</div> </div>
</td> </td>
@@ -113,7 +113,7 @@
<td>25</td> <td>25</td>
<td>5</td> <td>5</td>
<td>0</td> <td>0</td>
<td>0.988s</td> <td>0.911s</td>
<td class="failures">80%</td> <td class="failures">80%</td>
</tr> </tr>
</tbody> </tbody>
@@ -140,7 +140,7 @@
<td>8</td> <td>8</td>
<td>0</td> <td>0</td>
<td>0</td> <td>0</td>
<td>0.017s</td> <td>0.096s</td>
<td class="success">100%</td> <td class="success">100%</td>
</tr> </tr>
<tr> <tr>
@@ -150,7 +150,7 @@
<td>1</td> <td>1</td>
<td>0</td> <td>0</td>
<td>0</td> <td>0</td>
<td>0.739s</td> <td>0.037s</td>
<td class="success">100%</td> <td class="success">100%</td>
</tr> </tr>
<tr> <tr>
@@ -160,7 +160,7 @@
<td>3</td> <td>3</td>
<td>3</td> <td>3</td>
<td>0</td> <td>0</td>
<td>0.099s</td> <td>0.695s</td>
<td class="failures">0%</td> <td class="failures">0%</td>
</tr> </tr>
<tr> <tr>
@@ -170,7 +170,7 @@
<td>13</td> <td>13</td>
<td>2</td> <td>2</td>
<td>0</td> <td>0</td>
<td>0.133s</td> <td>0.083s</td>
<td class="failures">84%</td> <td class="failures">84%</td>
</tr> </tr>
</tbody> </tbody>
@@ -184,7 +184,7 @@
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label> </label>
</div>Generated by </div>Generated by
<a href="https://www.gradle.org">Gradle 8.14</a> at 04.01.2026, 15:20:17</p> <a href="https://www.gradle.org">Gradle 8.14</a> at 04.01.2026, 16:08:46</p>
</div> </div>
</div> </div>
</body> </body>

View File

@@ -40,7 +40,7 @@
</td> </td>
<td> <td>
<div class="infoBox" id="duration"> <div class="infoBox" id="duration">
<div class="counter">0.988s</div> <div class="counter">0.911s</div>
<p>duration</p> <p>duration</p>
</div> </div>
</td> </td>
@@ -111,7 +111,7 @@
<td>8</td> <td>8</td>
<td>0</td> <td>0</td>
<td>0</td> <td>0</td>
<td>0.017s</td> <td>0.096s</td>
<td class="success">100%</td> <td class="success">100%</td>
</tr> </tr>
<tr> <tr>
@@ -121,7 +121,7 @@
<td>1</td> <td>1</td>
<td>0</td> <td>0</td>
<td>0</td> <td>0</td>
<td>0.739s</td> <td>0.037s</td>
<td class="success">100%</td> <td class="success">100%</td>
</tr> </tr>
<tr> <tr>
@@ -131,7 +131,7 @@
<td>3</td> <td>3</td>
<td>3</td> <td>3</td>
<td>0</td> <td>0</td>
<td>0.099s</td> <td>0.695s</td>
<td class="failures">0%</td> <td class="failures">0%</td>
</tr> </tr>
<tr> <tr>
@@ -141,7 +141,7 @@
<td>13</td> <td>13</td>
<td>2</td> <td>2</td>
<td>0</td> <td>0</td>
<td>0.133s</td> <td>0.083s</td>
<td class="failures">84%</td> <td class="failures">84%</td>
</tr> </tr>
</table> </table>
@@ -154,7 +154,7 @@
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/> <input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label> </label>
</div>Generated by </div>Generated by
<a href="https://www.gradle.org">Gradle 8.14</a> at 04.01.2026, 15:20:17</p> <a href="https://www.gradle.org">Gradle 8.14</a> at 04.01.2026, 16:08:46</p>
</div> </div>
</div> </div>
</body> </body>

View File

@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuite name="hhn.temp.project.BadCasesTest" tests="8" skipped="0" failures="0" errors="0" timestamp="2026-01-04T14:20:17.301Z" hostname="KEVIN-THINKPAD" time="0.025"> <testsuite name="hhn.temp.project.BadCasesTest" tests="8" skipped="0" failures="0" errors="0" timestamp="2026-01-04T15:08:44.985Z" hostname="KEVIN-THINKPAD" time="0.121">
<properties/> <properties/>
<testcase name="Assert List isn't empty after adding a task" classname="hhn.temp.project.BadCasesTest" time="0.002"/> <testcase name="Assert List isn't empty after adding a task" classname="hhn.temp.project.BadCasesTest" time="0.045"/>
<testcase name="Assert non-existent commands are recognized as such" classname="hhn.temp.project.BadCasesTest" time="0.0"/> <testcase name="Assert non-existent commands are recognized as such" classname="hhn.temp.project.BadCasesTest" time="0.015"/>
<testcase name="Assert that Remove Task is programmed defensively" classname="hhn.temp.project.BadCasesTest" time="0.002"/> <testcase name="Assert that Remove Task is programmed defensively" classname="hhn.temp.project.BadCasesTest" time="0.014"/>
<testcase name="Assert that removing a non-existent worker throws an Exception" classname="hhn.temp.project.BadCasesTest" time="0.002"/> <testcase name="Assert that removing a non-existent worker throws an Exception" classname="hhn.temp.project.BadCasesTest" time="0.006"/>
<testcase name="Assert Add Task is programmed defensively" classname="hhn.temp.project.BadCasesTest" time="0.003"/> <testcase name="Assert Add Task is programmed defensively" classname="hhn.temp.project.BadCasesTest" time="0.007"/>
<testcase name="Assert only existing tasks can be edited" classname="hhn.temp.project.BadCasesTest" time="0.003"/> <testcase name="Assert only existing tasks can be edited" classname="hhn.temp.project.BadCasesTest" time="0.003"/>
<testcase name="Assert that un-/finishing a Task only works with valid parameters" classname="hhn.temp.project.BadCasesTest" time="0.003"/> <testcase name="Assert that un-/finishing a Task only works with valid parameters" classname="hhn.temp.project.BadCasesTest" time="0.003"/>
<testcase name="Assert that added tasks can't be Null" classname="hhn.temp.project.BadCasesTest" time="0.002"/> <testcase name="Assert that added tasks can't be Null" classname="hhn.temp.project.BadCasesTest" time="0.003"/>
<system-out><![CDATA[]]></system-out> <system-out><![CDATA[Unknown command. Type 'help' for available commands.
]]></system-out>
<system-err><![CDATA[]]></system-err> <system-err><![CDATA[]]></system-err>
</testsuite> </testsuite>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuite name="hhn.temp.project.GoodCasesTest" tests="13" skipped="0" failures="2" errors="0" timestamp="2026-01-04T14:20:17.133Z" hostname="KEVIN-THINKPAD" time="0.162"> <testsuite name="hhn.temp.project.GoodCasesTest" tests="13" skipped="0" failures="2" errors="0" timestamp="2026-01-04T15:08:45.821Z" hostname="KEVIN-THINKPAD" time="0.107">
<properties/> <properties/>
<testcase name="Check Getters" classname="hhn.temp.project.GoodCasesTest" time="0.026"/> <testcase name="Check Getters" classname="hhn.temp.project.GoodCasesTest" time="0.007"/>
<testcase name="Check that editing is possible through UI" classname="hhn.temp.project.GoodCasesTest" time="0.067"> <testcase name="Check that editing is possible through UI" classname="hhn.temp.project.GoodCasesTest" time="0.026">
<failure message="org.opentest4j.AssertionFailedError: expected: &lt;Walk&gt; but was: &lt;Run&gt;" type="org.opentest4j.AssertionFailedError">org.opentest4j.AssertionFailedError: expected: &lt;Walk&gt; but was: &lt;Run&gt; <failure message="org.opentest4j.AssertionFailedError: expected: &lt;Walk&gt; but was: &lt;Run&gt;" type="org.opentest4j.AssertionFailedError">org.opentest4j.AssertionFailedError: expected: &lt;Walk&gt; but was: &lt;Run&gt;
at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151) at app//org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132) at app//org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
@@ -16,14 +16,14 @@
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)
</failure> </failure>
</testcase> </testcase>
<testcase name="Check that every required surface command actually works" classname="hhn.temp.project.GoodCasesTest" time="0.014"/> <testcase name="Check that every required surface command actually works" classname="hhn.temp.project.GoodCasesTest" time="0.012"/>
<testcase name="Assert that added Tasks are added to the List" classname="hhn.temp.project.GoodCasesTest" time="0.003"/> <testcase name="Assert that added Tasks are added to the List" classname="hhn.temp.project.GoodCasesTest" time="0.002"/>
<testcase name="Assert that Worker can remove Task" classname="hhn.temp.project.GoodCasesTest" time="0.001"/> <testcase name="Assert that Worker can remove Task" classname="hhn.temp.project.GoodCasesTest" time="0.002"/>
<testcase name="Check that every task command works" classname="hhn.temp.project.GoodCasesTest" time="0.005"/> <testcase name="Check that every task command works" classname="hhn.temp.project.GoodCasesTest" time="0.006"/>
<testcase name="Assert that a Worker can add a Task" classname="hhn.temp.project.GoodCasesTest" time="0.003"/> <testcase name="Assert that a Worker can add a Task" classname="hhn.temp.project.GoodCasesTest" time="0.003"/>
<testcase name="Assert that removing Workers is possible through the UI" classname="hhn.temp.project.GoodCasesTest" time="0.003"/> <testcase name="Assert that removing Workers is possible through the UI" classname="hhn.temp.project.GoodCasesTest" time="0.005"/>
<testcase name="Assert existing Tasks can be edited" classname="hhn.temp.project.GoodCasesTest" time="0.001"/> <testcase name="Assert existing Tasks can be edited" classname="hhn.temp.project.GoodCasesTest" time="0.001"/>
<testcase name="Assert that removing a worker removes the worker from the worker list" classname="hhn.temp.project.GoodCasesTest" time="0.004"> <testcase name="Assert that removing a worker removes the worker from the worker list" classname="hhn.temp.project.GoodCasesTest" time="0.003">
<failure message="org.opentest4j.AssertionFailedError: Expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown." type="org.opentest4j.AssertionFailedError">org.opentest4j.AssertionFailedError: Expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown. <failure message="org.opentest4j.AssertionFailedError: Expected java.lang.IllegalArgumentException to be thrown, but nothing was thrown." type="org.opentest4j.AssertionFailedError">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.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:73)
@@ -35,9 +35,41 @@
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)
</failure> </failure>
</testcase> </testcase>
<testcase name="Assert that the Scanner is actually started when AM calls start" classname="hhn.temp.project.GoodCasesTest" time="0.001"/> <testcase name="Assert that the Scanner is actually started when AM calls start" classname="hhn.temp.project.GoodCasesTest" time="0.002"/>
<testcase name="Assert that Task State is actually changed when submitted as finished" classname="hhn.temp.project.GoodCasesTest" time="0.002"/> <testcase name="Assert that Task State is actually changed when submitted as finished" classname="hhn.temp.project.GoodCasesTest" time="0.011"/>
<testcase name="Assert deleted Tasks no longer show up in the List" classname="hhn.temp.project.GoodCasesTest" time="0.003"/> <testcase name="Assert deleted Tasks no longer show up in the List" classname="hhn.temp.project.GoodCasesTest" time="0.003"/>
<system-out><![CDATA[]]></system-out> <system-out><![CDATA[Enter task ID: Error: Cannot invoke "java.util.Scanner.nextLine()" because "this.scanner" is null
Enter new name;description: Error: Cannot invoke "java.util.Scanner.nextLine()" because "this.scanner" is null
Unknown command. Type 'help' for available commands.
Available commands:
createWorker - Create a new worker
createTask - Create a new task
selectTask - Select a task to work with
listWorkers - List all workers
help/? - Show this help
exit - Exit the program
Available commands:
createWorker - Create a new worker
createTask - Create a new task
selectTask - Select a task to work with
listWorkers - List all workers
help/? - Show this help
exit - Exit the program
Enter worker name: Error: Cannot invoke "java.util.Scanner.nextLine()" because "this.scanner" is null
Enter worker ID: Error: Cannot invoke "java.util.Scanner.nextLine()" because "this.scanner" is null
Enter task ID: Error: Cannot invoke "java.util.Scanner.nextLine()" because "this.scanner" is null
Unknown command. Type 'help' for available commands.
Unknown command. Type 'help' for available commands.
Enter task ID: Error: Cannot invoke "java.util.Scanner.nextLine()" because "this.scanner" is null
Task marked as finished
Task marked as unfinished
Task removed
Unknown command. Type 'help' for available commands.
Unknown command. Type 'help' for available commands.
Enter worker ID: Error: Cannot invoke "java.util.Scanner.nextLine()" because "this.scanner" is null
Worker removed
Unknown command. Type 'help' for available commands.
Unknown command. Type 'help' for available commands.
]]></system-out>
<system-err><![CDATA[]]></system-err> <system-err><![CDATA[]]></system-err>
</testsuite> </testsuite>

View File

@@ -17,8 +17,7 @@ public class AssignmentManager {
taskMap = new HashMap<>(); taskMap = new HashMap<>();
int workerIdCounter = 1000; int workerIdCounter = 1000;
int taskIdCounter = 0; int taskIdCounter = 0;
userInterface = new UserCommands(); userInterface = new UserCommands(this);
userInterface.start();
} }
public int createWorker(String name) { public int createWorker(String name) {
@@ -80,5 +79,12 @@ public class AssignmentManager {
public UserCommands getUserCommands() { public UserCommands getUserCommands() {
return userInterface; return userInterface;
} }
public void startCLI() {
userInterface.start();
}
public void stopCLI() {
userInterface.stop();
}
} }

View File

@@ -1,24 +1,234 @@
package hhn.temp.project; package hhn.temp.project;
import java.util.Scanner; import java.util.Scanner;
import java.util.concurrent.atomic.AtomicBoolean;
public class UserCommands implements Runnable {
private Scanner scanner;
private AssignmentManager manager;
private boolean inTaskSelection = false;
private boolean inWorkerSelection = false;
private Integer selectedTaskId = null;
private Integer selectedWorkerId = null;
private AtomicBoolean running = new AtomicBoolean(false);
private Thread cliThread;
public UserCommands(AssignmentManager manager) {
this.manager = manager;
}
@Override
public void run() {
scanner = new Scanner(System.in);
running.set(true);
while (running.get()) {
printPrompt();
String input = scanner.nextLine().trim();
if ("exit".equalsIgnoreCase(input)) {
stop();
continue;
}
handleInput(input);
}
scanner.close();
}
public class UserCommands {
Scanner scanner;
public void start() { public void start() {
boolean close = false; if (cliThread == null || !cliThread.isAlive()) {
// scanner = new Scanner(System.in); cliThread = new Thread(this, "CLI-Thread");
// while (!close) { cliThread.start();
// System.out.println("Type '?' or 'help' for a list of commands"); }
// System.out.println("Please enter a command:");
// String input = scanner.nextLine();
// handleInput(input);
// }
// scanner.close();
} }
public void handleInput(String input) {
public void stop() {
running.set(false);
if (cliThread != null) {
cliThread.interrupt();
}
} }
private void printPrompt() {
if (!running.get()) return;
if (inTaskSelection && selectedTaskId != null) {
System.out.println("Task " + selectedTaskId + " selected. Commands: finish, unfinish, remove, edit, back");
} else if (inWorkerSelection && selectedWorkerId != null) {
System.out.println("Worker " + selectedWorkerId + " selected. Commands: remove, back");
} else {
System.out.println("Type '?' or 'help' for a list of commands");
}
System.out.print("> ");
}
public void handleInput(String input) {
if (input == null || input.isEmpty()) {
return;
}
if ("?".equals(input) || "help".equalsIgnoreCase(input)) {
showHelp();
return;
}
try {
if (inTaskSelection) {
handleTaskSelectionInput(input);
} else if (inWorkerSelection) {
handleWorkerSelectionInput(input);
} else {
handleMainMenuInput(input);
}
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
private void showHelp() {
if (inTaskSelection && selectedTaskId != null) {
System.out.println("Task commands:");
System.out.println(" finish - Mark task as finished");
System.out.println(" unfinish - Mark task as unfinished");
System.out.println(" remove - Remove this task");
System.out.println(" edit - Edit task (prompts for name;description)");
System.out.println(" back - Return to main menu");
} else if (inWorkerSelection && selectedWorkerId != null) {
System.out.println("Worker commands:");
System.out.println(" remove - Remove this worker");
System.out.println(" back - Return to main menu");
} else {
System.out.println("Available commands:");
System.out.println(" createWorker - Create a new worker");
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(" help/? - Show this help");
System.out.println(" exit - Exit the program");
}
}
private void handleMainMenuInput(String input) {
switch (input.toLowerCase()) {
case "createworker":
System.out.print("Enter worker name: ");
String workerName = scanner.nextLine().trim();
int workerId = manager.createWorker(workerName);
System.out.println("Created worker with ID: " + workerId);
break;
case "createtask":
System.out.print("Enter worker ID: ");
int workerIdForTask = Integer.parseInt(scanner.nextLine().trim());
System.out.print("Enter task name: ");
String taskName = scanner.nextLine().trim();
System.out.print("Enter task description: ");
String taskDesc = scanner.nextLine().trim();
int taskId = manager.addTask(workerIdForTask, taskName, taskDesc);
System.out.println("Created task with ID: " + taskId);
break;
case "selecttask":
inTaskSelection = true;
System.out.print("Enter task ID: ");
String taskIdInput = scanner.nextLine().trim();
selectedTaskId = Integer.parseInt(taskIdInput);
break;
case "listworkers":
inWorkerSelection = true;
System.out.print("Enter worker ID: ");
String workerIdInput = scanner.nextLine().trim();
selectedWorkerId = Integer.parseInt(workerIdInput);
break;
default:
System.out.println("Unknown command. Type 'help' for available commands.");
}
}
private void handleTaskSelectionInput(String input) {
switch (input.toLowerCase()) {
case "finish":
manager.finishTask(manager.getTask(selectedTaskId).getWorkerId(), selectedTaskId);
System.out.println("Task marked as finished");
break;
case "unfinish":
manager.unfinishTask(manager.getTask(selectedTaskId).getWorkerId(), selectedTaskId);
System.out.println("Task marked as unfinished");
break;
case "remove":
manager.removeTask(selectedTaskId);
System.out.println("Task removed");
resetSelection();
break;
case "edit":
System.out.print("Enter new name;description: ");
String editInput = scanner.nextLine().trim();
String[] parts = editInput.split(";", 2);
if (parts.length == 2) {
manager.editTask(manager.getTask(selectedTaskId).getWorkerId(),selectedTaskId,parts[0],parts[1]);
System.out.println("Task edited");
} else {
System.out.println("Invalid format. Use: name;description");
}
break;
case "back":
resetSelection();
break;
default:
try {
selectedTaskId = Integer.parseInt(input);
} catch (NumberFormatException e) {
System.out.println("Unknown command. Type 'help' for available commands.");
}
}
}
private void handleWorkerSelectionInput(String input) {
switch (input.toLowerCase()) {
case "remove":
manager.removeWorker(selectedWorkerId);
System.out.println("Worker removed");
resetSelection();
break;
case "back":
resetSelection();
break;
default:
try {
selectedWorkerId = Integer.parseInt(input);
} catch (NumberFormatException e) {
System.out.println("Unknown command. Type 'help' for available commands.");
}
}
}
private void resetSelection() {
inTaskSelection = false;
inWorkerSelection = false;
selectedTaskId = null;
selectedWorkerId = null;
}
public Scanner getScanner() { public Scanner getScanner() {
return scanner; return scanner;
} }
// For testing - allows setting scanner
public void setScanner(Scanner scanner) {
this.scanner = scanner;
}
public boolean isRunning() {
return running.get();
}
} }