Search in sources :

Example 1 with PlayerKeys

use of com.djrapitops.plan.delivery.domain.keys.PlayerKeys in project Plan by plan-player-analytics.

the class DatabaseTest method playerContainerSupportsAllPlayerKeys.

@Test
default void playerContainerSupportsAllPlayerKeys() throws IllegalAccessException {
    saveUserOne();
    saveUserTwo();
    saveTwoWorlds();
    FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
    execute(DataStoreQueries.storeSession(session));
    db().executeTransaction(new NicknameStoreTransaction(playerUUID, RandomData.randomNickname(serverUUID()), (uuid, name) -> false));
    saveGeoInfo(playerUUID, new GeoInfo("TestLoc", RandomData.randomTime()));
    assertTrue(db().query(PlayerFetchQueries.isPlayerRegistered(playerUUID)));
    db().executeTransaction(new PingStoreTransaction(playerUUID, serverUUID(), RandomData.randomIntDateObjects()));
    PlayerContainer playerContainer = db().query(ContainerFetchQueries.fetchPlayerContainer(playerUUID));
    // Active sessions are added after fetching
    playerContainer.putRawData(PlayerKeys.ACTIVE_SESSION, RandomData.randomUnfinishedSession(serverUUID(), worlds, playerUUID));
    List<String> unsupported = new ArrayList<>();
    List<Key> keys = FieldFetcher.getPublicStaticFields(PlayerKeys.class, Key.class);
    for (Key<?> key : keys) {
        if (!playerContainer.supports(key)) {
            unsupported.add(key.getKeyName());
        }
    }
    assertTrue(unsupported.isEmpty(), () -> "Some keys are not supported by PlayerContainer: PlayerKeys." + unsupported.toString());
}
Also used : SELECT(com.djrapitops.plan.storage.database.sql.building.Sql.SELECT) java.util(java.util) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) ServerTablePlayersQuery(com.djrapitops.plan.storage.database.queries.objects.playertable.ServerTablePlayersQuery) UserInfoTable(com.djrapitops.plan.storage.database.sql.tables.UserInfoTable) ServerUUID(com.djrapitops.plan.identification.ServerUUID) TablePlayer(com.djrapitops.plan.delivery.domain.TablePlayer) Disabled(org.junit.jupiter.api.Disabled) utilities(utilities) GeoInfo(com.djrapitops.plan.gathering.domain.GeoInfo) com.djrapitops.plan.storage.database.queries(com.djrapitops.plan.storage.database.queries) SQLException(java.sql.SQLException) NetworkTablePlayersQuery(com.djrapitops.plan.storage.database.queries.objects.playertable.NetworkTablePlayersQuery) ResultSet(java.sql.ResultSet) BaseUser(com.djrapitops.plan.gathering.domain.BaseUser) PlayerKeys(com.djrapitops.plan.delivery.domain.keys.PlayerKeys) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) StoreConfigTransaction(com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction) Transaction(com.djrapitops.plan.storage.database.transactions.Transaction) ContainerFetchQueries(com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) WHERE(com.djrapitops.plan.storage.database.sql.building.Sql.WHERE) ServerPlayerContainersQuery(com.djrapitops.plan.storage.database.queries.containers.ServerPlayerContainersQuery) QuerySvc(com.djrapitops.plan.query.QuerySvc) Sql(com.djrapitops.plan.storage.database.sql.building.Sql) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) Key(com.djrapitops.plan.delivery.domain.keys.Key) DBCleanTask(com.djrapitops.plan.storage.upkeep.DBCleanTask) Locale(com.djrapitops.plan.settings.locale.Locale) com.djrapitops.plan.storage.database.transactions.events(com.djrapitops.plan.storage.database.transactions.events) Assertions(org.junit.jupiter.api.Assertions) PlayerContainer(com.djrapitops.plan.delivery.domain.container.PlayerContainer) com.djrapitops.plan.storage.database.queries.objects(com.djrapitops.plan.storage.database.queries.objects) RemovePlayerTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemovePlayerTransaction) CreateIndexTransaction(com.djrapitops.plan.storage.database.transactions.init.CreateIndexTransaction) RegisterDateMinimizationPatch(com.djrapitops.plan.storage.database.transactions.patches.RegisterDateMinimizationPatch) Nickname(com.djrapitops.plan.delivery.domain.Nickname) Config(com.djrapitops.plan.settings.config.Config) PlayerContainer(com.djrapitops.plan.delivery.domain.container.PlayerContainer) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) GeoInfo(com.djrapitops.plan.gathering.domain.GeoInfo) Key(com.djrapitops.plan.delivery.domain.keys.Key) Test(org.junit.jupiter.api.Test)

Aggregations

Nickname (com.djrapitops.plan.delivery.domain.Nickname)1 TablePlayer (com.djrapitops.plan.delivery.domain.TablePlayer)1 PlayerContainer (com.djrapitops.plan.delivery.domain.container.PlayerContainer)1 Key (com.djrapitops.plan.delivery.domain.keys.Key)1 PlayerKeys (com.djrapitops.plan.delivery.domain.keys.PlayerKeys)1 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)1 BaseUser (com.djrapitops.plan.gathering.domain.BaseUser)1 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)1 GeoInfo (com.djrapitops.plan.gathering.domain.GeoInfo)1 ServerUUID (com.djrapitops.plan.identification.ServerUUID)1 QuerySvc (com.djrapitops.plan.query.QuerySvc)1 Config (com.djrapitops.plan.settings.config.Config)1 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)1 Locale (com.djrapitops.plan.settings.locale.Locale)1 com.djrapitops.plan.storage.database.queries (com.djrapitops.plan.storage.database.queries)1 ContainerFetchQueries (com.djrapitops.plan.storage.database.queries.containers.ContainerFetchQueries)1 ServerPlayerContainersQuery (com.djrapitops.plan.storage.database.queries.containers.ServerPlayerContainersQuery)1 com.djrapitops.plan.storage.database.queries.objects (com.djrapitops.plan.storage.database.queries.objects)1 NetworkTablePlayersQuery (com.djrapitops.plan.storage.database.queries.objects.playertable.NetworkTablePlayersQuery)1 ServerTablePlayersQuery (com.djrapitops.plan.storage.database.queries.objects.playertable.ServerTablePlayersQuery)1