@@ -171,7 +171,7 @@ class SentryJCacheWrapperTest {
171171 // -- putIfAbsent --
172172
173173 @Test
174- fun `putIfAbsent delegates without creating span` () {
174+ fun `putIfAbsent creates cache put span` () {
175175 val tx = createTransaction()
176176 val wrapper = SentryJCacheWrapper (delegate, scopes)
177177 whenever(delegate.putIfAbsent(" myKey" , " myValue" )).thenReturn(true )
@@ -180,13 +180,18 @@ class SentryJCacheWrapperTest {
180180
181181 assertTrue(result)
182182 verify(delegate).putIfAbsent(" myKey" , " myValue" )
183- assertEquals(0 , tx.spans.size)
183+ assertEquals(1 , tx.spans.size)
184+ val span = tx.spans.first()
185+ assertEquals(" cache.put" , span.operation)
186+ assertEquals(SpanStatus .OK , span.status)
187+ assertEquals(listOf (" myKey" ), span.getData(SpanDataConvention .CACHE_KEY_KEY ))
188+ assertEquals(" putIfAbsent" , span.getData(" db.operation.name" ))
184189 }
185190
186- // -- replace (passthrough, no span — conditional write) --
191+ // -- replace --
187192
188193 @Test
189- fun `replace with old value delegates without creating span` () {
194+ fun `replace with old value creates cache put span` () {
190195 val tx = createTransaction()
191196 val wrapper = SentryJCacheWrapper (delegate, scopes)
192197 whenever(delegate.replace(" myKey" , " old" , " new" )).thenReturn(true )
@@ -195,11 +200,15 @@ class SentryJCacheWrapperTest {
195200
196201 assertTrue(result)
197202 verify(delegate).replace(" myKey" , " old" , " new" )
198- assertEquals(0 , tx.spans.size)
203+ assertEquals(1 , tx.spans.size)
204+ val span = tx.spans.first()
205+ assertEquals(" cache.put" , span.operation)
206+ assertEquals(SpanStatus .OK , span.status)
207+ assertEquals(" replace" , span.getData(" db.operation.name" ))
199208 }
200209
201210 @Test
202- fun `replace delegates without creating span` () {
211+ fun `replace creates cache put span` () {
203212 val tx = createTransaction()
204213 val wrapper = SentryJCacheWrapper (delegate, scopes)
205214 whenever(delegate.replace(" myKey" , " value" )).thenReturn(true )
@@ -208,13 +217,17 @@ class SentryJCacheWrapperTest {
208217
209218 assertTrue(result)
210219 verify(delegate).replace(" myKey" , " value" )
211- assertEquals(0 , tx.spans.size)
220+ assertEquals(1 , tx.spans.size)
221+ val span = tx.spans.first()
222+ assertEquals(" cache.put" , span.operation)
223+ assertEquals(SpanStatus .OK , span.status)
224+ assertEquals(" replace" , span.getData(" db.operation.name" ))
212225 }
213226
214- // -- getAndReplace (passthrough, no span — conditional write) --
227+ // -- getAndReplace --
215228
216229 @Test
217- fun `getAndReplace delegates without creating span` () {
230+ fun `getAndReplace creates cache put span` () {
218231 val tx = createTransaction()
219232 val wrapper = SentryJCacheWrapper (delegate, scopes)
220233 whenever(delegate.getAndReplace(" myKey" , " newValue" )).thenReturn(" oldValue" )
@@ -223,7 +236,11 @@ class SentryJCacheWrapperTest {
223236
224237 assertEquals(" oldValue" , result)
225238 verify(delegate).getAndReplace(" myKey" , " newValue" )
226- assertEquals(0 , tx.spans.size)
239+ assertEquals(1 , tx.spans.size)
240+ val span = tx.spans.first()
241+ assertEquals(" cache.put" , span.operation)
242+ assertEquals(SpanStatus .OK , span.status)
243+ assertEquals(" getAndReplace" , span.getData(" db.operation.name" ))
227244 }
228245
229246 // -- remove(K) --
0 commit comments