use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.
the class JSErrorRegressionTest 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 ExtensionsDatabaseTest method extensionPlayerValuesCanBeQueriedAsTableData.
@Test
default void extensionPlayerValuesCanBeQueriedAsTableData() {
extensionPlayerValuesAreStored();
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
// Store a session to check against issue https://github.com/plan-player-analytics/Plan/issues/1039
ActiveSession session = new ActiveSession(playerUUID, serverUUID(), 32345L, worlds[0], "SURVIVAL");
session.getExtraData().put(WorldTimes.class, RandomData.randomWorldTimes(worlds));
db().executeTransaction(new StoreSessionTransaction(session.toFinishedSession(42345L)));
Map<UUID, ExtensionTabData> result = db().query(new ExtensionServerTableDataQuery(serverUUID(), 50));
assertEquals(1, result.size());
ExtensionTabData playerData = result.get(playerUUID);
assertNotNull(playerData);
OptionalAssert.equals("5", playerData.getNumber("value").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("No", playerData.getBoolean("boolVal").map(ExtensionBooleanData::getFormattedValue));
OptionalAssert.equals("0.5", playerData.getDouble("doubleVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("0.5", playerData.getPercentage("percentageVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("Something", playerData.getString("stringVal").map(ExtensionStringData::getFormattedValue));
}
use of com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction in project Plan by plan-player-analytics.
the class JoinAddressQueriesTest method latestJoinAddressIsUpdatedUponSecondSession.
@Test
default void latestJoinAddressIsUpdatedUponSecondSession() {
joinAddressCanBeUnknown();
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
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(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 JoinAddressQueriesTest method joinAddressUpdateIsUniquePerServer.
@Test
default void joinAddressUpdateIsUniquePerServer() {
joinAddressCanBeUnknown();
db().executeTransaction(TestData.storeServers());
db().executeTransaction(new WorldNameStoreTransaction(TestConstants.SERVER_TWO_UUID, worlds[0]));
db().executeTransaction(new WorldNameStoreTransaction(TestConstants.SERVER_TWO_UUID, worlds[1]));
FinishedSession session = RandomData.randomSession(TestConstants.SERVER_TWO_UUID, worlds, playerUUID, player2UUID);
String expectedAddress = TestConstants.GET_PLAYER_HOSTNAME.get();
session.getExtraData().put(JoinAddress.class, new JoinAddress(expectedAddress));
db().executeTransaction(new StoreSessionTransaction(session));
Map<String, Integer> expected1 = Map.of(JoinAddressTable.DEFAULT_VALUE_FOR_LOOKUP, 1);
Map<String, Integer> result1 = db().query(JoinAddressQueries.latestJoinAddresses(serverUUID()));
assertEquals(expected1, result1);
Map<String, Integer> expected2 = Map.of(expectedAddress, 1);
Map<String, Integer> result2 = db().query(JoinAddressQueries.latestJoinAddresses(TestConstants.SERVER_TWO_UUID));
assertEquals(expected2, result2);
}
Aggregations