Skip to content

Commit 9172dff

Browse files
Claude Opus 4.5claude
andcommitted
Migrate test files from deprecated toObjects() to toJava().asClass() API
- Updated 8 calls in CompactMapTest and ConverterEverythingTest - Uses new fluent builder pattern from json-io Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2b4ac56 commit 9172dff

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* **BUG FIX**: `DeepEquals` - URL comparison now uses string representation instead of `URL.equals()`
55
* Java's `URL.equals()` performs DNS resolution which causes flaky CI failures
66
* Now compares URLs using `toExternalForm()` for reliable, deterministic comparison
7+
* **MAINTENANCE**: Migrated test files from deprecated `JsonIo.toObjects()` to `JsonIo.toJava().asClass()` API
8+
* Updated 8 calls in `CompactMapTest` and `ConverterEverythingTest`
79

810
#### 4.89.0 - 2026-01-31
911
* **PERFORMANCE**: `FastReader.getLastSnippet()` now returns bounded 200-char context

src/test/java/com/cedarsoftware/util/CompactMapTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.logging.Logger;
2525

2626
import com.cedarsoftware.io.JsonIo;
27+
import com.cedarsoftware.io.TypeHolder;
2728
import org.junit.jupiter.api.Test;
2829
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
2930

@@ -3562,7 +3563,7 @@ public void testStringKeysWithResolvedValues() {
35623563

35633564
// Serialize and deserialize
35643565
String json = JsonIo.toJson(map, null);
3565-
CompactMap<String, Object> restoredMap = JsonIo.toObjects(json, null, CompactMap.class);
3566+
CompactMap<String, Object> restoredMap = JsonIo.toJava(json, null).asClass(CompactMap.class);
35663567

35673568
// Verify the map was properly restored
35683569
assertEquals(3, restoredMap.size());
@@ -3606,7 +3607,7 @@ public void testNonStringKeysWithSimpleValues() {
36063607

36073608
// Serialize and deserialize
36083609
String json = JsonIo.toJson(map, null);
3609-
CompactMap<Object, String> restoredMap = JsonIo.toObjects(json, null, CompactMap.class);
3610+
CompactMap<Object, String> restoredMap = JsonIo.toJava(json, null).asClass(CompactMap.class);
36103611

36113612
// Verify the map was properly restored
36123613
assertEquals(3, restoredMap.size());
@@ -3663,7 +3664,7 @@ public void testNonStringKeysAndValuesWithResolution() {
36633664
// Serialize and deserialize
36643665
String json = JsonIo.toJson(map, null);
36653666
LOG.info("JSON: " + json);
3666-
CompactMap<Object, Object> restoredMap = JsonIo.toObjects(json, null, CompactMap.class);
3667+
CompactMap<Object, Object> restoredMap = JsonIo.toJava(json, null).asClass(CompactMap.class);
36673668

36683669
// Verify map size
36693670
assertEquals(4, restoredMap.size(), "Map should have 4 entries");
@@ -3735,7 +3736,7 @@ public void testCircularReferencesWithNonStringKeys() {
37353736
// Serialize and deserialize
37363737
String json = JsonIo.toJson(map, null);
37373738
LOG.info("Circular reference JSON: " + json);
3738-
CompactMap<Object, Object> restoredMap = JsonIo.toObjects(json, null, CompactMap.class);
3739+
CompactMap<Object, Object> restoredMap = JsonIo.toJava(json, null).asClass(CompactMap.class);
37393740

37403741
// Get reference objects
37413742
Person personFromMarker = (Person) restoredMap.get("personKey");
@@ -3815,7 +3816,7 @@ public void testReferenceHandling() {
38153816

38163817
// Serialize and deserialize
38173818
String json = JsonIo.toJson(map, null);
3818-
CompactMap<Object, Object> restoredMap = JsonIo.toObjects(json, null, CompactMap.class);
3819+
CompactMap<Object, Object> restoredMap = JsonIo.toJava(json, null).asClass(CompactMap.class);
38193820

38203821
// Get reference objects
38213822
Person personFromMarker = (Person) restoredMap.get("personKey");

src/test/java/com/cedarsoftware/util/convert/ConverterEverythingTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4888,7 +4888,7 @@ void testConvertJsonIo(String shortNameSource, String shortNameTarget, Object so
48884888
WriteOptions writeOptions = new WriteOptionsBuilder().build();
48894889
ReadOptions readOptions = new ReadOptionsBuilder().setZoneId(TOKYO_Z).build();
48904890
String json = JsonIo.toJson(source, writeOptions);
4891-
Object restored = JsonIo.toObjects(json, readOptions, targetClass);
4891+
Object restored = JsonIo.toJava(json, readOptions).asClass(targetClass);
48924892

48934893
// Compare dates by LocalDate
48944894
LocalDate restoredDate = (restored instanceof java.sql.Date) ?
@@ -4924,7 +4924,7 @@ void testConvertJsonIo(String shortNameSource, String shortNameTarget, Object so
49244924
if (target instanceof Throwable) {
49254925
Throwable t = (Throwable) target;
49264926
try {
4927-
Object x = JsonIo.toObjects(json, readOptions, targetClass);
4927+
Object x = JsonIo.toJava(json, readOptions).asClass(targetClass);
49284928
// LOG.info("x = " + x);
49294929
throw new ConversionTestException("This test: " + shortNameSource + " ==> " + shortNameTarget + " should have thrown: " + target.getClass().getName());
49304930
} catch (Throwable e) {
@@ -4940,7 +4940,7 @@ void testConvertJsonIo(String shortNameSource, String shortNameTarget, Object so
49404940
} else {
49414941
Object restored = null;
49424942
try {
4943-
restored = JsonIo.toObjects(json, readOptions, targetClass);
4943+
restored = JsonIo.toJava(json, readOptions).asClass(targetClass);
49444944
} catch (Exception e) {
49454945
e.printStackTrace();
49464946
throw new RuntimeException(e);

0 commit comments

Comments
 (0)