Gaelyk stories are easyb

Posted by: Andrew Glover on 2010-10-25 12:21:00.0

On the heels of easyb’s newest release and the addition of a Google App Engine plugin for easyb comes another plugin: easyb-gaelyk.GAE Briefly, Gaelyk is a slick Groovy based web application framework for the Google App Engine. As its documentation states (among other benefits), Gaelyk:

simplifies the usage of the Google App Engine SDK by providing more concise and more powerful shortcuts when using the datastore, memcache, the blobstore, the images service, the URL fetch service, when sending and receiving emails or Jabber messages, and much more.

The easyb Gaelyk plugin, when used along side easyb’s GAE plugin, enables easyb stories to leverage these Gaelyk shortcuts as Gaelyk’s GaelykCategory is now implicitly added into the context of a story.

For example, the following easyb story demonstrates the easyb-gaelyk plugin in action:

import com.google.appengine.api.datastore.Entity
import com.google.appengine.api.datastore.Query
import static com.google.appengine.api.datastore.FetchOptions.Builder.withLimit

using "GAE"
using "gaelyk"

scenario "Gaelyk magic should work as normal", {
 given "params map i.e. form inputs", {
   params = [:]
   params.name = "Andy"
   params.type = "Facebook"
 }

 then "n account low-level entity should be created", {
    acct = new Entity("account")
	acct.name = params.name
	acct.type = params.type
	acct.save()
 }

 and "one can find it easily and it should act Gaelyk-y", {
 	qry = new Query("account")
 	qry.addSort("name", Query.SortDirection.DESCENDING)
 	prp = datastore.prepare(qry)
 	accts = prp.asList(withLimit(1))
 	accts[0].class.shouldBe Entity
 	accts[0].type.shouldBe "Facebook"
 }
}

As you can see from the code above, issuing a using "gaelyk" along with a call to using "GAE" enables both the local Google infrastructure and Gaelyk to implicitly be available to code running inside of a story. Thus, with Google’s Entity object, for example, I can auto-magically attach properties (such as type in the code above) that are then persisted in a column-oriented fashion. As you’ve probably guessed, this can only be done within the confines of a Gaelyk application.

For more information on Gaelyk, check out “Gaelyk for Google App Engine” and “Schemaless data modeling with Bigtable and Groovy’s Gaelyk” and for more information on the easyb-gaelyk plugin, check out easyb’s wiki. Lastly, download the plugin — it’ll make testing of Gaelyk applications a blast, baby!

Looking to spin up Continuous Integration quickly? Check out www.ciinabox.com.


be the first to rate this blog

About Andrew Glover

Andrew Glover

Andrew is the founder of the easyb BDD framework and the co-author of Addison Wesley's "Continuous Integration", Manning's "Groovy in Action" and "Java Testing Patterns". He is an author for multiple online publications including IBM's developerWorks and Oreilly's ONJava and ONLamp portals. He actively blogs about software at thediscoblog.com.

More About Andrew »

NFJS, the Magazine

2010-10-01 00:00:00.0 Issue Now Available
  • What's Brewing in Java 7: The Language Features
    by Venkat Subramaniam
  • Waste!
    by Hamlet D`Arcy
  • Arquillian: A component Model for Integration Testing
    by Dan Allen
  • Spring Roo - A Jump-Start for Your Java Project
    by Paul Chapman
Learn More »