Fix unit test #1344

This commit is contained in:
Gabriele C 2017-10-02 09:03:30 +02:00
parent 10c09dbf17
commit d6e2f35efd
2 changed files with 7 additions and 2 deletions

View File

@ -805,18 +805,19 @@ public class PlayerListenerTest {
Player player = mock(Player.class); Player player = mock(Player.class);
given(player.getName()).willReturn("doooew"); given(player.getName()).willReturn("doooew");
given(player.getDisplayName()).willReturn("Displ"); given(player.getDisplayName()).willReturn("Displ");
given(player.getPlayerListName()).willReturn("List");
String joinMsg = "The player joined"; String joinMsg = "The player joined";
PlayerJoinEvent event = new PlayerJoinEvent(player, joinMsg); PlayerJoinEvent event = new PlayerJoinEvent(player, joinMsg);
given(settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)).willReturn(false); given(settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)).willReturn(false);
given(settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE)) given(settings.getProperty(RegistrationSettings.CUSTOM_JOIN_MESSAGE))
.willReturn("Hello {PLAYERNAME} (aka {DISPLAYNAME})"); .willReturn("Hello {PLAYERNAME} (aka {DISPLAYNAME} / {PLAYERLISTNAME})");
given(settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)).willReturn(false); given(settings.getProperty(RegistrationSettings.DELAY_JOIN_MESSAGE)).willReturn(false);
// when // when
listener.onJoinMessage(event); listener.onJoinMessage(event);
// then // then
assertThat(event.getJoinMessage(), equalTo("Hello doooew (aka Displ)")); assertThat(event.getJoinMessage(), equalTo("Hello doooew (aka Displ / List)"));
verifyZeroInteractions(joinMessageService); verifyZeroInteractions(joinMessageService);
} }
@ -826,6 +827,7 @@ public class PlayerListenerTest {
Player player = mock(Player.class); Player player = mock(Player.class);
given(player.getName()).willReturn("thename0"); given(player.getName()).willReturn("thename0");
given(player.getDisplayName()).willReturn("(not used)"); given(player.getDisplayName()).willReturn("(not used)");
given(player.getPlayerListName()).willReturn("listName");
String joinMsg = "The player joined"; String joinMsg = "The player joined";
PlayerJoinEvent event = new PlayerJoinEvent(player, joinMsg); PlayerJoinEvent event = new PlayerJoinEvent(player, joinMsg);
given(settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)).willReturn(false); given(settings.getProperty(RegistrationSettings.REMOVE_JOIN_MESSAGE)).willReturn(false);

View File

@ -7,6 +7,7 @@ import fr.xephi.authme.TestHelper;
import fr.xephi.authme.data.auth.PlayerCache; import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.initialization.DataFolder; import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.service.BukkitService; import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.CommonService;
import fr.xephi.authme.service.GeoIpService; import fr.xephi.authme.service.GeoIpService;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World; import org.bukkit.World;
@ -49,6 +50,8 @@ public class WelcomeMessageConfigurationTest {
private GeoIpService geoIpService; private GeoIpService geoIpService;
@Mock @Mock
private PlayerCache playerCache; private PlayerCache playerCache;
@Mock
private CommonService service;
@DataFolder @DataFolder
private File testPluginFolder; private File testPluginFolder;