|
17 | 17 |
|
18 | 18 | import com.github.copilot.sdk.events.AbstractSessionEvent; |
19 | 19 | import com.github.copilot.sdk.json.CopilotClientOptions; |
| 20 | +import com.github.copilot.sdk.json.InfiniteSessionConfig; |
20 | 21 | import com.github.copilot.sdk.json.MessageOptions; |
21 | 22 | import com.github.copilot.sdk.json.ModelInfo; |
22 | 23 | import com.github.copilot.sdk.json.ResumeSessionConfig; |
23 | 24 | import com.github.copilot.sdk.json.SessionConfig; |
| 25 | +import com.github.copilot.sdk.json.SystemMessageConfig; |
| 26 | +import com.github.copilot.sdk.json.TelemetryConfig; |
24 | 27 |
|
25 | 28 | class ConfigCloneTest { |
26 | 29 |
|
@@ -193,4 +196,97 @@ void clonePreservesNullFields() { |
193 | 196 | MessageOptions msgClone = msg.clone(); |
194 | 197 | assertNull(msgClone.getMode()); |
195 | 198 | } |
| 199 | + |
| 200 | + @Test |
| 201 | + @SuppressWarnings("deprecation") |
| 202 | + void copilotClientOptionsDeprecatedAutoRestart() { |
| 203 | + CopilotClientOptions opts = new CopilotClientOptions(); |
| 204 | + assertFalse(opts.isAutoRestart()); |
| 205 | + opts.setAutoRestart(true); |
| 206 | + assertTrue(opts.isAutoRestart()); |
| 207 | + } |
| 208 | + |
| 209 | + @Test |
| 210 | + void copilotClientOptionsSetCliArgsNullClearsExisting() { |
| 211 | + CopilotClientOptions opts = new CopilotClientOptions(); |
| 212 | + opts.setCliArgs(new String[]{"--flag1"}); |
| 213 | + assertNotNull(opts.getCliArgs()); |
| 214 | + |
| 215 | + // Setting null should clear the existing array |
| 216 | + opts.setCliArgs(null); |
| 217 | + assertNotNull(opts.getCliArgs()); |
| 218 | + assertEquals(0, opts.getCliArgs().length); |
| 219 | + } |
| 220 | + |
| 221 | + @Test |
| 222 | + void copilotClientOptionsSetEnvironmentNullClearsExisting() { |
| 223 | + CopilotClientOptions opts = new CopilotClientOptions(); |
| 224 | + opts.setEnvironment(Map.of("KEY", "VALUE")); |
| 225 | + assertNotNull(opts.getEnvironment()); |
| 226 | + |
| 227 | + // Setting null should clear the existing map (clears in-place → returns empty |
| 228 | + // map) |
| 229 | + opts.setEnvironment(null); |
| 230 | + var env = opts.getEnvironment(); |
| 231 | + assertTrue(env == null || env.isEmpty()); |
| 232 | + } |
| 233 | + |
| 234 | + @Test |
| 235 | + @SuppressWarnings("deprecation") |
| 236 | + void copilotClientOptionsDeprecatedGithubToken() { |
| 237 | + CopilotClientOptions opts = new CopilotClientOptions(); |
| 238 | + opts.setGithubToken("ghp_deprecated_token"); |
| 239 | + assertEquals("ghp_deprecated_token", opts.getGithubToken()); |
| 240 | + assertEquals("ghp_deprecated_token", opts.getGitHubToken()); |
| 241 | + } |
| 242 | + |
| 243 | + @Test |
| 244 | + void copilotClientOptionsSetTelemetry() { |
| 245 | + var telemetry = new TelemetryConfig().setOtlpEndpoint("http://localhost:4318"); |
| 246 | + var opts = new CopilotClientOptions(); |
| 247 | + opts.setTelemetry(telemetry); |
| 248 | + assertSame(telemetry, opts.getTelemetry()); |
| 249 | + } |
| 250 | + |
| 251 | + @Test |
| 252 | + void copilotClientOptionsSetUseLoggedInUserNull() { |
| 253 | + var opts = new CopilotClientOptions(); |
| 254 | + opts.setUseLoggedInUser(null); |
| 255 | + // null → Boolean.FALSE |
| 256 | + assertEquals(Boolean.FALSE, opts.getUseLoggedInUser()); |
| 257 | + } |
| 258 | + |
| 259 | + @Test |
| 260 | + void resumeSessionConfigAllSetters() { |
| 261 | + var config = new ResumeSessionConfig(); |
| 262 | + |
| 263 | + var sysMsg = new SystemMessageConfig(); |
| 264 | + config.setSystemMessage(sysMsg); |
| 265 | + assertSame(sysMsg, config.getSystemMessage()); |
| 266 | + |
| 267 | + config.setAvailableTools(List.of("bash", "read_file")); |
| 268 | + assertEquals(List.of("bash", "read_file"), config.getAvailableTools()); |
| 269 | + |
| 270 | + config.setExcludedTools(List.of("write_file")); |
| 271 | + assertEquals(List.of("write_file"), config.getExcludedTools()); |
| 272 | + |
| 273 | + config.setReasoningEffort("high"); |
| 274 | + assertEquals("high", config.getReasoningEffort()); |
| 275 | + |
| 276 | + config.setWorkingDirectory("/project/src"); |
| 277 | + assertEquals("/project/src", config.getWorkingDirectory()); |
| 278 | + |
| 279 | + config.setConfigDir("/home/user/.config/copilot"); |
| 280 | + assertEquals("/home/user/.config/copilot", config.getConfigDir()); |
| 281 | + |
| 282 | + config.setSkillDirectories(List.of("/skills/custom")); |
| 283 | + assertEquals(List.of("/skills/custom"), config.getSkillDirectories()); |
| 284 | + |
| 285 | + config.setDisabledSkills(List.of("some-skill")); |
| 286 | + assertEquals(List.of("some-skill"), config.getDisabledSkills()); |
| 287 | + |
| 288 | + var infiniteConfig = new InfiniteSessionConfig().setEnabled(true); |
| 289 | + config.setInfiniteSessions(infiniteConfig); |
| 290 | + assertSame(infiniteConfig, config.getInfiniteSessions()); |
| 291 | + } |
196 | 292 | } |
0 commit comments