use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.
the class ActivityIndexQueriesTest method storeSessions.
default void storeSessions(Predicate<FinishedSession> save) {
db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
for (String world : worlds) {
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), world));
}
for (FinishedSession session : RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID)) {
if (save.test(session))
db().executeTransaction(new StoreSessionTransaction(session));
}
}
use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.
the class JoinAddressQueriesTest method joinAddressCanBeUnknown.
@Test
default void joinAddressCanBeUnknown() {
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
db().executeTransaction(new PlayerRegisterTransaction(playerUUID, System::currentTimeMillis, TestConstants.PLAYER_ONE_NAME));
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
session.getExtraData().remove(JoinAddress.class);
db().executeTransaction(new StoreSessionTransaction(session));
Set<Integer> expected = Set.of(db().query(BaseUserQueries.fetchUserId(playerUUID)).orElseThrow(AssertionError::new));
Set<Integer> result = db().query(JoinAddressQueries.userIdsOfPlayersWithJoinAddresses(List.of(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP)));
assertEquals(expected, result);
Map<String, Integer> expectedAddressCounts = Map.of(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP, 1);
Map<String, Integer> resultAddressCounts = db().query(JoinAddressQueries.latestJoinAddresses());
assertEquals(expectedAddressCounts, resultAddressCounts);
}
use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.
the class JoinAddressQueriesTest method joinAddressQueryHasDistinctPlayers.
@Test
default void joinAddressQueryHasDistinctPlayers() {
joinAddressCanBeUnknown();
db().executeTransaction(TestData.storeServers());
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, player2UUID, playerUUID);
String expectedAddress = TestConstants.GET_PLAYER_HOSTNAME.get();
session.getExtraData().put(JoinAddress.class, new JoinAddress(expectedAddress));
db().executeTransaction(new StoreSessionTransaction(session));
Map<String, Integer> expected = Map.of(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP, 1, expectedAddress, 1);
Map<String, Integer> result = db().query(JoinAddressQueries.latestJoinAddresses());
assertEquals(expected, result);
}
use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.
the class ExportJSErrorRegressionTest method savePlayerData.
private static void savePlayerData() {
DBSystem dbSystem = planSystem.getDatabaseSystem();
Database database = dbSystem.getDatabase();
UUID uuid = TestConstants.PLAYER_ONE_UUID;
database.executeTransaction(new PlayerRegisterTransaction(uuid, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME));
FinishedSession session = new FinishedSession(uuid, serverUUID, 1000L, 11000L, 500L, new DataMap());
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, "world"));
database.executeTransaction(new StoreSessionTransaction(session));
}
use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.
the class PlanPlaceholdersTest method storeSomeData.
private static void storeSomeData() {
Database database = component.system().getDatabaseSystem().getDatabase();
database.executeTransaction(new PlayerServerRegisterTransaction(playerUUID, System::currentTimeMillis, RandomData.randomString(5), serverUUID, () -> RandomData.randomString(5)));
database.executeTransaction(new PlayerServerRegisterTransaction(TestConstants.PLAYER_TWO_UUID, System::currentTimeMillis, TestConstants.PLAYER_TWO_NAME, serverUUID, () -> RandomData.randomString(5)));
String worldName = RandomData.randomString(10);
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName));
database.executeTransaction(new StoreSessionTransaction(RandomData.randomSession(serverUUID, new String[] { worldName }, playerUUID, TestConstants.PLAYER_TWO_UUID)));
}
Aggregations