56 lines
1.5 KiB
Java
56 lines
1.5 KiB
Java
package hhn.temp.project;
|
|
|
|
import hhn.temp.project.provider.DatabaseManager;
|
|
import hhn.temp.project.provider.SimpleDatabaseManager;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.DisplayName;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import java.io.IOException;
|
|
import java.sql.SQLException;
|
|
|
|
public class DatabaseGoodCasesTest {
|
|
|
|
private DatabaseManager<DatabaseGoodCasesTest.TestClass> databaseManager;
|
|
|
|
public class TestClass {
|
|
private int id;
|
|
private String dataString;
|
|
private int dataInteger;
|
|
|
|
public TestClass(int id, String dataString, int dataInteger) {
|
|
this.id = id;
|
|
this.dataString = dataString;
|
|
this.dataInteger = dataInteger;
|
|
}
|
|
}
|
|
|
|
@BeforeEach
|
|
public void setup() {
|
|
databaseManager = new SimpleDatabaseManager<>();
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("Assert that the TestClass could be inserted into the database")
|
|
public void assertGetTestClass() throws SQLException, IOException {
|
|
TestClass testClass = new TestClass(1, "Hello World", 123);
|
|
|
|
databaseManager.connect();
|
|
databaseManager.getObject(1);
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("Assert that the TestClass could be inserted into the database")
|
|
public void assertInsertTestClass() throws SQLException, IOException {
|
|
TestClass testClass = new TestClass(1, "Hello World", 123);
|
|
|
|
databaseManager.connect();
|
|
databaseManager.saveObject(testClass);
|
|
}
|
|
|
|
@Test
|
|
@DisplayName("Assert connecting to database")
|
|
public void assertConnectToDatabase() throws SQLException, IOException {
|
|
databaseManager.connect();
|
|
}
|
|
} |