Package com.googlecode.objectify.test.entity

Examples of com.googlecode.objectify.test.entity.Trivial


  /** */
  @Test
  public void deleteBatch() throws Exception {
    fact().register(Trivial.class);

    Trivial triv1 = new Trivial("foo5", 5);
    Trivial triv2 = new Trivial("foo6", 6);

    ofy().save().entities(triv1, triv2).now();

    assert ofy().load().entities(triv1, triv2).size() == 2;

View Full Code Here


  /** */
  @Test
  public void loadWithManuallyCreatedKey() throws Exception {
    fact().register(Trivial.class);

    Trivial triv1 = new Trivial(123L, "foo5", 5);
    ofy().save().entity(triv1).now();

    Trivial fetched = ofy().load().key(Key.create(Trivial.class, 123L)).now();
    assert fetched.toString().equals(triv1.toString());
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void loadNonexistant() throws Exception {
    fact().register(Trivial.class);

    Trivial triv1 = new Trivial("foo5", 5);
    ofy().save().entity(triv1).now();

    Key<Trivial> triv1Key = Key.create(triv1);
    Key<Trivial> triv2Key = Key.create(Trivial.class, 998);
    Key<Trivial> triv3Key = Key.create(Trivial.class, 999);
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void loadNonexistantWithoutSession() throws Exception {
    fact().register(Trivial.class);

    Trivial triv1 = new Trivial("foo5", 5);
    ofy().save().entity(triv1).now();

    Key<Trivial> triv1Key = Key.create(triv1);
    Key<Trivial> triv2Key = Key.create(Trivial.class, 998);
    Key<Trivial> triv3Key = Key.create(Trivial.class, 999);
View Full Code Here

  /** */
  @Test
  public void simpleFetchById() throws Exception {
    fact().register(Trivial.class);

    Trivial triv1 = new Trivial("foo5", 5);

    ofy().save().entity(triv1).now();

    ofy().clear();

    Trivial fetched = ofy().load().type(Trivial.class).id(triv1.getId()).now();

    assert fetched.getSomeString().equals(triv1.getSomeString());
  }
View Full Code Here

      assert next.getId() > previousId;
      previousId = next.getId();
    }

    // Create an id with a put and verify it is > than the last
    Trivial triv = new Trivial("foo", 3);
    ofy().save().entity(triv).now();

    assert triv.getId() > previousId;
  }
View Full Code Here

  /** */
  @BeforeMethod
  public void setUpExtra() {
    fact().register(Trivial.class);

    this.triv1 = new Trivial("foo1", 1);
    this.triv2 = new Trivial("foo2", 2);

    Map<Key<Trivial>, Trivial> saved = ofy().save().entities(triv1, triv2).now();

    this.keys = new ArrayList<>(saved.keySet());
  }
View Full Code Here

  public void testCursorEnd() throws Exception {
    Query<Trivial> q = ofy().load().type(Trivial.class);
    QueryResultIterator<Trivial> it = q.limit(1).iterator();

    assert it.hasNext();
    Trivial t1 = it.next();
    assert t1.getId().equals(triv1.getId());
    assert !it.hasNext();

    Cursor cursor = it.getCursor();
    assert cursor != null;

    it = q.startAt(cursor).limit(1).iterator();

    assert it.hasNext();
    Trivial t2 = it.next();
    assert t2.getId().equals(triv2.getId());
    assert !it.hasNext();

    // We should be at end
    cursor = it.getCursor();
    assert cursor != null;
View Full Code Here

TOP

Related Classes of com.googlecode.objectify.test.entity.Trivial

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.