Package com.google.appengine.datanucleus.test.jdo

Examples of com.google.appengine.datanucleus.test.jdo.HasNotNullConstraintsJDO


  private static final Float VAL_FLOAT = 4f;
  private static final Double VAL_DOUBLE = 5d;
  private static final String VAL_STRING = "yam";

  public void testInsertNotNull() {
    HasNotNullConstraintsJDO pc = createHasConstraintsJDO(VAL_BOOL, VAL_CHAR,
                                                          VAL_BYTE, VAL_SHORT, VAL_INT, VAL_LONG,
                                                          VAL_FLOAT, VAL_DOUBLE, VAL_STRING);
    makePersistentInTxn(pc, TXN_START_END);

    beginTxn();
    pc = pm.getObjectById(HasNotNullConstraintsJDO.class, pc.getId());
    assertEquals(VAL_BOOL, pc.getBool());
    assertEquals(VAL_CHAR, pc.getC());
    assertEquals(VAL_BYTE, pc.getB());
    assertEquals(VAL_SHORT, pc.getS());
    assertEquals(VAL_INT, pc.getI());
    assertEquals(VAL_LONG, pc.getL());
    assertEquals(VAL_FLOAT, pc.getF());
    assertEquals(VAL_DOUBLE, pc.getD());
    assertEquals(VAL_STRING, pc.getStr());
    commitTxn();
  }
View Full Code Here


      assertEquals(0, countForClass(HasNotNullConstraintsJDO.class));
    }
  }

  public void testUpdateNotNull() {
    HasNotNullConstraintsJDO obj = create();

    beginTxn();
    obj = pm.getObjectById(HasNotNullConstraintsJDO.class, obj.getId());
    assertTrue(obj.getBool());
    obj.setBool(false);
    commitTxn();

    beginTxn();
    obj = pm.getObjectById(HasNotNullConstraintsJDO.class, obj.getId());
    assertFalse(obj.getBool());
    assertEquals(VAL_CHAR, obj.getC());
    assertEquals(VAL_BYTE, obj.getB());
    assertEquals(VAL_SHORT, obj.getS());
    assertEquals(VAL_INT, obj.getI());
    assertEquals(VAL_LONG, obj.getL());
    assertEquals(VAL_FLOAT, obj.getF());
    assertEquals(VAL_DOUBLE, obj.getD());
    assertEquals(VAL_STRING, obj.getStr());
    commitTxn();
  }
View Full Code Here

    assertEquals(VAL_STRING, obj.getStr());
    commitTxn();
  }

  public void testUpdateNull() {
    HasNotNullConstraintsJDO pc = create();

    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setBool(null);
      }
    });
    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setC(null);
      }
    });
    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setB(null);
      }
    });
    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setS(null);
      }
    });
    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setI(null);
      }
    });
    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setL(null);
      }
    });
    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setF(null);
      }
    });
    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setD(null);
      }
    });
    doUpdate(pc.getId(), new Update() {
      public void update(HasNotNullConstraintsJDO pc) {
        pc.setStr(null);
      }
    });
  }
View Full Code Here

      }
    });
  }

  private HasNotNullConstraintsJDO create() {
    HasNotNullConstraintsJDO pc = createHasConstraintsJDO(VAL_BOOL, VAL_CHAR,
                                                          VAL_BYTE, VAL_SHORT, VAL_INT, VAL_LONG,
                                                          VAL_FLOAT, VAL_DOUBLE, VAL_STRING);
    makePersistentInTxn(pc, TXN_START_END);
    return pc;
  }
View Full Code Here

  }

  private void doUpdate(Long id, Update update) {
    try {
      beginTxn();
      HasNotNullConstraintsJDO pc = pm.getObjectById(HasNotNullConstraintsJDO.class, id);
      update.update(pc);
      commitTxn();
      fail("expected Exception");
    } catch (JDOUserException e) {
      // good
View Full Code Here

    }
  }

  private void doRemove(Long id, Update update) {
    beginTxn();
    HasNotNullConstraintsJDO pc = pm.getObjectById(HasNotNullConstraintsJDO.class, id);
    update.update(pc);
    pm.deletePersistent(pc);
    commitTxn();

    assertEquals(0, countForClass(HasNotNullConstraintsJDO.class));
View Full Code Here

  }

  private HasNotNullConstraintsJDO createHasConstraintsJDO(Boolean bool, Character c, Byte b,
                                                           Short s, Integer i, Long l,
                                                           Float f, Double d, String str) {
    HasNotNullConstraintsJDO pc = new HasNotNullConstraintsJDO();
    pc.setBool(bool);
    pc.setC(c);
    pc.setB(b);
    pc.setS(s);
    pc.setI(i);
    pc.setL(l);
    pc.setF(f);
    pc.setD(d);
    pc.setStr(str);
    return pc;
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jdo.HasNotNullConstraintsJDO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.