mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-21 15:01:30 +01:00
fix unit tests
This commit is contained in:
parent
052194ca64
commit
5fad1e0623
@ -11,7 +11,6 @@ import com.onarandombox.MultiverseCore.api.Core;
|
|||||||
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
@ -28,8 +27,6 @@ import java.io.File;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class})
|
@PrepareForTest({ MultiverseCore.class, PluginDescriptionFile.class, JavaPluginLoader.class})
|
||||||
@ -68,16 +65,11 @@ public class TestDebugMode {
|
|||||||
File serverDirectory = new File(creator.getCore().getServerFolder(), "world");
|
File serverDirectory = new File(creator.getCore().getServerFolder(), "world");
|
||||||
serverDirectory.mkdirs();
|
serverDirectory.mkdirs();
|
||||||
|
|
||||||
// Initialize a fake command
|
|
||||||
Command mockCommand = mock(Command.class);
|
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
|
||||||
|
|
||||||
// Assert debug mode is off
|
// Assert debug mode is off
|
||||||
Assert.assertEquals(0, core.getMVConfig().getGlobalDebug());
|
Assert.assertEquals(0, core.getMVConfig().getGlobalDebug());
|
||||||
|
|
||||||
// Send the debug command.
|
// Send the debug command.
|
||||||
String[] debugArgs = new String[] { "debug", "3" };
|
assertTrue(creator.dispatch(mockCommandSender, "mv debug 3"));
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", debugArgs);
|
|
||||||
|
|
||||||
Assert.assertEquals(3, core.getMVConfig().getGlobalDebug());
|
Assert.assertEquals(3, core.getMVConfig().getGlobalDebug());
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
|||||||
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
import com.onarandombox.MultiverseCore.utils.TestInstanceCreator;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
@ -17,8 +16,6 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
|||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
|
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@ -49,15 +46,16 @@ public class TestModifyCommand {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetHidden() {
|
public void testSetHidden() {
|
||||||
Command cmd = mock(Command.class);
|
|
||||||
when(cmd.getName()).thenReturn("mv");
|
|
||||||
|
|
||||||
MultiverseWorld world = core.getMVWorldManager().getMVWorld("world");
|
MultiverseWorld world = core.getMVWorldManager().getMVWorld("world");
|
||||||
assertNotNull(world);
|
assertNotNull(world);
|
||||||
|
|
||||||
assertFalse(world.isHidden()); // ensure it's not hidden now
|
// ensure it's not hidden now
|
||||||
assertTrue(core.onCommand(mockCommandSender, cmd, "", // run the command
|
assertFalse(world.isHidden());
|
||||||
new String[] { "modify", "set", "hidden", "true", "world" }));
|
|
||||||
assertTrue(world.isHidden()); // test if it worked
|
// run the command
|
||||||
|
assertTrue(creator.dispatch(mockCommandSender, "mv modify set hidden true world"));
|
||||||
|
|
||||||
|
// test if it worked
|
||||||
|
assertTrue(world.isHidden());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldType;
|
import org.bukkit.WorldType;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
@ -102,13 +101,8 @@ public class TestWorldProperties {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
// Initialize a fake command
|
|
||||||
Command mockCommand = mock(Command.class);
|
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
|
||||||
|
|
||||||
// Import the first world
|
// Import the first world
|
||||||
String[] normalArgs = new String[] { "import", "world", "normal" };
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world normal"));
|
||||||
core.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
|
||||||
verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
||||||
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Complete!");
|
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Complete!");
|
||||||
|
|
||||||
@ -119,8 +113,7 @@ public class TestWorldProperties {
|
|||||||
|
|
||||||
|
|
||||||
// Import a second world
|
// Import a second world
|
||||||
String[] netherArgs = new String[] { "import", "world_nether", "nether" };
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world_nether nether"));
|
||||||
core.onCommand(mockCommandSender, mockCommand, "", netherArgs);
|
|
||||||
verify(mockCommandSender).sendMessage("Starting import of world 'world_nether'...");
|
verify(mockCommandSender).sendMessage("Starting import of world 'world_nether'...");
|
||||||
verify(mockCommandSender, VerificationModeFactory.times(2)).sendMessage(
|
verify(mockCommandSender, VerificationModeFactory.times(2)).sendMessage(
|
||||||
ChatColor.GREEN + "Complete!");
|
ChatColor.GREEN + "Complete!");
|
||||||
|
@ -18,7 +18,6 @@ import org.bukkit.ChatColor;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.permissions.Permission;
|
import org.bukkit.permissions.Permission;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -80,18 +79,13 @@ public class TestWorldStuff {
|
|||||||
|
|
||||||
// Make sure Core is enabled
|
// Make sure Core is enabled
|
||||||
assertTrue(plugin.isEnabled());
|
assertTrue(plugin.isEnabled());
|
||||||
// Initialize a fake command
|
|
||||||
Command mockCommand = mock(Command.class);
|
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
|
||||||
String[] normalArgs = new String[]{ "import", "world", "normal" };
|
|
||||||
|
|
||||||
// Ensure we have a fresh copy of MV, 0 worlds.
|
// Ensure we have a fresh copy of MV, 0 worlds.
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Import the first world. The world folder does not exist.
|
// Import the first world. The world folder does not exist.
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world normal"));
|
||||||
verify(mockCommandSender).sendMessage(ChatColor.RED + "FAILED.");
|
verify(mockCommandSender).sendMessage(ChatColor.RED + "Error: World folder 'world' does not exist.");
|
||||||
verify(mockCommandSender).sendMessage("That world folder does not exist. These look like worlds to me:");
|
|
||||||
|
|
||||||
// We should still have no worlds.
|
// We should still have no worlds.
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
@ -112,30 +106,23 @@ public class TestWorldStuff {
|
|||||||
// Make sure Core is enabled
|
// Make sure Core is enabled
|
||||||
assertTrue(plugin.isEnabled());
|
assertTrue(plugin.isEnabled());
|
||||||
|
|
||||||
// Initialize a fake command
|
|
||||||
Command mockCommand = mock(Command.class);
|
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
|
||||||
|
|
||||||
// Ensure that there are no worlds imported. This is a fresh setup.
|
// Ensure that there are no worlds imported. This is a fresh setup.
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Import the first world.
|
// Import the first world.
|
||||||
String[] normalArgs = new String[]{ "import", "world", "normal" };
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world normal"));
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
|
||||||
|
|
||||||
// We should now have one world imported!
|
// We should now have one world imported!
|
||||||
assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Import the second world.
|
// Import the second world.
|
||||||
String[] netherArgs = new String[]{ "import", "world_nether", "nether" };
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world_nether nether"));
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", netherArgs);
|
|
||||||
|
|
||||||
// We should now have 2 worlds imported!
|
// We should now have 2 worlds imported!
|
||||||
assertEquals(2, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(2, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Import the third world.
|
// Import the third world.
|
||||||
String[] skyArgs = new String[]{ "import", "world_the_end", "end" };
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world_the_end end"));
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", skyArgs);
|
|
||||||
|
|
||||||
// We should now have 2 worlds imported!
|
// We should now have 2 worlds imported!
|
||||||
assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
@ -158,23 +145,18 @@ public class TestWorldStuff {
|
|||||||
// Make sure Core is enabled
|
// Make sure Core is enabled
|
||||||
assertTrue(plugin.isEnabled());
|
assertTrue(plugin.isEnabled());
|
||||||
|
|
||||||
// Initialize a fake command
|
|
||||||
Command mockCommand = mock(Command.class);
|
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
|
||||||
|
|
||||||
// Ensure that there are no worlds imported. This is a fresh setup.
|
// Ensure that there are no worlds imported. This is a fresh setup.
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Create the world
|
// Create the world
|
||||||
String[] normalArgs = new String[]{ "create", "newworld", "normal" };
|
assertTrue(creator.dispatch(mockCommandSender, "mv create newworld normal"));
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
|
||||||
|
|
||||||
// We should now have one world!
|
// We should now have one world!
|
||||||
assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
verify(mockCommandSender).sendMessage("Starting creation of world 'newworld'...");
|
verify(mockCommandSender).sendMessage("Starting creation of world 'newworld'...");
|
||||||
verify(mockCommandSender).sendMessage("Complete!");
|
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Complete!");
|
||||||
|
|
||||||
WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("newworld"));
|
WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("newworld"));
|
||||||
verify(mockServer).createWorld(ArgumentMatchers.argThat(matcher));
|
verify(mockServer).createWorld(ArgumentMatchers.argThat(matcher));
|
||||||
@ -191,22 +173,17 @@ public class TestWorldStuff {
|
|||||||
// Make sure Core is enabled
|
// Make sure Core is enabled
|
||||||
assertTrue(plugin.isEnabled());
|
assertTrue(plugin.isEnabled());
|
||||||
|
|
||||||
// Initialize a fake command
|
|
||||||
Command mockCommand = mock(Command.class);
|
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
|
||||||
|
|
||||||
// Ensure that there are no worlds imported. This is a fresh setup.
|
// Ensure that there are no worlds imported. This is a fresh setup.
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Create the world
|
// Create the world
|
||||||
String[] normalArgs = new String[]{ "create", "newworld", "normal", "-g", "BogusGen"};
|
assertTrue(creator.dispatch(mockCommandSender, "mv create newworld normal -g BogusGen"));
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
|
||||||
|
|
||||||
// This command should halt, not creating any worlds
|
// This command should halt, not creating any worlds
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
verify(mockCommandSender).sendMessage("Invalid generator! 'BogusGen'. " + ChatColor.RED + "Aborting world creation.");
|
verify(mockCommandSender).sendMessage(ChatColor.RED + "Invalid generator 'BogusGen'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -220,24 +197,19 @@ public class TestWorldStuff {
|
|||||||
// Make sure Core is enabled
|
// Make sure Core is enabled
|
||||||
assertTrue(plugin.isEnabled());
|
assertTrue(plugin.isEnabled());
|
||||||
|
|
||||||
// Initialize a fake command
|
|
||||||
Command mockCommand = mock(Command.class);
|
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
|
||||||
|
|
||||||
// Ensure that there are no worlds imported. This is a fresh setup.
|
// Ensure that there are no worlds imported. This is a fresh setup.
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Create the NULL world
|
// Create the NULL world
|
||||||
// The safe check is now BALLS SLOW. Use the -n to skip checking.
|
// The safe check is now BALLS SLOW. Use the -n to skip checking.
|
||||||
String[] normalArgs = new String[]{ "create", "nullworld", "normal", "-n" };
|
assertTrue(creator.dispatch(mockCommandSender, "mv create nullworld normal -n"));
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
|
|
||||||
|
|
||||||
// We should now have one world!
|
// We should now have one world!
|
||||||
assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
verify(mockCommandSender).sendMessage("Starting creation of world 'nullworld'...");
|
verify(mockCommandSender).sendMessage("Starting creation of world 'nullworld'...");
|
||||||
verify(mockCommandSender).sendMessage("Complete!");
|
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Complete!");
|
||||||
|
|
||||||
WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("nullworld"));
|
WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("nullworld"));
|
||||||
verify(mockServer).createWorld(ArgumentMatchers.argThat(matcher));
|
verify(mockServer).createWorld(ArgumentMatchers.argThat(matcher));
|
||||||
@ -248,12 +220,10 @@ public class TestWorldStuff {
|
|||||||
public void testModifyGameMode() {
|
public void testModifyGameMode() {
|
||||||
// Pull a core instance from the server.
|
// Pull a core instance from the server.
|
||||||
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");
|
||||||
Command mockCommand = mock(Command.class);
|
|
||||||
when(mockCommand.getName()).thenReturn("mv");
|
|
||||||
|
|
||||||
// Ensure that there are no worlds imported. This is a fresh setup.
|
// Ensure that there are no worlds imported. This is a fresh setup.
|
||||||
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
this.createInitialWorlds(plugin, mockCommand);
|
this.createInitialWorlds();
|
||||||
|
|
||||||
// Ensure that the default worlds have been created.
|
// Ensure that the default worlds have been created.
|
||||||
assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size());
|
||||||
@ -263,35 +233,35 @@ public class TestWorldStuff {
|
|||||||
assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());
|
assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());
|
||||||
|
|
||||||
// Set the mode to creative in world.
|
// Set the mode to creative in world.
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "mode", "creative", "world" });
|
assertTrue(creator.dispatch(mockCommandSender, "mv modify set mode creative world"));
|
||||||
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + "mode" + ChatColor.WHITE + " was set to " + ChatColor.GREEN + "creative");
|
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + "mode" + ChatColor.WHITE + " was set to " + ChatColor.GREEN + "creative" + ChatColor.WHITE + ".");
|
||||||
// Ensure the world is now a creative world
|
// Ensure the world is now a creative world
|
||||||
assertEquals(GameMode.CREATIVE, mainWorld.getGameMode());
|
assertEquals(GameMode.CREATIVE, mainWorld.getGameMode());
|
||||||
|
|
||||||
// More tests, with alternate syntax.
|
// More tests, with alternate syntax.
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "gamemode", "0", "world" });
|
assertTrue(creator.dispatch(mockCommandSender, "mv modify set gamemode 0 world"));
|
||||||
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + "gamemode" + ChatColor.WHITE + " was set to " + ChatColor.GREEN + "0");
|
verify(mockCommandSender).sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + "gamemode" + ChatColor.WHITE + " was set to " + ChatColor.GREEN + "0" + ChatColor.WHITE + ".");
|
||||||
assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());
|
assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());
|
||||||
|
|
||||||
// Now fail one.
|
// Now fail one.
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "mode", "fish", "world" });
|
assertTrue(creator.dispatch(mockCommandSender, "mv modify set mode fish world"));
|
||||||
try {
|
try {
|
||||||
verify(mockCommandSender).sendMessage(ChatColor.RED + mainWorld.getPropertyHelp("mode"));
|
verify(mockCommandSender).sendMessage(ChatColor.RED + mainWorld.getPropertyHelp("mode"));
|
||||||
} catch (PropertyDoesNotExistException e) {
|
} catch (PropertyDoesNotExistException e) {
|
||||||
fail("Mode property did not exist.");
|
fail("Mode property did not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "blah", "fish", "world" });
|
assertTrue(creator.dispatch(mockCommandSender, "mv modify set blah fish world"));
|
||||||
verify(mockCommandSender).sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + "blah" + ChatColor.RED + "'");
|
verify(mockCommandSender).sendMessage(ChatColor.RED + "Sorry, You can't set '" + ChatColor.GRAY + "blah" + ChatColor.RED + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createInitialWorlds(Plugin plugin, Command command) {
|
private void createInitialWorlds() {
|
||||||
MockWorldFactory.createWorldDirectory("world");
|
MockWorldFactory.createWorldDirectory("world");
|
||||||
MockWorldFactory.createWorldDirectory("world_nether");
|
MockWorldFactory.createWorldDirectory("world_nether");
|
||||||
MockWorldFactory.createWorldDirectory("world_the_end");
|
MockWorldFactory.createWorldDirectory("world_the_end");
|
||||||
plugin.onCommand(mockCommandSender, command, "", new String[]{ "import", "world", "normal" });
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world normal"));
|
||||||
plugin.onCommand(mockCommandSender, command, "", new String[]{ "import", "world_nether", "nether" });
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world_nether nether"));
|
||||||
plugin.onCommand(mockCommandSender, command, "", new String[]{ "import", "world_the_end", "end" });
|
assertTrue(creator.dispatch(mockCommandSender, "mv import world_the_end end"));
|
||||||
verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
verify(mockCommandSender).sendMessage("Starting import of world 'world'...");
|
||||||
verify(mockCommandSender).sendMessage("Starting import of world 'world_nether'...");
|
verify(mockCommandSender).sendMessage("Starting import of world 'world_nether'...");
|
||||||
verify(mockCommandSender).sendMessage("Starting import of world 'world_the_end'...");
|
verify(mockCommandSender).sendMessage("Starting import of world 'world_the_end'...");
|
||||||
|
@ -59,6 +59,7 @@ public class TestInstanceCreator {
|
|||||||
private MultiverseCore core;
|
private MultiverseCore core;
|
||||||
private Server mockServer;
|
private Server mockServer;
|
||||||
private CommandSender commandSender;
|
private CommandSender commandSender;
|
||||||
|
private SimpleCommandMap simpleCommandMap;
|
||||||
|
|
||||||
public static final File pluginDirectory = new File("bin/test/server/plugins/coretest");
|
public static final File pluginDirectory = new File("bin/test/server/plugins/coretest");
|
||||||
public static final File serverDirectory = new File("bin/test/server");
|
public static final File serverDirectory = new File("bin/test/server");
|
||||||
@ -83,7 +84,8 @@ public class TestInstanceCreator {
|
|||||||
when(mockServer.getWorldContainer()).thenReturn(worldsDirectory);
|
when(mockServer.getWorldContainer()).thenReturn(worldsDirectory);
|
||||||
|
|
||||||
// Add an internal command map (needed for ACF)
|
// Add an internal command map (needed for ACF)
|
||||||
PowerMockito.when(mockServer, "getCommandMap").thenReturn(new SimpleCommandMap(mockServer));
|
this.simpleCommandMap = new SimpleCommandMap(mockServer);
|
||||||
|
PowerMockito.when(mockServer, "getCommandMap").thenReturn(this.simpleCommandMap);
|
||||||
|
|
||||||
// Return a fake PDF file.
|
// Return a fake PDF file.
|
||||||
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Multiverse-Core", "2.2-Test",
|
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Multiverse-Core", "2.2-Test",
|
||||||
@ -326,4 +328,8 @@ public class TestInstanceCreator {
|
|||||||
public CommandSender getCommandSender() {
|
public CommandSender getCommandSender() {
|
||||||
return commandSender;
|
return commandSender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean dispatch(CommandSender sender, String commandLine) {
|
||||||
|
return this.simpleCommandMap.dispatch(sender, commandLine);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user