Search in sources :

Example 6 with ExtensionSvc

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());
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) HtmlTable(com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable) ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) ExtensionPlayerDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery) List(java.util.List) Test(org.junit.jupiter.api.Test)

Example 7 with ExtensionSvc

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());
}
Also used : ExtensionServerDataQuery(com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery) HtmlTable(com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable) ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) Test(org.junit.jupiter.api.Test)

Example 8 with ExtensionSvc

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);
}
Also used : RemoveUnsatisfiedConditionalPlayerResultsTransaction(com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalPlayerResultsTransaction) ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) Test(org.junit.jupiter.api.Test)

Example 9 with ExtensionSvc

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());
}
Also used : ExtensionSvc(com.djrapitops.plan.extension.ExtensionSvc) Test(org.junit.jupiter.api.Test)

Aggregations

ExtensionSvc (com.djrapitops.plan.extension.ExtensionSvc)9 Test (org.junit.jupiter.api.Test)8 HtmlTable (com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable)5 ExtensionPlayerDataQuery (com.djrapitops.plan.extension.implementation.storage.queries.ExtensionPlayerDataQuery)4 ExtensionServerDataQuery (com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerDataQuery)4 RemoveUnsatisfiedConditionalPlayerResultsTransaction (com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalPlayerResultsTransaction)4 RemoveUnsatisfiedConditionalServerResultsTransaction (com.djrapitops.plan.extension.implementation.storage.transactions.results.RemoveUnsatisfiedConditionalServerResultsTransaction)4 ServerUUID (com.djrapitops.plan.identification.ServerUUID)4 List (java.util.List)4 BeforeEach (org.junit.jupiter.api.BeforeEach)4 CallEvents (com.djrapitops.plan.extension.CallEvents)3 DataExtension (com.djrapitops.plan.extension.DataExtension)3 NotReadyException (com.djrapitops.plan.extension.NotReadyException)3 com.djrapitops.plan.extension.annotation (com.djrapitops.plan.extension.annotation)3 ExtensionDataBuilder (com.djrapitops.plan.extension.builder.ExtensionDataBuilder)3 Color (com.djrapitops.plan.extension.icon.Color)3 Icon (com.djrapitops.plan.extension.icon.Icon)3 com.djrapitops.plan.extension.implementation.results (com.djrapitops.plan.extension.implementation.results)3 ExtensionServerTableDataQuery (com.djrapitops.plan.extension.implementation.storage.queries.ExtensionServerTableDataQuery)3 Table (com.djrapitops.plan.extension.table.Table)3