Merge pull request 'Hotfix to address the IOException in the SimpleDatabaseManager class, modified modifier and deleted useless test.' (#6) from database into main
Reviewed-on: #6 Jup, gecheckt
This commit is contained in:
@@ -19,14 +19,14 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
private final static Path SELECT_TASK = Path.of("resources/sql/SelectTaskTable.sql");
|
||||
private final static Path UPDATE_TASK = Path.of("resources/sql/UpdateTaskTable.sql");
|
||||
private final static Path COUNT_ALL_TASK = Path.of("resources/sql/CountAllFieldsTask.sql");
|
||||
private final static Path SELECT_ALL_TASK = Path.of("resources/sql/SelectAllFieldsTask.sql");
|
||||
private final static Path SELECT_ALL_TASK = Path.of("resources/sql/SelectAllTask.sql");
|
||||
private final static Path SELECT_TASK_BY_ID = Path.of("resources/sql/SelectTaskById.sql");
|
||||
private final static Path INSERT_WORKER = Path.of("resources/sql/InsertWorkerTable.sql");
|
||||
private final static Path DELETE_WORKER = Path.of("resources/sql/DeleteWorkerTable.sql");
|
||||
private final static Path SELECT_WORKER = Path.of("resources/sql/SelectWorkerTable.sql");
|
||||
private final static Path UPDATE_WORKER = Path.of("resources/sql/UpdateWorkerTable.sql");
|
||||
private final static Path COUNT_ALL_WORKER = Path.of("resources/sql/CountAllFieldsWorker.sql");
|
||||
private final static Path SELECT_ALL_WORKER = Path.of("resources/sql/SelectAllFieldsWorker.sql");
|
||||
private final static Path SELECT_ALL_WORKER = Path.of("resources/sql/SelectAllWorker.sql");
|
||||
private final static Path SELECT_WORKER_BY_ID = Path.of("resources/sql/SelectWorkerById.sql");
|
||||
|
||||
public enum QueryMode {
|
||||
@@ -46,7 +46,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
SELECT_WORKER_BY_ID,
|
||||
}
|
||||
|
||||
public String loadFile(QueryMode queryMode) throws IOException {
|
||||
private String loadFile(QueryMode queryMode) throws IOException {
|
||||
switch (queryMode) {
|
||||
case INSERT_TASK -> {
|
||||
return Files.readString(INSERT_TASK);
|
||||
@@ -110,7 +110,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.INSERT_TASK);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(query);) {
|
||||
@@ -136,7 +136,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.INSERT_WORKER);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(query);) {
|
||||
@@ -159,7 +159,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.UPDATE_TASK);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(query);) {
|
||||
@@ -177,7 +177,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.UPDATE_WORKER);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(query);) {
|
||||
@@ -194,7 +194,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.DELETE_TASK);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(query);) {
|
||||
@@ -209,7 +209,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.DELETE_WORKER);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(query);) {
|
||||
@@ -224,7 +224,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.SELECT_ALL_TASK);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.SELECT_ALL_WORKER);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.SELECT_TASK_BY_ID);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.SELECT_WORKER_BY_ID);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.COUNT_ALL_TASK);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
try (Statement statement = connection.createStatement();
|
||||
@@ -370,7 +370,7 @@ public class SimpleDatabaseManager implements DatabaseManager {
|
||||
try {
|
||||
query = loadFile(QueryMode.COUNT_ALL_WORKER);
|
||||
} catch (IOException e) {
|
||||
System.err.println(e.getStackTrace());
|
||||
e.printStackTrace();
|
||||
return -1;
|
||||
}
|
||||
try (Statement statement = connection.createStatement();
|
||||
|
||||
@@ -5,12 +5,8 @@ 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;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class DatabaseBadCasesTest {
|
||||
|
||||
private DatabaseManager databaseManager;
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -82,9 +80,4 @@ public class DatabaseGoodCasesTest {
|
||||
assertEquals(0, databaseManager.getTotalNumberOfTasks());
|
||||
assertEquals(0, databaseManager.getTotalNumberOfWorkers());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandom() throws IOException, URISyntaxException {
|
||||
System.out.println(databaseManager.loadFile(SimpleDatabaseManager.QueryMode.INSERT_TASK));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user