SolrSearchDao implements SearchDao { protected AccessConfig getAccessConfig() { return accessConfig; } SolrSearchDao(SolrClient client, AccessConfig accessConfig); @Override SearchResponse search(SearchRequest searchRequest); SearchResponse search(SearchRequest searchRequest, String fieldList); @Override GroupResponse group(GroupRequest groupRequest);  }
@Test public void getSearchResultShouldProperlyReturnResults() { SolrDocument solrDocument = mock(SolrDocument.class); when(solrDocument.getFieldValue(Constants.GUID)).thenReturn("guid"); when(solrDocument.getFieldValue(Constants.SENSOR_TYPE)).thenReturn("sensorType"); when(solrDocument.getFieldValue("field1")).thenReturn("value1"); when(solrDocument.getFieldValue("field2")).thenReturn("value2"); when(solrDocument.getFieldNames()).thenReturn(Arrays.asList("field1", "field2")); SearchResult expectedSearchResult = new SearchResult(); expectedSearchResult.setId("guid"); expectedSearchResult.setIndex("sensorType"); expectedSearchResult.setSource(new HashMap<String, Object>() {{ put("field1", "value1"); }}); assertEquals(expectedSearchResult, SolrUtilities.getSearchResult(solrDocument, Collections.singletonList("field1"), solrSearchDao.getAccessConfig().getIndexSupplier())); SearchResult expectedSearchResultAllFields = new SearchResult(); expectedSearchResultAllFields.setId("guid"); expectedSearchResultAllFields.setIndex("sensorType"); expectedSearchResultAllFields.setSource(new HashMap<String, Object>() {{ put("field1", "value1"); put("field2", "value2"); }}); assertEquals(expectedSearchResultAllFields, SolrUtilities.getSearchResult(solrDocument, null, solrSearchDao.getAccessConfig().getIndexSupplier())); }