Ejemplo n.º 1
0
  @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());
  }
Ejemplo n.º 2
0
  @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());
  }
Ejemplo n.º 3
0
  @Test
  public void testSaveListOfBoringData() throws InterruptedException {
    SQLStore<ListWithId> longStore = new SQLStore<ListWithId>(ListWithId.class, context);
    open(longStore);
    ListWithId<Long> longList = new ListWithId<Long>(100);

    longList.setId(1);

    for (long i = 0; i < 100; i++) {
      longList.data.add(i);
    }
    longStore.save(longList);
    Assert.assertEquals(100, longStore.readAll().iterator().next().data.size());
  }
Ejemplo n.º 4
0
 private void saveData(Integer id, String name, String desc, boolean enable)
     throws InterruptedException {
   open(store);
   store.save(new Data(id, name, desc, enable));
 }