title: Understanding Grails mockFor demand
body: <p>I'm trying to write a unit test for my filters, and I'm struggling to understand the <strong>demand</strong> for my mocked object. Here is a simple failing test:</p>
  
  <pre><code>void "test my sanity"() {
      setup:
      def vendorPayment = mockFor(Payment)
      vendorPayment.demand.buyerId { -&gt; 123}
  
      def vp = vendorPayment.createMock()
      //vp.buyerId=123
      println "buyer id: ${vp.buyerId}"
  
      when:
        def a = "testing"
  
      then:
        vp.buyerId == 123
  }
  </code></pre>
  
  <p>I wanted to mock the getter for buyerId. Using demand doesn't work, but if I create the mock and then set the buyer id (the commented line), the test will pass. Does demand not work with getters? Is it because the getter is implicitly/dynamically created?</p>