mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-26 22:49:51 +02:00
[Debt] Removed getServerUUID usage in Tests and Processors
This commit is contained in:
parent
f398c2a2c2
commit
062ecc86a7
|
@ -12,6 +12,7 @@ public interface CheckOperations {
|
|||
|
||||
boolean doesWebUserExists(String username);
|
||||
|
||||
@Deprecated
|
||||
default boolean isPlayerRegisteredOnThisServer(UUID player) {
|
||||
return isPlayerRegistered(player, ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.djrapitops.plan.system.database.databases.sql.operation;
|
|||
|
||||
import com.djrapitops.plan.system.database.databases.operation.CheckOperations;
|
||||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -27,11 +26,6 @@ public class SQLCheckOps extends SQLOps implements CheckOperations {
|
|||
return securityTable.userExists(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerRegisteredOnThisServer(UUID player) {
|
||||
return isPlayerRegistered(player, ServerInfo.getServerUUID_Old());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerInDatabase(UUID serverUUID) {
|
||||
return serverTable.getServerID(serverUUID).isPresent();
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.djrapitops.plan.data.store.objects.Nickname;
|
|||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.databases.operation.SaveOperations;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.CriticalRunnable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
@ -29,13 +28,13 @@ public class NameProcessor implements CriticalRunnable {
|
|||
private final DataCache dataCache;
|
||||
|
||||
NameProcessor(
|
||||
UUID uuid, String playerName, String displayName,
|
||||
UUID uuid, String playerName, Nickname nickname,
|
||||
Database database,
|
||||
DataCache dataCache
|
||||
) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
this.nickname = new Nickname(displayName, System.currentTimeMillis(), ServerInfo.getServerUUID_Old());
|
||||
this.nickname = nickname;
|
||||
this.database = database;
|
||||
this.dataCache = dataCache;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ package com.djrapitops.plan.system.processing.processors.player;
|
|||
import com.djrapitops.plan.data.container.Ping;
|
||||
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.CriticalRunnable;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -24,15 +23,17 @@ import java.util.UUID;
|
|||
public class PingInsertProcessor implements CriticalRunnable {
|
||||
|
||||
private final UUID uuid;
|
||||
private final UUID serverUUID;
|
||||
private final List<DateObj<Integer>> pingList;
|
||||
|
||||
private final Database database;
|
||||
|
||||
public PingInsertProcessor(
|
||||
UUID uuid, List<DateObj<Integer>> pingList,
|
||||
PingInsertProcessor(
|
||||
UUID uuid, UUID serverUUID, List<DateObj<Integer>> pingList,
|
||||
Database database
|
||||
) {
|
||||
this.uuid = uuid;
|
||||
this.serverUUID = serverUUID;
|
||||
this.pingList = pingList;
|
||||
this.database = database;
|
||||
}
|
||||
|
@ -62,10 +63,7 @@ public class PingInsertProcessor implements CriticalRunnable {
|
|||
|
||||
int maxValue = max.getAsInt();
|
||||
|
||||
Ping ping = new Ping(lastDate, ServerInfo.getServerUUID_Old(),
|
||||
minValue,
|
||||
maxValue,
|
||||
avgValue);
|
||||
Ping ping = new Ping(lastDate, serverUUID, minValue, maxValue, avgValue);
|
||||
|
||||
database.save().ping(uuid, ping);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.djrapitops.plan.system.processing.processors.player;
|
||||
|
||||
import com.djrapitops.plan.data.store.objects.DateObj;
|
||||
import com.djrapitops.plan.data.store.objects.Nickname;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.processing.Processing;
|
||||
import dagger.Lazy;
|
||||
|
||||
|
@ -23,6 +25,7 @@ import java.util.function.Supplier;
|
|||
public class PlayerProcessors {
|
||||
|
||||
private final Lazy<Processing> processing;
|
||||
private final Lazy<ServerInfo> serverInfo;
|
||||
private final Lazy<Database> database;
|
||||
private final Lazy<DataCache> dataCache;
|
||||
private final Lazy<GeolocationCache> geolocationCache;
|
||||
|
@ -30,11 +33,13 @@ public class PlayerProcessors {
|
|||
@Inject
|
||||
public PlayerProcessors(
|
||||
Lazy<Processing> processing,
|
||||
Lazy<ServerInfo> serverInfo,
|
||||
Lazy<Database> database,
|
||||
Lazy<DataCache> dataCache,
|
||||
Lazy<GeolocationCache> geolocationCache
|
||||
) {
|
||||
this.processing = processing;
|
||||
this.serverInfo = serverInfo;
|
||||
this.database = database;
|
||||
this.dataCache = dataCache;
|
||||
this.geolocationCache = geolocationCache;
|
||||
|
@ -61,11 +66,12 @@ public class PlayerProcessors {
|
|||
}
|
||||
|
||||
public NameProcessor nameProcessor(UUID uuid, String playerName, String displayName) {
|
||||
return new NameProcessor(uuid, playerName, displayName, database.get(), dataCache.get());
|
||||
Nickname nickname = new Nickname(displayName, System.currentTimeMillis(), serverInfo.get().getServerUUID());
|
||||
return new NameProcessor(uuid, playerName, nickname, database.get(), dataCache.get());
|
||||
}
|
||||
|
||||
public PingInsertProcessor pingInsertProcessor(UUID uuid, List<DateObj<Integer>> pingList) {
|
||||
return new PingInsertProcessor(uuid, pingList, database.get());
|
||||
return new PingInsertProcessor(uuid, serverInfo.get().getServerUUID(), pingList, database.get());
|
||||
}
|
||||
|
||||
public RegisterProcessor registerProcessor(UUID uuid, Supplier<Long> registered, String name, Runnable... afterProcess) {
|
||||
|
|
|
@ -7,7 +7,6 @@ package com.djrapitops.plan.system;
|
|||
import com.djrapitops.plan.Plan;
|
||||
import com.djrapitops.plan.PlanBungee;
|
||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
@ -76,7 +75,7 @@ public class BungeeBukkitConnectionTest {
|
|||
bukkitSystem = null; // TODO
|
||||
bukkitSystem.enable();
|
||||
|
||||
bukkitUUID = ServerInfo.getServerUUID_Old();
|
||||
bukkitUUID = null;
|
||||
|
||||
bungeeSystem = null; // TODO
|
||||
|
||||
|
@ -87,7 +86,7 @@ public class BungeeBukkitConnectionTest {
|
|||
|
||||
bungeeSystem.enable();
|
||||
|
||||
bungeeUUID = ServerInfo.getServerUUID_Old();
|
||||
bungeeUUID = null;
|
||||
|
||||
System.out.println("------------------------------");
|
||||
System.out.println("Enable Complete");
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
|||
import com.djrapitops.plan.system.database.databases.sql.SQLiteDB;
|
||||
import com.djrapitops.plan.system.database.databases.sql.tables.*;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.utilities.Base64Util;
|
||||
import com.djrapitops.plan.utilities.SHA256Hash;
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
|
@ -90,7 +89,7 @@ public class SQLiteTest {
|
|||
db.remove().everything();
|
||||
ServerTable serverTable = db.getServerTable();
|
||||
serverTable.saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20));
|
||||
assertEquals(ServerInfo.getServerUUID_Old(), TestConstants.SERVER_UUID);
|
||||
// assertEquals(ServerInfo.getServerUUID_Old(), TestConstants.SERVER_UUID); TODO check if assertion is required
|
||||
System.out.println("-- Clear Complete --\n");
|
||||
}
|
||||
|
||||
|
@ -395,7 +394,7 @@ public class SQLiteTest {
|
|||
System.out.println(" " + entry.getValue());
|
||||
}
|
||||
|
||||
List<Session> savedSessions = sessions.get(ServerInfo.getServerUUID_Old());
|
||||
List<Session> savedSessions = sessions.get(serverUUID);
|
||||
|
||||
assertNotNull(savedSessions);
|
||||
assertEquals(1, savedSessions.size());
|
||||
|
@ -427,7 +426,7 @@ public class SQLiteTest {
|
|||
assertEquals(playerUUID, userInfo.getUuid());
|
||||
assertEquals(123456789L, (long) usersTable.getRegisterDates().get(0));
|
||||
assertEquals(123456789L, userInfo.getRegistered());
|
||||
assertEquals(1, userInfoTable.getServerUserCount(ServerInfo.getServerUUID_Old()));
|
||||
assertEquals(1, userInfoTable.getServerUserCount(serverUUID));
|
||||
assertEquals("Waiting for Update..", userInfo.getName());
|
||||
assertFalse(userInfo.isBanned());
|
||||
assertFalse(userInfo.isOperator());
|
||||
|
@ -803,7 +802,7 @@ public class SQLiteTest {
|
|||
List<Session> sessions = new ArrayList<>();
|
||||
sessions.add(session);
|
||||
sessionMap.put(playerUUID, sessions);
|
||||
map.put(ServerInfo.getServerUUID_Old(), sessionMap);
|
||||
map.put(serverUUID, sessionMap);
|
||||
|
||||
worldTimesTable.saveWorldTimes(map);
|
||||
|
||||
|
@ -826,7 +825,6 @@ public class SQLiteTest {
|
|||
List<Session> sessions = new ArrayList<>();
|
||||
sessions.add(session);
|
||||
sessionMap.put(playerUUID, sessions);
|
||||
UUID serverUUID = ServerInfo.getServerUUID_Old();
|
||||
map.put(serverUUID, sessionMap);
|
||||
|
||||
sessionsTable.insertSessions(map, true);
|
||||
|
|
|
@ -4,15 +4,12 @@ import com.djrapitops.plan.Plan;
|
|||
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
|
||||
import com.djrapitops.plan.system.database.databases.sql.tables.ServerTable;
|
||||
import com.djrapitops.plan.system.info.server.Server;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import utilities.TestConstants;
|
||||
import utilities.mocks.SystemMockUtil;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class NetworkSettingsTest {
|
||||
|
||||
@ClassRule
|
||||
|
@ -46,7 +43,7 @@ public class NetworkSettingsTest {
|
|||
db.remove().everything();
|
||||
ServerTable serverTable = db.getServerTable();
|
||||
serverTable.saveCurrentServerInfo(new Server(-1, TestConstants.SERVER_UUID, "ServerName", "", 20));
|
||||
assertEquals(ServerInfo.getServerUUID_Old(), TestConstants.SERVER_UUID);
|
||||
// assertEquals(ServerInfo.getServerUUID_Old(), TestConstants.SERVER_UUID); TODO check if assert is necessary.
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue
Block a user