Skip to content

Commit 3938c6e

Browse files
committed
test: use canonical streaming API names
1 parent f7ec8c4 commit 3938c6e

5 files changed

Lines changed: 19 additions & 17 deletions

File tree

src/test/java/io/github/easy4j/opencode/OpenCodeClientConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ void shouldInitializeWithDefaultSubConfigs() {
2121
@Test
2222
void shouldShareSubConfigReferences() {
2323
OpenCodeClientConfig config = new OpenCodeClientConfig();
24-
config.getHttp().setServerUrl("http://custom:8080");
25-
assertEquals("http://custom:8080", config.getHttp().getServerUrl());
24+
config.getHttp().setBaseUrl("http://custom:8080");
25+
assertEquals("http://custom:8080", config.getHttp().getBaseUrl());
2626

2727
config.getCli().setExecutable("my-opencode");
2828
assertEquals("my-opencode", config.getCli().getExecutable());

src/test/java/io/github/easy4j/opencode/OpenCodeClientTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void tearDown() throws IOException {
4040
@Test
4141
void shouldCreateClientWithHttpConfigOnly() {
4242
OpenCodeHttpClientConfig httpConfig = new OpenCodeHttpClientConfig();
43-
httpConfig.setServerUrl(server.url("/").toString().replaceAll("/$", ""));
43+
httpConfig.setBaseUrl(server.url("/").toString().replaceAll("/$", ""));
4444
OpenCodeClientConfig config = new OpenCodeClientConfig();
4545
OpenCodeHttpClient httpClient = new OpenCodeHttpClient(httpConfig, new ObjectMapper(), null);
4646
OpenCodeClient client = new OpenCodeClient(config, httpClient, null, null);
@@ -66,7 +66,7 @@ void shouldCreateClientWithCliConfigOnly() {
6666
@Test
6767
void shouldCreateClientWithBothSubsystems() {
6868
OpenCodeHttpClientConfig httpConfig = new OpenCodeHttpClientConfig();
69-
httpConfig.setServerUrl(server.url("/").toString().replaceAll("/$", ""));
69+
httpConfig.setBaseUrl(server.url("/").toString().replaceAll("/$", ""));
7070
OpenCodeClientConfig config = new OpenCodeClientConfig();
7171
OpenCodeHttpClient httpClient = new OpenCodeHttpClient(httpConfig, new ObjectMapper(), null);
7272
OpenCodeCliExecutor executor = new OpenCodeCliExecutor(config.getCli());
@@ -122,7 +122,7 @@ void shouldDisableCliWhenConfigDisabled() {
122122
@Test
123123
void shouldDelegateHealthToHttpClient() {
124124
OpenCodeHttpClientConfig httpConfig = new OpenCodeHttpClientConfig();
125-
httpConfig.setServerUrl(server.url("/").toString().replaceAll("/$", ""));
125+
httpConfig.setBaseUrl(server.url("/").toString().replaceAll("/$", ""));
126126
server.enqueue(new MockResponse()
127127
.setHeader("Content-Type", "application/json")
128128
.setBody("{\"healthy\":true,\"version\":\"1.0.0\"}"));
@@ -140,7 +140,7 @@ void shouldDelegateHealthToHttpClient() {
140140
@Test
141141
void shouldDelegateListSessions() {
142142
OpenCodeHttpClientConfig httpConfig = new OpenCodeHttpClientConfig();
143-
httpConfig.setServerUrl(server.url("/").toString().replaceAll("/$", ""));
143+
httpConfig.setBaseUrl(server.url("/").toString().replaceAll("/$", ""));
144144
server.enqueue(new MockResponse()
145145
.setHeader("Content-Type", "application/json")
146146
.setBody("[{\"id\":\"sess-1\",\"title\":\"test\"}]"));
@@ -158,7 +158,7 @@ void shouldDelegateListSessions() {
158158
@Test
159159
void shouldDelegateListAgents() {
160160
OpenCodeHttpClientConfig httpConfig = new OpenCodeHttpClientConfig();
161-
httpConfig.setServerUrl(server.url("/").toString().replaceAll("/$", ""));
161+
httpConfig.setBaseUrl(server.url("/").toString().replaceAll("/$", ""));
162162
server.enqueue(new MockResponse()
163163
.setHeader("Content-Type", "application/json")
164164
.setBody("[{\"name\":\"coder\"}]"));
@@ -176,7 +176,7 @@ void shouldDelegateListAgents() {
176176
@Test
177177
void shouldDelegateGetConfig() {
178178
OpenCodeHttpClientConfig httpConfig = new OpenCodeHttpClientConfig();
179-
httpConfig.setServerUrl(server.url("/").toString().replaceAll("/$", ""));
179+
httpConfig.setBaseUrl(server.url("/").toString().replaceAll("/$", ""));
180180
server.enqueue(new MockResponse()
181181
.setHeader("Content-Type", "application/json")
182182
.setBody("{\"theme\":\"dark\"}"));
@@ -194,7 +194,7 @@ void shouldDelegateGetConfig() {
194194
@Test
195195
void shouldDelegateAbort() {
196196
OpenCodeHttpClientConfig httpConfig = new OpenCodeHttpClientConfig();
197-
httpConfig.setServerUrl(server.url("/").toString().replaceAll("/$", ""));
197+
httpConfig.setBaseUrl(server.url("/").toString().replaceAll("/$", ""));
198198
server.enqueue(new MockResponse()
199199
.setHeader("Content-Type", "application/json")
200200
.setBody("{}"));

src/test/java/io/github/easy4j/opencode/OpenCodeHttpClientConfigTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void shouldHaveCorrectDefaults() {
1616
assertTrue(config.isEnabled());
1717
assertFalse(config.isStartupCheckEnabled());
1818
assertFalse(config.isFailFastOnUnavailable());
19-
assertEquals("http://localhost:4096", config.getServerUrl());
19+
assertEquals("http://localhost:4096", config.getBaseUrl());
2020
assertEquals("opencode", config.getUsername());
2121
assertNull(config.getPassword());
2222
assertEquals(15_000, config.getConnectTimeoutMillis());
@@ -55,7 +55,7 @@ void shouldResolveEmptyPasswordWhenNull() {
5555
@Test
5656
void shouldKeepLegacySseEventQueueAlias() {
5757
OpenCodeHttpClientConfig config = new OpenCodeHttpClientConfig();
58-
config.setSseEventQueueCapacity(17);
58+
config.setStreamEventQueueCapacity(17);
5959
assertEquals(17, config.getStreamEventQueueCapacity());
6060
}
6161
}

src/test/java/io/github/easy4j/opencode/api/OpenCodeSseClientTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void setUp() throws IOException {
3333
server = new MockWebServer();
3434
server.start();
3535
OpenCodeHttpClientConfig config = new OpenCodeHttpClientConfig();
36-
config.setServerUrl(server.url("/").toString().replaceAll("/$", ""));
36+
config.setBaseUrl(server.url("/").toString().replaceAll("/$", ""));
3737
sseClient = new OpenCodeSseClient(config, null, null);
3838
}
3939

src/test/java/io/github/easy4j/opencode/api/model/ModelClassesTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package io.github.easy4j.opencode.api.model;
22

3+
import io.github.easy4j.opencode.api.sse.StreamingChatResponse;
4+
35
import org.junit.jupiter.api.Test;
46

57
import java.util.Collections;
@@ -162,12 +164,12 @@ void shouldSetAndGetUsage() {
162164
}
163165

164166
// ============================================================
165-
// ChatStreamingResponse
167+
// StreamingChatResponse
166168
// ============================================================
167169

168170
@Test
169171
void shouldAccumulateDeltasAndFinish() {
170-
ChatStreamingResponse stream = new ChatStreamingResponse();
172+
StreamingChatResponse stream = new StreamingChatResponse();
171173
StringBuilder received = new StringBuilder();
172174
stream.onDelta(received::append);
173175

@@ -185,7 +187,7 @@ void shouldAccumulateDeltasAndFinish() {
185187

186188
@Test
187189
void shouldFailStreamOnException() {
188-
ChatStreamingResponse stream = new ChatStreamingResponse();
190+
StreamingChatResponse stream = new StreamingChatResponse();
189191
RuntimeException error = new RuntimeException("boom");
190192
stream.fail(error);
191193

@@ -196,15 +198,15 @@ void shouldFailStreamOnException() {
196198

197199
@Test
198200
void shouldHandleNullAndEmptyDelta() {
199-
ChatStreamingResponse stream = new ChatStreamingResponse();
201+
StreamingChatResponse stream = new StreamingChatResponse();
200202
stream.acceptDelta(null);
201203
stream.acceptDelta("");
202204
assertEquals("", stream.getAccumulatedContent());
203205
}
204206

205207
@Test
206208
void shouldWorkWithoutDeltaConsumer() {
207-
ChatStreamingResponse stream = new ChatStreamingResponse();
209+
StreamingChatResponse stream = new StreamingChatResponse();
208210
stream.acceptDelta("data");
209211
assertEquals("data", stream.getAccumulatedContent());
210212
}

0 commit comments

Comments
 (0)