Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fragosoluana committed Feb 1, 2025
1 parent e79b3c3 commit d58ecb7
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,39 @@ public void testResponseSizeReductionWithStartHitAndHitsToLogLessThanHitsCount()
assertEquals(5, response.getHitsCount());
}

@Test
public void testLoggingWithZeroHitsToLog() {
SearchRequest request =
SearchRequest.newBuilder()
.setTopHits(1)
.setStartHit(0)
.setIndexName(DEFAULT_TEST_INDEX)
.addRetrieveFields("doc_id")
.setQuery(
Query.newBuilder()
.setTermQuery(
TermQuery.newBuilder()
.setField("vendor_name")
.setTextValue("vendor")
.build())
.build())
.setLoggingHits(
LoggingHits.newBuilder()
.setName("custom_logger")
.setHitsToLog(0)
.setParams(
Struct.newBuilder()
.putFields(
"external_value", Value.newBuilder().setStringValue("abc").build()))
.build())
.build();
SearchResponse response = getGrpcServer().getBlockingStub().search(request);

assertEquals("", HitsLoggerTest.logMessage);
assertEquals(10, response.getTotalHits().getValue());
assertEquals(1, response.getHitsCount());
}

@Test
public void testLoggingTimeTaken() {
SearchRequest request =
Expand Down

0 comments on commit d58ecb7

Please sign in to comment.