@Test
public void fetchDetailsWithSearchPhaseExecutionException() {

  when(searchPhaseExecutionException.shardFailures())
      .thenReturn(new ShardSearchFailure[] {shardSearchFailure});
  when(shardSearchFailure.shardId()).thenReturn(1);
  when(shardSearchFailure.getCause()).thenReturn(new IllegalStateException("illegal state"));
  ElasticsearchErrorMessage errorMessage =
      new ElasticsearchErrorMessage(searchPhaseExecutionException,
          SERVICE_UNAVAILABLE.getStatus());
  assertEquals("Shard[1]: java.lang.IllegalStateException: illegal state\n"
          + "\n"
          + "For more details, please send request for Json format to see the "
          + "raw response from elasticsearch engine.",
      errorMessage.fetchDetails());
}