Fix unit testing

This commit is contained in:
Gabriele C 2017-10-09 09:44:22 +02:00
parent 41af94aab2
commit 29c30f6c22

View File

@ -805,19 +805,18 @@ 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} / {PLAYERLISTNAME})"); .willReturn("Hello {PLAYERNAME} (aka {DISPLAYNAME})");
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 / List)")); assertThat(event.getJoinMessage(), equalTo("Hello doooew (aka Displ)"));
verifyZeroInteractions(joinMessageService); verifyZeroInteractions(joinMessageService);
} }
@ -827,7 +826,6 @@ 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);