Package com.google.code.gaeom

Examples of com.google.code.gaeom.ObjectStoreSession


  @Test(expected = IllegalArgumentException.class)
  public void testDetectStoreUnactivated()
  {
    Key key = load();
    ObjectStoreSession oss2 = os.beginSession();
    A a = oss2.load(key).activate(0).now();

    a.b.name = "bob";
    oss2.store(a.b).now();
  }
View Full Code Here


  @Test
  public void testCount()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    List<Foo> foos = Lists.newArrayList();
    for (int ct = 0; ct < 100; ct++)
      foos.add(new Foo(ct));
    oss.store(foos).now();

    assertEquals(100, oss.find(Foo.class).count().now().intValue());

    assertEquals(50, oss.find(Foo.class).filter("value", Op.LessThan, 50).count().now().intValue());
    assertEquals(51, oss.find(Foo.class).filter("value", Op.LessThanOrEqualTo, 50).count().now().intValue());
    assertEquals(1, oss.find(Foo.class).filter("value", Op.EqualTo, 50).count().now().intValue());
    assertEquals(99, oss.find(Foo.class).filter("value", Op.NotEqualTo, 50).count().now().intValue());
    assertEquals(24, oss.find(Foo.class).filter("value", Op.GreaterThan, 75).count().now().intValue());
    assertEquals(25, oss.find(Foo.class).filter("value", Op.GreaterThanOrEqualTo, 75).count().now().intValue());
  }
View Full Code Here

    Foo foo= new Foo();
    foo.values.add("Foo");
    foo.values.add("Bar");
    foo.values.add("Bas");
   
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
    oss.store(foo).now();
   
    List<String> orig = foo.values;
    foo.values = null;
   
    oss.refresh(foo).now();
   
    assertEquals(orig, foo.values);
  }
View Full Code Here

    p.phones.add(new Phone(207, 444, 3333));
    p.phones.add(new Phone(207, 686, 7777));
    p.phones.add(new Phone(207, 555, 7777));
    p.phones.get(1).prefix = null// prove out the rectangulation of the thing
   
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
    oss.store(p).now();
   
    List<Phone> orig = p.phones;
    p.phones = null;
   
    oss.refresh(p).now();
   
    assertEquals(orig, p.phones);
  }
View Full Code Here

  @Test(expected = KeysNotFoundException.class)
  public void testDeleteCommand()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Tester t1 = new Tester();
    t1.name = "Fred Flintstone";
    Key key = oss.store(t1).now();

    oss.delete(t1).now();

    os.beginSession().load(key).now(); // may not fail because changes not rolled forward see superclass

    assertNull(os.beginSession().load(key).retries(0).now());
  }
View Full Code Here

  @Test(expected = KeysNotFoundException.class)
  public void testDeleteCommandLocal()
  {
    ObjectStore os = ObjectStore.Factory.create();
    ObjectStoreSession oss = os.beginSession();

    Tester t1 = new Tester();
    t1.name = "Fred Flintstone";
    Key key = oss.store(t1).now();

    oss.delete(t1).now();

    os.beginSession().load(key).now(); // may not fail because changes not rolled forward see superclass

    assertNull(oss.load(key).retries(0).now());
  }
View Full Code Here

 
  @Test
  public void testReStoring()
  {
    Foo foo = new Foo("Fred Flintstone");
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
   
    oss.store(foo).now();
   
    foo.name = "Barney Rubble";
   
    oss.store(foo).now();
   
    List<Foo> foos = Lists.newArrayList(oss.find(Foo.class).now());
    assertEquals(1, foos.size());
    assertEquals(foo, foos.get(0));
  }
View Full Code Here

  @Test
  public void testParenting()
  {
    Node node = create(3, 3);
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
    oss.store(node).now();

    testParent(oss, node, null);
  }
View Full Code Here

  public void testPolymorphicSingleRelationship()
  {
    Foo foo = new Foo();
    foo.bar1 = new Bar1();
    foo.bar2 = new Bar2();
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
   
    oss.store(foo).now();
   
    foo.bar1 = null;
    foo.bar2 = null;
   
    oss.refresh(foo).now();
   
    assertTrue(foo.bar1 instanceof Bar1);
    assertTrue(foo.bar2 instanceof Bar2);
  }
View Full Code Here

    foo.bars.add(new Bar1());
    foo.bars.add(new Bar2());
    foo.bars.add(new Bar1());
    foo.bars.add(new Bar2());
   
    ObjectStoreSession oss = ObjectStore.Factory.create().beginSession();
   
    oss.store(foo).now();
   
    foo.bars = null;
   
    oss.refresh(foo).now();
   
    assertEquals(4, foo.bars.size());
    assertTrue(foo.bars.get(0) instanceof Bar1);
    assertTrue(foo.bars.get(1) instanceof Bar2);
    assertTrue(foo.bars.get(2) instanceof Bar1);
View Full Code Here

TOP

Related Classes of com.google.code.gaeom.ObjectStoreSession

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.