use of fr.xephi.authme.data.auth.PlayerCache in project AuthMeReloaded by AuthMe.
the class MySqlDefaultChangerTest method shouldLeaveMySqlFieldToNullOnInitialization.
@Test
public void shouldLeaveMySqlFieldToNullOnInitialization() {
// given
DataSource dataSource = mock(DataSource.class);
PlayerCache playerCache = mock(PlayerCache.class);
CacheDataSource cacheDataSource = new CacheDataSource(dataSource, playerCache);
MySqlDefaultChanger defaultChanger = createDefaultChanger(cacheDataSource);
// when
defaultChanger.setMySqlField();
// then
assertThat(ReflectionTestUtils.getFieldValue(MySqlDefaultChanger.class, defaultChanger, "mySql"), nullValue());
}
use of fr.xephi.authme.data.auth.PlayerCache in project AuthMeReloaded by AuthMe.
the class AsynchronousLoginTest method shouldNotForceLoginForCanceledEvent.
@Test
public void shouldNotForceLoginForCanceledEvent() {
// given
String name = "oscar";
String ip = "1.1.1.245";
Player player = mockPlayer(name);
TestHelper.mockPlayerIp(player, ip);
given(playerCache.isAuthenticated(name)).willReturn(false);
PlayerAuth auth = PlayerAuth.builder().name(name).build();
given(dataSource.getAuth(name)).willReturn(auth);
given(commonService.getProperty(DatabaseSettings.MYSQL_COL_GROUP)).willReturn("");
given(commonService.getProperty(PluginSettings.USE_ASYNC_TASKS)).willReturn(true);
doReturn(false).when(asynchronousLogin).hasReachedMaxLoggedInPlayersForIp(any(Player.class), anyString());
doAnswer((Answer<Void>) invocation -> {
((AuthMeAsyncPreLoginEvent) invocation.getArgument(0)).setCanLogin(false);
return null;
}).when(bukkitService).callEvent(any(AuthMeAsyncPreLoginEvent.class));
// when
asynchronousLogin.forceLogin(player);
// then
verify(playerCache, only()).isAuthenticated(name);
verify(dataSource, only()).getAuth(name);
verify(asynchronousLogin).hasReachedMaxLoggedInPlayersForIp(player, ip);
}
use of fr.xephi.authme.data.auth.PlayerCache in project AuthMeReloaded by AuthMe.
the class DebugSectionUtilsTest method shouldUnwrapCacheDataSource.
@Test
public void shouldUnwrapCacheDataSource() {
// given
DataSource source = mock(DataSource.class);
PlayerCache playerCache = mock(PlayerCache.class);
CacheDataSource cacheDataSource = new CacheDataSource(source, playerCache);
// when
DataSource result = DebugSectionUtils.unwrapSourceFromCacheDataSource(cacheDataSource);
// then
assertThat(result, equalTo(source));
}
Aggregations