title: Spock throw exception test
body: <p>I test Java code with Spock. I test this code:</p>
  
  <pre><code> try {
      Set&lt;String&gt; availableActions = getSthAction()
      List&lt;String&gt; goodActions = getGoodAction()
      if (!CollectionUtils.containsAny(availableActions ,goodActions )){
         throw new CustomException();
      }
  } catch (AnotherCustomExceptio e) {
       throw new CustomException(e.getMessage());
  }
  </code></pre>
  
  <p>I wrote test:</p>
  
  <pre><code>def "some test"() {
      given:
      bean.methodName(_) &gt;&gt; {throw new AnotherCustomExceptio ("Sth wrong")}
      def order = new Order();
      when:
      validator.validate(order )
      then:
      final CustomException exception = thrown()
  }
  </code></pre>
  
  <p>And it fails because <code>AnotherCustomExceptio</code> is thrown. But in the <code>try{}catch</code> block I catch this exception and throw a <code>CustomException</code> so I expected that my method will throw <code>CustomException</code> and not <code>AnotherCustomExceptio</code>. How do I test it?</p>