Skip to content

Commit

Permalink
HSEARCH-4142 Test projection id in documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever committed Mar 1, 2021
1 parent 347331e commit 3bcb6f1
Showing 1 changed file with 30 additions and 0 deletions.
Expand Up @@ -134,6 +134,36 @@ public void reference() {
} );
}

@Test
public void id_object() {
withinSearchSession( searchSession -> {
// tag::id-object[]
List<Object> hits = searchSession.search( Book.class )
.select( f -> f.id() )
.where( f -> f.matchAll() )
.fetchHits( 20 );
// end::id-object[]
assertThat( hits ).containsExactlyInAnyOrder(
BOOK1_ID, BOOK2_ID, BOOK3_ID, BOOK4_ID
);
} );
}

@Test
public void id_int() {
withinSearchSession( searchSession -> {
// tag::id-int[]
List<Integer> hits = searchSession.search( Book.class )
.select( f -> f.id( Integer.class ) )
.where( f -> f.matchAll() )
.fetchHits( 20 );
// end::id-int[]
assertThat( hits ).containsExactlyInAnyOrder(
BOOK1_ID, BOOK2_ID, BOOK3_ID, BOOK4_ID
);
} );
}

@Test
public void entity() {
withinSearchSession( searchSession -> {
Expand Down

0 comments on commit 3bcb6f1

Please sign in to comment.