Prepared new tests
This commit is contained in:
@@ -7,8 +7,12 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class DatabaseGoodCasesTest {
|
||||
|
||||
@@ -16,23 +20,37 @@ public class DatabaseGoodCasesTest {
|
||||
private AssignmentManager manager;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
public void setup() throws SQLException, IOException {
|
||||
databaseManager = new SimpleDatabaseManager<>();
|
||||
databaseManager.connect();
|
||||
databaseManager.clearDatabase();
|
||||
manager = new AssignmentManager();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Assert that the TestClass could be inserted into the database")
|
||||
public void assertGetTestClass() throws SQLException, IOException, ExecutionControl.NotImplementedException {
|
||||
public void assertGetTestClass() throws SQLException, IOException {
|
||||
|
||||
databaseManager.connect();
|
||||
Task task = databaseManager.getObject(1);
|
||||
|
||||
Task task = new Task(1, 1, "hi", "hi");
|
||||
|
||||
databaseManager.saveObject(task);
|
||||
|
||||
Task taskNew = databaseManager.getObject(1);
|
||||
|
||||
assertEquals(task.getTaskId(), taskNew.getTaskId());
|
||||
assertEquals(task.getName(), taskNew.getName());
|
||||
assertEquals(task.getDescription(), taskNew.getDescription());
|
||||
assertEquals(task.getWorkerId(), taskNew.getWorkerId());
|
||||
assertEquals(task.getTaskState(), taskNew.getTaskState());
|
||||
|
||||
databaseManager.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Assert that a simple Task could be inserted into the database")
|
||||
public void assertInsertTestClass() throws SQLException, IOException, ExecutionControl.NotImplementedException {
|
||||
public void assertInsertTask() throws SQLException, IOException, ExecutionControl.NotImplementedException {
|
||||
|
||||
Task testTask = new Task(1, 1, "Hello World", "Description");
|
||||
|
||||
@@ -42,9 +60,20 @@ public class DatabaseGoodCasesTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Assert connecting to database")
|
||||
public void assertConnectToDatabase() throws SQLException, IOException {
|
||||
@DisplayName("Assert that simple Tasks could be inserted into the database")
|
||||
public void assertInsertMultipleTasks() throws SQLException, IOException, ExecutionControl.NotImplementedException {
|
||||
|
||||
Task testTaskZero = new Task(1, 1, "Hello", "Description");
|
||||
Task testTaskOne = new Task(2, 2, "World", "Description");
|
||||
Task testTaskTwo = new Task(3, 3, "Hello World", "Description");
|
||||
|
||||
Collection<Task> tasks = new ArrayList<>();
|
||||
tasks.add(testTaskZero);
|
||||
tasks.add(testTaskOne);
|
||||
tasks.add(testTaskTwo);
|
||||
|
||||
databaseManager.connect();
|
||||
databaseManager.saveObjects(tasks);
|
||||
databaseManager.close();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user