2727import org .junit .jupiter .api .Test ;
2828
2929import java .io .IOException ;
30+ import java .util .Arrays ;
31+ import java .util .Collections ;
3032import java .util .List ;
3133import java .util .Map ;
3234import java .util .concurrent .CopyOnWriteArrayList ;
@@ -79,12 +81,12 @@ void tearDown() {
7981 void shouldCoverChatModelsStreamingAndValidation () throws Exception {
8082 try (OpenClawChatClient chat = new OpenClawChatClient (config , new ObjectMapper (), client )) {
8183 ChatRequest agentRequest = ChatRequest .builder ().agent ("openclaw/default" )
82- .messages (List . of (ChatMessage .ofUser ("hello" ))).build ();
84+ .messages (Arrays . asList (ChatMessage .ofUser ("hello" ))).build ();
8385 ChatRequest modelRequest = ChatRequest .builder ().model ("gpt-5.4" )
84- .messages (List . of (ChatMessage .ofUser ("hello" ))).build ();
86+ .messages (Arrays . asList (ChatMessage .ofUser ("hello" ))).build ();
8587
8688 assertEquals ("chat-id" , chat .chatCompletion (agentRequest ).getId ());
87- assertEquals ("chat-id" , chat .chatCompletion (modelRequest , Map . of ("X-Custom" , "value" )).getId ());
89+ assertEquals ("chat-id" , chat .chatCompletion (modelRequest , Collections . singletonMap ("X-Custom" , "value" )).getId ());
8890 AtomicBoolean cancellationRegistered = new AtomicBoolean ();
8991 assertThrows (OpenClawHttpException .class , () -> chat .chatCompletion (agentRequest , null , callback -> {
9092 cancellationRegistered .set (true );
@@ -100,17 +102,17 @@ void shouldCoverChatModelsStreamingAndValidation() throws Exception {
100102
101103 assertThrows (NullPointerException .class , () -> chat .chatCompletion (null ));
102104 assertThrows (IllegalArgumentException .class , () -> chat .chatCompletion (ChatRequest .builder ()
103- .messages (List . of (ChatMessage .ofUser ("hello" ))).build ()));
105+ .messages (Arrays . asList (ChatMessage .ofUser ("hello" ))).build ()));
104106 assertThrows (IllegalArgumentException .class , () -> chat .chatCompletion (ChatRequest .builder ()
105- .agent ("openclaw/default" ).messages (List . of ()).build ()));
107+ .agent ("openclaw/default" ).messages (Collections . emptyList ()).build ()));
106108
107109 StreamingChatResponse stream = chat .chatCompletionStream (agentRequest );
108110 assertEquals ("hello" , stream .get (3 , TimeUnit .SECONDS ).getChoices ().get (0 ).getDelta ().getContent ());
109111 StreamingChatResponse callbackStream = chat .chatCompletionStream (agentRequest ,
110112 StreamingChatResponse .builder ().onDelta (ignored -> { }).onChunk (ignored -> { })
111113 .onToolCall (ignored -> { }).onComplete (ignored -> { }).onError (ignored -> { }));
112114 assertEquals ("hello" , callbackStream .get (3 , TimeUnit .SECONDS ).getChoices ().get (0 ).getDelta ().getContent ());
113- try (Response raw = chat .chatCompletionStreamRaw (agentRequest , Map . of ("X-Raw" , "yes" ))) {
115+ try (Response raw = chat .chatCompletionStreamRaw (agentRequest , Collections . singletonMap ("X-Raw" , "yes" ))) {
114116 assertEquals (200 , raw .code ());
115117 }
116118
@@ -126,19 +128,19 @@ void shouldCoverResponsesEmbeddingsToolsAndBaseHttpErrors() {
126128 OpenClawEmbeddingsClient embeddings = new OpenClawEmbeddingsClient (config , null , client );
127129 OpenClawToolInvokeClient tools = new OpenClawToolInvokeClient (config , null , client )) {
128130 assertNotNull (responses .createResponse (ResponseRequest .builder ().agent ("openclaw/default" ).input ("hello" ).build ()));
129- assertNotNull (responses .createResponse (ResponseRequest .builder ().model ("gpt-5.4" ).input (List . of ("hello" )).build ()));
131+ assertNotNull (responses .createResponse (ResponseRequest .builder ().model ("gpt-5.4" ).input (Arrays . asList ("hello" )).build ()));
130132 assertThrows (IllegalArgumentException .class , () -> responses .createResponse (ResponseRequest .builder ().input ("hello" ).build ()));
131133 assertThrows (IllegalArgumentException .class , () -> responses .createResponse (ResponseRequest .builder ().agent ("a" ).build ()));
132134
133135 assertNotNull (embeddings .createEmbeddings (EmbeddingsRequest .builder ().agent ("openclaw/default" ).input ("hello" ).build ()));
134- assertNotNull (embeddings .createEmbeddings (EmbeddingsRequest .builder ().model ("embed-model" ).input (List . of ("hello" )).build ()));
136+ assertNotNull (embeddings .createEmbeddings (EmbeddingsRequest .builder ().model ("embed-model" ).input (Arrays . asList ("hello" )).build ()));
135137 assertThrows (IllegalArgumentException .class , () -> embeddings .createEmbeddings (EmbeddingsRequest .builder ().input ("hello" ).build ()));
136138 assertThrows (IllegalArgumentException .class , () -> embeddings .createEmbeddings (EmbeddingsRequest .builder ().agent ("a" ).build ()));
137139
138140 ToolInvokeRequest request = new ToolInvokeRequest ();
139141 request .setTool ("browser" );
140142 request .setAction ("open" );
141- request .setArgs (Map . of ("url" , "http://localhost" ));
143+ request .setArgs (Collections . singletonMap ("url" , "http://localhost" ));
142144 assertTrue (tools .invoke (request ).getOk ());
143145 assertThrows (NullPointerException .class , () -> tools .invoke (null ));
144146 assertThrows (IllegalArgumentException .class , () -> tools .invoke (new ToolInvokeRequest ()));
@@ -181,7 +183,7 @@ void shouldCoverWebhookBodiesAuthenticationParsingAndErrors() {
181183 assertTrue (webhooks .postHooksWake ("wake" , "later" ).contains ("runId" ));
182184 assertTrue (webhooks .postMappedHook ("/hooks/custom" , null ).contains ("runId" ));
183185 assertThrows (IllegalArgumentException .class , () -> webhooks .postHooksWake (" " , "now" ));
184- assertThrows (IllegalArgumentException .class , () -> webhooks .postMappedHook ("bad/name" , Map . of ()));
186+ assertThrows (IllegalArgumentException .class , () -> webhooks .postMappedHook ("bad/name" , Collections . emptyMap ()));
185187 assertThrows (IllegalArgumentException .class , () -> OpenClawWebhookClient .buildHooksAgentBody (new HookRequest ()));
186188 assertEquals ("custom" , OpenClawWebhookClient .normalizeHookName (" /hooks/custom " ));
187189 assertTrue (OpenClawWebhookClient .parseOk ("{\" ok\" :true}" ));
@@ -192,9 +194,9 @@ void shouldCoverWebhookBodiesAuthenticationParsingAndErrors() {
192194 assertNull (OpenClawWebhookClient .parseRunId ("invalid" ));
193195
194196 status .set (500 );
195- assertThrows (OpenClawHttpException .class , () -> webhooks .postMappedHook ("custom" , Map . of ()));
197+ assertThrows (OpenClawHttpException .class , () -> webhooks .postMappedHook ("custom" , Collections . emptyMap ()));
196198 transportFailure .set (true );
197- assertThrows (OpenClawHttpException .class , () -> webhooks .postMappedHook ("custom" , Map . of ()));
199+ assertThrows (OpenClawHttpException .class , () -> webhooks .postMappedHook ("custom" , Collections . emptyMap ()));
198200 }
199201 }
200202
@@ -219,7 +221,7 @@ void shouldBuildHeadersSessionKeysAndMessageFactories() {
219221 assertEquals ("system" , ChatMessage .ofSystem ("s" ).getRole ());
220222 assertEquals ("user" , ChatMessage .ofUser ("u" ).getRole ());
221223 assertEquals ("assistant" , ChatMessage .ofAssistant ("a" ).getRole ());
222- assertEquals (toolCall , ChatMessage .ofAssistant (null , List . of (toolCall )).getToolCalls ().get (0 ));
224+ assertEquals (toolCall , ChatMessage .ofAssistant (null , Arrays . asList (toolCall )).getToolCalls ().get (0 ));
223225 assertEquals ("tool" , ChatMessage .ofTool ("id" , "result" ).getRole ());
224226 }
225227
0 commit comments