title: Unable to mock dynamoDBMapper.query
body: <p>Here is piece of code that i want to test</p>
  
  <p>...</p>
  
  <pre><code>DynamoDBQueryExpression&lt;Order&gt; queryExpression = createQueryForLatestOrders(orderId, storeId, time);
  PaginatedQueryList&lt;Order&gt; orders;
      try{
          orders = dynamoDBMapper.query(Order.class, queryExpression);
      } catch (AmazonServiceException ase){
          if (AmazonServiceException.ErrorType.Client.equals(ase.getErrorType())) {
              throw new InternalServiceException(ase);
          } else {
              throw new DependencyFailureException(ase);
          }
      } catch (AmazonClientException e) {
          throw new DependencyFailureException(e);
      }
    // other business logic
  </code></pre>
  
  <p>The function which is creating query is defined like this</p>
  
  <pre><code>private DynamoDBQueryExpression&lt;Order&gt; createQueryForLatestOrders(String orderId, String storeId, LocalDateTime time) { // ... implementation // }
  </code></pre>
  
  <p>...</p>
  
  <p>and I a trying to test it like this</p>
  
  <pre><code>@Test(expected = DependencyFailureException.class)
  public void testGetOrdersThrowsAWSServerException() throws Exception {
      when(mockDynamoDBMapper.scan(eq(Order.class), any())).thenThrow(AmazonServiceException.class);
  
      mockOrdersManager.getOrders(orderId, storeId, LocalDateTime.now());
  }
  </code></pre>
  
  <p>But instead of being caught under <code>AmazonServiceException</code> the code moves on the next business logic. which makes me think that probably i am not doing mocking properly. What I am missing here. </p>