Package com.vercer.engine.persist.annotation

Examples of com.vercer.engine.persist.annotation.AnnotationObjectDatastore


  @Override
  public void setUp()
  {
    super.setUp();
    datastore = new AnnotationObjectDatastore();
  }
View Full Code Here


  {
    MusicFestival musicFestival = createFestival();

    Key key = datastore.store(musicFestival);

    AnnotationObjectDatastore typesafe2 = new AnnotationObjectDatastore();
    typesafe2.setActivationDepth(5);
    Object reloaded = typesafe2.load(key);

    // they should be different instances from distinct sessions
    assertNotSame(musicFestival, reloaded);

    // they should have the same data
View Full Code Here

  @Test
  public void embeddedQueryTest()
  {
    {
      ObjectDatastore datastore = new AnnotationObjectDatastore(false);

      Foo foo = new Foo();
      foo.myKey = "foo1";
      foo.innerFoo = new InnerFoo("foo1Name");
      foo.moreInnerFoos = new HashMap<String, InnerFoo>();
      foo.moreInnerFoos.put("hello", new InnerFoo("helloFoo"));
      foo.moreInnerFoos.put("goodbye", new InnerFoo("goodbyeFoo"));

      datastore.store(foo);
    }

    {
      ObjectDatastore datastore = new AnnotationObjectDatastore(false);
      Foo foundFoo = datastore.load(Foo.class, "foo1");

      assertEquals("foo1", foundFoo.myKey);
      assertEquals("foo1Name", foundFoo.innerFoo.myName);
      assertEquals(2, foundFoo.moreInnerFoos.size());
      assertEquals("helloFoo", foundFoo.moreInnerFoos.get("hello").myName);
View Full Code Here

public class PolymorphicCollectionsTest extends LocalDatastoreTestCase
{
  @Test
  public void test()
  {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
     
    for(int i=0;i<10; i++){
      datastore.store(new Driver(new Car(new Date())));
      datastore.store(new Driver(new Lorry(new Long(50+i))));
    }
   
    QueryResultIterator<Driver> result = datastore.find().type(Driver.class).fetchNoFields().returnResultsNow();
   
    Assert.assertTrue(result.hasNext());
  }
View Full Code Here

  }
 
  @Test
  public void missingStringField()
  {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
   
    HasStringKey hasNullKey = new HasStringKey();
    datastore.store(hasNullKey);
   
    Assert.assertNotNull(hasNullKey.keyField);
  }
View Full Code Here

  }

  @Test
  public void missingIntField()
  {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
   
    HasIntKey hasNullKey = new HasIntKey();
    datastore.store(hasNullKey);
   
    Assert.assertTrue(hasNullKey.keyField > 0);
  }
View Full Code Here

  }

  @Test
  public void missingLongField()
  {
    ObjectDatastore datastore = new AnnotationObjectDatastore();
   
    HasLongKey hasNullKey = new HasLongKey();
    datastore.store(hasNullKey);
   
    Assert.assertNotNull(hasNullKey.keyField);
  }
View Full Code Here

  {
    EnumSet<MyEnum> myEnums = EnumSet.allOf(MyEnum.class);
    EnumContainer container = new EnumContainer();
    container.theEnumSet = myEnums;
   
    ObjectDatastore datastore = new AnnotationObjectDatastore();
    Key key = datastore.store(container);
   
    datastore.disassociateAll();
   
    EnumContainer loaded = datastore.load(key);
   
    Assert.assertTrue(loaded.theEnumSet instanceof EnumSet<?>);
    Assert.assertTrue(loaded.theEnumSet.size() == 2);
  }
View Full Code Here

  }

  @org.junit.Test
  public void testJoinTable()
  {
    ObjectDatastore ds = new AnnotationObjectDatastore();

    A a;
    B b;
    ds.store(a = new A());
    ds.store(b = new B());
    ds.store(new AB(a, b));

    final AB ab = ds.find().type(AB.class).addFilter("a", Query.FilterOperator.EQUAL,
        ds.associatedKey(a)).returnResultsNow().next();

    if (!ab.b.equals(b))
      fail();
  }
View Full Code Here

    c11.field = "c11";
    C c12 = new C();
    c12.field = "c12";
    b1.cs = Lists.newArrayList(c11, c12);
   
    ObjectDatastore datastore = new AnnotationObjectDatastore();
    Key key = datastore.store(a);
    datastore.disassociateAll();
    A reloaded = datastore.load(key);
   
    Assert.assertNull(reloaded.bs.get(0).cs.get(0).field);
  }
View Full Code Here

TOP

Related Classes of com.vercer.engine.persist.annotation.AnnotationObjectDatastore

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.