package io.github.binaryoverload;

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

import static org.junit.Assert.assertTrue;

public class JSONConfigTest {

    private static JSONConfig config = new JSONConfig(JSONConfig.class.getClassLoader().getResourceAsStream("test.json"));

    @Test
    public void testSet() {
        config.set("title", "Hi there");
        assertTrue((config.getElement("title").getAsString()).equalsIgnoreCase("Hi there"));
    }

    @Test
    public void testGet() {
        assertTrue(config.getString("type").isPresent());
        assertTrue(config.getString("type").get().equalsIgnoreCase("array"));
    }

    @Test
    public void testGetEmpty() {
        assertTrue(config.getElement("").equals(config.getObject()));
    }

    @Test(expected = IllegalArgumentException.class)
    public void testGetMalformedPath() {
        config.getElement("title...");
    }

    @Test
    public void testGetString() {
        assertTrue(config.getString("items.title").isPresent());
        assertTrue(!config.getString("items.properties").isPresent());
        assertTrue(!config.getString("items.required").isPresent());
    }

    @Test
    public void testGetInteger() {
        assertTrue(config.getInteger("date").isPresent());
        assertTrue(!config.getInteger("title").isPresent());
        assertTrue(!config.getInteger("items").isPresent());
    }


    @Test
    public void testGetDouble() {
        assertTrue(config.getDouble("items.properties.price.minimum").isPresent());
        assertTrue(config.getDouble("date").isPresent());
        assertTrue(!config.getDouble("items.title").isPresent());
    }

    @Test
    public void testGetLong() {
        assertTrue(config.getLong("items.properties.price.minimum").isPresent());
        assertTrue(config.getLong("date").isPresent());
        assertTrue(!config.getLong("items.title").isPresent());
    }

    @Test
    public void testGetBoolean() {
        assertTrue(config.getBoolean("items.properties.price.exclusiveMinimum").isPresent());
        assertTrue(!config.getBoolean("date").isPresent());
        assertTrue(!config.getBoolean("items.title").isPresent());
    }

}

@@ -87,16 +87,60 @@
 .Test;%0A%0A
+import static org.junit.Assert.assertFalse;%0A
 import s
@@ -1065,38 +1065,38 @@
 ;%0A        assert
-Tru
+Fals
 e(
-!
 config.getString
@@ -1136,38 +1136,38 @@
 ;%0A        assert
-Tru
+Fals
 e(
-!
 config.getString
@@ -1316,38 +1316,38 @@
 ;%0A        assert
-Tru
+Fals
 e(
-!
 config.getIntege
@@ -1377,38 +1377,38 @@
 ;%0A        assert
-Tru
+Fals
 e(
-!
 config.getIntege
@@ -1632,38 +1632,38 @@
 ;%0A        assert
-Tru
+Fals
 e(
-!
 config.getDouble
@@ -1885,38 +1885,38 @@
 ;%0A        assert
-Tru
+Fals
 e(
-!
 config.getLong(%22
@@ -2095,38 +2095,38 @@
 ;%0A        assert
-Tru
+Fals
 e(
-!
 config.getBoolea
@@ -2167,14 +2167,14 @@
 sert
-Tru
+Fals
 e(
-!
 conf

Use assert false