title: Unit testing mocking for Criteria
body: <p>I'm new to grails and trying to write unit tests for Service class has the method, it  calls criteria on domain object.</p>
  
  <p>How do you mock the domain behavior in the following method of a service class?</p>
  
  <pre><code>{def checkForDuplicates(firstName, lastName, gender, birthDate, accountId){
   def duplicateIndividual = Individual.withCriteria{
             eq('firstName',firstName)
             eq('lastName',lastName)
             eq('gender',gender)
             eq('birthDate',birthDate)
             and{
                 accounts{
                     eq('id', accountId)
                 }
             }
      }
  
      if(duplicateIndividual){
          log.error("Found duplicate for ${duplicateIndividual.firstName}
        ${duplicateIndividual.lastName}")
          return true
      }
      return false
  }"
  </code></pre>