@@ -3,6 +3,7 @@ package io.ably.lib.objects.unit.type.livemap
33import io.ably.lib.objects.*
44import io.ably.lib.objects.type.livemap.LiveMapEntry
55import io.ably.lib.objects.type.livemap.LiveMapManager
6+ import io.ably.lib.objects.type.map.LiveMapUpdate
67import io.ably.lib.objects.unit.LiveMapManager
78import io.ably.lib.objects.unit.getDefaultLiveMapWithMockedDeps
89import io.ably.lib.types.AblyException
@@ -55,10 +56,10 @@ class LiveMapManagerTest {
5556
5657 // Assert on update field - should show changes from old to new state
5758 val expectedUpdate = mapOf (
58- " key1" to " updated " , // key1 was updated from "oldValue" to "newValue1"
59- " key2" to " updated " // key2 was added
59+ " key1" to LiveMapUpdate . Change . UPDATED , // key1 was updated from "oldValue" to "newValue1"
60+ " key2" to LiveMapUpdate . Change . UPDATED // key2 was added
6061 )
61- assertEquals(expectedUpdate, update)
62+ assertEquals(expectedUpdate, update.update )
6263 }
6364
6465 @Test
@@ -89,8 +90,8 @@ class LiveMapManagerTest {
8990 assertEquals(0 , liveMap.data.size) // RTLM6c - should be empty map
9091
9192 // Assert on update field - should show that key1 was removed
92- val expectedUpdate = mapOf (" key1" to " removed " )
93- assertEquals(expectedUpdate, update)
93+ val expectedUpdate = mapOf (" key1" to LiveMapUpdate . Change . REMOVED )
94+ assertEquals(expectedUpdate, update.update )
9495 }
9596
9697 @Test
@@ -118,8 +119,8 @@ class LiveMapManagerTest {
118119 assertEquals(0 , liveMap.data.size) // RTLM6c - should be empty map when map is null
119120
120121 // Assert on update field - should show that key1 was removed
121- val expectedUpdate = mapOf (" key1" to " removed " )
122- assertEquals(expectedUpdate, update)
122+ val expectedUpdate = mapOf (" key1" to LiveMapUpdate . Change . REMOVED )
123+ assertEquals(expectedUpdate, update.update )
123124 }
124125
125126 @Test
@@ -177,10 +178,10 @@ class LiveMapManagerTest {
177178
178179 // Assert on update field - should show changes from create operation
179180 val expectedUpdate = mapOf (
180- " key1" to " updated " , // key1 was updated from "existingValue" to "stateValue"
181- " key2" to " updated " // key2 was added from create operation
181+ " key1" to LiveMapUpdate . Change . UPDATED , // key1 was updated from "existingValue" to "stateValue"
182+ " key2" to LiveMapUpdate . Change . UPDATED // key2 was added from create operation
182183 )
183- assertEquals(expectedUpdate, update)
184+ assertEquals(expectedUpdate, update.update )
184185 }
185186
186187
@@ -637,7 +638,7 @@ class LiveMapManagerTest {
637638 val prevData1 = mapOf<String , LiveMapEntry >()
638639 val newData1 = mapOf<String , LiveMapEntry >()
639640 val result1 = livemapManager.calculateUpdateFromDataDiff(prevData1, newData1)
640- assertEquals(emptyMap<String , String >(), result1, " Should return empty map for no changes" )
641+ assertEquals(emptyMap<String , LiveMapUpdate . Change >(), result1.update , " Should return empty map for no changes" )
641642
642643 // Test case 2: Entry added
643644 val prevData2 = mapOf<String , LiveMapEntry >()
@@ -649,7 +650,7 @@ class LiveMapManagerTest {
649650 )
650651 )
651652 val result2 = livemapManager.calculateUpdateFromDataDiff(prevData2, newData2)
652- assertEquals(mapOf (" key1" to " updated " ), result2, " Should detect added entry" )
653+ assertEquals(mapOf (" key1" to LiveMapUpdate . Change . UPDATED ), result2.update , " Should detect added entry" )
653654
654655 // Test case 3: Entry removed
655656 val prevData3 = mapOf (
@@ -661,7 +662,7 @@ class LiveMapManagerTest {
661662 )
662663 val newData3 = mapOf<String , LiveMapEntry >()
663664 val result3 = livemapManager.calculateUpdateFromDataDiff(prevData3, newData3)
664- assertEquals(mapOf (" key1" to " removed " ), result3, " Should detect removed entry" )
665+ assertEquals(mapOf (" key1" to LiveMapUpdate . Change . REMOVED ), result3.update , " Should detect removed entry" )
665666
666667 // Test case 4: Entry updated
667668 val prevData4 = mapOf (
@@ -679,7 +680,7 @@ class LiveMapManagerTest {
679680 )
680681 )
681682 val result4 = livemapManager.calculateUpdateFromDataDiff(prevData4, newData4)
682- assertEquals(mapOf (" key1" to " updated " ), result4, " Should detect updated entry" )
683+ assertEquals(mapOf (" key1" to LiveMapUpdate . Change . UPDATED ), result4.update , " Should detect updated entry" )
683684
684685 // Test case 5: Entry tombstoned
685686 val prevData5 = mapOf (
@@ -697,7 +698,7 @@ class LiveMapManagerTest {
697698 )
698699 )
699700 val result5 = livemapManager.calculateUpdateFromDataDiff(prevData5, newData5)
700- assertEquals(mapOf (" key1" to " removed " ), result5, " Should detect tombstoned entry" )
701+ assertEquals(mapOf (" key1" to LiveMapUpdate . Change . REMOVED ), result5.update , " Should detect tombstoned entry" )
701702
702703 // Test case 6: Entry untombstoned
703704 val prevData6 = mapOf (
@@ -715,7 +716,7 @@ class LiveMapManagerTest {
715716 )
716717 )
717718 val result6 = livemapManager.calculateUpdateFromDataDiff(prevData6, newData6)
718- assertEquals(mapOf (" key1" to " updated " ), result6, " Should detect untombstoned entry" )
719+ assertEquals(mapOf (" key1" to LiveMapUpdate . Change . UPDATED ), result6.update , " Should detect untombstoned entry" )
719720
720721 // Test case 7: Both entries tombstoned (noop)
721722 val prevData7 = mapOf (
@@ -733,7 +734,7 @@ class LiveMapManagerTest {
733734 )
734735 )
735736 val result7 = livemapManager.calculateUpdateFromDataDiff(prevData7, newData7)
736- assertEquals(emptyMap<String , String >(), result7, " Should not detect change for both tombstoned entries" )
737+ assertEquals(emptyMap<String , LiveMapUpdate . Change >(), result7.update , " Should not detect change for both tombstoned entries" )
737738
738739 // Test case 8: New tombstoned entry (noop)
739740 val prevData8 = mapOf<String , LiveMapEntry >()
@@ -745,7 +746,7 @@ class LiveMapManagerTest {
745746 )
746747 )
747748 val result8 = livemapManager.calculateUpdateFromDataDiff(prevData8, newData8)
748- assertEquals(emptyMap<String , String >(), result8, " Should not detect change for new tombstoned entry" )
749+ assertEquals(emptyMap<String , LiveMapUpdate . Change >(), result8.update , " Should not detect change for new tombstoned entry" )
749750
750751 // Test case 9: Multiple changes
751752 val prevData9 = mapOf (
@@ -774,11 +775,11 @@ class LiveMapManagerTest {
774775 )
775776 val result9 = livemapManager.calculateUpdateFromDataDiff(prevData9, newData9)
776777 val expected9 = mapOf (
777- " key1" to " updated " ,
778- " key2" to " removed " ,
779- " key3" to " updated "
778+ " key1" to LiveMapUpdate . Change . UPDATED ,
779+ " key2" to LiveMapUpdate . Change . REMOVED ,
780+ " key3" to LiveMapUpdate . Change . UPDATED
780781 )
781- assertEquals(expected9, result9, " Should detect multiple changes correctly" )
782+ assertEquals(expected9, result9.update , " Should detect multiple changes correctly" )
782783
783784 // Test case 10: ObjectId references
784785 val prevData10 = mapOf (
@@ -796,7 +797,7 @@ class LiveMapManagerTest {
796797 )
797798 )
798799 val result10 = livemapManager.calculateUpdateFromDataDiff(prevData10, newData10)
799- assertEquals(mapOf (" key1" to " updated " ), result10, " Should detect objectId change" )
800+ assertEquals(mapOf (" key1" to LiveMapUpdate . Change . UPDATED ), result10.update , " Should detect objectId change" )
800801
801802 // Test case 11: Same data, no change
802803 val prevData11 = mapOf (
@@ -814,6 +815,6 @@ class LiveMapManagerTest {
814815 )
815816 )
816817 val result11 = livemapManager.calculateUpdateFromDataDiff(prevData11, newData11)
817- assertEquals(emptyMap<String , String >(), result11, " Should not detect change for same data" )
818+ assertEquals(emptyMap<String , LiveMapUpdate . Change >(), result11.update , " Should not detect change for same data" )
818819 }
819820}
0 commit comments