mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-09 20:31:38 +01:00
Test for KillsTable getPlayerKills(serverUUID) method & fix for it.
This commit is contained in:
parent
e78dea9cd9
commit
b82b1dd97e
@ -156,17 +156,18 @@ public class KillsTable extends UserIDTable {
|
|||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
ResultSet set = null;
|
ResultSet set = null;
|
||||||
try {
|
try {
|
||||||
String usersIDColumn = usersTable + "." + usersTable.getColumnID();
|
String usersVictimIDColumn = usersTable + "." + usersTable.getColumnID();
|
||||||
String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid";
|
String usersKillerIDColumn = "a." + usersTable.getColumnID();
|
||||||
String usersUUIDColumn2 = usersTable + "." + usersTable.getColumnUUID() + " as killer_uuid";
|
String usersVictimUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as victim_uuid";
|
||||||
|
String usersKillerUUIDColumn = "a." + usersTable.getColumnUUID() + " as killer_uuid";
|
||||||
statement = prepareStatement("SELECT " +
|
statement = prepareStatement("SELECT " +
|
||||||
columnDate + ", " +
|
columnDate + ", " +
|
||||||
columnWeapon + ", " +
|
columnWeapon + ", " +
|
||||||
usersUUIDColumn + ", " +
|
usersVictimUUIDColumn + ", " +
|
||||||
usersUUIDColumn2 +
|
usersKillerUUIDColumn +
|
||||||
" FROM " + tableName +
|
" FROM " + tableName +
|
||||||
" JOIN " + usersTable + " on " + usersIDColumn + "=" + columnVictimUserID +
|
" JOIN " + usersTable + " on " + usersVictimIDColumn + "=" + columnVictimUserID +
|
||||||
" JOIN " + usersTable + " on " + usersIDColumn + "=" + columnKillerUserID);
|
" JOIN " + usersTable + " a on " + usersKillerIDColumn + "=" + columnKillerUserID);
|
||||||
|
|
||||||
statement.setFetchSize(10000);
|
statement.setFetchSize(10000);
|
||||||
set = statement.executeQuery();
|
set = statement.executeQuery();
|
||||||
|
@ -704,4 +704,23 @@ public class DatabaseTest {
|
|||||||
assertFalse(sSessions.isEmpty());
|
assertFalse(sSessions.isEmpty());
|
||||||
assertEquals(session, sSessions.get(0));
|
assertEquals(session, sSessions.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testKillTableGetKillsOfServer() throws SQLException, DatabaseInitException {
|
||||||
|
saveUserOne();
|
||||||
|
saveUserTwo();
|
||||||
|
|
||||||
|
KillsTable killsTable = db.getKillsTable();
|
||||||
|
List<PlayerKill> expected = createKills();
|
||||||
|
killsTable.savePlayerKills(uuid, 1, expected);
|
||||||
|
|
||||||
|
commitTest();
|
||||||
|
|
||||||
|
Map<UUID, List<PlayerKill>> playerKills = killsTable.getPlayerKills();
|
||||||
|
List<PlayerKill> kills = playerKills.get(uuid);
|
||||||
|
assertFalse(playerKills.isEmpty());
|
||||||
|
assertNotNull(kills);
|
||||||
|
assertFalse(kills.isEmpty());
|
||||||
|
assertEquals(expected, kills);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user