Added Task Adding, Removing, Editing and corrected some relatex tests. Coverage still not 100%
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="de"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AssignmentManager.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Template</a> > <a href="index.source.html" class="el_package">hhn.temp.project</a> > <span class="el_source">AssignmentManager.java</span></div><h1>AssignmentManager.java</h1><pre class="source lang-java linenums">package hhn.temp.project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AssignmentManager {
|
||||
Map<Integer, Worker> workerMap;
|
||||
Map<Integer, Task> taskMap;
|
||||
int workerIdCounter;
|
||||
int taskIdCounter;
|
||||
|
||||
<span class="fc" id="L14"> public AssignmentManager() {</span>
|
||||
<span class="fc" id="L15"> workerMap = new HashMap<>();</span>
|
||||
<span class="fc" id="L16"> taskMap = new HashMap<>();</span>
|
||||
<span class="fc" id="L17"> int workerIdCounter = 1000;</span>
|
||||
<span class="fc" id="L18"> int taskIdCounter = 0;</span>
|
||||
<span class="fc" id="L19"> }</span>
|
||||
|
||||
public int createWorker(String name) {
|
||||
<span class="fc" id="L22"> Worker worker = new Worker(name, ++workerIdCounter);</span>
|
||||
<span class="fc" id="L23"> workerMap.put(workerIdCounter, worker);</span>
|
||||
<span class="fc" id="L24"> return workerIdCounter;</span>
|
||||
}
|
||||
public int addTask(int workerId, String name, String description) {
|
||||
<span class="pc bpc" id="L27" title="2 of 6 branches missed."> if (!workerMap.containsKey(workerId) || name == null || description == null) {</span>
|
||||
<span class="fc" id="L28"> throw new IllegalArgumentException("WorkerId must exist and name or description can't be null");</span>
|
||||
}
|
||||
<span class="fc" id="L30"> Task task = new Task(++taskIdCounter, workerId, name, description, this);</span>
|
||||
<span class="fc" id="L31"> taskMap.put(taskIdCounter, task);</span>
|
||||
<span class="fc" id="L32"> return taskIdCounter;</span>
|
||||
}
|
||||
public Task getTask(int taskId) {
|
||||
<span class="fc bfc" id="L35" title="All 2 branches covered."> if (!taskMap.containsKey(taskId)) {</span>
|
||||
<span class="fc" id="L36"> throw new IllegalArgumentException("Task Id does not exist");</span>
|
||||
}
|
||||
<span class="fc" id="L38"> return taskMap.get(taskId);</span>
|
||||
}
|
||||
public Map<Integer, Task> getTaskMap() {
|
||||
<span class="fc" id="L41"> return taskMap;</span>
|
||||
}
|
||||
public void editTask(int workerId, int taskId, String name, String description) {
|
||||
<span class="pc bpc" id="L44" title="1 of 4 branches missed."> if (!workerMap.containsKey(workerId) || !taskMap.containsKey(taskId)) {</span>
|
||||
<span class="fc" id="L45"> throw new IllegalArgumentException("Task Id or Worker Id does not exist");</span>
|
||||
}
|
||||
<span class="fc" id="L47"> Task task = taskMap.get(taskId);</span>
|
||||
<span class="fc" id="L48"> task.setName(name);</span>
|
||||
<span class="fc" id="L49"> task.setDescription(description);</span>
|
||||
<span class="fc" id="L50"> }</span>
|
||||
public void removeTask(int taskId) {
|
||||
<span class="pc bpc" id="L52" title="1 of 2 branches missed."> if (!taskMap.containsKey(taskId)) {</span>
|
||||
<span class="nc" id="L53"> throw new IllegalArgumentException("Task Id does not exist");</span>
|
||||
}
|
||||
<span class="fc" id="L55"> taskMap.remove(taskId);</span>
|
||||
<span class="fc" id="L56"> }</span>
|
||||
}
|
||||
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.13.202504020838</span></div></body></html>
|
||||
Reference in New Issue
Block a user