Search in sources :

Example 11 with PlanConfig

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

the class TimeAmountFormatterExtraZerosTest method setUpFormatter.

@BeforeAll
static void setUpFormatter() {
    PlanConfig config = Mockito.mock(PlanConfig.class);
    when(config.get(FormatSettings.YEAR)).thenReturn("1 year, ");
    when(config.get(FormatSettings.YEARS)).thenReturn("%years% years, ");
    when(config.get(FormatSettings.MONTH)).thenReturn("1 month, ");
    when(config.get(FormatSettings.MONTHS)).thenReturn("%months% months, ");
    when(config.get(FormatSettings.DAY)).thenReturn("1d ");
    when(config.get(FormatSettings.DAYS)).thenReturn("%days%d ");
    when(config.get(FormatSettings.HOURS)).thenReturn("%zero%%hours%:");
    when(config.get(FormatSettings.MINUTES)).thenReturn("%hours%%zero%%minutes%:");
    when(config.get(FormatSettings.SECONDS)).thenReturn("%minutes%%zero%%seconds%");
    when(config.get(FormatSettings.ZERO_SECONDS)).thenReturn("00:00:00");
    underTest = new TimeAmountFormatter(config);
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) TimeAmountFormatter(com.djrapitops.plan.delivery.formatting.time.TimeAmountFormatter) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 12 with PlanConfig

use of com.djrapitops.plan.settings.config.PlanConfig 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 13 with PlanConfig

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

the class BungeeSystemTest method testEnableWithMySQL.

@Test
void testEnableWithMySQL() throws Exception {
    PlanSystem bungeeSystem = component.getPlanSystem();
    try {
        PlanConfig config = bungeeSystem.getConfigSystem().getConfig();
        // MySQL settings might not be available.
        assumeTrue(dbPreparer.setUpMySQLSettings(config).isPresent());
        config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
        config.set(ProxySettings.IP, "8.8.8.8");
        bungeeSystem.enable();
        assertTrue(bungeeSystem.isEnabled());
    } finally {
        bungeeSystem.disable();
    }
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 14 with PlanConfig

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

the class BukkitSystemTest method bukkitSystemHasDefaultConfigValuesAfterEnable.

@Test
void bukkitSystemHasDefaultConfigValuesAfterEnable() throws IllegalAccessException {
    try {
        system.enable();
        PlanConfig config = system.getConfigSystem().getConfig();
        TestSettings.assertValidDefaultValuesForAllSettings(config, TestSettings.getServerSettings());
    } finally {
        system.disable();
    }
}
Also used : PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 15 with PlanConfig

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

the class BukkitAFKListenerTest method setUp.

@BeforeAll
static void setUp() {
    PlanConfig config = Mockito.mock(PlanConfig.class);
    when(config.get(TimeSettings.AFK_THRESHOLD)).thenReturn(TimeUnit.MINUTES.toMillis(3));
    errorLogger = Mockito.mock(ErrorLogger.class);
    underTest = new BukkitAFKListener(config, errorLogger);
    new SessionCache().cacheSession(TestConstants.PLAYER_ONE_UUID, new ActiveSession(null, null, 0, null, null));
    new SessionCache().cacheSession(TestConstants.PLAYER_TWO_UUID, new ActiveSession(null, null, 0, null, null));
}
Also used : ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) BukkitAFKListener(com.djrapitops.plan.gathering.listeners.bukkit.BukkitAFKListener) SessionCache(com.djrapitops.plan.gathering.cache.SessionCache) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)31 Test (org.junit.jupiter.api.Test)17 BeforeAll (org.junit.jupiter.api.BeforeAll)8 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