Browse Source

Refactored Class and Test File

dev
Adem Berber 3 years ago
parent
commit
e8f46e214a
  1. 28
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Games.java
  2. 12
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/GamesTest.java

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

@ -34,8 +34,6 @@ public class Games {
while (resultSet.next()) { while (resultSet.next()) {
String gameName = resultSet.getString("Game_Name"); String gameName = resultSet.getString("Game_Name");
result += gameName + ", "; result += gameName + ", ";
} }
@ -48,7 +46,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkConsoles() { public String checkConsoles() {
String result = ""; String result = "";
String query = "SELECT Game_Console FROM Games"; String query = "SELECT Game_Console FROM Games";
@ -675,7 +673,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPublishers() { public String checkPublishers() {
String result = ""; String result = "";
String query = "SELECT Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games"; String query = "SELECT Game_Publisher_EU, Game_Publisher_JP, Game_Publisher_NA FROM Games";
@ -687,8 +685,6 @@ public class Games {
boolean spikeChun = false; boolean spikeChun = false;
boolean bandaiNamco = false; boolean bandaiNamco = false;
boolean activision = false; boolean activision = false;
boolean whileSwitchOne = true;
boolean whileSwitchTwo = true;
try { try {
Connection connection = DriverManager.getConnection(databaseURL); Connection connection = DriverManager.getConnection(databaseURL);
@ -700,9 +696,9 @@ public class Games {
String gamePublisherEu = resultSet.getString("Game_Publisher_EU"); String gamePublisherEu = resultSet.getString("Game_Publisher_EU");
String gamePublisherJp = resultSet.getString("Game_Publisher_JP"); String gamePublisherJp = resultSet.getString("Game_Publisher_JP");
String gamePublisherNa = resultSet.getString("Game_Publisher_NA"); String gamePublisherNa = resultSet.getString("Game_Publisher_NA");
while (whileSwitchOne) {
while (whileSwitchTwo) {
while (true) {
while (true) {
if (sega && gamePublisherEu.equals("Sega")) { if (sega && gamePublisherEu.equals("Sega")) {
break; break;
} else if (atlus && gamePublisherEu.equals("Atlus")) { } else if (atlus && gamePublisherEu.equals("Atlus")) {
@ -846,8 +842,6 @@ public class Games {
result += gamePublisherNa + ", "; result += gamePublisherNa + ", ";
} }
statement.close(); statement.close();
connection.close(); connection.close();
@ -858,7 +852,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPublishersEu() { public String checkPublishersEu() {
String result = ""; String result = "";
String query = "SELECT Game_Publisher_EU FROM Games"; String query = "SELECT Game_Publisher_EU FROM Games";
@ -901,7 +895,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPublishersJp() { public String checkPublishersJp() {
String result = ""; String result = "";
String query = "SELECT Game_Publisher_JP FROM Games"; String query = "SELECT Game_Publisher_JP FROM Games";
@ -950,7 +944,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkPublishersNa() { public String checkPublishersNa() {
String result = ""; String result = "";
String query = "SELECT Game_Publisher_NA FROM Games"; String query = "SELECT Game_Publisher_NA FROM Games";
@ -999,7 +993,7 @@ public class Games {
return result.substring(0, result.length() - 2); return result.substring(0, result.length() - 2);
} }
public String checkReleaseDateUnknown() { public String checkReleaseDateUnknown() {
String result = ""; String result = "";
String query = "SELECT Game_Name, Game_Release_AU FROM Games"; String query = "SELECT Game_Name, Game_Release_AU FROM Games";
@ -1015,8 +1009,8 @@ public class Games {
String gameReleaseAu = resultSet.getString("Game_Release_AU"); String gameReleaseAu = resultSet.getString("Game_Release_AU");
if (gameReleaseAu == null) { if (gameReleaseAu == null) {
result += gameName + ", ";
result += gameName + ", ";
} }
} }

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

@ -9,7 +9,7 @@ public class GamesTest extends TestCase {
boolean actual = testObject.checkConnection(); boolean actual = testObject.checkConnection();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkGames() { public void test_checkGames() {
Games testObject = new Games(); 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 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";
@ -142,35 +142,35 @@ public class GamesTest extends TestCase {
String actual = testObject.checkPublisherSega(); String actual = testObject.checkPublisherSega();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPublishers() { public void test_checkPublishers() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Sega, Atlus, Sony Computer Entertainment, Nintendo, Square Enix, Electronic Arts, Namco, Numskull Games, Spike Chunsoft, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Gust Co. Ltd., Tecmo Koei America, Activision"; String expected = "Sega, Atlus, Sony Computer Entertainment, Nintendo, Square Enix, Electronic Arts, Namco, Numskull Games, Spike Chunsoft, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Gust Co. Ltd., Tecmo Koei America, Activision";
String actual = testObject.checkPublishers(); String actual = testObject.checkPublishers();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPublishersEu() { public void test_checkPublishersEu() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Sega, Sony Computer Entertainment, Nintendo, Electronic Arts, Numskull Games, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Activision"; String expected = "Sega, Sony Computer Entertainment, Nintendo, Electronic Arts, Numskull Games, Ghostlight, Bandai Namco Games, Tecmo Koei Europe, Activision";
String actual = testObject.checkPublishersEu(); String actual = testObject.checkPublishersEu();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPublishersJp() { public void test_checkPublishersJp() {
Games testObject = new Games(); 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 expected = "Atlus, Sony Computer Entertainment, Nintendo, Square Enix, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Gust Co. Ltd., Activision";
String actual = testObject.checkPublishersJp(); String actual = testObject.checkPublishersJp();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkPublishersNa() { public void test_checkPublishersNa() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Atlus, Sony Computer Entertainment, Nintendo, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Tecmo Koei America, Activision"; String expected = "Atlus, Sony Computer Entertainment, Nintendo, Sega, Namco, Spike Chunsoft, Bandai Namco Games, Tecmo Koei America, Activision";
String actual = testObject.checkPublishersNa(); String actual = testObject.checkPublishersNa();
assertEquals(expected, actual); assertEquals(expected, actual);
} }
public void test_checkReleaseDateUnknown() { public void test_checkReleaseDateUnknown() {
Games testObject = new Games(); Games testObject = new Games();
String expected = "Breakdown, Atelier Totori Plus"; String expected = "Breakdown, Atelier Totori Plus";

Loading…
Cancel
Save