title: How to make a mock return 'false' for 'Optional.isPresent()'?
body: <p>I want to mock the statement below which returns <code>OptionalData</code>. I want to mock that data such that <code>Optional.isPresent()</code> returns <code>false</code>.</p>
  <pre class="lang-groovy prettyprint-override"><code>private static Optional&lt;UserList&gt; userListOptional
  private static SharedList sharedList
  
  sharedList = SharedList.builder()
    .sharedListId(2000L)
    .collaboratorList(collaboratorLists)
    .build()
  
  userListOptional = Optional.of(
    UserList.builder()
      .userListId(1234)
      .userId(607042)
      .activeFlag(true)
      .userName(&quot;UnitedStates&quot;)
      .sharedList(sharedList)
      .build()
  )
  
  userListRepository.findByUserIdAndSharedListAndActiveFlagTrue(*_) &gt;&gt; userListOptional
  </code></pre>
  <p>My code under test is:</p>
  <pre class="lang-java prettyprint-override"><code>Optional&lt;UserList&gt; userListOptional = userListRepository
    .findByUserIdAndSharedListAndActiveFlagTrue(user.getUserId(), sharedList);
  </code></pre>