Search in sources :

Example 1 with PluginMockComponent

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

the class JSErrorRegressionTest method setUpClass.

@BeforeAll
static void setUpClass(@TempDir Path tempDir) throws Exception {
    component = new PluginMockComponent(tempDir);
    planSystem = component.getPlanSystem();
    PlanConfig config = planSystem.getConfigSystem().getConfig();
    config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
    config.set(ProxySettings.IP, "localhost:" + TEST_PORT_NUMBER);
    planSystem.enable();
    serverUUID = planSystem.getServerInfo().getServerUUID();
    savePlayerData();
}
Also used : PluginMockComponent(utilities.mocks.PluginMockComponent) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with PluginMockComponent

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

the class Pkcs12HttpsServerTest method setUpClass.

@BeforeAll
static void setUpClass(@TempDir Path tempDir) throws Exception {
    File file = tempDir.resolve("TestCert.p12").toFile();
    File testCert = TestResources.getTestResourceFile("TestCert.p12", ConfigUpdater.class);
    Files.copy(testCert.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING);
    String absolutePath = file.getAbsolutePath();
    PluginMockComponent component = new PluginMockComponent(tempDir);
    system = component.getPlanSystem();
    PlanConfig config = system.getConfigSystem().getConfig();
    config.set(WebserverSettings.CERTIFICATE_PATH, absolutePath);
    config.set(WebserverSettings.CERTIFICATE_KEYPASS, "test");
    config.set(WebserverSettings.CERTIFICATE_STOREPASS, "test");
    config.set(WebserverSettings.CERTIFICATE_ALIAS, "test");
    config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
    system.enable();
    User user = new User("test", "console", null, PassEncryptUtil.createHash("testPass"), 0, Collections.emptyList());
    system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(user));
}
Also used : User(com.djrapitops.plan.delivery.domain.auth.User) RegisterWebUserTransaction(com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction) PluginMockComponent(utilities.mocks.PluginMockComponent) File(java.io.File) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 3 with PluginMockComponent

use of utilities.mocks.PluginMockComponent 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 4 with PluginMockComponent

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

the class DBPatchSQLiteRegressionTest method setUpDBWithOldSchema.

@BeforeEach
void setUpDBWithOldSchema(@TempDir Path tempDir) throws Exception {
    component = new PluginMockComponent(tempDir);
    underTest = this.component.getPlanSystem().getDatabaseSystem().getSqLiteFactory().usingFileCalled("test");
    underTest.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService);
    underTest.init();
    // Initialize database with the old table schema
    dropAllTables(underTest);
    underTest.executeTransaction(new Transaction() {

        @Override
        protected void performOperations() {
            execute(serverTable);
            execute(usersTable);
            execute(userInfoTable);
            execute(geoInfoTable);
            execute(nicknameTable);
            execute(sessionsTable);
            execute(killsTable);
            execute(pingTable);
            execute(commandUseTable);
            execute(tpsTable);
            execute(worldsTable);
            execute(worldTimesTable);
            execute(securityTable);
            execute(transferTable);
        }
    });
    underTest.executeTransaction(new CreateTablesTransaction());
    insertData(underTest);
}
Also used : Transaction(com.djrapitops.plan.storage.database.transactions.Transaction) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) CreateTablesTransaction(com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) PluginMockComponent(utilities.mocks.PluginMockComponent) CreateTablesTransaction(com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with PluginMockComponent

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

the class JksHttpsServerTest method setUpClass.

@BeforeAll
static void setUpClass(@TempDir Path tempDir) throws Exception {
    File file = tempDir.resolve("PlanCert.jks").toFile();
    TestResources.copyResourceIntoFile(file, "/PlanCert.jks");
    String absolutePath = file.getAbsolutePath();
    PluginMockComponent component = new PluginMockComponent(tempDir);
    system = component.getPlanSystem();
    PlanConfig config = system.getConfigSystem().getConfig();
    config.set(WebserverSettings.CERTIFICATE_PATH, absolutePath);
    config.set(WebserverSettings.CERTIFICATE_KEYPASS, "MnD3bU5HpmPXag0e");
    config.set(WebserverSettings.CERTIFICATE_STOREPASS, "wDwwf663NLTm73gL");
    config.set(WebserverSettings.CERTIFICATE_ALIAS, "DefaultPlanCert");
    config.set(WebserverSettings.PORT, TEST_PORT_NUMBER);
    system.enable();
    User user = new User("test", "console", null, PassEncryptUtil.createHash("testPass"), 0, Collections.emptyList());
    system.getDatabaseSystem().getDatabase().executeTransaction(new RegisterWebUserTransaction(user));
}
Also used : User(com.djrapitops.plan.delivery.domain.auth.User) RegisterWebUserTransaction(com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction) PluginMockComponent(utilities.mocks.PluginMockComponent) File(java.io.File) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

PluginMockComponent (utilities.mocks.PluginMockComponent)11 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)5 BeforeAll (org.junit.jupiter.api.BeforeAll)5 BeforeEach (org.junit.jupiter.api.BeforeEach)4 User (com.djrapitops.plan.delivery.domain.auth.User)3 RegisterWebUserTransaction (com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction)3 File (java.io.File)3 PlanSystem (com.djrapitops.plan.PlanSystem)2 Server (com.djrapitops.plan.identification.Server)1 Locale (com.djrapitops.plan.settings.locale.Locale)1 DBSystem (com.djrapitops.plan.storage.database.DBSystem)1 StoreServerInformationTransaction (com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction)1 Transaction (com.djrapitops.plan.storage.database.transactions.Transaction)1 RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)1 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)1 CreateTablesTransaction (com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction)1 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)1 Path (java.nio.file.Path)1 PlatformAbstractionLayer (net.playeranalytics.plugin.PlatformAbstractionLayer)1 TestPluginLogger (utilities.TestPluginLogger)1