66package com .liferay .mcp .server .test ;
77
88import com .liferay .arquillian .extension .junit .bridge .junit .Arquillian ;
9+ import com .liferay .portal .kernel .json .JSONArray ;
910import com .liferay .portal .kernel .json .JSONFactoryUtil ;
11+ import com .liferay .portal .kernel .json .JSONObject ;
1012import com .liferay .portal .kernel .test .rule .AggregateTestRule ;
1113import com .liferay .portal .kernel .util .HashMapBuilder ;
1214import 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