This commit is contained in:
@@ -3,6 +3,8 @@ import hhn.temp.project.Main;
|
||||
import hhn.temp.project.Task;
|
||||
import hhn.temp.project.TaskManager;
|
||||
import hhn.temp.project.TaskStatus;
|
||||
import hhn.temp.project.expections.SQLNoConectionException;
|
||||
import hhn.temp.project.expections.SQLStatmentException;
|
||||
import hhn.temp.project.expections.TaskAlreadyExistsException;
|
||||
import hhn.temp.project.expections.TaskHasNoWorkerException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -16,17 +18,27 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
public class BadCaseTaskTest {
|
||||
|
||||
private TaskManager taskManager;
|
||||
private String user = "hhn";
|
||||
private String password = "!9oSmhsiwYO.m)_x";
|
||||
private String db = "hhn";
|
||||
private String host = "localhost";
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
Main main = new Main();
|
||||
taskManager = new TaskManager();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Create a new TaskManager and test Connecton")
|
||||
public void assertCreateNewTaskManager() {
|
||||
assertThrows(SQLNoConectionException.class,() -> taskManager = new TaskManager("deep", "deep", db, host));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Assert an IllegalArgumentException when you create a new Task with no or wrong Name, Description")
|
||||
public void assertExceptionOnCreateNewTask() {
|
||||
taskManager = new TaskManager(user, password, db, host);
|
||||
assertThrows(IllegalArgumentException.class,() -> taskManager.createTask("", null));
|
||||
assertThrows(IllegalArgumentException.class,() -> taskManager.createTask(null, ""));
|
||||
assertThrows(IllegalArgumentException.class,() -> taskManager.createTask(null, null));
|
||||
@@ -34,21 +46,27 @@ public class BadCaseTaskTest {
|
||||
assertThrows(IllegalArgumentException.class,() -> taskManager.createTask("", "test"));
|
||||
assertThrows(IllegalArgumentException.class,() -> taskManager.createTask("ä#eadsew2", "test"));
|
||||
|
||||
assertDoesNotThrow(() -> taskManager.resetTest());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Assert an IllegalArgumentException when you create a new Task with the same Name of a exits Task")
|
||||
public void assertExceptionOnCreateNewTaskWithExitsName() {
|
||||
taskManager = new TaskManager(user, password, db, host);
|
||||
String name = "Name";
|
||||
String description = "Description";
|
||||
assertDoesNotThrow(() -> taskManager.createTask(name, description));
|
||||
assertThrows(TaskAlreadyExistsException.class, () -> taskManager.createTask(name, description));
|
||||
|
||||
assertDoesNotThrow(() -> taskManager.resetTest());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Assert an IllegalArgumentException when you edit a exits Task")
|
||||
public void assertExceptionOnEditATask() {
|
||||
taskManager = new TaskManager(user, password, db, host);
|
||||
String name = "Name";
|
||||
String description = "Description";
|
||||
Task task = taskManager.createTask(name, description);
|
||||
@@ -56,12 +74,15 @@ public class BadCaseTaskTest {
|
||||
assertThrows(IllegalArgumentException.class, () -> task.setDescription(null));
|
||||
assertThrows(IllegalArgumentException.class, () -> task.setStatus(null));
|
||||
|
||||
assertDoesNotThrow(() -> taskManager.resetTest());
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Assert an IllegalArgumentException when calling a non-Existing Task")
|
||||
public void assertExceptionOnCallingANonextistingTask (){
|
||||
taskManager = new TaskManager(user, password, db, host);
|
||||
String wrongName = "Manager";
|
||||
String name = "Name";
|
||||
String description = "Description";
|
||||
@@ -70,11 +91,14 @@ public class BadCaseTaskTest {
|
||||
assertThrows(IllegalArgumentException.class, () -> taskManager.getTask(wrongName));
|
||||
assertThrows(IllegalArgumentException.class, () -> taskManager.getTask(23));
|
||||
|
||||
assertDoesNotThrow(() -> taskManager.resetTest());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Assert an IllegalArgumentException when delete a existing Task with wrong arguments")
|
||||
public void assertExceptionOnDeletingTask (){
|
||||
taskManager = new TaskManager(user, password, db, host);
|
||||
String wrongName = "Manager";
|
||||
String name = "Name";
|
||||
String description = "Description";
|
||||
@@ -84,11 +108,14 @@ public class BadCaseTaskTest {
|
||||
assertThrows(IllegalArgumentException.class, () -> taskManager.deleteTask(""));
|
||||
assertThrows(IllegalArgumentException.class, () -> taskManager.deleteTask(wrongName));
|
||||
|
||||
assertDoesNotThrow(() -> taskManager.resetTest());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Get a Exeption by setWorker and getWorker")
|
||||
public void assertExeptionBySetAndGetAuthorOfATask() {
|
||||
taskManager = new TaskManager(user, password, db, host);
|
||||
String name = "Name";
|
||||
String description = "Description";
|
||||
String workerName = "worker";
|
||||
@@ -99,6 +126,8 @@ public class BadCaseTaskTest {
|
||||
assertThrows(IllegalArgumentException.class, () -> task.setWorker(""));
|
||||
assertThrows(IllegalArgumentException.class, () -> task.setWorker("ewrgi43rfoiw2öa#-"));
|
||||
|
||||
assertDoesNotThrow(() -> taskManager.resetTest());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user