use of com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable 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.delivery.rendering.html.structure.HtmlTable 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.delivery.rendering.html.structure.HtmlTable 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());
}
Aggregations