title: Grails unit testing help needed
body: <p>I want to test a Grails controller which calls a service.  I'd like to mock the service.  The Service has a method:</p>
  
  <p><code>JobIF JobServiceIF.getJob(int)</code></p>
  
  <p>and JobIF has a method:</p>
  
  <p><code>String JobIF.getTitle()</code></p>
  
  <p>Here's my controller</p>
  
  <pre>
  def workActivities = {
     JobIF job = jobService.getJob(params.id)
     [career:job]
  }
  </pre>
  
  <p>I understand that I need to mock the service and the job class (there are concrete implementations for both) but I'm struggling to get my head around the Groovy mocking object syntax.  How do I mock a job and set the title to something, say "Architect" and then test the code?</p>
  
  <p>So far I have:</p>
  
  <pre>
  void testWorkActivities() {
     def controller = new CareersController()
     ... // Mocking stuff I don't know how to do
     controller.params.id = 12
     def model = controller.workActivities()
     assertEquals "Architect", model["career"].getTitle()
  }
  </pre>