Removed AboutCommand test to get a clean build.

Please see my comment on the commit. Final classes can't be mocked (as
far as I know) so it's kinda impossible to make a test for this one.
This commit is contained in:
tastybento 2018-08-05 20:00:23 -07:00
parent d6da1daa48
commit cfdabbb176
3 changed files with 5 additions and 74 deletions

View File

@ -27,7 +27,11 @@ public class AboutCommand extends CompositeCommand {
@Override @Override
public boolean execute(User user, String label, List<String> args) { public boolean execute(User user, String label, List<String> args) {
user.sendRawMessage("About " + BentoBox.getInstance().getDescription().getName() + " v" + BentoBox.getInstance().getDescription().getVersion() + ":"); user.sendRawMessage("About " + BentoBox
.getInstance()
.getDescription()
.getName() + " v" +
BentoBox.getInstance().getDescription().getVersion() + ":");
user.sendRawMessage("Copyright (c) 2017 - 2018 Tastybento, Poslovitch"); user.sendRawMessage("Copyright (c) 2017 - 2018 Tastybento, Poslovitch");
user.sendRawMessage("See https://www.eclipse.org/legal/epl-2.0/ for license information."); user.sendRawMessage("See https://www.eclipse.org/legal/epl-2.0/ for license information.");
return true; return true;

View File

@ -56,7 +56,6 @@ public class AddonTest {
PluginManager pluginManager = mock(PluginManager.class); PluginManager pluginManager = mock(PluginManager.class);
when(server.getPluginManager()).thenReturn(pluginManager); when(server.getPluginManager()).thenReturn(pluginManager);
//Bukkit.setServer(server);
PowerMockito.mockStatic(Bukkit.class); PowerMockito.mockStatic(Bukkit.class);
when(Bukkit.getServer()).thenReturn(server); when(Bukkit.getServer()).thenReturn(server);
when(Bukkit.getPluginManager()).thenReturn(pluginManager); when(Bukkit.getPluginManager()).thenReturn(pluginManager);

View File

@ -1,72 +0,0 @@
package world.bentobox.bentobox.commands;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.managers.CommandsManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(PowerMockRunner.class)
@PrepareForTest({Bukkit.class, BentoBox.class})
public class AboutCommandTest {
private User user;
private CompositeCommand parent;
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
// Set up plugin
BentoBox plugin = mock(BentoBox.class);
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
// Command manager
CommandsManager cm = mock(CommandsManager.class);
when(plugin.getCommandsManager()).thenReturn(cm);
// Player
Player player = mock(Player.class);
// Sometimes use: Mockito.withSettings().verboseLogging()
user = mock(User.class);
when(user.isOp()).thenReturn(false);
UUID uuid = UUID.randomUUID();
when(user.getUniqueId()).thenReturn(uuid);
when(user.getPlayer()).thenReturn(player);
User.setPlugin(plugin);
// Set up user already
User.getInstance(player);
// Parent command has no aliases
parent = mock(CompositeCommand.class);
when(parent.getSubCommandAliases()).thenReturn(new HashMap<>());
}
// FIXME how to avoid NPE with getDescription() ?
/* @Test
public void testExecute() {
AboutCommand ac = new AboutCommand(parent);
assertTrue(ac.execute(user, ac.getLabel(), new ArrayList<>()));
Mockito.verify(user).sendRawMessage("Copyright (c) 2017 - 2018 Tastybento, Poslovitch");
Mockito.verify(user).sendRawMessage("See https://www.eclipse.org/legal/epl-2.0/ for license information.");
} */
}