package io.github.binaryoverload;

import com.google.gson.JsonObject;
import org.junit.Test;

import static org.junit.Assert.assertTrue;

public class JSONConfigTest {

    @Test
    public void testSet() {
        JSONConfig config = new JSONConfig(this.getClass().getClassLoader().getResourceAsStream("test.json"));
        config.set("glossary.title", "Hi there");
        assertTrue((config.getElement("glossary.title").getAsString()).equalsIgnoreCase("Hi there"));
    }

    @Test
    public void testGet() {
        JSONConfig config = new JSONConfig(this.getClass().getClassLoader().getResourceAsStream("test.json"));
        assertTrue((config.getElement("glossary.GlossDiv.title").getAsString()).equalsIgnoreCase("S"));
    }

    @Test
    public void testGetEmpty() {
        JSONConfig config = new JSONConfig(this.getClass().getClassLoader().getResourceAsStream("test.json"));
        assertTrue(config.getElement("").equals(config.getObject()));
    }

    @Test(expected = IllegalArgumentException.class)
    public void testGetMalformedPath() {
        JSONConfig config = new JSONConfig(this.getClass().getClassLoader().getResourceAsStream("test.json"));
        config.getElement("glossary.title...");
    }

}

@@ -170,49 +170,21 @@
     
-@Test%0A    public void testSet() %7B%0A       
+public static
  JSO
@@ -211,39 +211,40 @@
  JSONConfig(
-this.getC
+JSONConfig.c
 lass
-()
 .getClassLoa
@@ -275,32 +275,71 @@
 m(%22test.json%22));
+%0A%0A    @Test%0A    public void testSet() %7B
 %0A        config.
@@ -524,119 +524,8 @@
 ) %7B%0A
-        JSONConfig config = new JSONConfig(this.getClass().getClassLoader().getResourceAsStream(%22test.json%22));%0A
     
@@ -678,119 +678,8 @@
 ) %7B%0A
-        JSONConfig config = new JSONConfig(this.getClass().getClassLoader().getResourceAsStream(%22test.json%22));%0A
     
@@ -857,119 +857,187 @@
     
-JSONConfig config = new JSONConfig(this.getClass().getClassLoader().getResourceAsStream(%22test.json%22));%0A        
+config.getElement(%22glossary.title...%22);%0A    %7D%0A%0A    @Test%0A    public void testGetString() %7B%0A        assertTrue(config.getString(%22glossary.title%22).isPresent());%0A        assertTrue(!
 conf
@@ -1034,39 +1034,38 @@
 True(!config.get
-Element
+String
 (%22glossary.title
@@ -1055,33 +1055,46 @@
 g(%22glossary.
-title...%22
+GlossDiv%22).isPresent()
 );%0A    %7D%0A%0A%7D%0A

Make config a global