Updates Spigot, and fixes depreciated code
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
This commit is contained in:
@ -1,16 +1,8 @@
|
||||
package net.knarcraft.blacksmith.util;
|
||||
|
||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||
import net.knarcraft.blacksmith.CustomServerMock;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@ -19,80 +11,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
*/
|
||||
public class ItemHelperTest {
|
||||
|
||||
@BeforeAll
|
||||
public static void setUp() {
|
||||
MockBukkit.mock(new CustomServerMock());
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void tearDown() {
|
||||
MockBukkit.unmock();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isRepairableTest() {
|
||||
for (Material material : Material.values()) {
|
||||
String name = material.name();
|
||||
if (name.endsWith("_SWORD") || name.endsWith("_PICKAXE") || name.endsWith("_AXE") ||
|
||||
name.endsWith("_HOE") || name.endsWith("_SHOVEL") || name.endsWith("_CHESTPLATE") ||
|
||||
name.endsWith("_HELMET") || name.equals("ELYTRA") || name.endsWith("BOW") ||
|
||||
name.endsWith("_LEGGINGS") || name.endsWith("_BOOTS") || name.equals("TRIDENT") ||
|
||||
name.equals("FISHING_ROD") || name.equals("FLINT_AND_STEEL") || name.equals("SHEARS")) {
|
||||
assertTrue(ItemHelper.isRepairable(new ItemStack(material, 1)));
|
||||
}
|
||||
}
|
||||
assertFalse(ItemHelper.isRepairable(new ItemStack(Material.POTATO, 1)));
|
||||
assertFalse(ItemHelper.isRepairable(new ItemStack(Material.DIRT, 1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMaxDurabilityTest() {
|
||||
assertEquals(1561, ItemHelper.getMaxDurability(new ItemStack(Material.DIAMOND_PICKAXE, 1)));
|
||||
assertEquals(0, ItemHelper.getMaxDurability(new ItemStack(Material.POTATO, 1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateAndGetDamageTest() {
|
||||
for (Material material : Material.values()) {
|
||||
//A lot of items seem to have weird metadata which isn't mocked properly. Therefore, this test is limited.
|
||||
if (!material.name().endsWith("_PICKAXE")) {
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack = new ItemStack(material, 1);
|
||||
assertEquals(0, ItemHelper.getDamage(itemStack));
|
||||
ItemHelper.updateDamage(itemStack, 3);
|
||||
assertEquals(3, ItemHelper.getDamage(itemStack));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getDurabilityTest() {
|
||||
for (Material material : Material.values()) {
|
||||
ItemStack itemStack = new ItemStack(material, 1);
|
||||
assertEquals(ItemHelper.getMaxDurability(itemStack), ItemHelper.getDurability(itemStack));
|
||||
}
|
||||
|
||||
for (Material material : Material.values()) {
|
||||
//A lot of items seem to have weird metadata which isn't mocked properly. Therefore, this test is limited.
|
||||
if (!material.name().endsWith("_PICKAXE")) {
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack = new ItemStack(material, 1);
|
||||
ItemHelper.updateDamage(itemStack, 100);
|
||||
assertEquals(ItemHelper.getMaxDurability(itemStack) - 100, ItemHelper.getDurability(itemStack));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllReforgeAbleMaterialsTest() {
|
||||
List<Material> materials = ItemHelper.getAllReforgeAbleMaterials();
|
||||
assertFalse(materials.isEmpty());
|
||||
|
||||
for (Material material : materials) {
|
||||
assertTrue(ItemHelper.getMaxDurability(new ItemStack(material, 1)) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAnvilRequiresDamagedTest() {
|
||||
assertTrue(ItemHelper.isAnvil(Material.DAMAGED_ANVIL, true));
|
||||
|
Reference in New Issue
Block a user