Search in sources :

Example 6 with CacheDataSource

use of fr.xephi.authme.datasource.CacheDataSource in project AuthMeReloaded by AuthMe.

the class DataStatisticsTest method shouldOutputCachedDataSourceStatistics.

@Test
public void shouldOutputCachedDataSourceStatistics() {
    // given
    CacheDataSource cacheDataSource = mock(CacheDataSource.class);
    LoadingCache<String, Optional<PlayerAuth>> cache = mock(LoadingCache.class);
    given(cache.size()).willReturn(11L);
    given(cacheDataSource.getCachedAuths()).willReturn(cache);
    ReflectionTestUtils.setField(DataStatistics.class, dataStatistics, "dataSource", cacheDataSource);
    CommandSender sender = mock(CommandSender.class);
    // when
    dataStatistics.execute(sender, Collections.emptyList());
    // then
    ArgumentCaptor<String> stringCaptor = ArgumentCaptor.forClass(String.class);
    verify(sender, atLeastOnce()).sendMessage(stringCaptor.capture());
    assertThat(stringCaptor.getAllValues(), hasItem("Cached PlayerAuth objects: 11"));
}
Also used : Optional(java.util.Optional) CacheDataSource(fr.xephi.authme.datasource.CacheDataSource) CommandSender(org.bukkit.command.CommandSender) Test(org.junit.Test)

Aggregations

CacheDataSource (fr.xephi.authme.datasource.CacheDataSource)6 DataSource (fr.xephi.authme.datasource.DataSource)4 Test (org.junit.Test)3 PlayerCache (fr.xephi.authme.data.auth.PlayerCache)2 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 DataSourceType (fr.xephi.authme.datasource.DataSourceType)1 MySQL (fr.xephi.authme.datasource.MySQL)1 PostgreSqlDataSource (fr.xephi.authme.datasource.PostgreSqlDataSource)1 SQLite (fr.xephi.authme.datasource.SQLite)1 Field (java.lang.reflect.Field)1 Optional (java.util.Optional)1 CommandSender (org.bukkit.command.CommandSender)1