use of fr.xephi.authme.initialization.Reloadable 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"));
}
use of fr.xephi.authme.initialization.Reloadable in project AuthMeReloaded by AuthMe.
the class ReloadCommandTest method shouldReload.
@Test
public void shouldReload() {
// given
CommandSender sender = mock(CommandSender.class);
given(settings.getProperty(DatabaseSettings.BACKEND)).willReturn(DataSourceType.MYSQL);
given(dataSource.getType()).willReturn(DataSourceType.MYSQL);
List<Reloadable> reloadables = Arrays.asList(mock(Reloadable.class), mock(Reloadable.class), mock(Reloadable.class));
List<SettingsDependent> dependents = Arrays.asList(mock(SettingsDependent.class), mock(SettingsDependent.class));
given(reloadableStore.retrieveAllOfType()).willReturn(reloadables);
given(settingsDependentStore.retrieveAllOfType()).willReturn(dependents);
// when
command.executeCommand(sender, Collections.emptyList());
// then
verify(settings).reload();
verifyReloadingCalls(reloadables, dependents);
verify(commandService).send(sender, MessageKey.CONFIG_RELOAD_SUCCESS);
verify(settingsWarner).logWarningsForMisconfigurations();
}
Aggregations