@Test
  public void testNestedSaveAndFilter() throws InterruptedException, JSONException {
    ReadFilter filter;
    JSONObject where;
    List<TrivialNestedClass> result;

    Data data = new Data(10, "name", "description");

    TrivialNestedClass newNested = new TrivialNestedClass();
    newNested.setId(1);
    newNested.setText("nestedText");
    newNested.setData(data);

    open(nestedStore);
    nestedStore.save(newNested);

    filter = new ReadFilter();
    where = new JSONObject();
    where.put("text", "nestedText");
    JSONObject dataFilter = new JSONObject();
    dataFilter.put("id", 10);
    where.put("data", dataFilter);
    filter.setWhere(where);
    result = nestedStore.readWithFilter(filter);
    Assert.assertEquals(1, result.size());
    TrivialNestedClass nestedResult = result.get(0);
    Assert.assertEquals("name", nestedResult.data.getName());
  }
  @Test
  public void testNestedListSaveAndFilter() throws InterruptedException, JSONException {
    ReadFilter filter;
    JSONObject where;
    List<TrivialNestedClassWithCollection> result;

    List<Data> data = new ArrayList<Data>();
    data.add(new Data(10, "name", "description"));
    data.add(new Data(30, "name", "description"));

    TrivialNestedClassWithCollection newNested = new TrivialNestedClassWithCollection();
    newNested.setId(1);
    newNested.setText("nestedText");
    newNested.setData(data);

    open(nestedWithCollectionStore);
    nestedWithCollectionStore.save(newNested);

    filter = new ReadFilter();
    where = new JSONObject();
    where.put("text", "nestedText");
    where.put("id", 1);

    filter.setWhere(where);
    result = nestedWithCollectionStore.readWithFilter(filter);
    Assert.assertEquals(1, result.size());
    TrivialNestedClassWithCollection nestedResult = result.get(0);
    Assert.assertEquals((Integer) 10, nestedResult.data.get(0).getId());
    Assert.assertEquals((Integer) 30, nestedResult.data.get(1).getId());
  }
  @Test
  public void testFilter() throws InterruptedException, JSONException {
    ReadFilter filter;
    JSONObject where;
    List<Data> result;

    loadBulkData();

    result = store.readWithFilter(null);
    Assert.assertEquals(6, result.size());

    filter = new ReadFilter();
    where = new JSONObject();
    where.put("name", "name2");
    filter.setWhere(where);
    result = store.readWithFilter(filter);
    Assert.assertEquals(3, result.size());

    filter = new ReadFilter();
    where = new JSONObject();
    where.put("name", "name2");
    where.put("description", "description");
    filter.setWhere(where);
    result = store.readWithFilter(filter);
    Assert.assertEquals(2, result.size());
  }