Search in sources :

Example 6 with StoreSessionTransaction

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));
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) DBSystem(com.djrapitops.plan.storage.database.DBSystem) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) Database(com.djrapitops.plan.storage.database.Database) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataMap(com.djrapitops.plan.gathering.domain.DataMap)

Example 7 with StoreSessionTransaction

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));
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) BeforeEach(org.junit.jupiter.api.BeforeEach) com.djrapitops.plan.extension.annotation(com.djrapitops.plan.extension.annotation) WorldTimes(com.djrapitops.plan.gathering.domain.WorldTimes) ServerUUID(com.djrapitops.plan.identification.ServerUUID) ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) Map(java.util.Map) RemoveUnsatisfiedConditionalServerResultsTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalServerResultsTransaction) DatabaseTestPreparer(com.djrapitops.plan.storage.database.DatabaseTestPreparer) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) ExtensionServerDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery) TestConstants(utilities.TestConstants) NotReadyException(com.djrapitops.plan.extension.NotReadyException) ExtensionPlayerDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery) Table(com.djrapitops.plan.extension.table.Table) ExtensionDataBuilder(com.djrapitops.plan.extension.builder.ExtensionDataBuilder) TestErrorLogger(utilities.TestErrorLogger) HtmlTable(com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable) DataExtension(com.djrapitops.plan.extension.DataExtension) OptionalAssert(utilities.OptionalAssert) Color(com.djrapitops.plan.extension.icon.Color) ExtensionServerTableDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerTableDataQuery) Icon(com.djrapitops.plan.extension.icon.Icon) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) UUID(java.util.UUID) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) Test(org.junit.jupiter.api.Test) Objects(java.util.Objects) List(java.util.List) Assertions(org.junit.jupiter.api.Assertions) CallEvents(com.djrapitops.plan.extension.CallEvents) RandomData(utilities.RandomData) com.djrapitops.plan.extension.implementation.results(com.djrapitops.plan.extension.implementation.results) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) RemoveUnsatisfiedConditionalPlayerResultsTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalPlayerResultsTransaction) StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) ActiveSession(com.djrapitops.plan.gathering.domain.ActiveSession) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) ExtensionServerTableDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerTableDataQuery) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test)

Example 8 with StoreSessionTransaction

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);
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) JoinAddress(com.djrapitops.plan.gathering.domain.event.JoinAddress) Test(org.junit.jupiter.api.Test)

Example 9 with StoreSessionTransaction

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);
}
Also used : StoreSessionTransaction(com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) JoinAddress(com.djrapitops.plan.gathering.domain.event.JoinAddress) Test(org.junit.jupiter.api.Test)

Aggregations

StoreSessionTransaction (com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction)9 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)7 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)7 Test (org.junit.jupiter.api.Test)5 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)4 JoinAddress (com.djrapitops.plan.gathering.domain.event.JoinAddress)3 ServerUUID (com.djrapitops.plan.identification.ServerUUID)3 Database (com.djrapitops.plan.storage.database.Database)3 DataMap (com.djrapitops.plan.gathering.domain.DataMap)2 DBSystem (com.djrapitops.plan.storage.database.DBSystem)2 PlayerServerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction)2 HtmlTable (com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable)1 CallEvents (com.djrapitops.plan.extension.CallEvents)1 DataExtension (com.djrapitops.plan.extension.DataExtension)1 ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)1 NotReadyException (com.djrapitops.plan.extension.NotReadyException)1 com.djrapitops.plan.extension.annotation (com.djrapitops.plan.extension.annotation)1 ExtensionDataBuilder (com.djrapitops.plan.extension.builder.ExtensionDataBuilder)1 Color (com.djrapitops.plan.extension.icon.Color)1 Icon (com.djrapitops.plan.extension.icon.Icon)1