mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 09:00:28 +08:00
Test for getSessionInfoOfServer
This commit is contained in:
parent
451ebbf814
commit
ff5342ed16
@ -450,7 +450,6 @@ public class SessionsTable extends UserIDTable {
|
||||
return getSessionInfoOfServer(Plan.getServerUUID());
|
||||
}
|
||||
|
||||
// TODO Write tests for this method
|
||||
public Map<UUID, List<Session>> getSessionInfoOfServer(UUID serverUUID) throws SQLException {
|
||||
Optional<Integer> id = serverTable.getServerID(serverUUID);
|
||||
if (!id.isPresent()) {
|
||||
|
@ -270,7 +270,7 @@ public class DatabaseTest {
|
||||
assertEquals(expectedGeoLoc, result.get());
|
||||
}
|
||||
|
||||
@Test // Does not test getting sessions from another server.
|
||||
@Test
|
||||
public void testNicknamesTable() throws SQLException, DatabaseInitException {
|
||||
saveUserOne();
|
||||
NicknamesTable nickTable = db.getNicknamesTable();
|
||||
@ -677,4 +677,31 @@ public class DatabaseTest {
|
||||
db.close();
|
||||
db.init();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSessionTableGetInfoOfServer() throws SQLException, DatabaseInitException {
|
||||
saveUserOne();
|
||||
saveUserTwo();
|
||||
|
||||
Session session = new Session(12345L, "", "");
|
||||
session.endSession(22345L);
|
||||
session.setWorldTimes(createWorldTimes());
|
||||
session.setPlayerKills(createKills());
|
||||
|
||||
SessionsTable sessionsTable = db.getSessionsTable();
|
||||
sessionsTable.saveSession(uuid, session);
|
||||
|
||||
commitTest();
|
||||
|
||||
Map<UUID, List<Session>> sessions = sessionsTable.getSessionInfoOfServer();
|
||||
|
||||
session.setPlayerKills(new ArrayList<>());
|
||||
session.setWorldTimes(new WorldTimes(new HashMap<>()));
|
||||
|
||||
List<Session> sSessions = sessions.get(uuid);
|
||||
assertFalse(sessions.isEmpty());
|
||||
assertNotNull(sSessions);
|
||||
assertFalse(sSessions.isEmpty());
|
||||
assertEquals(session, sSessions.get(0));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user