Esempio n. 1
0
  @Test
  public void testFind() throws Exception {
    String ns = "hotels";
    Rectangle rect = new Rectangle(10, 10);
    rect.setId("1");

    // test delete(entity, id)
    ads.save(ns, rect);
    assertEquals(1, ads.getCount(ns));
    Rectangle rectLoaded = ads.find(ns, Rectangle.class).get();
    assertEquals(rect.getId(), rectLoaded.getId());
    assertEquals(rect.getArea(), rectLoaded.getArea(), 0);

    rect = new Rectangle(2, 1);
    rect.setId("2");
    ads.save(rect); // saved to default collection name (kind)
    assertEquals(1, ads.getCount(rect));

    rect.setId("3");
    ads.save(rect); // saved to default collection name (kind)
    assertEquals(2, ads.getCount(rect));

    rect = new Rectangle(4, 3);
    rect.setId("3");
    ads.save(ns, rect);
    assertEquals(2, ads.getCount(ns));
    List<Rectangle> rects = ads.find(ns, Rectangle.class).asList();

    rectLoaded = rects.get(1);
    assertEquals(rect.getId(), rectLoaded.getId());
    assertEquals(rect.getArea(), rectLoaded.getArea(), 0);

    rectLoaded = ads.find(ns, Rectangle.class, "_id !=", "-1", 1, 1).get();
  }
Esempio n. 2
0
  @Test
  public void testGet() throws Exception {
    String ns = "hotels";
    Rectangle rect = new Rectangle(10, 10);
    rect.setId("1");

    // test delete(entity, id)
    ads.save(ns, rect);
    assertEquals(1, ads.getCount(ns));
    Rectangle rectLoaded = ads.get(ns, Rectangle.class, rect.getId());
    assertEquals(rect.getId(), rectLoaded.getId());
    assertEquals(rect.getArea(), rectLoaded.getArea(), 0);
  }