Saturday, October 31, 2009

Gachi - "ORM" for Google App Engine

I've been working on a framework for Google App Engine, the Java version.

Gachi as I've named it, is a tiny framework where I've taken some ideas from QI4J and hence domain driven development for storing entities (POJO's) in the Google App Engine Datastore using the low-level API.

This is one of my testcases:


@Test
public void testCreateWishlistAndAddRecipient() {
UnitOfWork uow = new GAEUnitOfWork();

Date created = new Date();

Wishlist wishlist = uow.newEntity(Wishlist.class);
wishlist.title().set("Wishlist for christmas 2009");
wishlist.comment().set("No soft presents");
wishlist.created().set(created);

uow.complete();

uow = new GAEUnitOfWork();
wishlist = uow.get(wishlist.getEntityReference());
assertEquals("Wishlist for christmas 2009", wishlist.title().get());
assertEquals("No soft presents", wishlist.comment().get());
assertEquals(created, wishlist.created().get());

Recipient recipient1 = uow.newEntity(wishlist, Recipient.class);
recipient1.name().set("Test Person #1");
recipient1.email().set(new Email("testperson1@email.com"));

Recipient recipient2 = uow.newEntity(wishlist, Recipient.class);
recipient2.name().set("Test Person #2");
recipient2.email().set(new Email("testperson2@email.com"));

wishlist.recipients().add(recipient1);
wishlist.recipients().add(recipient2);

uow.complete();

uow = new GAEUnitOfWork();
wishlist = uow.get(wishlist.getEntityReference());
ManyAssociation recipients = wishlist.recipients();
assertEquals(2, recipients.getCount());
assertEquals("Test Person #1", recipients.get(0).name().get());
assertEquals("testperson1@email.com", recipients.get(0).email().get().getEmail());
assertEquals("Test Person #2", recipients.get(1).name().get());
assertEquals("testperson2@email.com", recipients.get(1).email().get().getEmail());
}


... more to come

1 Comments:

Anonymous Anonymous said...

hvorfor ikke:)

8/12/09 14:00  

Post a Comment

<< Home