Improved PanelItemBuilder test class

This commit is contained in:
tastybento 2019-03-09 19:31:18 -08:00
parent 91dec86b5a
commit ac079a6686

View File

@ -24,10 +24,12 @@ import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.PluginManager;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import world.bentobox.bentobox.api.panels.Panel;
@ -35,12 +37,15 @@ import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.user.User;
@RunWith(PowerMockRunner.class)
@PrepareForTest( {Bukkit.class})
public class PanelItemBuilderTest {
@SuppressWarnings("deprecation")
@BeforeClass
public static void setUp() throws Exception {
@Before
public void setUp() throws Exception {
PowerMockito.mockStatic(Bukkit.class);
Server server = mock(Server.class);
World world = mock(World.class);
world = mock(World.class);
@ -54,8 +59,6 @@ public class PanelItemBuilderTest {
ItemFactory itemFactory = mock(ItemFactory.class);
when(server.getItemFactory()).thenReturn(itemFactory);
Bukkit.setServer(server);
SkullMeta skullMeta = mock(SkullMeta.class);
when(skullMeta.getOwner()).thenReturn("tastybento");
when(itemFactory.getItemMeta(any())).thenReturn(skullMeta);