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"));
}
Aggregations