Search in sources :

Example 1 with RemoveEverythingTransaction

use of com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction in project Plan by plan-player-analytics.

the class SessionQueriesTest method removeEverythingRemovesSessions.

@Test
default void removeEverythingRemovesSessions() {
    sessionsAreStoredWithAllData();
    db().executeTransaction(new RemoveEverythingTransaction());
    assertTrue(db().query(SessionQueries.fetchAllSessions()).isEmpty());
    assertEquals(0L, db().query(WorldTimesQueries.fetchServerTotalWorldTimes(serverUUID())).getTotal());
    assertEquals(0, db().query(KillQueries.playerKillCount(0, System.currentTimeMillis(), serverUUID())));
}
Also used : RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 2 with RemoveEverythingTransaction

use of com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction in project Plan by plan-player-analytics.

the class SessionQueriesTest method removeEverythingRemovesWorldNames.

@Test
default void removeEverythingRemovesWorldNames() {
    prepareForSessionSave();
    db().executeTransaction(new RemoveEverythingTransaction());
    assertTrue(db().query(LargeFetchQueries.fetchAllWorldNames()).isEmpty());
}
Also used : RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 3 with RemoveEverythingTransaction

use of com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction in project Plan by plan-player-analytics.

the class UserInfoQueriesTest method removeEverythingRemovesUserInfo.

@Test
default void removeEverythingRemovesUserInfo() {
    playerIsRegisteredToBothTables();
    db().executeTransaction(new RemoveEverythingTransaction());
    assertTrue(db().query(UserInfoQueries.fetchAllUserInformation()).isEmpty());
}
Also used : RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) Test(org.junit.jupiter.api.Test)

Example 4 with RemoveEverythingTransaction

use of com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction in project Plan by plan-player-analytics.

the class ShutdownSaveTest method storeNecessaryInformation.

private void storeNecessaryInformation() throws Exception {
    database.executeTransaction(new RemoveEverythingTransaction());
    ServerUUID serverUUID = TestConstants.SERVER_UUID;
    UUID playerUUID = TestConstants.PLAYER_ONE_UUID;
    String worldName = TestConstants.WORLD_ONE_NAME;
    database.executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID, "-", "")));
    database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> 0L, TestConstants.PLAYER_ONE_NAME));
    database.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName)).get();
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) Server(com.djrapitops.plan.identification.Server) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID)

Example 5 with RemoveEverythingTransaction

use of com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction in project Plan by plan-player-analytics.

the class MySQLTest method setUp.

@BeforeEach
void setUp() {
    TestErrorLogger.throwErrors(true);
    db().executeTransaction(new Patch() {

        @Override
        public boolean hasBeenApplied() {
            return false;
        }

        @Override
        public void applyPatch() {
            dropTable("plan_world_times");
            dropTable("plan_kills");
            dropTable("plan_sessions");
            dropTable("plan_worlds");
            dropTable("plan_users");
        }
    });
    db().executeTransaction(new CreateTablesTransaction());
    db().executeTransaction(new RemoveEverythingTransaction());
    db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), TestConstants.SERVER_NAME, "")));
    assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
Also used : Server(com.djrapitops.plan.identification.Server) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) Patch(com.djrapitops.plan.storage.database.transactions.patches.Patch) CreateTablesTransaction(com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)17 Test (org.junit.jupiter.api.Test)12 Patch (com.djrapitops.plan.storage.database.transactions.patches.Patch)4 Server (com.djrapitops.plan.identification.Server)3 StoreServerInformationTransaction (com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction)3 PlayerContainer (com.djrapitops.plan.delivery.domain.container.PlayerContainer)2 CreateTablesTransaction (com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 RepeatedTest (org.junit.jupiter.api.RepeatedTest)2 DBOpException (com.djrapitops.plan.exceptions.database.DBOpException)1 ExtensionPlayerDataQuery (com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery)1 ExtensionServerDataQuery (com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery)1 ServerUUID (com.djrapitops.plan.identification.ServerUUID)1 Database (com.djrapitops.plan.storage.database.Database)1 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)1 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)1 KillsOptimizationPatch (com.djrapitops.plan.storage.database.transactions.patches.KillsOptimizationPatch)1 UUID (java.util.UUID)1 ExecutionException (java.util.concurrent.ExecutionException)1