Search in sources :

Example 26 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class NukkitSystemTest method nukkitSystemHasDefaultConfigValuesAfterEnable.

@Test
void nukkitSystemHasDefaultConfigValuesAfterEnable() throws EnableException, IllegalAccessException {
    try {
        system.enable();
        PlanConfig config = system.getConfigSystem().getConfig();
        Collection<Setting> serverSettings = TestSettings.getServerSettings();
        TestSettings.assertValidDefaultValuesForAllSettings(config, serverSettings);
    } finally {
        system.disable();
    }
}
Also used : Setting(com.djrapitops.plan.settings.config.paths.key.Setting) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 27 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class SpongeSystemTest method spongeSystemHasDefaultConfigValuesAfterEnable.

@Test
void spongeSystemHasDefaultConfigValuesAfterEnable() throws EnableException, IllegalAccessException {
    try {
        system.enable();
        PlanConfig config = system.getConfigSystem().getConfig();
        Collection<Setting> serverSettings = TestSettings.getServerSettings();
        TestSettings.assertValidDefaultValuesForAllSettings(config, serverSettings);
    } finally {
        system.disable();
    }
}
Also used : Setting(com.djrapitops.plan.settings.config.paths.key.Setting) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 28 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class DatabaseTest method unchangedConfigDoesNotUpdateInDatabase.

@Test
default void unchangedConfigDoesNotUpdateInDatabase() {
    configIsStoredInTheDatabase();
    long savedMs = System.currentTimeMillis();
    PlanConfig config = config();
    db().executeTransaction(new StoreConfigTransaction(serverUUID(), config, System.currentTimeMillis()));
    assertFalse(db().query(new NewerConfigQuery(serverUUID(), savedMs)).isPresent());
}
Also used : StoreConfigTransaction(com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 29 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class DatabaseTest method configIsStoredInTheDatabase.

@Test
default void configIsStoredInTheDatabase() {
    PlanConfig config = config();
    db().executeTransaction(new StoreConfigTransaction(serverUUID(), config, System.currentTimeMillis()));
    Optional<Config> foundConfig = db().query(new NewerConfigQuery(serverUUID(), 0));
    assertTrue(foundConfig.isPresent());
    assertEquals(config, foundConfig.get());
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Config(com.djrapitops.plan.settings.config.Config) StoreConfigTransaction(com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 30 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig in project Plan by plan-player-analytics.

the class DBPreparer method prepareMySQL.

public Optional<Database> prepareMySQL() {
    PlanConfig config = dependencies.config();
    Optional<String> formattedDB = setUpMySQLSettings(config);
    if (formattedDB.isPresent()) {
        String formattedDatabase = formattedDB.get();
        SQLDB mysql = prepareDBByName(DBType.MYSQL.getName());
        mysql.executeTransaction(new Transaction() {

            @Override
            protected void performOperations() {
                execute("SET GLOBAL innodb_file_per_table=0");
                execute("SET GLOBAL innodb_fast_shutdown=2");
                execute("DROP DATABASE " + formattedDatabase);
                execute("CREATE DATABASE " + formattedDatabase);
                execute("USE " + formattedDatabase);
            }
        });
        return Optional.of(mysql);
    }
    return Optional.empty();
}
Also used : Transaction(com.djrapitops.plan.storage.database.transactions.Transaction) SQLDB(com.djrapitops.plan.storage.database.SQLDB) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig)

Aggregations

PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)31 Test (org.junit.jupiter.api.Test)17 BeforeAll (org.junit.jupiter.api.BeforeAll)7 Path (java.nio.file.Path)5 TestPluginLogger (utilities.TestPluginLogger)5 PluginMockComponent (utilities.mocks.PluginMockComponent)5 DBSystem (com.djrapitops.plan.storage.database.DBSystem)4 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)4 User (com.djrapitops.plan.delivery.domain.auth.User)3 SessionCache (com.djrapitops.plan.gathering.cache.SessionCache)3 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)3 SQLiteDB (com.djrapitops.plan.storage.database.SQLiteDB)3 RegisterWebUserTransaction (com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction)3 File (java.io.File)3 TimeAmountFormatter (com.djrapitops.plan.delivery.formatting.time.TimeAmountFormatter)2 Setting (com.djrapitops.plan.settings.config.paths.key.Setting)2 SQLDB (com.djrapitops.plan.storage.database.SQLDB)2 StoreConfigTransaction (com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction)2 ErrorLogger (com.djrapitops.plan.utilities.logging.ErrorLogger)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2