mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 19:55:17 +01:00
Fixes tab complete error with no island.
EWR -> DEN
This commit is contained in:
parent
0bd800ac09
commit
c88ea31237
@ -103,6 +103,7 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
List<String> options = Bukkit.getOnlinePlayers().stream()
|
List<String> options = Bukkit.getOnlinePlayers().stream()
|
||||||
.filter(p -> !p.getUniqueId().equals(user.getUniqueId()))
|
.filter(p -> !p.getUniqueId().equals(user.getUniqueId()))
|
||||||
.filter(p -> !island.isBanned(p.getUniqueId()))
|
.filter(p -> !island.isBanned(p.getUniqueId()))
|
||||||
@ -110,5 +111,8 @@ public class IslandBanCommand extends CompositeCommand {
|
|||||||
.map(Player::getName).collect(Collectors.toList());
|
.map(Player::getName).collect(Collectors.toList());
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,12 @@ public class IslandUnbanCommand extends CompositeCommand {
|
|||||||
@Override
|
@Override
|
||||||
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
public Optional<List<String>> tabComplete(User user, String alias, List<String> args) {
|
||||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
List<String> options = island.getBanned().stream().map(getPlayers()::getName).collect(Collectors.toList());
|
List<String> options = island.getBanned().stream().map(getPlayers()::getName).collect(Collectors.toList());
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,6 @@ package world.bentobox.bentobox.api.commands.island.team;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||||
@ -96,13 +92,7 @@ public class IslandTeamTrustCommand extends CompositeCommand {
|
|||||||
// Don't show every player on the server. Require at least the first letter
|
// Don't show every player on the server. Require at least the first letter
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
String lastArg = args.get(args.size()-1);
|
||||||
List<String> options = Bukkit.getOnlinePlayers().stream()
|
return Optional.of(Util.tabLimit(Util.getOnlinePlayerList(user), lastArg));
|
||||||
.filter(p -> !p.getUniqueId().equals(user.getUniqueId()))
|
|
||||||
.filter(p -> !island.getMemberSet().contains(p.getUniqueId()))
|
|
||||||
.filter(p -> user.getPlayer().canSee(p))
|
|
||||||
.map(Player::getName).collect(Collectors.toList());
|
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,7 @@ public class IslandTeamUncoopCommand extends CompositeCommand {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
List<String> options = island.getMemberSet().stream()
|
List<String> options = island.getMemberSet().stream()
|
||||||
.filter(uuid -> island.getRank(User.getInstance(uuid)) == RanksManager.COOP_RANK)
|
.filter(uuid -> island.getRank(User.getInstance(uuid)) == RanksManager.COOP_RANK)
|
||||||
.map(Bukkit::getOfflinePlayer)
|
.map(Bukkit::getOfflinePlayer)
|
||||||
@ -110,5 +111,8 @@ public class IslandTeamUncoopCommand extends CompositeCommand {
|
|||||||
|
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,7 @@ public class IslandTeamUntrustCommand extends CompositeCommand {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
Island island = getIslands().getIsland(getWorld(), user.getUniqueId());
|
||||||
|
if (island != null) {
|
||||||
List<String> options = island.getMemberSet().stream()
|
List<String> options = island.getMemberSet().stream()
|
||||||
.filter(uuid -> island.getRank(User.getInstance(uuid)) == RanksManager.TRUSTED_RANK)
|
.filter(uuid -> island.getRank(User.getInstance(uuid)) == RanksManager.TRUSTED_RANK)
|
||||||
.map(Bukkit::getOfflinePlayer)
|
.map(Bukkit::getOfflinePlayer)
|
||||||
@ -110,5 +111,8 @@ public class IslandTeamUntrustCommand extends CompositeCommand {
|
|||||||
|
|
||||||
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
String lastArg = !args.isEmpty() ? args.get(args.size()-1) : "";
|
||||||
return Optional.of(Util.tabLimit(options, lastArg));
|
return Optional.of(Util.tabLimit(options, lastArg));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,6 +292,33 @@ public class IslandBanCommandTest {
|
|||||||
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName());
|
Mockito.verify(targetUser, Mockito.never()).sendMessage("commands.island.ban.owner-banned-you", "[owner]", user.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTabCompleteNoIsland() {
|
||||||
|
// No island
|
||||||
|
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(null);
|
||||||
|
IslandBanCommand ibc = new IslandBanCommand(ic);
|
||||||
|
// Set up the user
|
||||||
|
User user = mock(User.class);
|
||||||
|
when(user.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||||
|
// Get the tab-complete list with one argument
|
||||||
|
LinkedList<String> args = new LinkedList<>();
|
||||||
|
args.add("");
|
||||||
|
Optional<List<String>> result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with one letter argument
|
||||||
|
args = new LinkedList<>();
|
||||||
|
args.add("d");
|
||||||
|
result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with one letter argument
|
||||||
|
args = new LinkedList<>();
|
||||||
|
args.add("fr");
|
||||||
|
result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTabComplete() {
|
public void testTabComplete() {
|
||||||
|
|
||||||
|
@ -256,4 +256,31 @@ public class IslandUnbanCommandTest {
|
|||||||
String[] names = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};
|
String[] names = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};
|
||||||
assertTrue(Arrays.equals(names, result.get().toArray()));
|
assertTrue(Arrays.equals(names, result.get().toArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTabCompleteNoIsland() {
|
||||||
|
// No island
|
||||||
|
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(null);
|
||||||
|
IslandUnbanCommand iubc = new IslandUnbanCommand(ic);
|
||||||
|
// Set up the user
|
||||||
|
User user = mock(User.class);
|
||||||
|
when(user.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||||
|
// Get the tab-complete list with one argument
|
||||||
|
LinkedList<String> args = new LinkedList<>();
|
||||||
|
args.add("");
|
||||||
|
Optional<List<String>> result = iubc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with one letter argument
|
||||||
|
args = new LinkedList<>();
|
||||||
|
args.add("d");
|
||||||
|
result = iubc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with one letter argument
|
||||||
|
args = new LinkedList<>();
|
||||||
|
args.add("fr");
|
||||||
|
result = iubc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package world.bentobox.bentobox.api.commands.island.team;
|
package world.bentobox.bentobox.api.commands.island.team;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@ -11,9 +12,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -25,6 +31,9 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
import org.powermock.reflect.Whitebox;
|
import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.Settings;
|
import world.bentobox.bentobox.Settings;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
@ -215,5 +224,77 @@ public class IslandTeamUncoopCommandTest {
|
|||||||
itl.execute(user, itl.getLabel(), Arrays.asList(name));
|
itl.execute(user, itl.getLabel(), Arrays.asList(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTabCompleteNoIsland() {
|
||||||
|
// No island
|
||||||
|
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(null);
|
||||||
|
IslandTeamUncoopCommand ibc = new IslandTeamUncoopCommand(ic);
|
||||||
|
// Set up the user
|
||||||
|
User user = mock(User.class);
|
||||||
|
when(user.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||||
|
// Get the tab-complete list with one argument
|
||||||
|
LinkedList<String> args = new LinkedList<>();
|
||||||
|
args.add("");
|
||||||
|
Optional<List<String>> result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with one letter argument
|
||||||
|
args = new LinkedList<>();
|
||||||
|
args.add("d");
|
||||||
|
result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with one letter argument
|
||||||
|
args = new LinkedList<>();
|
||||||
|
args.add("fr");
|
||||||
|
result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTabComplete() {
|
||||||
|
|
||||||
|
Builder<UUID> memberSet = new ImmutableSet.Builder<>();
|
||||||
|
for (int j = 0; j < 11; j++) {
|
||||||
|
memberSet.add(UUID.randomUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
when(island.getMemberSet()).thenReturn(memberSet.build());
|
||||||
|
// Return a set of players
|
||||||
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
|
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||||
|
when(Bukkit.getOfflinePlayer(Mockito.any(UUID.class))).thenReturn(offlinePlayer);
|
||||||
|
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
||||||
|
when(island.getRank(Mockito.any())).thenReturn(
|
||||||
|
RanksManager.COOP_RANK,
|
||||||
|
RanksManager.COOP_RANK,
|
||||||
|
RanksManager.COOP_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK
|
||||||
|
);
|
||||||
|
|
||||||
|
IslandTeamUncoopCommand ibc = new IslandTeamUncoopCommand(ic);
|
||||||
|
// Get the tab-complete list with no argument
|
||||||
|
Optional<List<String>> result = ibc.tabComplete(user, "", new LinkedList<>());
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with no argument
|
||||||
|
LinkedList<String> args = new LinkedList<>();
|
||||||
|
args.add("");
|
||||||
|
result = ibc.tabComplete(user, "", args);
|
||||||
|
assertTrue(result.isPresent());
|
||||||
|
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
|
||||||
|
// Compare the expected with the actual
|
||||||
|
String[] expectedNames = {"adam", "ben", "cara"};
|
||||||
|
|
||||||
|
assertTrue(Arrays.equals(expectedNames, r.toArray()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
package world.bentobox.bentobox.api.commands.island.team;
|
package world.bentobox.bentobox.api.commands.island.team;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@ -11,9 +12,14 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -25,6 +31,9 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
import org.powermock.reflect.Whitebox;
|
import org.powermock.reflect.Whitebox;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.collect.ImmutableSet.Builder;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.Settings;
|
import world.bentobox.bentobox.Settings;
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||||
@ -215,5 +224,76 @@ public class IslandTeamUntrustCommandTest {
|
|||||||
itl.execute(user, itl.getLabel(), Arrays.asList(name));
|
itl.execute(user, itl.getLabel(), Arrays.asList(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTabCompleteNoIsland() {
|
||||||
|
// No island
|
||||||
|
when(im.getIsland(Mockito.any(), Mockito.any(UUID.class))).thenReturn(null);
|
||||||
|
IslandTeamUntrustCommand ibc = new IslandTeamUntrustCommand(ic);
|
||||||
|
// Set up the user
|
||||||
|
User user = mock(User.class);
|
||||||
|
when(user.getUniqueId()).thenReturn(UUID.randomUUID());
|
||||||
|
// Get the tab-complete list with one argument
|
||||||
|
LinkedList<String> args = new LinkedList<>();
|
||||||
|
args.add("");
|
||||||
|
Optional<List<String>> result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with one letter argument
|
||||||
|
args = new LinkedList<>();
|
||||||
|
args.add("d");
|
||||||
|
result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with one letter argument
|
||||||
|
args = new LinkedList<>();
|
||||||
|
args.add("fr");
|
||||||
|
result = ibc.tabComplete(user, "", args);
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTabComplete() {
|
||||||
|
|
||||||
|
Builder<UUID> memberSet = new ImmutableSet.Builder<>();
|
||||||
|
for (int j = 0; j < 11; j++) {
|
||||||
|
memberSet.add(UUID.randomUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
when(island.getMemberSet()).thenReturn(memberSet.build());
|
||||||
|
// Return a set of players
|
||||||
|
PowerMockito.mockStatic(Bukkit.class);
|
||||||
|
OfflinePlayer offlinePlayer = mock(OfflinePlayer.class);
|
||||||
|
when(Bukkit.getOfflinePlayer(Mockito.any(UUID.class))).thenReturn(offlinePlayer);
|
||||||
|
when(offlinePlayer.getName()).thenReturn("adam", "ben", "cara", "dave", "ed", "frank", "freddy", "george", "harry", "ian", "joe");
|
||||||
|
when(island.getRank(Mockito.any())).thenReturn(
|
||||||
|
RanksManager.TRUSTED_RANK,
|
||||||
|
RanksManager.TRUSTED_RANK,
|
||||||
|
RanksManager.TRUSTED_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK,
|
||||||
|
RanksManager.MEMBER_RANK
|
||||||
|
);
|
||||||
|
|
||||||
|
IslandTeamUntrustCommand ibc = new IslandTeamUntrustCommand(ic);
|
||||||
|
// Get the tab-complete list with no argument
|
||||||
|
Optional<List<String>> result = ibc.tabComplete(user, "", new LinkedList<>());
|
||||||
|
assertFalse(result.isPresent());
|
||||||
|
|
||||||
|
// Get the tab-complete list with no argument
|
||||||
|
LinkedList<String> args = new LinkedList<>();
|
||||||
|
args.add("");
|
||||||
|
result = ibc.tabComplete(user, "", args);
|
||||||
|
assertTrue(result.isPresent());
|
||||||
|
List<String> r = result.get().stream().sorted().collect(Collectors.toList());
|
||||||
|
// Compare the expected with the actual
|
||||||
|
String[] expectedNames = {"adam", "ben", "cara"};
|
||||||
|
|
||||||
|
assertTrue(Arrays.equals(expectedNames, r.toArray()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user