I have a method in which is it using RestTemplate. I using the following code to make a call:
         final ResponseEntity<RESTResponse> responseEntity = restTemplate.exchange(uri,
                                                                               HttpMethod.POST,
                                                                               httpEntityWithHeaders,
                                                                               RESTResponse.class);
httpEntityWithHeads is of type HttpEntity<String>. I am writing a test and trying to mock RestTemplate so that when it calls the exchange method, it will throw an exception. 
I am trying to mock it like this:
      when(restTemplate.exchange(
     ArgumentMatchers.contains(randomHost),
     ArgumentMatchers.eq(HttpMethod.POST),
     ArgumentMatchers.<HttpEntity<List<String>>>any(),
     ArgumentMatchers.<ParameterizedTypeReference<List<RESTResponse>>>any())
  ).thenThrow(new ResourceAccessException("Random exception message."));
But when running the test, it doesn't throw the exception, it just continues.
Any suggestions?