Package com.googlecode.objectify.test.entity

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


  public void testChunking() throws Exception {
    fact().register(Trivial.class);

    List<Trivial> trivs = new ArrayList<>(100);
    for (int i = 0; i < 100; i++) {
      Trivial triv = new Trivial(1000L + i, "foo" + i, i);
      trivs.add(triv);
    }

    ofy().save().entities(trivs).now();

    assert trivs.size() == 100;

    int count = 0;
    for (Trivial triv: ofy().load().type(Trivial.class).chunk(2)) {
      assert triv.getSomeNumber() == count;
      count++;
    }
    assert count == 100;
  }
View Full Code Here


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

    t0 = new Trivial("foo", 11);
    k0 = ofy().save().entity(t0).now();

    t1 = new Trivial("bar", 22);
    k1 = ofy().save().entity(t1).now();

    tNone0 = new Trivial(123L, "fooNone", 33);
    tNone1 = new Trivial(456L, "barNone", 44);

    kNone0 = Key.create(tNone0);
    kNone1 = Key.create(tNone1);
  }
View Full Code Here

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

    Trivial triv = new Trivial("foo", 5);
    ofy().save().entity(triv).now();

    List<Trivial> trivs = ofy().load().type(Trivial.class).list();
   
    serialize(trivs);
   
    List<Trivial> back = deserialize();
   
    assert back.size() == 1;
    assert back.get(0).getId().equals(triv.getId());
  }
View Full Code Here

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

    Trivial triv = new Trivial("foo", 5);
    Key<Trivial> k = ofy().save().entity(triv).now();

    @SuppressWarnings("unchecked")
    Map<Key<Trivial>, Trivial> trivs = ofy().load().keys(k);
   
    serialize(trivs);
   
    Map<Key<Trivial>, Trivial> back = deserialize();
   
    assert back.size() == 1;
    assert back.get(k).getId().equals(triv.getId());
  }
View Full Code Here

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

    Trivial triv = new Trivial(123L, "foo", 12);
    ofy().save().entity(triv).now();
    ofy().clear();

    List<Trivial> projected = ofy().load().type(Trivial.class).project("someString").list();
    assert projected.size() == 1;

    Trivial pt = projected.get(0);
    assert pt.getId() == triv.getId();
    assert pt.getSomeString().equals(triv.getSomeString());
    assert pt.getSomeNumber() == 0// default value
  }
View Full Code Here

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

    Trivial triv = new Trivial(123L, "foo", 12);
    Key<Trivial> trivKey = ofy().save().entity(triv).now();
    ofy().clear();

    List<Trivial> projected = ofy().load().type(Trivial.class).project("someString").list();
    assert projected.size() == 1;
    assert !ofy().isLoaded(trivKey);

    Trivial fetched = ofy().load().key(trivKey).now();
    assert fetched.getSomeNumber() == triv.getSomeNumber();
  }
View Full Code Here

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

    Trivial triv = new Trivial(123L, "foo", 12);
    Trivial triv2 = new Trivial(456L, "foo", 12);
    ofy().save().entities(triv, triv2).now();
    ofy().clear();

    List<Trivial> projected = ofy().load().type(Trivial.class).project("someString").distinct(true).list();
    assert projected.size() == 1;

    Trivial pt = projected.get(0);
    assert pt.getId() == triv.getId();
    assert pt.getSomeString().equals(triv.getSomeString());
    assert pt.getSomeNumber() == 0// default value
  }
View Full Code Here

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

    t1 = new Trivial("foo", 11);
    k1 = ofy().save().entity(t1).now();

    t2 = new Trivial("bar", 22);
    k2 = ofy().save().entity(t2).now();

    kNone = Key.create(Trivial.class, 12345L);

    ofy().clear();
View Full Code Here

  /** */
  @Test
  public void standaloneLoad() throws Exception {
    Ref<Trivial> ref = Ref.create(k1);

    Trivial loaded = ref.get();
    assert ref.isLoaded();
    assert loaded.getSomeString().equals(t1.getSomeString());
  }
View Full Code Here

      }
    });

    fact().register(Trivial.class);

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

    ofy().save().entity(triv1).now();
    ofy().clear();
  }
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.