@@ -86,4 +86,44 @@ void jsonBindsBothPropertyNamesAndRoundTrips() throws Exception {
8686 assertEquals (config , mapper .readValue (mapper .writeValueAsString (config ), OpenCodeHttpClientConfig .class ));
8787 }
8888 }
89+
90+ @ Test
91+ void jsonOutputExposesEqualCanonicalAndLegacyValues () throws Exception {
92+ com .fasterxml .jackson .databind .ObjectMapper mapper = new com .fasterxml .jackson .databind .ObjectMapper ();
93+ OpenCodeHttpClientConfig config = new OpenCodeHttpClientConfig ();
94+ config .setBaseUrl ("http://output:4096" );
95+ config .setStreamEventQueueCapacity (41 );
96+ com .fasterxml .jackson .databind .JsonNode json = mapper .valueToTree (config );
97+ assertEquals ("http://output:4096" , json .get ("baseUrl" ).asText ());
98+ assertEquals (json .get ("baseUrl" ), json .get ("serverUrl" ));
99+ assertEquals (41 , json .get ("streamEventQueueCapacity" ).asInt ());
100+ assertEquals (json .get ("streamEventQueueCapacity" ), json .get ("sseEventQueueCapacity" ));
101+ }
102+
103+ @ Test
104+ void conflictingJsonNamesUseLastValueInDocumentOrder () throws Exception {
105+ com .fasterxml .jackson .databind .ObjectMapper mapper = new com .fasterxml .jackson .databind .ObjectMapper ();
106+ OpenCodeHttpClientConfig canonicalLast = mapper .readValue ("""
107+ {"serverUrl":"http://legacy:4096","baseUrl":"http://canonical:4096",
108+ "sseEventQueueCapacity":11,"streamEventQueueCapacity":22}
109+ """ , OpenCodeHttpClientConfig .class );
110+ assertEquals ("http://canonical:4096" , canonicalLast .getServerUrl ());
111+ assertEquals (22 , canonicalLast .getSseEventQueueCapacity ());
112+ OpenCodeHttpClientConfig legacyLast = mapper .readValue ("""
113+ {"baseUrl":"http://canonical:4096","serverUrl":"http://legacy:4096",
114+ "streamEventQueueCapacity":22,"sseEventQueueCapacity":11}
115+ """ , OpenCodeHttpClientConfig .class );
116+ assertEquals ("http://legacy:4096" , legacyLast .getBaseUrl ());
117+ assertEquals (11 , legacyLast .getStreamEventQueueCapacity ());
118+ }
119+
120+ @ Test
121+ void jsonAliasesAlsoBindNestedHttpConfiguration () throws Exception {
122+ com .fasterxml .jackson .databind .ObjectMapper mapper = new com .fasterxml .jackson .databind .ObjectMapper ();
123+ OpenCodeClientConfig config = mapper .readValue ("""
124+ {"http":{"serverUrl":"http://nested:4096","sseEventQueueCapacity":19}}
125+ """ , OpenCodeClientConfig .class );
126+ assertEquals ("http://nested:4096" , config .getHttp ().getBaseUrl ());
127+ assertEquals (19 , config .getHttp ().getStreamEventQueueCapacity ());
128+ }
89129}
0 commit comments