use of com.djrapitops.plan.extension.ExtensionSvc in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionPlayerTableValuesAreInserted.
@Test
default void extensionPlayerTableValuesAreInserted() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new TableExtension());
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
Map<ServerUUID, List<ExtensionData>> ofPlayer = db().query(new ExtensionPlayerDataQuery(playerUUID));
assertFalse(ofPlayer.isEmpty());
List<ExtensionData> ofServer = ofPlayer.get(serverUUID());
assertEquals(1, ofServer.size());
ExtensionData extensionServerData = ofServer.get(0);
List<ExtensionTabData> tabs = extensionServerData.getTabs();
// No tab defined, should contain 1 tab
assertEquals(1, tabs.size());
ExtensionTabData tabData = tabs.get(0);
List<ExtensionTableData> tableData = tabData.getTableData();
assertEquals(1, tableData.size());
ExtensionTableData table = tableData.get(0);
HtmlTable expected = HtmlTable.fromExtensionTable(Table.builder().columnOne("first", Icon.called("gavel").build()).columnTwo("second", Icon.called("what").build()).columnThree("third", Icon.called("question").build()).addRow("value", 3, 0.5, 400L).build(), com.djrapitops.plan.delivery.rendering.html.icon.Color.AMBER);
assertEquals(expected.toHtml(), table.getHtmlTable().toHtml());
}
use of com.djrapitops.plan.extension.ExtensionSvc in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionServerTableValuesAreInserted.
@Test
default void extensionServerTableValuesAreInserted() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new TableExtension());
extensionService.updateServerValues(CallEvents.MANUAL);
extensionService.updateServerValues(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);
List<ExtensionTableData> tableData = tabData.getTableData();
assertEquals(1, tableData.size());
ExtensionTableData table = tableData.get(0);
HtmlTable expected = HtmlTable.fromExtensionTable(Table.builder().columnOne("first", Icon.called("gavel").build()).columnTwo("second", Icon.called("what").build()).columnThree("third", Icon.called("question").build()).addRow("value", 3, 0.5, 400L).build(), com.djrapitops.plan.delivery.rendering.html.icon.Color.AMBER);
assertEquals(expected.toHtml(), table.getHtmlTable().toHtml());
}
use of com.djrapitops.plan.extension.ExtensionSvc in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method unsatisfiedPlayerConditionalResultsAreCleaned.
@Test
default void unsatisfiedPlayerConditionalResultsAreCleaned() {
ExtensionSvc extensionService = extensionService();
extensionService.register(new ConditionalExtension());
ConditionalExtension.condition = true;
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
// Check that the wanted data exists
checkThatPlayerDataExists(ConditionalExtension.condition);
// Reverse condition
ConditionalExtension.condition = false;
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
db().executeTransaction(new RemoveUnsatisfiedConditionalPlayerResultsTransaction());
// Check that the wanted data exists
checkThatPlayerDataExists(ConditionalExtension.condition);
// Reverse condition
ConditionalExtension.condition = false;
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
db().executeTransaction(new RemoveUnsatisfiedConditionalPlayerResultsTransaction());
// Check that the wanted data exists
checkThatPlayerDataExists(ConditionalExtension.condition);
}
use of com.djrapitops.plan.extension.ExtensionSvc in project Plan by plan-player-analytics.
the class ExtensionsDatabaseTest method extensionExceptionsAreCaught.
@Test
default void extensionExceptionsAreCaught() {
TestErrorLogger.throwErrors(false);
ExtensionSvc extensionService = extensionService();
extensionService.register(new ThrowingExtension());
extensionService.updateServerValues(CallEvents.MANUAL);
extensionService.updatePlayerValues(playerUUID, TestConstants.PLAYER_ONE_NAME, CallEvents.MANUAL);
// 5 of the exceptions need to be logged, there are 8 exceptions total 3 of which are ignored.
assertEquals(5, TestErrorLogger.getCaught().size(), () -> "Not all exceptions got logged, logged exceptions: " + TestErrorLogger.getCaught().toString());
}
Aggregations