Esempio n. 1
0
  @Test
  public void testExceptionsinBatchLifeCycleMethods() {
    LifeCycle lc0 = new LifeCycle();
    lc0.foo = "bar";
    lc0.bar = "order";
    lc0.save();

    LifeCycle lc1 = new LifeCycle();
    lc1.foo = "foo";
    lc1.bar = "order";
    lc1.save();

    MorphiaQuery q = LifeCycle.q("bar", "order");
    LifeCycle.batchDeleteFail = true;
    try {
      q.delete();
    } catch (Exception e) {
      // ignore
    }
    assertEquals(q.count(), 2);
    LifeCycle.batchDeleteFail = false;

    LifeCycle.batchDeletedFail = true;
    try {
      q.delete();
      assertFalse(true);
    } catch (Exception e) {
      // ignore
    }
    assertEquals(q.count(), 0);
    LifeCycle.batchDeletedFail = false;
  }