mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Added a few more tests
This commit is contained in:
parent
d39906866d
commit
fe499a357e
@ -0,0 +1,70 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.tests;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
||||||
|
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||||
|
|
||||||
|
public class TestPluginClass {
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
public static void load() {
|
||||||
|
MockBukkit.mock();
|
||||||
|
MockBukkit.load(SlimefunPlugin.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterAll
|
||||||
|
public static void unload() {
|
||||||
|
MockBukkit.unmock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyTestEnvironment() {
|
||||||
|
MinecraftVersion version = SlimefunPlugin.getMinecraftVersion();
|
||||||
|
|
||||||
|
Assertions.assertEquals(MinecraftVersion.UNIT_TEST, version);
|
||||||
|
Assertions.assertEquals("Unit Test Environment", version.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testConfigs() {
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getCfg());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getResearchCfg());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getItemCfg());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetters() {
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getTicker());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getVersion());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getRegistry());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testServicesNotNull() {
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getLocal());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getMinecraftRecipes());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getItemDataService());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getItemTextureService());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getPermissionsService());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getBlockDataService());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getThirdPartySupportService());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getWorldSettingsService());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getGitHubService());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getUpdater());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListenersNotNull() {
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getAncientAltarListener());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getGrapplingHookListener());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getBackpackListener());
|
||||||
|
Assertions.assertNotNull(SlimefunPlugin.getBowListener());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,7 +2,9 @@ package io.github.thebusybiscuit.slimefun4.tests.profiles;
|
|||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
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;
|
||||||
@ -82,4 +84,31 @@ public class TestPlayerBackpacks {
|
|||||||
Assertions.assertFalse(profile.getBackpack(500).isPresent());
|
Assertions.assertFalse(profile.getBackpack(500).isPresent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoadBackpackFromFile() throws InterruptedException {
|
||||||
|
Player player = server.addPlayer();
|
||||||
|
PlayerProfile profile = TestUtilities.awaitProfile(player);
|
||||||
|
|
||||||
|
profile.getConfig().setValue("backpacks.50.size", 27);
|
||||||
|
|
||||||
|
for (int i = 0; i < 27; i++) {
|
||||||
|
profile.getConfig().setValue("backpacks.50.contents." + i, new ItemStack(Material.DIAMOND));
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<PlayerBackpack> optional = profile.getBackpack(50);
|
||||||
|
Assertions.assertTrue(optional.isPresent());
|
||||||
|
|
||||||
|
PlayerBackpack backpack = optional.get();
|
||||||
|
Assertions.assertEquals(50, backpack.getId());
|
||||||
|
Assertions.assertEquals(27, backpack.getSize());
|
||||||
|
Assertions.assertEquals(-1, backpack.getInventory().firstEmpty());
|
||||||
|
|
||||||
|
backpack.getInventory().setItem(1, new ItemStack(Material.NETHER_STAR));
|
||||||
|
|
||||||
|
Assertions.assertEquals(new ItemStack(Material.DIAMOND), profile.getConfig().getItem("backpacks.50.contents.1"));
|
||||||
|
|
||||||
|
// Saving should write it to the Config file
|
||||||
|
backpack.save();
|
||||||
|
Assertions.assertEquals(new ItemStack(Material.NETHER_STAR), profile.getConfig().getItem("backpacks.50.contents.1"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user