Search in sources :

Example 1 with PartiesSQLDispatcher

use of com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher in project Parties by AlessioDP.

the class MigrationsTest method testDatabaseFreshPostgreSQL.

@Test
public void testDatabaseFreshPostgreSQL() {
    PartiesSQLDispatcher dispatcher = SQLDispatcherTest.getSQLDispatcherPostgreSQL(mockPlugin);
    if (dispatcher != null) {
        dispatcher.init();
        dispatcher.getConnectionFactory().getJdbi().useHandle(handle -> {
            handle.execute("SELECT 1 FROM <prefix>parties");
            handle.execute("SELECT 1 FROM <prefix>players");
        });
        dispatcher.stop();
    }
}
Also used : PartiesSQLDispatcher(com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher) Test(org.junit.jupiter.api.Test)

Example 2 with PartiesSQLDispatcher

use of com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher in project Parties by AlessioDP.

the class MigrationsTest method testDatabaseFreshMySQL.

@Test
public void testDatabaseFreshMySQL() {
    PartiesSQLDispatcher dispatcher = SQLDispatcherTest.getSQLDispatcherMySQL(mockPlugin);
    if (dispatcher != null) {
        dispatcher.init();
        dispatcher.getConnectionFactory().getJdbi().useHandle(handle -> {
            handle.execute("SELECT 1 FROM <prefix>parties");
            handle.execute("SELECT 1 FROM <prefix>players");
        });
        dispatcher.stop();
    }
}
Also used : PartiesSQLDispatcher(com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher) Test(org.junit.jupiter.api.Test)

Example 3 with PartiesSQLDispatcher

use of com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher in project Parties by AlessioDP.

the class MigrationsTest method testDatabaseFreshH2.

@Test
public void testDatabaseFreshH2() {
    ConfigMain.STORAGE_SETTINGS_H2_DBFILE = "database_h2.db";
    PartiesSQLDispatcher dispatcher = new PartiesSQLDispatcher(mockPlugin, StorageType.H2);
    dispatcher.init();
    dispatcher.getConnectionFactory().getJdbi().useHandle(handle -> {
        handle.execute("SELECT 1 FROM <prefix>parties");
        handle.execute("SELECT 1 FROM <prefix>players");
    });
    dispatcher.stop();
}
Also used : PartiesSQLDispatcher(com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher) Test(org.junit.jupiter.api.Test)

Example 4 with PartiesSQLDispatcher

use of com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher in project Parties by AlessioDP.

the class SQLDispatcherTest method testListParties.

@Test
public void testListParties(@TempDir Path tempDir) {
    PartyManager mockPartyManager = mock(PartyManager.class);
    when(mockPlugin.getPartyManager()).thenReturn(mockPartyManager);
    when(mockPartyManager.initializeParty(any())).thenAnswer((mock) -> initializeParty(mockPlugin, mock.getArgument(0)));
    PlayerManager mockPlayerManager = mock(PlayerManager.class);
    when(mockPlugin.getPlayerManager()).thenReturn(mockPlayerManager);
    when(mockPlayerManager.initializePlayer(any())).thenAnswer((mock) -> initializePlayer(mockPlugin, mock.getArgument(0)));
    PartiesSQLDispatcher dispatcher = getSQLDispatcherH2();
    PartiesDao daoParties = dispatcher.getConnectionFactory().getJdbi().onDemand(H2PartiesDao.class);
    PlayersDao daoPlayers = dispatcher.getConnectionFactory().getJdbi().onDemand(H2PlayersDao.class);
    populateWithParties(dispatcher, daoParties, daoPlayers);
    listPartiesNumber(dispatcher);
    listPartiesByName(dispatcher);
    listPartiesByMembers(dispatcher);
    listPartiesByKills(dispatcher);
    listPartiesByExperience(dispatcher);
    dispatcher.stop();
    dispatcher = getSQLDispatcherSQLite(tempDir);
    daoParties = dispatcher.getConnectionFactory().getJdbi().onDemand(SQLitePartiesDao.class);
    daoPlayers = dispatcher.getConnectionFactory().getJdbi().onDemand(SQLitePlayersDao.class);
    populateWithParties(dispatcher, daoParties, daoPlayers);
    listPartiesNumber(dispatcher);
    listPartiesByName(dispatcher);
    listPartiesByMembers(dispatcher);
    listPartiesByKills(dispatcher);
    listPartiesByExperience(dispatcher);
    dispatcher.stop();
    dispatcher = getSQLDispatcherMySQL(mockPlugin);
    if (dispatcher != null) {
        daoParties = dispatcher.getConnectionFactory().getJdbi().onDemand(PartiesDao.class);
        daoPlayers = dispatcher.getConnectionFactory().getJdbi().onDemand(PlayersDao.class);
        populateWithParties(dispatcher, daoParties, daoPlayers);
        listPartiesNumber(dispatcher);
        listPartiesByName(dispatcher);
        listPartiesByMembers(dispatcher);
        listPartiesByKills(dispatcher);
        listPartiesByExperience(dispatcher);
        dispatcher.stop();
    }
    dispatcher = getSQLDispatcherMariaDB(mockPlugin);
    if (dispatcher != null) {
        daoParties = dispatcher.getConnectionFactory().getJdbi().onDemand(PartiesDao.class);
        daoPlayers = dispatcher.getConnectionFactory().getJdbi().onDemand(PlayersDao.class);
        populateWithParties(dispatcher, daoParties, daoPlayers);
        listPartiesNumber(dispatcher);
        listPartiesByName(dispatcher);
        listPartiesByMembers(dispatcher);
        listPartiesByKills(dispatcher);
        listPartiesByExperience(dispatcher);
        dispatcher.stop();
    }
    dispatcher = getSQLDispatcherPostgreSQL(mockPlugin);
    if (dispatcher != null) {
        daoParties = dispatcher.getConnectionFactory().getJdbi().onDemand(PostgreSQLPartiesDao.class);
        daoPlayers = dispatcher.getConnectionFactory().getJdbi().onDemand(PostgreSQLPlayersDao.class);
        populateWithParties(dispatcher, daoParties, daoPlayers);
        listPartiesNumber(dispatcher);
        listPartiesByName(dispatcher);
        listPartiesByMembers(dispatcher);
        listPartiesByKills(dispatcher);
        listPartiesByExperience(dispatcher);
        dispatcher.stop();
    }
}
Also used : PlayerManager(com.alessiodp.parties.common.players.PlayerManager) SQLitePartiesDao(com.alessiodp.parties.common.storage.sql.dao.parties.SQLitePartiesDao) PartiesDao(com.alessiodp.parties.common.storage.sql.dao.parties.PartiesDao) H2PartiesDao(com.alessiodp.parties.common.storage.sql.dao.parties.H2PartiesDao) PostgreSQLPartiesDao(com.alessiodp.parties.common.storage.sql.dao.parties.PostgreSQLPartiesDao) PartyManager(com.alessiodp.parties.common.parties.PartyManager) PartiesSQLDispatcher(com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher) SQLitePartiesDao(com.alessiodp.parties.common.storage.sql.dao.parties.SQLitePartiesDao) PostgreSQLPartiesDao(com.alessiodp.parties.common.storage.sql.dao.parties.PostgreSQLPartiesDao) SQLitePlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.SQLitePlayersDao) H2PlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.H2PlayersDao) PostgreSQLPlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.PostgreSQLPlayersDao) PlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.PlayersDao) SQLitePlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.SQLitePlayersDao) PostgreSQLPlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.PostgreSQLPlayersDao) Test(org.junit.jupiter.api.Test)

