Test for getSessionInfoOfServer

This commit is contained in:
Rsl1122 2017-09-02 16:51:30 +03:00
parent 451ebbf814
commit ff5342ed16
2 changed files with 28 additions and 2 deletions

View File

@ -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()) {

View File

@ -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));
}
}