WorldSystem/src/test/java/de/butzlabben/world/config/TestPluginConfig.java

128 lines
4.0 KiB
Java

package de.butzlabben.world.config;
import de.butzlabben.world.utils.PlanerCords;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.FileNotFoundException;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class TestPluginConfig {
@Test
public void testPluginConfigInit() throws FileNotFoundException {
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
}
//TODO ADD Invalid Config Test
//TESTS For General Settings
@Test
public void testGetLanguage() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals("en", cfg.getLanguage());
}
@Test
public void testGetWorldDir() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals("plugins/WorldSystem/Worlds", cfg.getWorldDir());
}
@Test
public void testGetUnloadTime() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(20, cfg.getUnloadTime());
}
@Test
public void testGetPrefix() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals("&8[&3WorldSystem&8] &6", cfg.getPrefix());
}
@Test
public void testGetDeleteAfter() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(-1, cfg.getDeleteAfter());
}
@Test
public void testGameDifficulty() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(Difficulty.EASY, cfg.getWorldDifficulty());
}
//TESTS For General Settings World Creation Setting
@Test
public void testMultiChoice() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(false, cfg.allowsMultiChoice());
}
@Test
public void testgetDefaultGenerator() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals("Vanilla", cfg.getDefaultWorldGenerator());
}
@Test
public void worldGenTemplates() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals("plugins/WorldSystem/Generators", cfg.getGeneratorTemplatesDir());
}
@Test
public void testWorldBorderDefaultSize() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(500, cfg.getDefaultWorldBorderSize());
}
@Test
public void testWorldBorderCords() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(0, cfg.getWorldBorderCords().getX());
assertEquals(0, cfg.getWorldBorderCords().getY());
}
//TESTS for World Entering/Exiting
@Test
public void testServerGamemode() throws FileNotFoundException
{
File cfgFile = new File("TestFiles/TestConfig.yml");
PluginConfig cfg = new PluginConfig(cfgFile);
assertEquals(GameMode.SURVIVAL, cfg.getServerGamemode());
}
}