Skip to content

Commit

Permalink
fix unit tests for abstract retriever tool
Browse files Browse the repository at this point in the history
Signed-off-by: yuye-aws <[email protected]>
  • Loading branch information
yuye-aws committed Dec 12, 2023
1 parent 41b33b9 commit 36ab02a
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,23 @@ public void testRunAsyncWithEmptySearchResponse() {
}

@Test
@SneakyThrows
public void testRunAsyncWithIllegalQueryThenThrowException() {
Client client = mock(Client.class);
mockedImpl.setClient(client);

assertThrows(
"[input] is null or empty, can not process it.",
Exception exception = assertThrows(
IllegalArgumentException.class,
() -> mockedImpl.run(Map.of(AbstractRetrieverTool.INPUT_FIELD, ""), null)
);
assertEquals("[input] is null or empty, can not process it.", exception.getMessage());

assertThrows(
"[input] is null or empty, can not process it.",
exception = assertThrows(
IllegalArgumentException.class,
() -> mockedImpl.run(Map.of(AbstractRetrieverTool.INPUT_FIELD, " "), null)
);
assertEquals("[input] is null or empty, can not process it.", exception.getMessage());

assertThrows(
"[input] is null or empty, can not process it.",
IllegalArgumentException.class,
() -> mockedImpl.run(Map.of("test", "hello world"), null)
);
exception = assertThrows(IllegalArgumentException.class, () -> mockedImpl.run(Map.of("test", "hello world"), null));
assertEquals("[input] is null or empty, can not process it.", exception.getMessage());
}
}

0 comments on commit 36ab02a

Please sign in to comment.