Skip to content

Commit 3c161c0

Browse files
committed
Fix unit test
1 parent d0ea158 commit 3c161c0

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/spring/OpenAiChatOptions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ private static ChatCompletionTool toOpenAiTool(final ToolCallback toolCallback)
6464

6565
@Override
6666
public void setInternalToolExecutionEnabled(
67-
@Nullable final Boolean internalToolExecutionEnabled) {}
67+
@Nullable final Boolean internalToolExecutionEnabled) {
68+
this.internalToolExecutionEnabled = internalToolExecutionEnabled;
69+
}
6870

6971
@Override
7072
@Nonnull

sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/SpringAiOpenAiTest.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
import com.sap.ai.sdk.app.services.SpringAiOpenAiService;
66
import com.sap.ai.sdk.foundationmodels.openai.OpenAiModel;
7+
import java.util.List;
78
import org.junit.jupiter.api.Test;
9+
import org.springframework.ai.chat.messages.AssistantMessage;
810
import org.springframework.ai.chat.model.ChatResponse;
911

1012
class SpringAiOpenAiTest {
@@ -47,25 +49,25 @@ void testToolCallingWithExecution() {
4749
assertThat(response.getResult().getOutput().getText()).contains("Potsdam", "Toulouse", "°C");
4850
}
4951

50-
// @Test
51-
// void testToolCallingWithoutExecution() {
52-
// ChatResponse response = service.toolCalling(false);
53-
// assertThat(response.getResult().getOutput().getText()).contains("Potsdam", "Toulouse", "°C");
54-
// List<AssistantMessage.ToolCall> toolCalls = response.getResult().getOutput().getToolCalls();
55-
// assertThat(toolCalls).hasSize(2);
56-
// AssistantMessage.ToolCall toolCall1 = toolCalls.get(0);
57-
// AssistantMessage.ToolCall toolCall2 = toolCalls.get(1);
58-
// assertThat(toolCall1.type()).isEqualTo("function");
59-
// assertThat(toolCall2.type()).isEqualTo("function");
60-
// assertThat(toolCall1.name()).isEqualTo("getCurrentWeather");
61-
// assertThat(toolCall2.name()).isEqualTo("getCurrentWeather");
62-
// assertThat(toolCall1.arguments())
63-
// .isEqualTo("{\"arg0\": {\"location\": \"Potsdam\", \"unit\": \"C\"}}");
64-
// assertThat(toolCall2.arguments())
65-
// .isEqualTo("{\"arg0\": {\"location\": \"Toulouse\", \"unit\": \"C\"}}");
66-
// }
6752
@Test
68-
void testchatMemory() {
53+
void testToolCallingWithoutExecution() {
54+
ChatResponse response = service.toolCalling(false);
55+
List<AssistantMessage.ToolCall> toolCalls = response.getResult().getOutput().getToolCalls();
56+
assertThat(toolCalls).hasSize(2);
57+
AssistantMessage.ToolCall toolCall1 = toolCalls.get(0);
58+
AssistantMessage.ToolCall toolCall2 = toolCalls.get(1);
59+
assertThat(toolCall1.type()).isEqualTo("function");
60+
assertThat(toolCall2.type()).isEqualTo("function");
61+
assertThat(toolCall1.name()).isEqualTo("getCurrentWeather");
62+
assertThat(toolCall2.name()).isEqualTo("getCurrentWeather");
63+
assertThat(toolCall1.arguments())
64+
.isEqualTo("{\"arg0\": {\"location\": \"Potsdam\", \"unit\": \"C\"}}");
65+
assertThat(toolCall2.arguments())
66+
.isEqualTo("{\"arg0\": {\"location\": \"Toulouse\", \"unit\": \"C\"}}");
67+
}
68+
69+
@Test
70+
void testChatMemory() {
6971
ChatResponse response = service.chatMemory();
7072
assertThat(response).isNotNull();
7173
String text = response.getResult().getOutput().getText();

0 commit comments

Comments
 (0)