Added unit test for the config

This commit is contained in:
Jaime Martínez Rincón 2017-12-29 12:20:29 +01:00
parent 71ffd842db
commit bd5cf508c9

View File

@ -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);
}
}