Skip to content

Commit 85fe001

Browse files
committed
[AIT-208] chore: update spec references in code and tests
1 parent 74bf748 commit 85fe001

7 files changed

Lines changed: 30 additions & 31 deletions

File tree

liveobjects/src/main/kotlin/io/ably/lib/objects/DefaultRealtimeObjects.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ internal class DefaultRealtimeObjects(internal val channelName: String, internal
112112
throw invalidInputError("Map keys should not be empty")
113113
}
114114

115-
// RTO11f4 - Create initial value operation
115+
// RTO11f14 - Create initial value operation
116116
val initialMapValue = DefaultLiveMap.initialValue(entries)
117117

118-
// RTO11f5 - Create initial value JSON string
118+
// RTO11f15 - Create initial value JSON string
119119
val initialValueJSONString = gson.toJson(initialMapValue)
120120

121121
// RTO11f8 - Create object ID from initial value
@@ -150,9 +150,9 @@ internal class DefaultRealtimeObjects(internal val channelName: String, internal
150150
throw invalidInputError("Counter value should be a valid number")
151151
}
152152

153-
// RTO12f2
153+
// RTO12f12
154154
val initialCounterValue = DefaultLiveCounter.initialValue(initialValue)
155-
// RTO12f3 - Create initial value operation
155+
// RTO12f13 - Create initial value operation
156156
val initialValueJSONString = gson.toJson(initialCounterValue)
157157

158158
// RTO12f6- Create object ID from initial value

