Skip to content

Commit a216bf1

Browse files
committed
Refactor MethodToolCallbackProviderTests
- Move the existing buildToolsWithBridgeMethodReturnOnlyUserDeclaredMethods into MethodToolCallbackProviderTests - Delete MethodToolCallbackProviderTest Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
1 parent 99e59a2 commit a216bf1

File tree

2 files changed

+28
-32
lines changed

2 files changed

+28
-32
lines changed

spring-ai-model/src/test/java/org/springframework/ai/tool/method/MethodToolCallbackProviderTest.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

spring-ai-model/src/test/java/org/springframework/ai/tool/method/MethodToolCallbackProviderTests.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@
2323

2424
import org.junit.jupiter.api.Test;
2525

26+
import org.springframework.ai.tool.ToolCallback;
2627
import org.springframework.ai.tool.annotation.Tool;
2728
import org.springframework.ai.tool.execution.DefaultToolCallResultConverter;
2829
import org.springframework.ai.tool.execution.ToolCallResultConverter;
2930
import org.springframework.core.annotation.AliasFor;
3031

3132
import static org.assertj.core.api.Assertions.assertThat;
3233
import static org.assertj.core.api.Assertions.assertThatThrownBy;
34+
import static org.junit.jupiter.api.Assertions.assertEquals;
35+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
3336

3437
/**
3538
* Unit tests for {@link MethodToolCallbackProvider}.
@@ -112,6 +115,31 @@ void whenEnhanceToolObjectHasMixOfValidAndFunctionalTypeToolMethodsThenSucceed()
112115
assertThat(provider.getToolCallbacks()[0].getToolDefinition().name()).isEqualTo("validTool");
113116
}
114117

118+
@Test
119+
public void buildToolsWithBridgeMethodReturnOnlyUserDeclaredMethods() {
120+
MethodToolCallbackProvider provider = MethodToolCallbackProvider.builder()
121+
.toolObjects(new TestObjectSuperClass())
122+
.build();
123+
ToolCallback[] toolCallbacks = provider.getToolCallbacks();
124+
assertEquals(1, toolCallbacks.length);
125+
assertInstanceOf(MethodToolCallback.class, toolCallbacks[0]);
126+
}
127+
128+
abstract class TestObjectClass<T> {
129+
130+
public abstract String test(T input);
131+
132+
}
133+
134+
class TestObjectSuperClass extends TestObjectClass<String> {
135+
136+
@Tool
137+
public String test(String input) {
138+
return input;
139+
}
140+
141+
}
142+
115143
static class ValidToolObject {
116144

117145
@Tool

0 commit comments

Comments
 (0)