mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
[CI skip] Added more Unit Tests
This commit is contained in:
parent
0d27a787ab
commit
d4953dd029
@ -42,8 +42,10 @@ public class BeeListener implements Listener {
|
||||
|
||||
if (profile.hasFullProtectionAgainst(ProtectionType.BEES)) {
|
||||
for (ItemStack armor : p.getInventory().getArmorContents()) {
|
||||
if (armor != null) {
|
||||
ItemUtils.damageItem(armor, 1, false);
|
||||
}
|
||||
}
|
||||
|
||||
e.setDamage(0D);
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ 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.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
@ -22,7 +23,7 @@ import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
public class TestBackpackCommand {
|
||||
class TestBackpackCommand {
|
||||
|
||||
private static ServerMock server;
|
||||
|
||||
@ -52,7 +53,8 @@ public class TestBackpackCommand {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidBackpack() throws InterruptedException {
|
||||
@DisplayName("Test /sf backpack giving a restored backpack")
|
||||
void testValidBackpack() throws InterruptedException {
|
||||
Player player = server.addPlayer();
|
||||
player.setOp(true);
|
||||
PlayerProfile profile = TestUtilities.awaitProfile(player);
|
||||
@ -64,8 +66,9 @@ public class TestBackpackCommand {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = { "ABC", "-100", "123456789" })
|
||||
public void testNonExistantBackpacks(String id) throws InterruptedException {
|
||||
@DisplayName("Test /sf backpack with invalid id parameters")
|
||||
@ValueSource(strings = { "", " ", "ABC", "-100", "123456789" })
|
||||
void testNonExistentBackpacks(String id) throws InterruptedException {
|
||||
Player player = server.addPlayer();
|
||||
player.setOp(true);
|
||||
TestUtilities.awaitProfile(player);
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
@ -13,7 +14,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
public class TestDebugFishCommand {
|
||||
class TestDebugFishCommand {
|
||||
|
||||
private static ServerMock server;
|
||||
|
||||
@ -30,7 +31,8 @@ public class TestDebugFishCommand {
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = { true, false })
|
||||
public void testCommand(boolean op) {
|
||||
@DisplayName("Test if Debug Fish is given on /sf debug_fish")
|
||||
void testCommand(boolean op) {
|
||||
Player player = server.addPlayer();
|
||||
player.setOp(op);
|
||||
server.execute("slimefun", player, "debug_fish").assertSucceeded();
|
||||
|
@ -5,6 +5,7 @@ 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.DisplayName;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
@ -15,7 +16,7 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
public class TestGuideCommand {
|
||||
class TestGuideCommand {
|
||||
|
||||
private static ServerMock server;
|
||||
|
||||
@ -31,8 +32,9 @@ public class TestGuideCommand {
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@DisplayName("Test if Slimefun Guide is given on /sf guide")
|
||||
@ValueSource(booleans = { true, false })
|
||||
public void testCommand(boolean op) {
|
||||
void testCommand(boolean op) {
|
||||
Player player = server.addPlayer();
|
||||
player.setOp(op);
|
||||
server.execute("slimefun", player, "guide").assertSucceeded();
|
||||
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.testing.tests.guide;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
@ -10,7 +11,7 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
||||
|
||||
public class TestBookSlimefunGuide {
|
||||
class TestBookSlimefunGuide {
|
||||
|
||||
@BeforeAll
|
||||
public static void load() {
|
||||
@ -24,7 +25,8 @@ public class TestBookSlimefunGuide {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicGetters() {
|
||||
@DisplayName("Test Getters for Chest Slimefun Guide")
|
||||
void testBasicGetters() {
|
||||
BookSlimefunGuide guide = new BookSlimefunGuide();
|
||||
|
||||
Assertions.assertEquals(SlimefunGuideLayout.BOOK, guide.getLayout());
|
||||
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.testing.tests.guide;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
@ -10,7 +11,7 @@ import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
||||
|
||||
public class TestChestSlimefunGuide {
|
||||
class TestChestSlimefunGuide {
|
||||
|
||||
@BeforeAll
|
||||
public static void load() {
|
||||
@ -24,7 +25,8 @@ public class TestChestSlimefunGuide {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicGetters() {
|
||||
@DisplayName("Test Getters for Chest Slimefun Guide")
|
||||
void testBasicGetters() {
|
||||
ChestSlimefunGuide guide = new ChestSlimefunGuide(false);
|
||||
|
||||
Assertions.assertEquals(SlimefunGuideLayout.CHEST, guide.getLayout());
|
||||
|
@ -6,6 +6,7 @@ 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.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
@ -17,7 +18,7 @@ import io.github.thebusybiscuit.slimefun4.testing.interfaces.SlimefunItemTest;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class TestEnderBackpack implements SlimefunItemTest<EnderBackpack> {
|
||||
class TestEnderBackpack implements SlimefunItemTest<EnderBackpack> {
|
||||
|
||||
private static ServerMock server;
|
||||
private static SlimefunPlugin plugin;
|
||||
@ -42,7 +43,8 @@ public class TestEnderBackpack implements SlimefunItemTest<EnderBackpack> {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRightClickBehaviour() {
|
||||
@DisplayName("Test Ender Backpack opening Enderchest")
|
||||
void testRightClickBehaviour() {
|
||||
Player player = server.addPlayer();
|
||||
EnderBackpack backpack = registerSlimefunItem(plugin, "TEST_ENDER_BACKPACK");
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
class MockBeeProtectionSuit extends SlimefunArmorPiece implements ProtectiveArmor {
|
||||
|
||||
public MockBeeProtectionSuit(Category category, SlimefunItemStack item) {
|
||||
super(category, item, RecipeType.NULL, new ItemStack[9], new PotionEffect[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtectionType[] getProtectionTypes() {
|
||||
return new ProtectionType[] { ProtectionType.BEES };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFullSetRequired() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getArmorSetId() {
|
||||
return new NamespacedKey(getAddon().getJavaPlugin(), "mock_bees");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Bee;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
import be.seeseemelk.mockbukkit.ServerMock;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BeeListener;
|
||||
import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
class TestBeeListener {
|
||||
|
||||
private static ServerMock server;
|
||||
private static SlimefunPlugin plugin;
|
||||
private static BeeListener listener;
|
||||
|
||||
@BeforeAll
|
||||
public static void load() {
|
||||
server = MockBukkit.mock();
|
||||
plugin = MockBukkit.load(SlimefunPlugin.class);
|
||||
listener = new BeeListener(plugin);
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void unload() {
|
||||
MockBukkit.unmock();
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@DisplayName("Test Bee damage protection")
|
||||
@ValueSource(booleans = { true, false })
|
||||
void testBeeDamage(boolean hasArmor) throws InterruptedException {
|
||||
Player player = server.addPlayer();
|
||||
PlayerProfile profile = TestUtilities.awaitProfile(player);
|
||||
|
||||
if (hasArmor) {
|
||||
Category category = TestUtilities.getCategory(plugin, "bee_suit_test");
|
||||
SlimefunItemStack chestplate = new SlimefunItemStack("MOCK_BEE_SUIT", Material.LEATHER_CHESTPLATE, "&cBee Suit Prototype");
|
||||
MockBeeProtectionSuit armor = new MockBeeProtectionSuit(category, chestplate);
|
||||
armor.register(plugin);
|
||||
|
||||
player.getInventory().setChestplate(chestplate.clone());
|
||||
// Force update the cached armor
|
||||
profile.getArmor()[1].update(chestplate, armor);
|
||||
}
|
||||
|
||||
double damage = 7.5;
|
||||
|
||||
Bee bee = Mockito.mock(Bee.class);
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(bee, player, DamageCause.ENTITY_ATTACK, damage);
|
||||
listener.onDamage(event);
|
||||
|
||||
if (hasArmor) {
|
||||
Assertions.assertEquals(0, event.getDamage());
|
||||
}
|
||||
else {
|
||||
Assertions.assertEquals(damage, event.getDamage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -11,6 +11,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
@ -28,7 +29,7 @@ import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class TestCoolerListener {
|
||||
class TestCoolerListener {
|
||||
|
||||
private static ServerMock server;
|
||||
private static CoolerListener listener;
|
||||
@ -59,14 +60,16 @@ public class TestCoolerListener {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnlyJuiceAllowance() {
|
||||
@DisplayName("Test if Coolers only allow juices")
|
||||
void testOnlyJuiceAllowance() {
|
||||
Assertions.assertFalse(cooler.isItemAllowed(new ItemStack(Material.DIAMOND), null));
|
||||
Assertions.assertFalse(cooler.isItemAllowed(cooler.getItem(), cooler));
|
||||
Assertions.assertTrue(cooler.isItemAllowed(juice.getItem(), juice));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCoolerUsage() throws InterruptedException {
|
||||
@DisplayName("Test if Coolers consume Juices when hunger gets low")
|
||||
void testCoolerUsage() throws InterruptedException {
|
||||
Player player = server.addPlayer();
|
||||
PlayerProfile profile = TestUtilities.awaitProfile(player);
|
||||
PlayerBackpack backpack = profile.createBackpack(cooler.getSize());
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
@ -19,7 +20,7 @@ import be.seeseemelk.mockbukkit.inventory.meta.FireworkMetaMock;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.FireworksListener;
|
||||
|
||||
public class TestFireworksListener {
|
||||
class TestFireworksListener {
|
||||
|
||||
private static ServerMock server;
|
||||
|
||||
@ -36,7 +37,8 @@ public class TestFireworksListener {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFireworkDamage() {
|
||||
@DisplayName("Test if Fireworks from Research cause no damage")
|
||||
void testFireworkDamage() {
|
||||
Player player = server.addPlayer();
|
||||
Firework firework = Mockito.mock(Firework.class);
|
||||
FireworkMeta meta = new FireworkMetaMock();
|
||||
|
@ -7,6 +7,7 @@ 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.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
@ -16,7 +17,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
public class TextCustomTextureService {
|
||||
class TextCustomTextureService {
|
||||
|
||||
private static SlimefunPlugin plugin;
|
||||
|
||||
@ -32,7 +33,8 @@ public class TextCustomTextureService {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
@DisplayName("Test creating a new Custom Texture Service")
|
||||
void testInitialization() {
|
||||
Config config = new Config("plugins/temporary");
|
||||
CustomTextureService service = new CustomTextureService(config);
|
||||
Assertions.assertFalse(service.isActive());
|
||||
@ -51,7 +53,8 @@ public class TextCustomTextureService {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetTexture() {
|
||||
@DisplayName("Test applying a custom item model")
|
||||
void testSetTexture() {
|
||||
Config config = new Config("plugins/temporary");
|
||||
CustomTextureService service = new CustomTextureService(config);
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "TEXTURE_TEST", new ItemStack(Material.LANTERN));
|
||||
|
@ -4,14 +4,16 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
|
||||
public class TestHeadTextures {
|
||||
class TestHeadTextures {
|
||||
|
||||
@Test
|
||||
public void testForDuplicates() {
|
||||
@DisplayName("Test if the HeadTexture enum contains any duplicates")
|
||||
void testForDuplicates() {
|
||||
Set<String> textures = new HashSet<>();
|
||||
|
||||
for (HeadTexture head : HeadTexture.values()) {
|
||||
|
@ -1,10 +1,14 @@
|
||||
package io.github.thebusybiscuit.slimefun4.testing.tests.utils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
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.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
@ -13,7 +17,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
|
||||
|
||||
public class TestItemStackWrapper {
|
||||
class TestItemStackWrapper {
|
||||
|
||||
@BeforeAll
|
||||
public static void load() {
|
||||
@ -27,7 +31,8 @@ public class TestItemStackWrapper {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquality() {
|
||||
@DisplayName("Test if an ItemStackWrappers can be compared properly (With ItemMeta)")
|
||||
void testEqualityWithItemMeta() {
|
||||
ItemStack item = new CustomItem(Material.LAVA_BUCKET, "&4SuperHot.exe", "", "&6Hello");
|
||||
ItemStackWrapper wrapper = new ItemStackWrapper(item);
|
||||
|
||||
@ -38,7 +43,20 @@ public class TestItemStackWrapper {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testImmutability() {
|
||||
@DisplayName("Test if an ItemStackWrappers can be compared properly (No ItemMeta)")
|
||||
void testEqualityWithoutItemMeta() {
|
||||
ItemStack item = new ItemStack(Material.DIAMOND_AXE);
|
||||
ItemStackWrapper wrapper = new ItemStackWrapper(item);
|
||||
|
||||
Assertions.assertEquals(item.getType(), wrapper.getType());
|
||||
Assertions.assertEquals(item.hasItemMeta(), wrapper.hasItemMeta());
|
||||
Assertions.assertEquals(item.getItemMeta(), wrapper.getItemMeta());
|
||||
Assertions.assertTrue(SlimefunUtils.isItemSimilar(wrapper, item, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test if an ItemStackWrapper is immutable")
|
||||
void testImmutability() {
|
||||
ItemStack item = new CustomItem(Material.LAVA_BUCKET, "&4SuperHot.exe", "", "&6Hello");
|
||||
ItemStackWrapper wrapper = new ItemStackWrapper(item);
|
||||
|
||||
@ -51,4 +69,39 @@ public class TestItemStackWrapper {
|
||||
Assertions.assertThrows(UnsupportedOperationException.class, () -> wrapper.equals(wrapper));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test wrapping an ItemStack Array")
|
||||
void testWrapArray() {
|
||||
ItemStack[] items = { new ItemStack(Material.DIAMOND), null, new ItemStack(Material.EMERALD), new CustomItem(Material.REDSTONE, "&4Firey thing", "with lore :o") };
|
||||
ItemStackWrapper[] wrappers = ItemStackWrapper.wrapArray(items);
|
||||
|
||||
Assertions.assertEquals(items.length, wrappers.length);
|
||||
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
assertWrapped(items[i], wrappers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("Test wrapping an ItemStack List")
|
||||
void testWrapList() {
|
||||
List<ItemStack> items = Arrays.asList(new ItemStack(Material.DIAMOND), null, new ItemStack(Material.EMERALD), new CustomItem(Material.REDSTONE, "&4Firey thing", "with lore :o"));
|
||||
List<ItemStackWrapper> wrappers = ItemStackWrapper.wrapList(items);
|
||||
|
||||
Assertions.assertEquals(items.size(), wrappers.size());
|
||||
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
assertWrapped(items.get(i), wrappers.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void assertWrapped(ItemStack expected, ItemStack actual) {
|
||||
if (expected == null) {
|
||||
Assertions.assertNull(actual);
|
||||
}
|
||||
else {
|
||||
Assertions.assertTrue(actual instanceof ItemStackWrapper);
|
||||
Assertions.assertTrue(SlimefunUtils.isItemSimilar(actual, expected, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,15 +8,17 @@ import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
public class TestWikiResource {
|
||||
class TestWikiResource {
|
||||
|
||||
@Test
|
||||
public void testWikiJson() throws IOException {
|
||||
@DisplayName("Test wiki.json file format")
|
||||
void testWikiJson() throws IOException {
|
||||
JsonParser parser = new JsonParser();
|
||||
Pattern pattern = Pattern.compile("[A-Z_0-9]+");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user