Search in sources :

Example 1 with HasCleanup

use of fr.xephi.authme.initialization.HasCleanup in project AuthMeReloaded by AuthMe.

the class DataStatisticsTest method shouldOutputStatistics.

@Test
public void shouldOutputStatistics() {
    // given
    CommandSender sender = mock(CommandSender.class);
    given(singletonStore.retrieveAllOfType()).willReturn(mockListOfSize(Object.class, 7));
    given(singletonStore.retrieveAllOfType(Reloadable.class)).willReturn(mockListOfSize(Reloadable.class, 4));
    given(singletonStore.retrieveAllOfType(SettingsDependent.class)).willReturn(mockListOfSize(SettingsDependent.class, 3));
    given(singletonStore.retrieveAllOfType(HasCleanup.class)).willReturn(mockListOfSize(HasCleanup.class, 2));
    given(dataSource.getAccountsRegistered()).willReturn(219);
    given(playerCache.getLogged()).willReturn(12);
    // Clear any loggers that might exist and trigger the generation of two loggers
    Map loggers = ReflectionTestUtils.getFieldValue(ConsoleLoggerFactory.class, null, "consoleLoggers");
    loggers.clear();
    ConsoleLoggerFactory.get(String.class);
    ConsoleLoggerFactory.get(Integer.class);
    // when
    dataStatistics.execute(sender, Collections.emptyList());
    // then
    ArgumentCaptor<String> stringCaptor = ArgumentCaptor.forClass(String.class);
    verify(sender, atLeastOnce()).sendMessage(stringCaptor.capture());
    assertThat(stringCaptor.getAllValues(), containsInAnyOrder(ChatColor.BLUE + "AuthMe statistics", "Singleton Java classes: 7", "(Reloadable: 4 / SettingsDependent: 3 / HasCleanup: 2)", "LimboPlayers in memory: 1", "Total players in DB: 219", "PlayerCache size: 12 (= logged in players)", "Total logger instances: 2"));
}
Also used : SettingsDependent(fr.xephi.authme.initialization.SettingsDependent) CommandSender(org.bukkit.command.CommandSender) HasCleanup(fr.xephi.authme.initialization.HasCleanup) HashMap(java.util.HashMap) Map(java.util.Map) Reloadable(fr.xephi.authme.initialization.Reloadable) Test(org.junit.Test)

Aggregations

HasCleanup (fr.xephi.authme.initialization.HasCleanup)1 Reloadable (fr.xephi.authme.initialization.Reloadable)1 SettingsDependent (fr.xephi.authme.initialization.SettingsDependent)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CommandSender (org.bukkit.command.CommandSender)1 Test (org.junit.Test)1