@Test
public void testGetAggregationsFromSearchResponseAggregationsSetIsNull()
{

    // Create a mock search response.
    SearchResponse searchResponse = mock(SearchResponse.class);
    when(searchResponse.getAggregations()).thenReturn(null);
    // Mock the external calls.
    when(jsonHelper.objectToJson(searchResponse)).thenReturn(SEARCH_RESPONSE_JSON_STRING);
    // Try to call the method under test.
    try
    {
        elasticsearchHelper.getAggregationsFromSearchResponse(searchResponse);
    }
    catch (IllegalStateException e)
    {
        assertEquals("Invalid search result.", e.getMessage());
    }
    // Verify the external calls.
    verify(jsonHelper).objectToJson(searchResponse);
    verifyNoMoreInteractionsHelper();
}