Search in sources :

Example 1 with TestPluginLogger

use of utilities.TestPluginLogger in project Plan by plan-player-analytics.

the class JSONStorageTest method setUp.

@BeforeEach
void setUp(@TempDir Path tempDir) {
    PlanFiles files = Mockito.mock(PlanFiles.class);
    this.tempDir = tempDir;
    when(files.getJSONStorageDirectory()).thenReturn(this.tempDir);
    UNDER_TEST = new JSONFileStorage(files, value -> Long.toString(value), new TestPluginLogger());
}
Also used : PlanFiles(com.djrapitops.plan.storage.file.PlanFiles) BeforeEach(org.junit.jupiter.api.BeforeEach) Files(java.nio.file.Files) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) File(java.io.File) Test(org.junit.jupiter.api.Test) TimeUnit(java.util.concurrent.TimeUnit) Mockito(org.mockito.Mockito) List(java.util.List) Stream(java.util.stream.Stream) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) TempDir(org.junit.jupiter.api.io.TempDir) Optional(java.util.Optional) TestPluginLogger(utilities.TestPluginLogger) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Path(java.nio.file.Path) Collections(java.util.Collections) PlanFiles(com.djrapitops.plan.storage.file.PlanFiles) TestPluginLogger(utilities.TestPluginLogger) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with TestPluginLogger

use of utilities.TestPluginLogger 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 TestPluginLogger

use of utilities.TestPluginLogger in project Plan by plan-player-analytics.

the class ConfigUpdaterTest method prepareConfigFiles.

@BeforeAll
static void prepareConfigFiles() throws URISyntaxException, IOException {
    oldConfig = tempDir.resolve("config.yml").toFile();
    File configResource = TestResources.getTestResourceFile("config/4.5.2-config.yml", ConfigUpdater.class);
    Files.copy(configResource.toPath(), oldConfig.toPath(), StandardCopyOption.REPLACE_EXISTING);
    oldBungeeConfig = tempDir.resolve("bungeeconfig.yml").toFile();
    File bungeeConfigResource = TestResources.getTestResourceFile("config/4.5.2-bungeeconfig.yml", ConfigUpdater.class);
    Files.copy(bungeeConfigResource.toPath(), oldBungeeConfig.toPath(), StandardCopyOption.REPLACE_EXISTING);
    newConfig = tempDir.resolve("newconfig.yml");
    TestResources.copyResourceIntoFile(newConfig.toFile(), "/assets/plan/config.yml");
    newBungeeConfig = tempDir.resolve("newbungeeconfig.yml");
    TestResources.copyResourceIntoFile(newBungeeConfig.toFile(), "/assets/plan/bungeeconfig.yml");
    PluginLogger testLogger = new TestPluginLogger();
    errorLogger = Mockito.mock(ErrorLogger.class);
    UNDER_TEST = new ConfigUpdater(testLogger, errorLogger);
}
Also used : TestPluginLogger(utilities.TestPluginLogger) File(java.io.File) PluginLogger(net.playeranalytics.plugin.server.PluginLogger) TestPluginLogger(utilities.TestPluginLogger) ErrorLogger(com.djrapitops.plan.utilities.logging.ErrorLogger) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with TestPluginLogger

use of utilities.TestPluginLogger in project Plan by plan-player-analytics.

the class ConfigUpdaterTest method proxyConfigIsPatchedCorrectly.

@Test
void proxyConfigIsPatchedCorrectly() throws IOException, IllegalAccessException {
    Path configPath = tempDir.resolve("oldconfig.yml");
    Files.copy(oldBungeeConfig.toPath(), configPath, StandardCopyOption.REPLACE_EXISTING);
    PlanConfig config = new PlanConfig(configPath.toFile(), null, null, new TestPluginLogger());
    UNDER_TEST.applyConfigUpdate(config);
    // Ensure that added settings are present
    copyMissingFrom(config, newBungeeConfig);
    TestSettings.assertValidDefaultValuesForAllSettings(config, TestSettings.getProxySettings());
}
Also used : Path(java.nio.file.Path) TestPluginLogger(utilities.TestPluginLogger) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Example 5 with TestPluginLogger

use of utilities.TestPluginLogger in project Plan by plan-player-analytics.

the class ConfigUpdaterTest method serverMoveChangesDoNotLeaveNewEmptyValues.

@Test
void serverMoveChangesDoNotLeaveNewEmptyValues() throws IOException {
    Path configPath = tempDir.resolve("oldconfig.yml");
    Files.copy(oldConfig.toPath(), configPath, StandardCopyOption.REPLACE_EXISTING);
    PlanConfig config = new PlanConfig(configPath.toFile(), null, null, new TestPluginLogger());
    ConfigChange[] changes = UNDER_TEST.configEnhancementPatch();
    assertMoveChangesAreAppliedProperly(config, changes);
}
Also used : Path(java.nio.file.Path) TestPluginLogger(utilities.TestPluginLogger) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Test(org.junit.jupiter.api.Test)

Aggregations

TestPluginLogger (utilities.TestPluginLogger)8 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)5 Path (java.nio.file.Path)5 Test (org.junit.jupiter.api.Test)5 File (java.io.File)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 PlanSystem (com.djrapitops.plan.PlanSystem)1 Locale (com.djrapitops.plan.settings.locale.Locale)1 DBSystem (com.djrapitops.plan.storage.database.DBSystem)1 PlanFiles (com.djrapitops.plan.storage.file.PlanFiles)1 ErrorLogger (com.djrapitops.plan.utilities.logging.ErrorLogger)1 IOException (java.io.IOException)1 Files (java.nio.file.Files)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 PluginLogger (net.playeranalytics.plugin.server.PluginLogger)1