File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
models/spring-ai-anthropic/src/test/java/org/springframework/ai/anthropic/api
spring-ai-rag/src/test/java/org/springframework/ai/rag
preretrieval/query/expansion Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -59,4 +59,17 @@ void testMultipleErrorEventsHandling() {
5959 assertThat (response2 ).isNotNull ();
6060 }
6161
62+ @ Test
63+ void testPingEventHandling () {
64+ StreamHelper streamHelper = new StreamHelper ();
65+ AtomicReference <ChatCompletionResponseBuilder > contentBlockReference = new AtomicReference <>();
66+
67+ AnthropicApi .PingEvent pingEvent = new AnthropicApi .PingEvent (AnthropicApi .EventType .PING );
68+
69+ AnthropicApi .ChatCompletionResponse response = streamHelper .eventToChatCompletionResponse (pingEvent ,
70+ contentBlockReference );
71+
72+ assertThat (response ).isNotNull ();
73+ }
74+
6275}
Original file line number Diff line number Diff line change @@ -78,4 +78,22 @@ void whenCompareQueryToNullThenNotEqual() {
7878 assertThat (query ).isNotEqualTo (null );
7979 }
8080
81+ @ Test
82+ void whenCompareQueryToDifferentTypeThenNotEqual () {
83+ Query query = new Query ("Test query" );
84+ String notAQuery = "Test query" ;
85+
86+ assertThat (query ).isNotEqualTo (notAQuery );
87+ }
88+
89+ @ Test
90+ void toStringReturnsExpectedFormat () {
91+ Query query = new Query ("Test query text" );
92+ String toString = query .toString ();
93+
94+ assertThat (toString ).contains ("Query" );
95+ assertThat (toString ).contains ("text" );
96+ assertThat (toString ).contains ("Test query text" );
97+ }
98+
8199}
Original file line number Diff line number Diff line change 2222import org .springframework .ai .chat .prompt .PromptTemplate ;
2323
2424import static org .assertj .core .api .Assertions .assertThatThrownBy ;
25+ import static org .assertj .core .api .AssertionsForClassTypes .assertThat ;
2526import static org .mockito .Mockito .mock ;
2627
2728/**
@@ -69,4 +70,19 @@ void whenPromptHasMissingQueryPlaceholderThenThrow() {
6970 .hasMessageContaining ("query" );
7071 }
7172
73+ @ Test
74+ void whenBuilderIsNullThenThrow () {
75+ assertThatThrownBy (() -> MultiQueryExpander .builder ().build ()).isInstanceOf (IllegalArgumentException .class )
76+ .hasMessageContaining ("chatClientBuilder cannot be null" );
77+ }
78+
79+ @ Test
80+ void whenPromptTemplateIsNullThenUseDefault () {
81+ MultiQueryExpander queryExpander = MultiQueryExpander .builder ()
82+ .chatClientBuilder (mock (ChatClient .Builder .class ))
83+ .promptTemplate (null )
84+ .build ();
85+ assertThat (queryExpander ).isNotNull ();
86+ }
87+
7288}
You can’t perform that action at this time.
0 commit comments