List of usage examples for org.springframework.data.elasticsearch.core FacetedPage hasContent
boolean hasContent();
From source file:org.springframework.data.elasticsearch.core.DefaultResultMapperTests.java
@Test public void shouldMapSearchRequestToPage() { //Given/*from w ww . j av a2 s . co m*/ SearchHit[] hits = { createCarHit("Ford", "Grat"), createCarHit("BMW", "Arrow") }; SearchHits searchHits = mock(SearchHits.class); when(searchHits.totalHits()).thenReturn(2L); when(searchHits.iterator()).thenReturn(new ArrayIterator(hits)); when(response.getHits()).thenReturn(searchHits); //When FacetedPage<Car> page = resultMapper.mapResults(response, Car.class, null); //Then assertThat(page.hasContent(), is(true)); assertThat(page.getTotalElements(), is(2L)); assertThat(page.getContent().get(0).getName(), is("Ford")); }
From source file:org.springframework.data.elasticsearch.core.DefaultResultMapperTests.java
@Test public void shouldMapPartialSearchRequestToObject() { //Given//w w w . jav a2 s . c o m SearchHit[] hits = { createCarPartialHit("Ford", "Grat"), createCarPartialHit("BMW", "Arrow") }; SearchHits searchHits = mock(SearchHits.class); when(searchHits.totalHits()).thenReturn(2L); when(searchHits.iterator()).thenReturn(new ArrayIterator(hits)); when(response.getHits()).thenReturn(searchHits); //When FacetedPage<Car> page = resultMapper.mapResults(response, Car.class, null); //Then assertThat(page.hasContent(), is(true)); assertThat(page.getTotalElements(), is(2L)); assertThat(page.getContent().get(0).getName(), is("Ford")); }