use of com.djrapitops.plan.identification.ServerUUID 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 SessionEndTransaction(session));
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionServerAggregateQueriesWork.
@Test
default void extensionServerAggregateQueriesWork() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new PlayerExtension());
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
List<ExtensionData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
assertFalse(ofServer.isEmpty());
ExtensionData extensionData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionData.getTabs();
// No tab defined, should contain 1 tab
assertEquals(1, tabs.size());
ExtensionTabData tabData = tabs.get(0);
System.out.println(tabData.getValueOrder());
OptionalAssert.equals("0.0", tabData.getPercentage("boolVal_aggregate").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("0.5", tabData.getPercentage("percentageVal_avg").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("0.5", tabData.getDouble("doubleVal_avg").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("0.5", tabData.getDouble("doubleVal_total").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("5", tabData.getNumber("value_avg").map(data -> data.getFormattedValue(Objects::toString)));
OptionalAssert.equals("5", tabData.getNumber("value_total").map(data -> data.getFormattedValue(Objects::toString)));
List<ExtensionTableData> tableData = tabData.getTableData();
assertEquals(1, tableData.size());
HtmlTable table = tableData.get(0).getHtmlTable();
String result = table.toHtml();
assertTrue(result.contains("<tbody><tr><td>Group</td><td>1</td></tr></tbody>"), result);
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionServerValuesAreStored.
@Test
default void extensionServerValuesAreStored() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new ServerExtension());
extensionService.updateServerValues(CallEvents.SERVER_EXTENSION_REGISTER);
List<ExtensionData> ofServer = db().query(new ExtensionServerDataQuery(serverUUID()));
assertFalse(ofServer.isEmpty());
ExtensionData extensionData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionData.getTabs();
// No tab defined, should contain 1 tab
assertEquals(1, tabs.size());
ExtensionTabData tabData = tabs.get(0);
OptionalAssert.equals("5", tabData.getNumber("value").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("No", tabData.getBoolean("boolVal").map(ExtensionBooleanData::getFormattedValue));
OptionalAssert.equals("0.5", tabData.getDouble("doubleVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("0.5", tabData.getPercentage("percentageVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("Something", tabData.getString("stringVal").map(ExtensionStringData::getFormattedValue));
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionPlayerValuesAreStored.
@Test
default void extensionPlayerValuesAreStored() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new PlayerExtension());
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
Map<ServerUUID, List<ExtensionData>> playerDataByServerUUID = db().query(new ExtensionPlayerDataQuery(playerUUID));
List<ExtensionData> ofServer = playerDataByServerUUID.get(serverUUID());
assertNotNull(ofServer);
assertFalse(ofServer.isEmpty());
ExtensionData extensionPlayerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionPlayerData.getTabs();
// No tab defined, should contain 1 tab
assertEquals(1, tabs.size());
ExtensionTabData tabData = tabs.get(0);
OptionalAssert.equals("5", tabData.getNumber("value").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("No", tabData.getBoolean("boolVal").map(ExtensionBooleanData::getFormattedValue));
OptionalAssert.equals("0.5", tabData.getDouble("doubleVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("0.5", tabData.getPercentage("percentageVal").map(data -> data.getFormattedValue(Object::toString)));
OptionalAssert.equals("Something", tabData.getString("stringVal").map(ExtensionStringData::getFormattedValue));
OptionalAssert.equals("Group", tabData.getString("groupVal").map(ExtensionStringData::getFormattedValue));
}
use of com.djrapitops.plan.identification.ServerUUID in project Plan by plan-player-analytics.
the class PerServerMutator method worldTimesPerServer.
public Map<ServerUUID, WorldTimes> worldTimesPerServer() {
Map<ServerUUID, WorldTimes> timesMap = new HashMap<>();
for (Map.Entry<ServerUUID, DataContainer> entry : data.entrySet()) {
DataContainer container = entry.getValue();
timesMap.put(entry.getKey(), container.getValue(PerServerKeys.WORLD_TIMES).orElse(new WorldTimes()));
}
return timesMap;
}
Aggregations