Search in sources :

Example 1 with RandomData

use of utilities.RandomData in project Plan by plan-player-analytics.

the class DatabaseBackupTest method saveDataForBackup.

default void saveDataForBackup() {
    db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
    db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
    execute(DataStoreQueries.storeSession(session));
    db().executeTransaction(new NicknameStoreTransaction(playerUUID, RandomData.randomNickname(serverUUID()), (uuid, name) -> false));
    db().executeTransaction(new GeoInfoStoreTransaction(playerUUID, new GeoInfo("TestLoc", RandomData.randomTime())));
    List<TPS> expected = RandomData.randomTPS();
    for (TPS tps : expected) {
        execute(DataStoreQueries.storeTPS(serverUUID(), tps));
    }
    db().executeTransaction(new PingStoreTransaction(playerUUID, serverUUID(), Collections.singletonList(new DateObj<>(System.currentTimeMillis(), RandomData.randomInt(-1, 40)))));
    User user = new User("test", "console", null, PassEncryptUtil.createHash("testPass"), 0, Collections.emptyList());
    db().executeTransaction(new RegisterWebUserTransaction(user));
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) Files(java.nio.file.Files) GeoInfo(com.djrapitops.plan.gathering.domain.GeoInfo) File(java.io.File) Database(com.djrapitops.plan.storage.database.Database) Test(org.junit.jupiter.api.Test) List(java.util.List) SQLiteDB(com.djrapitops.plan.storage.database.SQLiteDB) RegisterWebUserTransaction(com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction) DateObj(com.djrapitops.plan.delivery.domain.DateObj) com.djrapitops.plan.storage.database.transactions.events(com.djrapitops.plan.storage.database.transactions.events) BackupCopyTransaction(com.djrapitops.plan.storage.database.transactions.BackupCopyTransaction) User(com.djrapitops.plan.delivery.domain.auth.User) DatabaseTestPreparer(com.djrapitops.plan.storage.database.DatabaseTestPreparer) TPS(com.djrapitops.plan.gathering.domain.TPS) PassEncryptUtil(com.djrapitops.plan.utilities.PassEncryptUtil) RandomData(utilities.RandomData) com.djrapitops.plan.storage.database.queries.objects(com.djrapitops.plan.storage.database.queries.objects) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TestConstants(utilities.TestConstants) Collections(java.util.Collections) User(com.djrapitops.plan.delivery.domain.auth.User) RegisterWebUserTransaction(com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction) GeoInfo(com.djrapitops.plan.gathering.domain.GeoInfo) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) TPS(com.djrapitops.plan.gathering.domain.TPS)

Example 2 with RandomData

use of utilities.RandomData in project Plan by plan-player-analytics.

the class NicknameQueriesTest method allNicknamesAreSaved.

@Test
default void allNicknamesAreSaved() {
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    List<Nickname> saved = RandomData.randomNicknames(serverUUID());
    for (Nickname nickname : saved) {
        db().executeTransaction(new NicknameStoreTransaction(playerUUID, nickname, (uuid, name) -> false));
        db().executeTransaction(new NicknameStoreTransaction(playerUUID, nickname, (uuid, name) -> true));
    }
    forcePersistenceCheck();
    List<Nickname> fetched = db().query(NicknameQueries.fetchNicknameDataOfPlayer(playerUUID));
    assertEquals(saved, fetched);
}
Also used : PlayerServerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) UUID(java.util.UUID) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) Test(org.junit.jupiter.api.Test) List(java.util.List) NicknameQueries(com.djrapitops.plan.storage.database.queries.objects.NicknameQueries) DatabaseTestPreparer(com.djrapitops.plan.storage.database.DatabaseTestPreparer) UserIdentifierQueries(com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries) Assertions(org.junit.jupiter.api.Assertions) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) RandomData(utilities.RandomData) TestConstants(utilities.TestConstants) Nickname(com.djrapitops.plan.delivery.domain.Nickname) NicknameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.NicknameStoreTransaction) PlayerServerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction) Nickname(com.djrapitops.plan.delivery.domain.Nickname) Test(org.junit.jupiter.api.Test)

Aggregations

DatabaseTestPreparer (com.djrapitops.plan.storage.database.DatabaseTestPreparer)2 List (java.util.List)2 Test (org.junit.jupiter.api.Test)2 RandomData (utilities.RandomData)2 TestConstants (utilities.TestConstants)2 DateObj (com.djrapitops.plan.delivery.domain.DateObj)1 Nickname (com.djrapitops.plan.delivery.domain.Nickname)1 User (com.djrapitops.plan.delivery.domain.auth.User)1 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)1 GeoInfo (com.djrapitops.plan.gathering.domain.GeoInfo)1 TPS (com.djrapitops.plan.gathering.domain.TPS)1 Database (com.djrapitops.plan.storage.database.Database)1 SQLiteDB (com.djrapitops.plan.storage.database.SQLiteDB)1 com.djrapitops.plan.storage.database.queries.objects (com.djrapitops.plan.storage.database.queries.objects)1 NicknameQueries (com.djrapitops.plan.storage.database.queries.objects.NicknameQueries)1 UserIdentifierQueries (com.djrapitops.plan.storage.database.queries.objects.UserIdentifierQueries)1 BackupCopyTransaction (com.djrapitops.plan.storage.database.transactions.BackupCopyTransaction)1 RegisterWebUserTransaction (com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction)1 RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)1 com.djrapitops.plan.storage.database.transactions.events (com.djrapitops.plan.storage.database.transactions.events)1