Gaelyk stories are easyb

how-to
Oct 25, 20102 mins

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.
andrew_glover

When Andrew Glover isn't listening to “Funkytown” or “Le Freak” he enjoys speaking on the No Fluff Just Stuff Tour. He also writes articles for multiple online publications including IBM's developerWorks and O'Reilly’s ONJava and ONLamp portals. Andrew is also the co-author of Java Testing Patterns, which was published by Wiley in September 2004; Addison-Wesley’s Continuous Integration; and Manning’s Groovy in Action.

More from this author