Search in sources :

Example 1 with DBSystem

use of com.djrapitops.plan.storage.database.DBSystem in project Plan by plan-player-analytics.

the class VelocitySystemTest method velocityEnables.

@Test
void velocityEnables(@TempDir Path temp) throws Exception {
    PlanSystem velocitySystem = new VelocityMockComponent(temp).getPlanSystem();
    try {
        PlanConfig config = velocitySystem.getConfigSystem().getConfig();
        config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
        config.set(ProxySettings.IP, "8.8.8.8");
        DBSystem dbSystem = velocitySystem.getDatabaseSystem();
        SQLiteDB db = dbSystem.getSqLiteFactory().usingDefaultFile();
        db.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
        dbSystem.setActiveDatabase(db);
        velocitySystem.enable();
        assertTrue(velocitySystem.isEnabled());
    } finally {
        velocitySystem.disable();
    }
}
Also used : VelocityMockComponent(utilities.mocks.VelocityMockComponent) DBSystem(com.djrapitops.plan.storage.database.DBSystem) SQLiteDB(com.djrapitops.plan.storage.database.SQLiteDB) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 2 with DBSystem

use of com.djrapitops.plan.storage.database.DBSystem in project Plan by plan-player-analytics.

the class ShutdownSaveTest method setupShutdownSaveObject.

@BeforeEach
void setupShutdownSaveObject(@TempDir Path temporaryFolder) throws Exception {
    PluginMockComponent pluginMockComponent = new PluginMockComponent(temporaryFolder);
    PlanSystem system = pluginMockComponent.getPlanSystem();
    database = system.getDatabaseSystem().getSqLiteFactory().usingFileCalled("test");
    database.init();
    sessionCache = system.getCacheSystem().getSessionCache();
    storeNecessaryInformation();
    placeSessionToCache();
    DBSystem dbSystemMock = mock(DBSystem.class);
    when(dbSystemMock.getDatabase()).thenReturn(database);
    TestPluginLogger logger = new TestPluginLogger();
    underTest = new ServerShutdownSave(new Locale(), dbSystemMock, logger, system.getErrorLogger()) {

        @Override
        protected boolean checkServerShuttingDownStatus() {
            return shutdownStatus;
        }
    };
    shutdownStatus = false;
}
Also used : Locale(com.djrapitops.plan.settings.locale.Locale) DBSystem(com.djrapitops.plan.storage.database.DBSystem) TestPluginLogger(utilities.TestPluginLogger) PlanSystem(com.djrapitops.plan.PlanSystem) PluginMockComponent(utilities.mocks.PluginMockComponent) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with DBSystem

use of com.djrapitops.plan.storage.database.DBSystem in project Plan by plan-player-analytics.

the class ExportJSErrorRegressionTest method savePlayerData.

private static void savePlayerData() {
    DBSystem dbSystem = planSystem.getDatabaseSystem();
    Database database = dbSystem.getDatabase();
    UUID uuid = TestConstants.PLAYER_ONE_UUID;
    database.executeTransaction(new PlayerRegisterTransaction(uuid, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME));
    FinishedSession session = new FinishedSession(uuid, serverUUID, 1000L, 11000L, 500L, new DataMap());
    database.executeTransaction(new WorldNameStoreTransaction(serverUUID, "world"));
    database.executeTransaction(new SessionEndTransaction(session));
}
Also used : SessionEndTransaction(com.djrapitops.plan.storage.database.transactions.events.SessionEndTransaction) DBSystem(com.djrapitops.plan.storage.database.DBSystem) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) Database(com.djrapitops.plan.storage.database.Database) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataMap(com.djrapitops.plan.gathering.domain.DataMap)

Example 4 with DBSystem

use of com.djrapitops.plan.storage.database.DBSystem in project Plan by plan-player-analytics.

the class BungeeSystemTest method bungeeEnables.

@Test
void bungeeEnables() throws Exception {
    PlanSystem bungeeSystem = component.getPlanSystem();
    try {
        PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
        config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
        config.set(ProxySettings.IP, "8.8.8.8");
        DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
        SQLiteDB db = dbSystem.getSqLiteFactory().usingDefaultFile();
        db.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
        dbSystem.setActiveDatabase(db);
        bungeeSystem.enable();
        assertTrue(bungeeSystem.isEnabled());
    } finally {
        bungeeSystem.disable();
    }
}
Also used : DBSystem(com.djrapitops.plan.storage.database.DBSystem) SQLiteDB(com.djrapitops.plan.storage.database.SQLiteDB) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 5 with DBSystem

use of com.djrapitops.plan.storage.database.DBSystem in project Plan by plan-player-analytics.

the class DBPreparer method prepareDBByName.

private SQLDB prepareDBByName(String dbName) {
    PlanConfig config = dependencies.config();
    config.set(WebserverSettings.PORT, testPortNumber);
    config.set(DatabaseSettings.TYPE, dbName);
    dependencies.enable();
    DBSystem dbSystem = dependencies.dbSystem();
    SQLDB db = (SQLDB) dbSystem.getActiveDatabaseByName(dbName);
    db.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
    db.init();
    return db;
}
Also used : DBSystem(com.djrapitops.plan.storage.database.DBSystem) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) SQLDB(com.djrapitops.plan.storage.database.SQLDB) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig)

Aggregations

DBSystem (com.djrapitops.plan.storage.database.DBSystem)8 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)4 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)4 Database (com.djrapitops.plan.storage.database.Database)3 SQLiteDB (com.djrapitops.plan.storage.database.SQLiteDB)3 Test (org.junit.jupiter.api.Test)3 DataMap (com.djrapitops.plan.gathering.domain.DataMap)2 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)2 ServerUUID (com.djrapitops.plan.identification.ServerUUID)2 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)2 SessionEndTransaction (com.djrapitops.plan.storage.database.transactions.events.SessionEndTransaction)2 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 PlanSystem (com.djrapitops.plan.PlanSystem)1 WebUser (com.djrapitops.plan.delivery.domain.WebUser)1 User (com.djrapitops.plan.delivery.domain.auth.User)1 EnableException (com.djrapitops.plan.exceptions.EnableException)1 Locale (com.djrapitops.plan.settings.locale.Locale)1 SQLDB (com.djrapitops.plan.storage.database.SQLDB)1 UUID (java.util.UUID)1