database #3
Binary file not shown.
Binary file not shown.
@@ -6,4 +6,5 @@ import java.sql.SQLException;
|
||||
|
||||
public interface Database {
|
||||
public void connect() throws SQLException, IOException;
|
||||
public void close() throws SQLException;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SimpleDatabaseManager<E> implements DatabaseManager<E> {
|
||||
|
||||
@Override
|
||||
public void saveObject(E object) {
|
||||
|
||||
g
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,4 +38,11 @@ public class SimpleDatabaseManager<E> implements DatabaseManager<E> {
|
||||
public void connect() throws SQLException, IOException {
|
||||
connection = DriverManager.getConnection("jdbc:mysql://sql7.freesqldatabase.com/sql7810540?user=sql7810540&password=mXdJCFtDZz");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,18 +13,6 @@ 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<>();
|
||||
@@ -33,7 +21,6 @@ public class DatabaseGoodCasesTest {
|
||||
@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);
|
||||
@@ -42,7 +29,6 @@ public class DatabaseGoodCasesTest {
|
||||
@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);
|
||||
|
||||
Reference in New Issue
Block a user