title: Mock a method inside a service class which is under unit test
body: <p>I have a service class which has 2 methods(one is public and other is protected). I am trying to unit test my code. Below is the code snippet
  MyServiceClass.groovy</p>
  
  <pre><code>class MyServiceClass {
  
         public boolean myMethod1() {
              // some code
              boolean success = myMethod2()
              // some code
         }
  
        public boolean myMethod2() {
            // some logic to return true/false
            return true
        }
  
  }
  
  MyServiceClassTests.groovy
  
  class MyServiceClassTests {
  
        void testMyMethod1() {
             // unit test code
        }
  
  }
  </code></pre>
  
  <p>In the above unit test code, I want to mock the myMethod2() return result which is invoked by myMethod1(), i.e., both the methods are in the same service class which is under unit test. How to mock it and get things done?? </p>