use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class DebugSectionUtilsTest method shouldFetchMapInLimboService.
@Test
public void shouldFetchMapInLimboService() {
// given
LimboService limboService = mock(LimboService.class);
Map<String, LimboPlayer> limboMap = new HashMap<>();
ReflectionTestUtils.setField(LimboService.class, limboService, "entries", limboMap);
// when
Map map = DebugSectionUtils.applyToLimboPlayersMap(limboService, Function.identity());
// then
assertThat(map, sameInstance(limboMap));
}
use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class IndividualFilesPersistenceHandlerTest method shouldReturnNullForUnavailablePlayer.
@Test
public void shouldReturnNullForUnavailablePlayer() {
// given
Player player = mock(Player.class);
given(player.getUniqueId()).willReturn(UUID.nameUUIDFromBytes("other-player".getBytes()));
// when
LimboPlayer data = handler.getLimboPlayer(player);
// then
assertThat(data, nullValue());
}
use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class IndividualFilesPersistenceHandlerTest method shouldSavePlayerData.
@Test
public void shouldSavePlayerData() {
// given
Player player = mock(Player.class);
UUID uuid = UUID.nameUUIDFromBytes("New player".getBytes());
given(player.getUniqueId()).willReturn(uuid);
World world = mock(World.class);
given(world.getName()).willReturn("player-world");
Location location = new Location(world, 0.2, 102.25, -89.28, 3.02f, 90.13f);
LimboPlayer limbo = new LimboPlayer(location, true, Collections.singletonList(new UserGroup("primary-grp")), true, 1.2f, 0.8f);
// when
handler.saveLimboPlayer(player, limbo);
// then
File playerFile = new File(dataFolder, FileUtils.makePath("playerdata", uuid.toString(), "data.json"));
assertThat(playerFile.exists(), equalTo(true));
// TODO ljacqu 20160711: Check contents of file
}
use of fr.xephi.authme.data.limbo.LimboPlayer in project AuthMeReloaded by AuthMe.
the class LimboPersistenceTest method shouldDelegateToHandler.
@Test
public void shouldDelegateToHandler() {
// given
Player player = mock(Player.class);
LimboPersistenceHandler handler = getHandler();
LimboPlayer limbo = mock(LimboPlayer.class);
given(handler.getLimboPlayer(player)).willReturn(limbo);
// when
LimboPlayer result = limboPersistence.getLimboPlayer(player);
limboPersistence.saveLimboPlayer(player, mock(LimboPlayer.class));
limboPersistence.removeLimboPlayer(mock(Player.class));
// then
assertThat(result, equalTo(limbo));
verify(handler).getLimboPlayer(player);
verify(handler).saveLimboPlayer(eq(player), argThat(notNullAndDifferentFrom(limbo)));
verify(handler).removeLimboPlayer(argThat(notNullAndDifferentFrom(player)));
}
Aggregations