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();
}
}
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();
}
}
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();
}
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();
}
}
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();
}
}
Aggregations