[Update][Fix] CacheStore-Redis 增加测试细节, 修复 RedisMap 中 'putAll()' 方法非空检查失败导致发生异常的问题;

[Update] RedisMapCacheStoreTest 增加对 'putAll()' 参数传递空 Map 的测试;
[Fix] RedisMapCacheStore 修复因条件错误导致未能准确排除空 Map 的问题;
This commit is contained in:
LamGC 2021-01-02 12:30:56 +08:00
parent 75458dd999
commit 37689f7253
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
2 changed files with 4 additions and 1 deletions

View File

@ -110,7 +110,7 @@ public class RedisMapCacheStore<V> extends RedisCacheStore<Map<String, V>> imple
public boolean putAll(CacheKey key, Map<String, V> map) {
Objects.requireNonNull(key);
Objects.requireNonNull(map);
if (map.size() == 0 && exists(key)) {
if (map.size() == 0) {
return true;
}

View File

@ -135,6 +135,9 @@ public class RedisMapCacheStoreTest {
Assert.assertTrue("clearMap operation failed!", cacheStore.clearMap(key));
// putAll
// empty map
Assert.assertTrue(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)));