ElasticsearchNativeServiceImpl implements ElasticsearchService { @Override public String findTicks() { QueryBuilder queryBuilder = matchAllQuery(); SearchResponse response = elasticsearch .prepareSearch(indexForTicks) .setQuery(queryBuilder) .setTypes(typeForTicks) .setSize(size) .get(); String results = Arrays.stream(response.getHits().getHits()) .map(hit -> hit.getSourceAsString()) .reduce((a, b) -> String.format("%s,%s", a, b)).orElse(""); return String.format("[%s]", results); }  @PostConstruct void init(); @Override String indexTick(TickJson tick); @Override String indexTicks(List<TickJson> ticks); @Override String indexIndicator(IndicatorJson indicator); @Override String indexIndicators(List<IndicatorJson> indicators); @Override String indexStrategy(StrategyJson strategy); @Override String indexStrategies(List<StrategyJson> strategies); @Override String findTicks(); @Override List<TickJson> findTicksByRic(String ric); @Override List<IndicatorJson> findIndicatorsByRic(String ric); @Override List<TickJson> findTicksByRicAndDateGreaterThan(String ric, Long date); @Override List<IndicatorJson> findIndicatorsByRicAndDateGreaterThan(String ric, Long date); @Override List<IndicatorJson> findIndicatorsByRicAndNameAndDateGreaterThan(String ric, String name, Long date); @Override List<Ticker> findTickersByExchange(ExchangeEnum exchange); InfrastructureProperties getInfrastructureProperties(); void setInfrastructureProperties(InfrastructureProperties infrastructureProperties);  }
@Test public void testGetAllTicks() throws Exception { int number = 12; logger.info("given any {} ticks", number); populateElasticsearch(rdogOne, number, indexForTicks, typeForTicks, null, TickJson.class); logger.info("it should return all ticks"); String result = service.findTicks(); logger.info(" *** getAllTicks(): {}", result); @SuppressWarnings("unchecked") List<TickJson> ticks = (List<TickJson>) json.readValue(result, List.class); logger.info("expected:{}, actual:{}", number, ticks.size()); assertThat(ticks).hasSize(number); assertThat(result).contains("timestamp"); }