Browse Source

Added JP and NA Publisher Checks + Tests

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

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

@ -873,4 +873,102 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPublishersJp() {
String result = "";
String query = "SELECT Game_Publisher_JP FROM Games";
boolean atlus = false;
boolean nintendo = false;
boolean sega = false;
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
if (atlus && gamePublisherJp.equals("Atlus")) {
continue;
} else if (nintendo && gamePublisherJp.equals("Nintendo")) {
continue;
} else if (sega && gamePublisherJp.equals("Sega")) {
continue;
}
switch (gamePublisherJp) {
case "Atlus":
atlus = true;
break;
case "Nintendo":
nintendo = true;
break;
case "Sega":
sega = true;
break;
}
result += gamePublisherJp + ", ";
}
statement.close();
connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
return result.substring(0, result.length() - 2);
}
public String checkPublishersNa() {
String result = "";
String query = "SELECT Game_Publisher_NA FROM Games";
boolean atlus = false;
boolean nintendo = false;
boolean sega = false;
try {
Connection connection = DriverManager.getConnection(databaseURL);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
String gamePublisherNa = resultSet.getString("Game_Publisher_Na");
if (atlus && gamePublisherNa.equals("Atlus")) {
continue;
} else if (nintendo && gamePublisherNa.equals("Nintendo")) {
continue;
} else if (sega && gamePublisherNa.equals("Sega")) {
continue;
}
switch (gamePublisherNa) {
case "Atlus":
atlus = true;
break;
case "Nintendo":
nintendo = true;
break;
case "Sega":
sega = true;
break;
}
result += gamePublisherNa + ", ";
}
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

@ -149,4 +149,18 @@ public class GamesTest extends TestCase {
String actual = testObject.checkPublishersEu(); String actual = testObject.checkPublishersEu();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPublishersJp() {
Games testObject = new Games();
String expected = "Atlus, Sony Computer Entertainment, Nintendo, Square Enix, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Gust Co. Ltd., Activision";
String actual = testObject.checkPublishersJp();
assertEquals(expected, actual);
}
public void test_checkPublishersNa() {
Games testObject = new Games();
String expected = "Atlus, Sony Computer Entertainment, Nintendo, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Tecmo Koei America, Activision";
String actual = testObject.checkPublishersNa();
assertEquals(expected, actual);
}
} }
Loading…
Cancel
Save