title: How do I mock a mocks fields in Grails 2.3.9?
body: <p>I'm a Grails/Groovy newb. I've written a script or two in Groovy but never tests. My background is Java. </p>
  
  <p>Project is an ancient part of a test harness that they want updated for Java 8 and our latest jars. </p>
  
  <p>I've been reading this:
  <a href="http://docs.grails.org/2.3.9/guide/testing.html" rel="nofollow">http://docs.grails.org/2.3.9/guide/testing.html</a>
  ... but there's much I don't understand. The test I'm trying to correct is responding with errors that pertain to null-ability. </p>
  
  <p>Test looks like this:</p>
  
  <pre><code>@TestFor(SomethingController)
  @Mock(Something)
  class SomethingControllerTests {
  ...
      void testDelete() {
          controller.delete()
          assert flash.message != null
          assert response.redirectedUrl == '/somethingPills/list'
  
          response.reset()
  
          populateValidParams(params)
  
          def SomethingPills = new SomethingPills(params)
  
          def saveValueReturned = SomethingPills.save()
  
          assert saveValueReturned != null
          assert SomethingPills.count() == 1
  
          params.id = SomethingPills.id
  
          controller.delete()
  
          assert SomethingPills.count() == 0
          assert SomethingPills.get(somethingPills.id) == null
          assert response.redirectedUrl == '/somethingPills/list'
      }
  
  }
  </code></pre>
  
  <p>The result is that an Exception is chucked out at the <code>assert saveValueReturned != null</code> line indicating that the save was unsuccessful. If I dig into the <code>Something</code> mock during a debug run, I see that all the fields are null except for an errors field. The errors field lists not-nullablle errors pertaining to several fields. Clearly what I have to do is set these within the mock. What I need are clues on how to do that. </p>