Browse Source

Added Specific Publisher Checkers + Tests

dev
Adem Berber 3 years ago
parent
commit
d9d81f9d69
  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

@ -581,4 +581,68 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPublisherNintendo() {
String result = "";
String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA 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 gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (gamePublisherEu.equals("Nintendo") || gamePublisherJp.equals("Nintendo") || gamePublisherNa.equals("Nintendo")) {
result += gameName + ", ";
}
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkPublisherSega() {
String result = "";
String query = "SELECT Game_Name, Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA 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 gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
if (gamePublisherEu.equals("Sega") || gamePublisherJp.equals("Sega") || gamePublisherNa.equals("Sega")) {
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

@ -121,4 +121,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkDevelopers(); String actual = testObject.checkDevelopers();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPublisherNintendo() {
Games testObject = new Games();
String expected = "Astral Chain, Fire Emblem: Three Houses, Triangle Strategy, Rhythm Paradise, Super Smash Bros. Ultimate, Tomodachi Life";
String actual = testObject.checkPublisherNintendo();
assertEquals(expected, actual);
}
public void test_checkPublisherSega() {
Games testObject = new Games();
String expected = "Persona 5 Royal, Yakuza: Dead Souls, Jet Set Radio Future";
String actual = testObject.checkPublisherSega();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save