Browse Source

Added More Specific Console Checkers + Tests

dev
Adem Berber 3 years ago
parent
commit
2ab773ee16
  1. 64
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 14
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

64
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java

@ -414,4 +414,68 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkConsoleXbox() {
String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games";
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() >= 4) {
if (gameConsole.substring(0, 4).equals("Xbox")) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkConsoleMultiplatform() {
String result = "";
String query = "SELECT Game_Name, Game_Console FROM Games";
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name");
String gameConsole = resultSet.getString("Game_Console");
if (gameConsole.length() >= 13) {
if (gameConsole.substring(0, 13).equals("Multiplatform")) {
result += gameName + ", ";
}
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
} }

14
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

@ -86,4 +86,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkConsoleNintendo(); String actual = testObject.checkConsoleNintendo();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkConsoleXbox() {
Games testObject = new Games();
String expected = "Jet Set Radio Future, Breakdown, Beautiful Katamari";
String actual = testObject.checkConsoleXbox();
assertEquals(expected, actual);
}
public void test_checkConsoleMultiplatform() {
Games testObject = new Games();
String expected = "Ratchet & Clank, AI: The Somnium Files, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkConsoleMultiplatform();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save