File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
src/test/java/com/layor/tinyflow/service Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 1010import com .layor .tinyflow .repository .DailyClickRepository ;
1111import com .layor .tinyflow .repository .ShortUrlRepository ;
1212import com .layor .tinyflow .repository .UserRepository ;
13+ import com .google .common .hash .BloomFilter ;
1314import org .junit .jupiter .api .BeforeEach ;
1415import org .junit .jupiter .api .Disabled ;
1516import org .junit .jupiter .api .DisplayName ;
@@ -72,6 +73,9 @@ class ShortUrlServiceTest {
7273
7374 @ Mock
7475 private ValueOperations <String , String > valueOperations ;
76+
77+ @ Mock
78+ private BloomFilter <String > shortCodeBloomFilter ;
7579
7680 @ InjectMocks
7781 private ShortUrlService shortUrlService ;
@@ -85,6 +89,11 @@ class ShortUrlServiceTest {
8589 void setUp () {
8690 ReflectionTestUtils .setField (shortUrlService , "baseUrl" , BASE_URL );
8791 when (redisTemplate .opsForValue ()).thenReturn (valueOperations );
92+
93+ // Mock 布隆过滤器行为:默认返回 true(可能存在)
94+ when (shortCodeBloomFilter .mightContain (anyString ())).thenReturn (true );
95+ // put 方法返回 true(模拟添加成功)
96+ when (shortCodeBloomFilter .put (anyString ())).thenReturn (true );
8897 }
8998
9099 @ Test
You can’t perform that action at this time.
0 commit comments