Package com.google.appengine.datanucleus.test.jpa

Examples of com.google.appengine.datanucleus.test.jpa.HasNotNullConstraintsJPA


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

  private void doRemove(Long id, Update update) {
    beginTxn();
    HasNotNullConstraintsJPA obj = em.find(HasNotNullConstraintsJPA.class, id);
    update.update(obj);
    em.remove(obj);
    commitTxn();

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


  }

  private HasNotNullConstraintsJPA createHasNotNullConstraintsJPA(Boolean bool, Character c, Byte b,
                                                                  Short s, Integer i, Long l,
                                                                  Float f, Double d, String str) {
    HasNotNullConstraintsJPA pc = new HasNotNullConstraintsJPA();
    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

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

  public void testInsertNotNull() {
    HasNotNullConstraintsJPA obj = create();

    obj = em.find(HasNotNullConstraintsJPA.class, obj.getId());
    assertEquals(VAL_BOOL, 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());
  }
View Full Code Here

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

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

    beginTxn();
    obj = em.find(HasNotNullConstraintsJPA.class, obj.getId());
    assertTrue(obj.getBool());
    obj.setBool(false);
    commitTxn();

    obj = em.find(HasNotNullConstraintsJPA.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());
  }
View Full Code Here

    assertEquals(VAL_DOUBLE, obj.getD());
    assertEquals(VAL_STRING, obj.getStr());
  }

  public void testUpdateNull() {
    HasNotNullConstraintsJPA obj = create();

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

    });
  }

  private HasNotNullConstraintsJPA create() {
    beginTxn();
    HasNotNullConstraintsJPA obj = createHasNotNullConstraintsJPA(VAL_BOOL, VAL_CHAR,
                                                                  VAL_BYTE, VAL_SHORT, VAL_INT,
                                                                  VAL_LONG, VAL_FLOAT, VAL_DOUBLE,
                                                                  VAL_STRING);
    em.persist(obj);
    commitTxn();
View Full Code Here

    commitTxn();
    return obj;
  }

  private void doUpdate(Long id, Update update) {
    HasNotNullConstraintsJPA obj;
    beginTxn();
    try {
      obj = em.find(HasNotNullConstraintsJPA.class, id);
      update.update(obj);
      em.persist(obj);
      commitTxn();
      fail("expected Exception");
    } catch (PersistenceException e) {
      // good
    }

    //  make sure no changes made
    beginTxn();
    obj = em.find(HasNotNullConstraintsJPA.class, id);
    rollbackTxn();
    assertEquals(VAL_BOOL, 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());
  }
View Full Code Here

TOP

Related Classes of com.google.appengine.datanucleus.test.jpa.HasNotNullConstraintsJPA

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.