Skip to content

Commit b1a68cc

Browse files
committed
Finishing the tests
1 parent 3c02160 commit b1a68cc

File tree

2 files changed

+13
-25
lines changed

2 files changed

+13
-25
lines changed

foundation-models/openai/pom.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
</scm>
3939
<properties>
4040
<project.rootdir>${project.basedir}/../../</project.rootdir>
41-
<coverage.complexity>70%</coverage.complexity>
42-
<coverage.line>80%</coverage.line>
43-
<coverage.instruction>76%</coverage.instruction>
44-
<coverage.branch>70%</coverage.branch>
45-
<coverage.method>75%</coverage.method>
46-
<coverage.class>84%</coverage.class>
41+
<coverage.complexity>83%</coverage.complexity>
42+
<coverage.line>92%</coverage.line>
43+
<coverage.instruction>90%</coverage.instruction>
44+
<coverage.branch>81%</coverage.branch>
45+
<coverage.method>90%</coverage.method>
46+
<coverage.class>92%</coverage.class>
4747
</properties>
4848
<dependencies>
4949
<dependency>
@@ -158,6 +158,7 @@
158158
<groupId>org.springframework.ai</groupId>
159159
<artifactId>spring-ai-client-chat</artifactId>
160160
<scope>test</scope>
161+
<optional>true</optional>
161162
</dependency>
162163
</dependencies>
163164

foundation-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/spring/OpenAiChatModelTest.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
1212
import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
1313
import static org.assertj.core.api.Assertions.assertThat;
14-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
1514
import static org.mockito.ArgumentMatchers.any;
1615
import static org.mockito.Mockito.doReturn;
1716
import static org.mockito.Mockito.mock;
@@ -88,16 +87,6 @@ void testCompletion() {
8887
assertThat(result.getResult().getOutput().getText()).isNotEmpty();
8988
}
9089

91-
@Test
92-
void testThrowsOnMissingChatOptions() {
93-
assertThatThrownBy(() -> client.call(new Prompt("test")))
94-
.isExactlyInstanceOf(IllegalArgumentException.class)
95-
.hasMessageContaining("Please add OrchestrationChatOptions to the Prompt");
96-
assertThatThrownBy(() -> client.stream(new Prompt("test")))
97-
.isExactlyInstanceOf(IllegalArgumentException.class)
98-
.hasMessageContaining("Please add OrchestrationChatOptions to the Prompt");
99-
}
100-
10190
@Test
10291
void testStreamCompletion() throws IOException {
10392
try (val inputStream = spy(fileLoader.apply("streamChatCompletion.txt"))) {
@@ -117,15 +106,13 @@ void testStreamCompletion() throws IOException {
117106
Flux<ChatResponse> flux = client.stream(prompt);
118107
val deltaList = flux.toStream().toList();
119108

120-
assertThat(deltaList).hasSize(3);
109+
assertThat(deltaList).hasSize(5);
121110
// the first delta doesn't have any content
122111
assertThat(deltaList.get(0).getResult().getOutput().getText()).isEqualTo("");
123-
assertThat(deltaList.get(1).getResult().getOutput().getText()).isEqualTo("Sure");
124-
assertThat(deltaList.get(2).getResult().getOutput().getText()).isEqualTo("!");
125-
126-
assertThat(deltaList.get(0).getResult().getMetadata().getFinishReason()).isEqualTo("");
127-
assertThat(deltaList.get(1).getResult().getMetadata().getFinishReason()).isEqualTo("");
128-
assertThat(deltaList.get(2).getResult().getMetadata().getFinishReason()).isEqualTo("stop");
112+
assertThat(deltaList.get(1).getResult().getOutput().getText()).isEqualTo("");
113+
assertThat(deltaList.get(2).getResult().getOutput().getText()).isEqualTo("Sure");
114+
assertThat(deltaList.get(3).getResult().getOutput().getText()).isEqualTo("!");
115+
assertThat(deltaList.get(4).getResult().getOutput().getText()).isEqualTo("");
129116

130117
Mockito.verify(inputStream, times(1)).close();
131118
}
@@ -217,7 +204,7 @@ void testChatMemory() throws IOException {
217204
.willSetStateTo("Second Call"));
218205

219206
stubFor(
220-
post(urlPathEqualTo("/v2/completion"))
207+
post(urlPathEqualTo("/chat/completions"))
221208
.inScenario("Chat Memory")
222209
.whenScenarioStateIs("Second Call")
223210
.willReturn(

0 commit comments

Comments
 (0)