use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class PurgeLastPositionCommandTest method shouldResetAllLastPositions.
@Test
public void shouldResetAllLastPositions() {
// given
PlayerAuth auth1 = mock(PlayerAuth.class);
PlayerAuth auth2 = mock(PlayerAuth.class);
PlayerAuth auth3 = mock(PlayerAuth.class);
given(dataSource.getAllAuths()).willReturn(Arrays.asList(auth1, auth2, auth3));
CommandSender sender = mock(CommandSender.class);
// when
command.executeCommand(sender, Collections.singletonList("*"));
// then
verify(dataSource).getAllAuths();
verifyPositionWasReset(auth1);
verifyPositionWasReset(auth2);
verifyPositionWasReset(auth3);
verify(sender).sendMessage(argThat(containsString("last position locations are now reset")));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class PurgeLastPositionCommandTest method shouldHandleNonExistentUser.
@Test
public void shouldHandleNonExistentUser() {
// given
String name = "invalidPlayer";
CommandSender sender = mock(CommandSender.class);
// when
command.executeCommand(sender, Collections.singletonList(name));
// then
verify(dataSource).getAuth(name);
verify(service).send(sender, MessageKey.UNKNOWN_USER);
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class RecentPlayersCommandTest method shouldShowRecentPlayers.
@Test
public void shouldShowRecentPlayers() {
// given
PlayerAuth auth1 = PlayerAuth.builder().name("hannah").realName("Hannah").lastIp("11.11.11.11").lastLogin(// 11/11/2017 @ 8:09am
1510387755000L).build();
PlayerAuth auth2 = PlayerAuth.builder().name("matt").realName("MATT").lastIp("22.11.22.33").lastLogin(// 11/09/2017 @ 11:15pm
1510269301000L).build();
doReturn(ZoneId.of("UTC")).when(command).getZoneId();
given(dataSource.getRecentlyLoggedInPlayers()).willReturn(Arrays.asList(auth1, auth2));
CommandSender sender = mock(CommandSender.class);
// when
command.executeCommand(sender, Collections.emptyList());
// then
verify(sender).sendMessage(argThat(containsString("Recently logged in players")));
verify(sender).sendMessage(argThat(equalToIgnoringCase("- Hannah (08:09 AM, 11 Nov with IP 11.11.11.11)")));
verify(sender).sendMessage(argThat(equalToIgnoringCase("- MATT (11:15 PM, 09 Nov with IP 22.11.22.33)")));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class ReloadCommandTest method shouldIssueWarningForChangedDataSourceSetting.
@Test
public void shouldIssueWarningForChangedDataSourceSetting() {
// given
CommandSender sender = mock(CommandSender.class);
given(settings.getProperty(DatabaseSettings.BACKEND)).willReturn(DataSourceType.MYSQL);
given(dataSource.getType()).willReturn(DataSourceType.SQLITE);
given(reloadableStore.retrieveAllOfType()).willReturn(Collections.emptyList());
given(settingsDependentStore.retrieveAllOfType()).willReturn(Collections.emptyList());
// when
command.executeCommand(sender, Collections.emptyList());
// then
verify(settings).reload();
verify(reloadableStore).retrieveAllOfType();
verify(settingsDependentStore).retrieveAllOfType();
verify(sender).sendMessage(argThat(containsString("cannot change database type")));
}
use of org.bukkit.command.CommandSender in project AuthMeReloaded by AuthMe.
the class TotpDisableAdminCommandTest method shouldHandleUnknownUser.
@Test
public void shouldHandleUnknownUser() {
// given
CommandSender sender = mock(CommandSender.class);
given(dataSource.getAuth("user")).willReturn(null);
// when
command.executeCommand(sender, Collections.singletonList("user"));
// then
verify(messages).send(sender, MessageKey.UNKNOWN_USER);
verify(dataSource, only()).getAuth("user");
}
Aggregations