package juglr;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;

/**
 *
 */
public class BoxParserTest {

    @DataProvider(name="json")
    public Iterator<Object[]> flatJSon() {
        List<Object[]> data = new ArrayList<Object[]>();

        data.add(new Object[]{
                "{}",
                Box.newMap()
        });
        data.add(new Object[]{
                "{\"One\":1}",
                Box.newMap().put("One", new Box(1))
        });
        data.add(new Object[]{
                "{\"One\":1, \"bad\":false}",
                Box.newMap()
                        .put("One", new Box(1))
                        .put("bad", new Box(false))
        });
        data.add(new Object[]{
                "{\"bad\":false, \"list\":[27,68,true]}",
                Box.newMap()
                        .put("bad", new Box(false))
                        .put("list", Box.newList()
                                              .add(new Box(27))
                                              .add(new Box(68))
                                              .add(new Box(true)))
        });

        return data.iterator();
    }

    @Test(dataProvider="json")
    public void parseJSon(String json, Message expected) {
        BoxParser parser = new JSonBoxParser();

        Box result = parser.parse(json);
        assertEquals(result,expected);

    }
}

@@ -1242,16 +1242,675 @@
      %7D);
+%0A        data.add(new Object%5B%5D%7B%0A                %22%7B%5C%22__store__%5C%22: %5B%7B%5C%22__index__%5C%22: %5B%5C%22firstname%5C%22%5D, %5C%22__base__%5C%22: %5C%22mybase%5C%22, %5C%22__id__%5C%22: %5C%22mke%5C%22, %5C%22firstname%5C%22: %5C%22Mikkel%5C%22, %5C%22lastname%5C%22: %5C%22kamstrup%5C%22%7D%5D%7D%22,%0A                Box.newMap()%0A                    .put(%22__store__%22, Box.newList()%0A                        .add(Box.newMap()%0A                            .put(%22__index__%22, Box.newList().add(%22firstname%22))%0A                            .put(%22__base__%22, %22mybase%22)%0A                            .put(%22__id__%22, %22mke%22)%0A                            .put(%22firstname%22, %22Mikkel%22)%0A                            .put(%22lastname%22, %22kamstrup%22))%0A                     )%0A        %7D);
 %0A%0A      

Add complex JSON object to BoxParserTest (still passes)