ElasticsearchErrorMessage extends ErrorMessage { @Override protected String fetchReason() { return "Error occurred in Elasticsearch engine: " + exception.getMessage(); } ElasticsearchErrorMessage(ElasticsearchException exception, int status);   }
@Test public void fetchReason() { when(elasticsearchException.getMessage()).thenReturn("error"); ElasticsearchErrorMessage errorMessage = new ElasticsearchErrorMessage(elasticsearchException, SERVICE_UNAVAILABLE.getStatus()); assertEquals("Error occurred in Elasticsearch engine: error", errorMessage.fetchReason()); }