From bd5cf508c9e4e381ecc79aea100a5b59611a1fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Mart=C3=ADnez=20Rinc=C3=B3n?= Date: Fri, 29 Dec 2017 12:20:29 +0100 Subject: [PATCH] Added unit test for the config --- .../src/test/java/DefaultConfigLoadTest.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Main Plugin/src/test/java/DefaultConfigLoadTest.java diff --git a/Main Plugin/src/test/java/DefaultConfigLoadTest.java b/Main Plugin/src/test/java/DefaultConfigLoadTest.java new file mode 100644 index 0000000..b174869 --- /dev/null +++ b/Main Plugin/src/test/java/DefaultConfigLoadTest.java @@ -0,0 +1,32 @@ +import com.google.common.reflect.TypeToken; +import com.jaimemartz.playerbalancer.settings.SettingsHolder; +import ninja.leaping.configurate.commented.CommentedConfigurationNode; +import ninja.leaping.configurate.hocon.HoconConfigurationLoader; +import ninja.leaping.configurate.objectmapping.ObjectMappingException; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; +import java.net.URL; + +public class DefaultConfigLoadTest { + private URL file; + + @Before + public void before() throws IOException { + file = getClass().getResource("default.conf"); + } + + @Test + public void test() throws IOException, ObjectMappingException { + HoconConfigurationLoader loader = HoconConfigurationLoader + .builder() + .setURL(file) + .build(); + + CommentedConfigurationNode node = loader.load(); + SettingsHolder settings = node.getValue(TypeToken.of(SettingsHolder.class)); + + System.out.println(settings); + } +}