mardi 4 avril 2017

How to test mapping for a Grails 3 domain class

Given a domain class like:

class Person {
    String name

    static mapping = {
        name column: 'TheName'
    }
}

The name attribute for the Person is actually mapped to the TheName column in an SQL table.

So how can I test, using Spock, to make sure that mapping is present in the domain class? How do I get access to the mapping when I create a new Person object as such:

new Person(name: 'Anderson')

Aucun commentaire:

Enregistrer un commentaire