17
17
package io.github.nstdio.http.ext
18
18
19
19
import io.github.nstdio.http.ext.Assertions.assertThat
20
+ import io.kotest.matchers.nulls.shouldBeNull
21
+ import io.kotest.matchers.shouldBe
20
22
import org.assertj.core.api.Assertions.assertThat
21
23
import org.junit.jupiter.api.Assertions.assertFalse
22
24
import org.junit.jupiter.api.Assertions.assertTrue
23
25
import org.junit.jupiter.api.Test
24
26
import org.mockito.Mockito
27
+ import org.mockito.Mockito.mock
25
28
import org.mockito.Mockito.verify
29
+ import org.mockito.Mockito.verifyNoInteractions
26
30
import org.mockito.Mockito.verifyNoMoreInteractions
27
31
import java.util.function.Consumer
28
32
import java.util.function.ToIntFunction
@@ -180,7 +184,7 @@ class LruMultimapTest {
180
184
181
185
// then
182
186
assertThat(map).isEmpty
183
- Mockito . verifyNoInteractions(mockEl)
187
+ verifyNoInteractions(mockEl)
184
188
}
185
189
186
190
@Test
@@ -217,7 +221,7 @@ class LruMultimapTest {
217
221
}
218
222
219
223
@Suppress(" UNCHECKED_CAST" )
220
- private fun mockConsumer () = Mockito . mock(Consumer ::class .java) as Consumer <String ?>
224
+ private fun mockConsumer () = mock(Consumer ::class .java) as Consumer <String ?>
221
225
222
226
@Test
223
227
fun shouldEvictAllForNonExistingKey () {
@@ -232,6 +236,27 @@ class LruMultimapTest {
232
236
233
237
// then
234
238
assertThat(map).hasMapSize(1 ).hasSize(2 )
235
- Mockito .verifyNoInteractions(mockEl)
239
+ verifyNoInteractions(mockEl)
240
+ }
241
+
242
+ @Test
243
+ fun `Should remove` () {
244
+ // given
245
+ val map = LruMultimap <String , String >(8 , null )
246
+ val nonExistingKeyFn = mock(ToIntFunction ::class .java) as ToIntFunction <List <String >>
247
+
248
+ // when
249
+ map.putSingle(" a" , " 1" , addFn)
250
+ map.putSingle(" a" , " 2" , addFn)
251
+ map.putSingle(" b" , " 2" , addFn)
252
+
253
+
254
+ // then
255
+ map.remove(" a" ) { 2 }.shouldBeNull()
256
+ map.remove(" a" ) { - 1 }.shouldBeNull()
257
+ map.remove(" a" ) { 0 }.shouldBe(" 2" )
258
+ map.remove(" b" ) { 0 }.shouldBe(" 2" )
259
+ map.remove(" c" , nonExistingKeyFn).shouldBeNull()
260
+ verifyNoInteractions(nonExistingKeyFn)
236
261
}
237
262
}
0 commit comments