Example 5 with PartiesSQLDispatcher

use of com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher in project Parties by AlessioDP.

the class SQLDispatcherTest method testCountPlayersInParty.

@Test
public void testCountPlayersInParty(@TempDir Path tempDir) {
    PartiesSQLDispatcher dispatcher = getSQLDispatcherH2();
    player(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(H2PlayersDao.class), false);
    countPlayersInParty(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(H2PlayersDao.class));
    dispatcher.stop();
    dispatcher = getSQLDispatcherSQLite(tempDir);
    player(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(SQLitePlayersDao.class), false);
    countPlayersInParty(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(SQLitePlayersDao.class));
    dispatcher.stop();
    dispatcher = getSQLDispatcherMySQL(mockPlugin);
    if (dispatcher != null) {
        player(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(PlayersDao.class), false);
        countPlayersInParty(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(PlayersDao.class));
        dispatcher.stop();
    }
    dispatcher = getSQLDispatcherMariaDB(mockPlugin);
    if (dispatcher != null) {
        player(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(PlayersDao.class), false);
        countPlayersInParty(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(PlayersDao.class));
        dispatcher.stop();
    }
    dispatcher = getSQLDispatcherPostgreSQL(mockPlugin);
    if (dispatcher != null) {
        player(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(PostgreSQLPlayersDao.class), false);
        countPlayersInParty(dispatcher, dispatcher.getConnectionFactory().getJdbi().onDemand(PostgreSQLPlayersDao.class));
        dispatcher.stop();
    }
}
Also used : H2PlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.H2PlayersDao) PartiesSQLDispatcher(com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher) SQLitePlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.SQLitePlayersDao) H2PlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.H2PlayersDao) PostgreSQLPlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.PostgreSQLPlayersDao) PlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.PlayersDao) SQLitePlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.SQLitePlayersDao) PostgreSQLPlayersDao(com.alessiodp.parties.common.storage.sql.dao.players.PostgreSQLPlayersDao) Test(org.junit.jupiter.api.Test)

Aggregations

PartiesSQLDispatcher (com.alessiodp.parties.common.storage.dispatchers.PartiesSQLDispatcher)16 Test (org.junit.jupiter.api.Test)14 H2PartiesDao (com.alessiodp.parties.common.storage.sql.dao.parties.H2PartiesDao)6 PartiesDao (com.alessiodp.parties.common.storage.sql.dao.parties.PartiesDao)6 PostgreSQLPartiesDao (com.alessiodp.parties.common.storage.sql.dao.parties.PostgreSQLPartiesDao)6 SQLitePartiesDao (com.alessiodp.parties.common.storage.sql.dao.parties.SQLitePartiesDao)6 H2PlayersDao (com.alessiodp.parties.common.storage.sql.dao.players.H2PlayersDao)3 PlayersDao (com.alessiodp.parties.common.storage.sql.dao.players.PlayersDao)3 PostgreSQLPlayersDao (com.alessiodp.parties.common.storage.sql.dao.players.PostgreSQLPlayersDao)3 SQLitePlayersDao (com.alessiodp.parties.common.storage.sql.dao.players.SQLitePlayersDao)3 ConnectionFactory (com.alessiodp.core.common.storage.sql.connection.ConnectionFactory)2 PartyManager (com.alessiodp.parties.common.parties.PartyManager)2 PlayerManager (com.alessiodp.parties.common.players.PlayerManager)2 ADPPlugin (com.alessiodp.core.common.ADPPlugin)1 Party (com.alessiodp.parties.api.interfaces.Party)1 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)1 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)1 PartiesYAMLDispatcher (com.alessiodp.parties.common.storage.dispatchers.PartiesYAMLDispatcher)1 ArrayList (java.util.ArrayList)1 CompletableFuture (java.util.concurrent.CompletableFuture)1