Search in sources :

Example 11 with RemoveEverythingTransaction

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

the class SQLiteTest 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(), "ServerName", "", TestConstants.VERSION)));
    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)

Example 12 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, "-", "", TestConstants.VERSION)));
    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 13 with RemoveEverythingTransaction

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

the class ExtensionsDatabaseTest method removeEverythingRemovesServerExtensionData.

@Test
default void removeEverythingRemovesServerExtensionData() {
    extensionServerValuesAreStored();
    db().executeTransaction(new RemoveEverythingTransaction());
    assertTrue(db().query(new ExtensionServerDataQuery(serverUUID())).isEmpty());
}
Also used : ExtensionServerDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) Test(org.junit.jupiter.api.Test)

Example 14 with RemoveEverythingTransaction

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

the class NicknameQueriesTest method removeEverythingRemovesNicknames.

@Test
default void removeEverythingRemovesNicknames() {
    allNicknamesAreSaved();
    db().executeTransaction(new RemoveEverythingTransaction());
    assertTrue(db().query(NicknameQueries.fetchAllNicknameData()).isEmpty());
}
Also used : RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) Test(org.junit.jupiter.api.Test)

Example 15 with RemoveEverythingTransaction

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

the class DBPatchMySQLRegressionTest method mysqlPatchesAreApplied.

@Test
void mysqlPatchesAreApplied() {
    Patch[] patches = underTest.patches();
    for (Patch patch : patches) {
        underTest.executeTransaction(patch);
    }
    assertPatchesHaveBeenApplied(patches);
    // Make sure that a fetch works.
    PlayerContainer player = underTest.query(ContainerFetchQueries.fetchPlayerContainer(TestConstants.PLAYER_ONE_UUID));
    OptionalAssert.equals(1, player.getValue(PlayerKeys.PLAYER_KILL_COUNT));
    // Make sure no foreign key checks fail on removal
    underTest.executeTransaction(new RemoveEverythingTransaction());
}
Also used : PlayerContainer(com.djrapitops.plan.delivery.domain.container.PlayerContainer) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) Patch(com.djrapitops.plan.storage.database.transactions.patches.Patch) KillsOptimizationPatch(com.djrapitops.plan.storage.database.transactions.patches.KillsOptimizationPatch)

Aggregations

RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)18 Test (org.junit.jupiter.api.Test)13 Server (com.djrapitops.plan.identification.Server)3 StoreServerInformationTransaction (com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction)3 Patch (com.djrapitops.plan.storage.database.transactions.patches.Patch)3 PlayerContainer (com.djrapitops.plan.delivery.domain.container.PlayerContainer)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 StoreJoinAddressTransaction (com.djrapitops.plan.storage.database.transactions.events.StoreJoinAddressTransaction)1 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)1 CreateTablesTransaction (com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction)1 KillsOptimizationPatch (com.djrapitops.plan.storage.database.transactions.patches.KillsOptimizationPatch)1 UUID (java.util.UUID)1 ExecutionException (java.util.concurrent.ExecutionException)1