@Test
public void testGetResultTypeIndexSearchResponseDto()
{

    // Build the mocks need for the test.
    SearchResponse searchResponse = mock(SearchResponse.class);
    Aggregations aggregations = mock(Aggregations.class);
    MockTerms terms = mock(MockTerms.class);
    MockBucket bucket = mock(MockBucket.class);
    List<MockBucket> buckets = Collections.singletonList(bucket);
    // Mock the calls to external methods.
    when(searchResponse.getAggregations()).thenReturn(aggregations);
    when(aggregations.get(RESULT_TYPE_AGGS)).thenReturn(terms);
    when(terms.getBuckets()).thenReturn(buckets);
    when(bucket.getKeyAsString()).thenReturn(TAG_CODE);
    when(bucket.getDocCount()).thenReturn(TAG_COUNT);
    // Build the objects needed for the test.
    List<ResultTypeIndexSearchResponseDto> expectedList = new ArrayList<>();
    expectedList.add(new ResultTypeIndexSearchResponseDto(TAG_CODE, TAG_COUNT, TAG_CODE));
    // Call the method under test.
    List<ResultTypeIndexSearchResponseDto> resultList = elasticsearchHelper.getResultTypeIndexSearchResponseDto(searchResponse);
    // Validate the results.
    assertEquals(expectedList, resultList);
    // Verify the calls to external methods.
    verify(searchResponse).getAggregations();
    verify(aggregations).get(RESULT_TYPE_AGGS);
    verify(terms).getBuckets();
    verify(bucket, times(2)).getKeyAsString();
    verify(bucket).getDocCount();
    verifyNoMoreInteractions(aggregations, bucket, searchResponse, terms);
}