Browse Source

Added Game Listing + Test

dev
Adem Berber 2 years ago
parent
commit
26dfeb3d8e
  1. 28
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 7
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

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

@ -21,6 +21,34 @@ public class Games {
}
}
public String checkGames() {
String result = "";
String query = "SELECT Game_Name 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");
result += gameName + ", ";
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkConsoles() {
String result = "";
String query = "SELECT Game_Console FROM Games";

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

@ -9,6 +9,13 @@ public class GamesTest extends TestCase {
boolean actual = testObject.checkConnection();
assertEquals(expected, actual);
}
public void test_checkGames() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Ratchet & Clank, Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Yakuza: Dead Souls, Jet Set Radio Future, Breakdown, AI: The Somnium Files, Persona 3 Portable, Tomodachi Life, Beautiful Katamari, Atelier Totori Plus, Crash Bandicoot N. Sane Trilogy";
String actual = testObject.checkGames();
assertEquals(expected, actual);
}
public void test_checkConsoles() {
Games testObject = new Games();

Loading…
Cancel
Save