mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-29 14:17:33 +00:00
[Fix] CacheStore-Redis 修复 'putAll' 因 Map 为空且检查疏漏导致抛出异常的问题, 完善测试项;
[Fix] RedisMapCacheStore 修复 'putAll' 因 Map 为空且检查疏漏导致抛出异常的问题; [Update] RedisMapCacheStoreTest 调整测试用前缀, 完善 'putAll' 对空 Map 参数在不同情况下的测试;
This commit is contained in:
parent
8d9debeb1b
commit
2bdfbeb72d
@ -111,7 +111,7 @@ public class RedisMapCacheStore<V> extends RedisCacheStore<Map<String, V>> imple
|
||||
Objects.requireNonNull(key);
|
||||
Objects.requireNonNull(map);
|
||||
if (map.size() == 0) {
|
||||
return true;
|
||||
return exists(key);
|
||||
}
|
||||
|
||||
final Map<String, String> targetMap = new HashMap<>(map.size());
|
||||
|
@ -54,7 +54,7 @@ public class RedisMapCacheStoreTest {
|
||||
}
|
||||
}
|
||||
|
||||
private final static MapCacheStore<String> cacheStore = factory.newMapCacheStore("test", new StringToStringConverter());
|
||||
private final static MapCacheStore<String> cacheStore = factory.newMapCacheStore("test:map", new StringToStringConverter());
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
@ -135,12 +135,14 @@ public class RedisMapCacheStoreTest {
|
||||
Assert.assertTrue("clearMap operation failed!", cacheStore.clearMap(key));
|
||||
|
||||
// putAll
|
||||
// empty map
|
||||
Assert.assertTrue(cacheStore.putAll(key, new HashMap<>()));
|
||||
// empty map, key no exist
|
||||
Assert.assertFalse(cacheStore.putAll(key, new HashMap<>()));
|
||||
// non-empty map
|
||||
Assert.assertTrue(cacheStore.putAll(key, expectedMap));
|
||||
Assert.assertTrue(expectedMap.keySet().containsAll(cacheStore.mapFieldSet(key)));
|
||||
Assert.assertTrue(expectedMap.values().containsAll(cacheStore.mapValueSet(key)));
|
||||
// empty map, key exist
|
||||
Assert.assertTrue(cacheStore.putAll(key, new HashMap<>()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user