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:
parent
dd633df96f
commit
f603841a7e
2
pom.xml
2
pom.xml
@ -288,7 +288,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.seeseemelk</groupId>
|
<groupId>com.github.seeseemelk</groupId>
|
||||||
<artifactId>MockBukkit</artifactId>
|
<artifactId>MockBukkit</artifactId>
|
||||||
<version>v1.15-d69d9ca9cb-1</version>
|
<version>v1.15-431f3a3fbc-1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -2,14 +2,12 @@ package io.github.thebusybiscuit.slimefun4.tests.items;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.junit.jupiter.api.AfterAll;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Disabled;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||||
@ -79,15 +77,6 @@ public class TestSlimefunItemRegistration {
|
|||||||
Assertions.assertEquals("https://github.com/TheBusyBiscuit/Slimefun4/wiki/Test", wiki.get());
|
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
|
@Test
|
||||||
public void testVanillaItemFallback() {
|
public void testVanillaItemFallback() {
|
||||||
VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.ACACIA_SIGN, false);
|
VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.ACACIA_SIGN, false);
|
||||||
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.tests.listeners;
|
|||||||
import org.apache.commons.lang.mutable.MutableObject;
|
import org.apache.commons.lang.mutable.MutableObject;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.block.BrewingStand;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event.Result;
|
import org.bukkit.event.Event.Result;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
@ -78,10 +79,12 @@ public class TestVanillaMachinesListener {
|
|||||||
private InventoryClickEvent mockBrewingEvent(ItemStack item) {
|
private InventoryClickEvent mockBrewingEvent(ItemStack item) {
|
||||||
Player player = server.addPlayer();
|
Player player = server.addPlayer();
|
||||||
Inventory inv = TestUtilities.mockInventory(InventoryType.BREWING);
|
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);
|
InventoryView view = player.openInventory(inv);
|
||||||
view.setCursor(item);
|
view.setCursor(item);
|
||||||
InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE);
|
InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE);
|
||||||
|
|
||||||
listener.onPreBrew(event);
|
listener.onPreBrew(event);
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
@ -242,12 +245,12 @@ public class TestVanillaMachinesListener {
|
|||||||
@Test
|
@Test
|
||||||
public void testBrewingWithoutSlimefunItems() {
|
public void testBrewingWithoutSlimefunItems() {
|
||||||
InventoryClickEvent event = mockBrewingEvent(new ItemStack(Material.BLAZE_POWDER));
|
InventoryClickEvent event = mockBrewingEvent(new ItemStack(Material.BLAZE_POWDER));
|
||||||
Assertions.assertEquals(Result.DEFAULT, event.getResult());
|
Assertions.assertEquals(Result.ALLOW, event.getResult());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBrewingWithSlimefunItem() {
|
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);
|
item.register(plugin);
|
||||||
|
|
||||||
InventoryClickEvent event = mockBrewingEvent(item.getItem());
|
InventoryClickEvent event = mockBrewingEvent(item.getItem());
|
||||||
@ -260,6 +263,6 @@ public class TestVanillaMachinesListener {
|
|||||||
item.register(plugin);
|
item.register(plugin);
|
||||||
|
|
||||||
InventoryClickEvent event = mockBrewingEvent(item.getItem());
|
InventoryClickEvent event = mockBrewingEvent(item.getItem());
|
||||||
Assertions.assertEquals(Result.DEFAULT, event.getResult());
|
Assertions.assertEquals(Result.ALLOW, event.getResult());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
|
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Player;
|
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.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.provider.ValueSource;
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
|
|
||||||
@ -22,17 +22,17 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
|||||||
|
|
||||||
public class TestResearchUnlocking {
|
public class TestResearchUnlocking {
|
||||||
|
|
||||||
private static ServerMock server;
|
private ServerMock server;
|
||||||
private static SlimefunPlugin plugin;
|
private SlimefunPlugin plugin;
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeEach
|
||||||
public static void load() throws InterruptedException {
|
public void load() throws InterruptedException {
|
||||||
server = MockBukkit.mock();
|
server = MockBukkit.mock();
|
||||||
plugin = MockBukkit.load(SlimefunPlugin.class);
|
plugin = MockBukkit.load(SlimefunPlugin.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterAll
|
@AfterEach
|
||||||
public static void unload() {
|
public void unload() {
|
||||||
MockBukkit.unmock();
|
MockBukkit.unmock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,11 +61,12 @@ public class TestResearchUnlocking {
|
|||||||
Optional<PlayerProfile> profile = PlayerProfile.find(p);
|
Optional<PlayerProfile> profile = PlayerProfile.find(p);
|
||||||
|
|
||||||
server.getPluginManager().assertEventFired(ResearchUnlockEvent.class, event -> {
|
server.getPluginManager().assertEventFired(ResearchUnlockEvent.class, event -> {
|
||||||
Assertions.assertEquals(player, event.getPlayer());
|
Assertions.assertEquals(p, event.getPlayer());
|
||||||
Assertions.assertEquals(research, event.getResearch());
|
Assertions.assertEquals(research, event.getResearch());
|
||||||
Assertions.assertFalse(event.isCancelled());
|
Assertions.assertFalse(event.isCancelled());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
Assertions.assertEquals(player, p);
|
Assertions.assertEquals(player, p);
|
||||||
Assertions.assertTrue(profile.isPresent());
|
Assertions.assertTrue(profile.isPresent());
|
||||||
Assertions.assertTrue(profile.get().hasUnlocked(research));
|
Assertions.assertTrue(profile.get().hasUnlocked(research));
|
||||||
|
Loading…
Reference in New Issue
Block a user