@Test
  public void testWorldImportWithNoFolder() {
    // Make sure the world directory do NOT exist
    // (it was created by the TestInstanceCreator)
    File worldFile = new File(TestInstanceCreator.serverDirectory, "world");
    assertTrue(worldFile.exists());
    assertTrue(worldFile.delete());

    // Start actual testing.
    // Pull a core instance from the server.
    Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");

    // Make sure Core is not null
    assertNotNull(plugin);

    // Make sure Core is enabled
    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.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Import the first world. The world folder does not exist.
    plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);
    verify(mockCommandSender).sendMessage(ChatColor.RED + "FAILED.");
    verify(mockCommandSender)
        .sendMessage("That world folder does not exist. These look like worlds to me:");

    // We should still have no worlds.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
  }
  @Test
  public void testNullWorld() {
    // Pull a core instance from the server.
    Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");

    // Make sure Core is not null
    assertNotNull(plugin);

    // Make sure Core is enabled
    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.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Create the NULL world
    // The safe check is now BALLS SLOW. Use the -n to skip checking.
    String[] normalArgs = new String[] {"create", "nullworld", "normal", "-n"};
    plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);

    // We should now have one world!
    assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Verify
    verify(mockCommandSender).sendMessage("Starting creation of world 'nullworld'...");
    verify(mockCommandSender).sendMessage("Complete!");

    WorldCreatorMatcher matcher = new WorldCreatorMatcher(new WorldCreator("nullworld"));
    verify(mockServer).createWorld(Matchers.argThat(matcher));
  }
  @Test
  public void testWorldCreateInvalidGenerator() {
    // Pull a core instance from the server.
    Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");

    // Make sure Core is not null
    assertNotNull(plugin);

    // Make sure Core is enabled
    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.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Create the world
    String[] normalArgs = new String[] {"create", "newworld", "normal", "-g", "BogusGen"};
    plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);

    // This command should halt, not creating any worlds
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Verify
    verify(mockCommandSender)
        .sendMessage(
            "Invalid generator! 'BogusGen'. " + ChatColor.RED + "Aborting world creation.");
  }
  @Test
  public void testWorldImport() {
    // Pull a core instance from the server.
    Plugin plugin = mockServer.getPluginManager().getPlugin("Multiverse-Core");

    // Make sure Core is not null
    assertNotNull(plugin);

    // Make sure Core is enabled
    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.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Import the first world.
    String[] normalArgs = new String[] {"import", "world", "normal"};
    plugin.onCommand(mockCommandSender, mockCommand, "", normalArgs);

    // We should now have one world imported!
    assertEquals(1, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Import the second world.
    String[] netherArgs = new String[] {"import", "world_nether", "nether"};
    plugin.onCommand(mockCommandSender, mockCommand, "", netherArgs);

    // We should now have 2 worlds imported!
    assertEquals(2, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Import the third world.
    String[] skyArgs = new String[] {"import", "world_the_end", "end"};
    plugin.onCommand(mockCommandSender, mockCommand, "", skyArgs);

    // We should now have 2 worlds imported!
    assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size());

    // Verify that the commandSender has been called 3 times.
    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_the_end'...");
    verify(mockCommandSender, VerificationModeFactory.times(3))
        .sendMessage(ChatColor.GREEN + "Complete!");
  }
  @Test
  // TODO Migrate this to TestWorldProperties
  public void testModifyGameMode() {
    // Pull a core instance from the server.
    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.
    assertEquals(0, creator.getCore().getMVWorldManager().getMVWorlds().size());
    this.createInitialWorlds(plugin, mockCommand);

    // Ensure that the default worlds have been created.
    assertEquals(3, creator.getCore().getMVWorldManager().getMVWorlds().size());
    MultiverseWorld mainWorld = creator.getCore().getMVWorldManager().getMVWorld("world");

    // Ensure that the default mode was normal.
    assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());

    // Set the mode to creative in world.
    plugin.onCommand(
        mockCommandSender,
        mockCommand,
        "",
        new String[] {"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");
    // Ensure the world is now a creative world
    assertEquals(GameMode.CREATIVE, mainWorld.getGameMode());

    // More tests, with alternate syntax.
    plugin.onCommand(
        mockCommandSender,
        mockCommand,
        "",
        new String[] {"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");
    assertEquals(GameMode.SURVIVAL, mainWorld.getGameMode());

    // Now fail one.
    plugin.onCommand(
        mockCommandSender,
        mockCommand,
        "",
        new String[] {"modify", "set", "mode", "fish", "world"});
    try {
      verify(mockCommandSender).sendMessage(ChatColor.RED + mainWorld.getPropertyHelp("mode"));
    } catch (PropertyDoesNotExistException e) {
      fail("Mode property did not exist.");
    }

    plugin.onCommand(
        mockCommandSender,
        mockCommand,
        "",
        new String[] {"modify", "set", "blah", "fish", "world"});
    verify(mockCommandSender)
        .sendMessage(
            ChatColor.RED
                + "Sorry, You can't set: '"
                + ChatColor.GRAY
                + "blah"
                + ChatColor.RED
                + "'");
  }