Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,17 @@ void testMultipleErrorEventsHandling() {
assertThat(response2).isNotNull();
}

@Test
void testPingEventHandling() {
StreamHelper streamHelper = new StreamHelper();
AtomicReference<ChatCompletionResponseBuilder> contentBlockReference = new AtomicReference<>();

AnthropicApi.PingEvent pingEvent = new AnthropicApi.PingEvent(AnthropicApi.EventType.PING);

AnthropicApi.ChatCompletionResponse response = streamHelper.eventToChatCompletionResponse(pingEvent,
contentBlockReference);

assertThat(response).isNotNull();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,22 @@ void whenCompareQueryToNullThenNotEqual() {
assertThat(query).isNotEqualTo(null);
}

@Test
void whenCompareQueryToDifferentTypeThenNotEqual() {
Query query = new Query("Test query");
String notAQuery = "Test query";

assertThat(query).isNotEqualTo(notAQuery);
}

@Test
void toStringReturnsExpectedFormat() {
Query query = new Query("Test query text");
String toString = query.toString();

assertThat(toString).contains("Query");
assertThat(toString).contains("text");
assertThat(toString).contains("Test query text");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.ai.chat.prompt.PromptTemplate;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.mockito.Mockito.mock;

/**
Expand Down Expand Up @@ -69,4 +70,19 @@ void whenPromptHasMissingQueryPlaceholderThenThrow() {
.hasMessageContaining("query");
}

@Test
void whenBuilderIsNullThenThrow() {
assertThatThrownBy(() -> MultiQueryExpander.builder().build()).isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("chatClientBuilder cannot be null");
}

@Test
void whenPromptTemplateIsNullThenUseDefault() {
MultiQueryExpander queryExpander = MultiQueryExpander.builder()
.chatClientBuilder(mock(ChatClient.Builder.class))
.promptTemplate(null)
.build();
assertThat(queryExpander).isNotNull();
}

}