gaelyk-template-project-hg / src / test / groovy / DatastoreServiceSpec.groovy

import groovyx.gaelyk.spock.*
import static*

class DatastoreServiceSpec extends GaelykUnitSpec {

    def setup() {
        groovlet 'dataStoreGroovlet.groovy'

    def "the datastore is used from within the groovlet"() {
        given: "the initialised groovlet is invoked and data is persisted"

        when: "the datastore is queried for data"
        def query = new Query("person")
        query.addFilter("firstname", Query.FilterOperator.EQUAL, "Marco")
        def preparedQuery = datastore.prepare(query)
        def entities = preparedQuery.asList(withLimit(1))

        then: "the persisted data is found in the datastore"
        def person = entities[0]
        person.firstname == 'Marco'
        person.lastname == 'Vermeulen'