use of com.djrapitops.plan.extension.ExtensionSvc 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.extension.ExtensionSvc 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.extension.ExtensionSvc 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.extension.ExtensionSvc in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method unsatisfiedServerConditionalResultsAreCleaned.
@Test
default void unsatisfiedServerConditionalResultsAreCleaned() {
ExtensionSvc extensionService = extensionService();
ConditionalExtension.condition = true;
extensionService.register(new ConditionalExtension());
extensionService.updateServerValues(CallEvents.MANUAL);
// Check that the wanted data exists
checkThatServerDataExists(ConditionalExtension.condition);
// Reverse condition
ConditionalExtension.condition = false;
extensionService.updateServerValues(CallEvents.MANUAL);
db().executeTransaction(new RemoveUnsatisfiedConditionalServerResultsTransaction());
// Check that the wanted data exists
checkThatServerDataExists(ConditionalExtension.condition);
// Reverse condition
ConditionalExtension.condition = false;
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
db().executeTransaction(new RemoveUnsatisfiedConditionalServerResultsTransaction());
// Check that the wanted data exists
checkThatServerDataExists(ConditionalExtension.condition);
}
use of com.djrapitops.plan.extension.ExtensionSvc in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method unregisterExtensions.
@BeforeEach
default void unregisterExtensions() {
ExtensionSvc extensionService = extensionService();
extensionService.register();
extensionService.unregister(new PlayerExtension());
extensionService.unregister(new ServerExtension());
extensionService.unregister(new ConditionalExtension());
extensionService.unregister(new TableExtension());
extensionService.unregister(new ThrowingExtension());
}
Aggregations