Skip to content

Commit 4bb1c91

Browse files
ling-alan-huangbrianchandotcom
authored andcommitted
LPD-73100 SF
1 parent 35f4374 commit 4bb1c91

File tree

1 file changed

+16
-11
lines changed
  • modules/apps/mcp/mcp-server-test/src/testIntegration/java/com/liferay/mcp/server/test

1 file changed

+16
-11
lines changed

modules/apps/mcp/mcp-server-test/src/testIntegration/java/com/liferay/mcp/server/test/MCPServerTest.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
package com.liferay.mcp.server.test;
77

88
import com.liferay.arquillian.extension.junit.bridge.junit.Arquillian;
9+
import com.liferay.portal.kernel.json.JSONArray;
910
import com.liferay.portal.kernel.json.JSONFactoryUtil;
11+
import com.liferay.portal.kernel.json.JSONObject;
1012
import com.liferay.portal.kernel.test.rule.AggregateTestRule;
1113
import com.liferay.portal.kernel.util.HashMapBuilder;
1214
import com.liferay.portal.kernel.util.PropsValues;
@@ -89,20 +91,23 @@ public void test() throws Exception {
8991
"get-openapi",
9092
HashMapBuilder.<String, Object>put(
9193
"url",
92-
JSONFactoryUtil.createJSONObject(
93-
content.text()
94-
).getJSONArray(
95-
"/test"
96-
).getString(
97-
0
98-
)
94+
() -> {
95+
JSONObject jsonObject =
96+
JSONFactoryUtil.createJSONObject(content.text());
97+
98+
JSONArray jsonArray = jsonObject.getJSONArray("/test");
99+
100+
return jsonArray.getString(0);
101+
}
99102
).build()));
100103

101104
contents = callToolResult.content();
102105

103-
content = (McpSchema.TextContent)contents.get(0);
106+
McpSchema.TextContent newContent = (McpSchema.TextContent)contents.get(
107+
0);
104108

105-
Assert.assertThat(content.text(), CoreMatchers.containsString("/test"));
109+
Assert.assertThat(
110+
newContent.text(), CoreMatchers.containsString("/test"));
106111

107112
callToolResult = mcpSyncClient.callTool(
108113
new McpSchema.CallToolRequest(
@@ -115,11 +120,11 @@ public void test() throws Exception {
115120

116121
contents = callToolResult.content();
117122

118-
content = (McpSchema.TextContent)contents.get(0);
123+
newContent = (McpSchema.TextContent)contents.get(0);
119124

120125
Assert.assertNotNull(
121126
JSONFactoryUtil.createJSONObject(
122-
content.text()
127+
newContent.text()
123128
).getJSONArray(
124129
"items"
125130
));

0 commit comments

Comments
 (0)