liveobjects/src/main/kotlin/io/ably/lib/objects/type/livecounter/DefaultLiveCounter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ internal class DefaultLiveCounter private constructor(
127127

128128
/**
129129
* Creates initial value payload for counter creation.
130-
* Spec: RTO12f2
130+
* Spec: RTO12f12
131131
*/
132132
internal fun initialValue(count: Number): CounterCreate {
133133
return CounterCreate(count = count.toDouble())

liveobjects/src/main/kotlin/io/ably/lib/objects/type/livecounter/LiveCounterManager.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ internal class LiveCounterManager(private val liveCounter: DefaultLiveCounter):
9393
private fun applyCounterInc(counterInc: CounterInc): LiveCounterUpdate {
9494
val amount = counterInc.number
9595
val previousValue = liveCounter.data.get()
96-
liveCounter.data.set(previousValue + amount) // RTLC9b
96+
liveCounter.data.set(previousValue + amount) // RTLC9f
9797
return LiveCounterUpdate(amount)
9898
}
9999

@@ -102,7 +102,7 @@ internal class LiveCounterManager(private val liveCounter: DefaultLiveCounter):
102102
}
103103

104104
/**
105-
* @spec RTLC10 - Merges initial data from create operation
105+
* @spec RTLC16 - Merges initial data from create operation
106106
*/
107107
private fun mergeInitialDataFromCreateOperation(operation: ObjectOperation): LiveCounterUpdate {
108108
// if a counter object is missing for the COUNTER_CREATE op, the initial value is implicitly 0 in this case.
@@ -113,8 +113,8 @@ internal class LiveCounterManager(private val liveCounter: DefaultLiveCounter):
113113
?: operation.counterCreate?.count
114114
?: 0.0
115115
val previousValue = liveCounter.data.get()
116-
liveCounter.data.set(previousValue + count) // RTLC10a
117-
liveCounter.createOperationIsMerged = true // RTLC10b
116+
liveCounter.data.set(previousValue + count) // RTLC16
117+
liveCounter.createOperationIsMerged = true // RTLC16
118118
return LiveCounterUpdate(count)
119119
}
120120

liveobjects/src/main/kotlin/io/ably/lib/objects/type/livemap/DefaultLiveMap.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ internal class DefaultLiveMap private constructor(
201201

202202
/**
203203
* Creates a MapCreate payload from map entries.
204-
* Spec: RTO11f4
204+
* Spec: RTO11f14
205205
*/
206206
internal fun initialValue(entries: MutableMap<String, LiveMapValue>): MapCreate {
207207
return MapCreate(

liveobjects/src/main/kotlin/io/ably/lib/objects/type/livemap/LiveMapManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ internal class LiveMapManager(private val liveMap: DefaultLiveMap): LiveMapChang
231231
}
232232

233233
/**
234-
* @spec RTLM17 - Merges initial data from create operation
234+
* @spec RTLM23 - Merges initial data from create operation
235235
*/
236236
private fun getEffectiveMapCreate(operation: ObjectOperation): MapCreate? =
237237
operation.mapCreateWithObjectId?.derivedFrom ?: operation.mapCreate
@@ -244,7 +244,7 @@ internal class LiveMapManager(private val liveMap: DefaultLiveMap): LiveMapChang
244244

245245
val aggregatedUpdate = mutableListOf<LiveMapUpdate>()
246246

247-
// RTLM17a
247+
// RTLM23a
248248
// in order to apply MAP_CREATE op for an existing map, we should merge their underlying entries keys.
249249
// we can do this by iterating over entries from MAP_CREATE op and apply changes on per-key basis as if we had MAP_SET, MAP_REMOVE operations.
250250
effectiveMapCreate?.entries?.forEach { (key, entry) ->
@@ -266,7 +266,7 @@ internal class LiveMapManager(private val liveMap: DefaultLiveMap): LiveMapChang
266266
aggregatedUpdate.add(update)
267267
}
268268

269-
liveMap.createOperationIsMerged = true // RTLM17b
269+
liveMap.createOperationIsMerged = true // RTLM23b
270270

271271
return LiveMapUpdate(
272272
aggregatedUpdate.map { it.update }.fold(emptyMap()) { acc, map -> acc + map }

liveobjects/src/test/kotlin/io/ably/lib/objects/unit/type/livecounter/LiveCounterManagerTest.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ class DefaultLiveCounterManagerTest {
192192
assertTrue(liveCounter.createOperationIsMerged) // Should be marked as merged
193193

194194
assertEquals(30.0, liveCounter.data.get()) // Should be set to counter count
195-
assertTrue(liveCounter.createOperationIsMerged) // RTLC10b - Should be marked as merged
195+
assertTrue(liveCounter.createOperationIsMerged) // RTLC16b - Should be marked as merged
196196
}
197197

198198
@Test
199-
fun `(RTLC8, RTLC10, RTLC10a) LiveCounterManager should handle null count in create operation`() {
199+
fun `(RTLC8, RTLC16) LiveCounterManager should handle null count in create operation`() {
200200
val liveCounter = getDefaultLiveCounterWithMockedDeps()
201201
val liveCounterManager = liveCounter.LiveCounterManager
202202

@@ -209,12 +209,11 @@ class DefaultLiveCounterManagerTest {
209209
counterCreate = null // No count specified
210210
)
211211

212-
// RTLC10a - Should default to 0
213-
// RTLC10b - Mark as merged
212+
// RTLC16a - Should default to 0
214213
liveCounterManager.applyOperation(operation, null)
215214

216215
assertEquals(10.0, liveCounter.data.get()) // No change (null defaults to 0)
217-
assertTrue(liveCounter.createOperationIsMerged) // RTLC10b
216+
assertTrue(liveCounter.createOperationIsMerged) // RTLC16b
218217
}
219218

220219
@Test
@@ -234,7 +233,7 @@ class DefaultLiveCounterManagerTest {
234233
// RTLC7d2 - Apply counter increment operation
235234
liveCounterManager.applyOperation(operation, null)
236235

237-
assertEquals(15.0, liveCounter.data.get()) // RTLC9b - 10 + 5
236+
assertEquals(15.0, liveCounter.data.get()) // RTLC9f - 10 + 5
238237
}
239238

240239
@Test
@@ -261,7 +260,7 @@ class DefaultLiveCounterManagerTest {
261260

262261

263262
@Test
264-
fun `(RTLC9, RTLC9b) LiveCounterManager should apply counter increment operation correctly`() {
263+
fun `(RTLC9, RTLC9f) LiveCounterManager should apply counter increment operation correctly`() {
265264
val liveCounter = getDefaultLiveCounterWithMockedDeps()
266265
val liveCounterManager = liveCounter.LiveCounterManager
267266

@@ -270,7 +269,7 @@ class DefaultLiveCounterManagerTest {
270269

271270
val counterInc = CounterInc(number = 7.0)
272271

273-
// RTLC9b - Apply counter increment
272+
// RTLC9f - Apply counter increment
274273
liveCounterManager.applyOperation(ObjectOperation(
275274
action = ObjectOperationAction.CounterInc,
276275
objectId = "testCounterId",

liveobjects/src/test/kotlin/io/ably/lib/objects/unit/type/livemap/LiveMapManagerTest.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class LiveMapManagerTest {
325325
}
326326

327327
@Test
328-
fun `(RTLM16, RTLM16d, RTLM17, OME2d) LiveMapManager should merge initial data from create operation with tombstoned entries`() {
328+
fun `(RTLM16, RTLM16d, RTLM23, OME2d) LiveMapManager should merge initial data from create operation with tombstoned entries`() {
329329
val liveMap = getDefaultLiveMapWithMockedDeps()
330330
val liveMapManager = liveMap.LiveMapManager
331331

@@ -366,11 +366,11 @@ class LiveMapManagerTest {
366366
liveMapManager.applyOperation(operation, "serial1", null)
367367

368368
assertEquals(3, liveMap.data.size) // Should have all entries
369-
assertTrue(liveMap.data["key1"]?.isTombstoned == true) // RTLM17a2 - Should be tombstoned
369+
assertTrue(liveMap.data["key1"]?.isTombstoned == true) // RTLM23a2 - Should be tombstoned
370370
assertEquals(expectedTimestamp, liveMap.data["key1"]?.tombstonedAt) // Should use provided serialTimestamp
371-
assertEquals("newValue", liveMap.data["key2"]?.data?.string) // RTLM17a1 - Should be added
372-
assertTrue(liveMap.data["key3"]?.isTombstoned == true) // RTLM17a2 - Should be tombstoned
373-
assertTrue(liveMap.createOperationIsMerged) // RTLM17b - Should be marked as merged
371+
assertEquals("newValue", liveMap.data["key2"]?.data?.string) // RTLM23a1 - Should be added
372+
assertTrue(liveMap.data["key3"]?.isTombstoned == true) // RTLM23a2 - Should be tombstoned
373+
assertTrue(liveMap.createOperationIsMerged) // RTLM23b - Should be marked as merged
374374
}
375375

376376
@Test
@@ -573,7 +573,7 @@ class LiveMapManagerTest {
573573

574574

575575
@Test
576-
fun `(RTLM16, RTLM16d, RTLM17) LiveMapManager should merge initial data from create operation`() {
576+
fun `(RTLM16, RTLM16d, RTLM23) LiveMapManager should merge initial data from create operation`() {
577577
val liveMap = getDefaultLiveMapWithMockedDeps()
578578
val liveMapManager = liveMap.LiveMapManager
579579

@@ -611,10 +611,10 @@ class LiveMapManagerTest {
611611
liveMapManager.applyOperation(operation, "serial1", null)
612612

613613
assertEquals(3, liveMap.data.size) // Should have all entries
614-
assertEquals("createValue", liveMap.data["key1"]?.data?.string) // RTLM17a1 - Should be updated
615-
assertEquals("newValue", liveMap.data["key2"]?.data?.string) // RTLM17a1 - Should be added
616-
assertTrue(liveMap.data["key3"]?.isTombstoned == true) // RTLM17a2 - Should be tombstoned
617-
assertTrue(liveMap.createOperationIsMerged) // RTLM17b - Should be marked as merged
614+
assertEquals("createValue", liveMap.data["key1"]?.data?.string) // RTLM23a1 - Should be updated
615+
assertEquals("newValue", liveMap.data["key2"]?.data?.string) // RTLM23a1 - Should be added
616+
assertTrue(liveMap.data["key3"]?.isTombstoned == true) // RTLM23a2 - Should be tombstoned
617+
assertTrue(liveMap.createOperationIsMerged) // RTLM23b - Should be marked as merged
618618
}
619619

620620
@Test

0 commit comments

Comments
 (0)