package org.sirix.xquery;

import org.junit.Test;

import java.io.IOException;

public final class JsonIntegrationTest extends AbstractJsonTest {
  @Test
  public void testArrayIteration() throws IOException {
    final String storeQuery = "jn:store('mycol.jn','mydoc.jn','[{\"key\":0,\"value\":true},{\"key\":\"hey\",\"value\":false}]')";
    final String openQuery = "for $i in jn:doc('mycol.jn','mydoc.jn') where deep-equal($i=>key, 0) return { $i, \"nodekey\": sdb:nodekey($i) }";
    test(storeQuery, openQuery,"{\"key\":0,\"value\":true,\"nodekey\":2}");
  }

  @Test
  public void testNesting() throws IOException {
    final String storeQuery = "jn:store('mycol.jn','mydoc.jn','[{\"key\":0},{\"value\":{\"key\":true}},{\"key\":\"hey\",\"value\":false}]')";
    final String openQuery = "for $i in jn:doc('mycol.jn','mydoc.jn')=>value where $i instance of record() and $i=>key eq true() return { $i, \"nodekey\": sdb:nodekey($i) }";
    test(storeQuery, openQuery,"{\"key\":true,\"nodekey\":7}");
  }
}

@@ -592,16 +592,17 @@
 tNesting
+1
 () throw
@@ -1001,11 +1001,450 @@
 %7D%22);%0A  %7D
+%0A%0A  @Test%0A  public void testNesting2() throws IOException %7B%0A    final String storeQuery = %22jn:store('mycol.jn','mydoc.jn','%5B%7B%5C%22key%5C%22:0%7D,%7B%5C%22value%5C%22:%5B%7B%5C%22key%5C%22:%7B%5C%22boolean%5C%22:true%7D%7D,%7B%5C%22newkey%5C%22:%5C%22yes%5C%22%7D%5D%7D,%7B%5C%22key%5C%22:%5C%22hey%5C%22,%5C%22value%5C%22:false%7D%5D')%22;%0A    final String openQuery = %22for $i in jn:doc('mycol.jn','mydoc.jn')=%3Evalue=%3Ekey return %7B $i, %5C%22nodekey%5C%22: sdb:nodekey($i) %7D%22;%0A    test(storeQuery, openQuery,%22%7B%5C%22boolean%5C%22:true,%5C%22nodekey%5C%22:10%7D%22);%0A  %7D
 %0A%7D%0A

Add test cases