From 26dfeb3d8ec16c629a88bd3d8e4e1d9a591532a6 Mon Sep 17 00:00:00 2001 From: Adem Berber Date: Sat, 12 Feb 2022 23:07:36 +0100 Subject: [PATCH] Added Game Listing + Test --- .../java/de/hs_fulda/ciip/projjpn/Games.java | 28 +++++++++++++++++++ .../de/hs_fulda/ciip/projjpn/GamesTest.java | 7 +++++ 2 files changed, 35 insertions(+) diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java index 6ccee27..3be21e7 100644 --- a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java +++ b/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"; diff --git a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java index 09c7e46..d4b2e69 100644 --- a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java +++ b/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();