1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

[CI skip] Updated MockBukkit test dependency

This commit is contained in:
TheBusyBiscuit 2020-05-18 11:34:26 +02:00
parent dd633df96f
commit f603841a7e
4 changed files with 18 additions and 25 deletions

View File

@ -288,7 +288,7 @@
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit</artifactId>
<version>v1.15-d69d9ca9cb-1</version>
<version>v1.15-431f3a3fbc-1</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@ -2,14 +2,12 @@ package io.github.thebusybiscuit.slimefun4.tests.items;
import java.util.Optional;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import be.seeseemelk.mockbukkit.MockBukkit;
@ -79,15 +77,6 @@ public class TestSlimefunItemRegistration {
Assertions.assertEquals("https://github.com/TheBusyBiscuit/Slimefun4/wiki/Test", wiki.get());
}
@Disabled("This Test provokes a ClassNotFoundException")
@Test
public void testGetItemName() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "ITEM_NAME_TEST", new CustomItem(Material.DIAMOND, "&cTest"));
item.register(plugin);
Assertions.assertEquals(ChatColor.RED + "Test", item.getItemName());
}
@Test
public void testVanillaItemFallback() {
VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.ACACIA_SIGN, false);

View File

@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.tests.listeners;
import org.apache.commons.lang.mutable.MutableObject;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.inventory.ClickType;
@ -78,10 +79,12 @@ public class TestVanillaMachinesListener {
private InventoryClickEvent mockBrewingEvent(ItemStack item) {
Player player = server.addPlayer();
Inventory inv = TestUtilities.mockInventory(InventoryType.BREWING);
Mockito.when(inv.getHolder()).thenReturn(Mockito.mock(BrewingStand.class));
Mockito.when(inv.getSize()).thenReturn(5);
InventoryView view = player.openInventory(inv);
view.setCursor(item);
InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE);
listener.onPreBrew(event);
return event;
}
@ -242,12 +245,12 @@ public class TestVanillaMachinesListener {
@Test
public void testBrewingWithoutSlimefunItems() {
InventoryClickEvent event = mockBrewingEvent(new ItemStack(Material.BLAZE_POWDER));
Assertions.assertEquals(Result.DEFAULT, event.getResult());
Assertions.assertEquals(Result.ALLOW, event.getResult());
}
@Test
public void testBrewingWithSlimefunItem() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_POWDER", new CustomItem(Material.BLAZE_POWDER, "&6Mock"));
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_POWDER", new CustomItem(Material.BLAZE_POWDER, "&6Magic Mock Powder"));
item.register(plugin);
InventoryClickEvent event = mockBrewingEvent(item.getItem());
@ -260,6 +263,6 @@ public class TestVanillaMachinesListener {
item.register(plugin);
InventoryClickEvent event = mockBrewingEvent(item.getItem());
Assertions.assertEquals(Result.DEFAULT, event.getResult());
Assertions.assertEquals(Result.ALLOW, event.getResult());
}
}

View File

@ -7,9 +7,9 @@ import java.util.concurrent.atomic.AtomicReference;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@ -22,17 +22,17 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
public class TestResearchUnlocking {
private static ServerMock server;
private static SlimefunPlugin plugin;
private ServerMock server;
private SlimefunPlugin plugin;
@BeforeAll
public static void load() throws InterruptedException {
@BeforeEach
public void load() throws InterruptedException {
server = MockBukkit.mock();
plugin = MockBukkit.load(SlimefunPlugin.class);
}
@AfterAll
public static void unload() {
@AfterEach
public void unload() {
MockBukkit.unmock();
}
@ -61,11 +61,12 @@ public class TestResearchUnlocking {
Optional<PlayerProfile> profile = PlayerProfile.find(p);
server.getPluginManager().assertEventFired(ResearchUnlockEvent.class, event -> {
Assertions.assertEquals(player, event.getPlayer());
Assertions.assertEquals(p, event.getPlayer());
Assertions.assertEquals(research, event.getResearch());
Assertions.assertFalse(event.isCancelled());
return true;
});
Assertions.assertEquals(player, p);
Assertions.assertTrue(profile.isPresent());
Assertions.assertTrue(profile.get().hasUnlocked(research));