Search in sources :

Example 6 with DBSystem

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

the class JSErrorRegressionTest 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) UUID(java.util.UUID) DataMap(com.djrapitops.plan.gathering.domain.DataMap)

Example 7 with DBSystem

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

the class ActiveCookieStoreTest method createActiveCookieStore.

@BeforeEach
void createActiveCookieStore() {
    DBSystem dbSystem = Mockito.mock(DBSystem.class);
    Database db = Mockito.mock(Database.class);
    when(dbSystem.getDatabase()).thenReturn(db);
    underTest = new ActiveCookieStore(Mockito.mock(ActiveCookieExpiryCleanupTask.class), Mockito.mock(PlanConfig.class), dbSystem, Mockito.mock(Processing.class));
    user = new User(TestConstants.PLAYER_ONE_NAME, "console", null, PassEncryptUtil.createHash("testPass"), 0, WebUser.getPermissionsForLevel(0));
}
Also used : DBSystem(com.djrapitops.plan.storage.database.DBSystem) User(com.djrapitops.plan.delivery.domain.auth.User) WebUser(com.djrapitops.plan.delivery.domain.WebUser) Database(com.djrapitops.plan.storage.database.Database) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with DBSystem

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

the class BungeeSystemTest method bungeeDoesNotEnableWithDefaultIP.

@Test
void bungeeDoesNotEnableWithDefaultIP() {
    EnableException thrown = assertThrows(EnableException.class, () -> {
        PlanSystem bungeeSystem = component.getPlanSystem();
        try {
            PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
            config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
            config.set(ProxySettings.IP, "0.0.0.0");
            DBSystem dbSystem = bungeeSystem.getDatabaseSystem();
            SQLiteDB db = dbSystem.getSqLiteFactory().usingDefaultFile();
            db.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
            dbSystem.setActiveDatabase(db);
            // Throws EnableException
            bungeeSystem.enable();
        } finally {
            bungeeSystem.disable();
        }
    });
    assertEquals("IP setting still 0.0.0.0 - Configure Alternative_IP/IP that connects to the Proxy server.", thrown.getMessage());
}
Also used : DBSystem(com.djrapitops.plan.storage.database.DBSystem) EnableException(com.djrapitops.plan.exceptions.EnableException) 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)

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