org.redisson.api.RMap Java Examples

The following examples show how to use org.redisson.api.RMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CartServiceImpl.java    From gpmall with Apache License 2.0 7 votes vote down vote up
@Override
public ClearCartItemResponse clearCartItemByUserID(ClearCartItemRequest request) {
    ClearCartItemResponse response=new ClearCartItemResponse();
    try{
        RMap itemMap = redissonClient.getMap(generatorCartItemKey(request.getUserId()));
        itemMap.values().forEach(obj -> {
            CartProductDto cartProductDto = JSON.parseObject(obj.toString(), CartProductDto.class);
            if(request.getProductIds().contains(cartProductDto.getProductId())){
                itemMap.remove(cartProductDto.getProductId());
            }
        });
        response.setCode(ShoppingRetCode.SUCCESS.getCode());
        response.setMsg(ShoppingRetCode.SUCCESS.getMessage());
    }catch (Exception e){
        log.error("CartServiceImpl.clearCartItemByUserID Occur Exception :"+e);
        ExceptionProcessorUtils.wrapperHandlerException(response,e);
    }
    return response;
}
 
Example #2
Source File: RedisJobRepositoryImpl.java    From earth-frost with Apache License 2.0 6 votes vote down vote up
@Override
public String addJobRecord(JobExecuteRecord record) {
  RMap<String, JobExecuteRecord> map = redissonClient.getMap(Container.RECORD);
  map.put(record.getId(), record);

  // 全部
  RListMultimap<String, String> sortmap = redissonClient.getListMultimap(Container.RECORD_SORT);
  sortmap.put(Strings.EMPTY, record.getId());
  // jobId
  sortmap.put(record.getJobId(), record.getId());

  JobInfo info = findJobInfoById(record.getJobId());
  JobGroup group = info.getGroup();
  if (Objects.equals(JobInfo.TYPE.BEAN.name(), info.getType())) {
    // groupKey
    sortmap.put(group.getGroupKey(), record.getId());
    // jobKey
    sortmap
        .put(String.join(Strings.COLON, group.getGroupKey(), group.getJobKey()), record.getId());
  } else if (group != null && group.getGroupKey() != null) {
    // groupKey
    sortmap.put(group.getGroupKey(), record.getId());
  }
  return record.getId();
}
 
Example #3
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetAllOrderPartially() {
    RMap<Integer, Integer> map = getMap("getAll");
    map.put(1, 100);
    map.put(2, 200);
    map.put(3, 300);
    map.put(4, 400);
    RMap<Integer, Integer> map2 = getMap("getAll");
    map2.put(5, 500);
    map2.put(6, 600);
    map2.put(7, 700);
    map2.put(8, 800);

    Map<Integer, Integer> filtered = map.getAll(new HashSet<Integer>(Arrays.asList(2, 3, 5, 1, 7, 8)));

    Map<Integer, Integer> expectedMap = new LinkedHashMap<Integer, Integer>();
    expectedMap.put(1, 100);
    expectedMap.put(2, 200);
    expectedMap.put(3, 300);
    expectedMap.put(5, 500);
    expectedMap.put(7, 700);
    expectedMap.put(8, 800);
    
    assertThat(filtered.entrySet()).containsExactlyElementsOf(expectedMap.entrySet());
    destroy(map);
}
 
Example #4
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadAll() {
    Map<String, String> cache = new HashMap<String, String>();
    for (int i = 0; i < 100; i++) {
        cache.put("" + i, "" + (i*10 + i));
    }
    
    RMap<String, String> map = getLoaderTestMap("test", cache);
    
    assertThat(map.size()).isEqualTo(0);
    map.loadAll(false, 2);
    assertThat(map.size()).isEqualTo(100);
    
    for (int i = 0; i < 100; i++) {
        assertThat(map.containsKey("" + i)).isTrue();
    }
    destroy(map);
}
 
Example #5
Source File: IpRule.java    From kk-anti-reptile with Apache License 2.0 6 votes vote down vote up
/**
 * 重置已记录规则
 * @param request 请求
 * @param realRequestUri 原始请求uri
 */
@Override
public void reset(HttpServletRequest request, String realRequestUri) {
    String ipAddress = getIpAddr(request);
    String requestUrl = realRequestUri;
    /**
     * 重置计数器
     */
    int expirationTime = properties.getIpRule().getExpirationTime();
    RAtomicLong rRequestCount = redissonClient.getAtomicLong(RATELIMITER_COUNT_PREFIX.concat(requestUrl).concat(ipAddress));
    RAtomicLong rExpirationTime = redissonClient.getAtomicLong(RATELIMITER_EXPIRATIONTIME_PREFIX.concat(requestUrl).concat(ipAddress));
    rRequestCount.set(0L);
    rExpirationTime.set(0L);
    rExpirationTime.expire(expirationTime, TimeUnit.MILLISECONDS);
    /**
     * 清除记录
     */
    RMap rHitMap = redissonClient.getMap(RATELIMITER_HIT_CRAWLERSTRATEGY);
    rHitMap.remove(ipAddress);
}
 
Example #6
Source File: RedissonBaseTransactionalMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testPutAll() {
    RMap<String, String> m = getMap();
    m.put("1", "2");
    m.put("3", "4");
    
    RTransaction t = redisson.createTransaction(TransactionOptions.defaults());
    RMap<String, String> map = getTransactionalMap(t);
    Map<String, String> putMap = new HashMap<String, String>();
    putMap.put("4", "5");
    putMap.put("6", "7");
    map.putAll(putMap);
    assertThat(m.keySet()).containsOnly("1", "3");
    
    t.commit();
    
    assertThat(m.keySet()).containsOnly("1", "3", "4", "6");
}
 
Example #7
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testWriterFastRemove() {
    Map<String, String> store = new HashMap<>();
    RMap<String, String> map = getWriterTestMap("test", store);

    map.put("1", "11");
    map.put("2", "22");
    map.put("3", "33");
    
    map.fastRemove("1", "2", "4");
    
    Map<String, String> expected = new HashMap<>();
    expected.put("3", "33");
    assertThat(store).isEqualTo(expected);
    destroy(map);
}
 
Example #8
Source File: RedisJobRepositoryImpl.java    From earth-frost with Apache License 2.0 6 votes vote down vote up
@Override
public void removeJobRecords(String jobId) {
  RMap<String, JobExecuteRecord> map = redissonClient.getMap(Container.RECORD);
  RListMultimap<String, String> sortmap = redissonClient.getListMultimap(Container.RECORD_SORT);
  List<String> list = sortmap.removeAll(jobId);
  RListMultimap<String, JobRecordStatus> statusMultimap = redissonClient
      .getListMultimap(Container.RECORD_STATUS);
  JobGroup group = findJobInfoById(jobId).getGroup();
  for (String key : list) {
    sortmap.get(Strings.EMPTY).remove(key);
    if (group != null) {
      sortmap.get(group.getGroupKey()).remove(key);
      sortmap.get(String.join(Strings.COLON, group.getGroupKey(), group.getJobKey())).remove(key);
    }
    statusMultimap.removeAll(key);
    map.remove(key);
    redissonClient.getKeys().delete(String.format(Container.EVENT_SHARDING, jobId, key));
  }
}
 
Example #9
Source File: RedissonKeysTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testMassDelete() {
    RBucket<String> bucket0 = redisson.getBucket("test0");
    bucket0.set("someValue");
    RBucket<String> bucket1 = redisson.getBucket("test1");
    bucket1.set("someValue");
    RBucket<String> bucket2 = redisson.getBucket("test2");
    bucket2.set("someValue");
    RBucket<String> bucket3 = redisson.getBucket("test3");
    bucket3.set("someValue");
    RBucket<String> bucket10 = redisson.getBucket("test10");
    bucket10.set("someValue");

    RBucket<String> bucket12 = redisson.getBucket("test12");
    bucket12.set("someValue");
    RMap<String, String> map = redisson.getMap("map2");
    map.fastPut("1", "2");

    Assert.assertEquals(7, redisson.getKeys().delete("test0", "test1", "test2", "test3", "test10", "test12", "map2"));
    Assert.assertEquals(0, redisson.getKeys().delete("test0", "test1", "test2", "test3", "test10", "test12", "map2"));
}
 
Example #10
Source File: RedissonMapCacheTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testAddAndGetTTL() {
    RMapCache<String, Object> mapCache = redisson.getMapCache("test_put_if_absent", LongCodec.INSTANCE);
    assertThat(mapCache.putIfAbsent("4", 0L, 10000L, TimeUnit.SECONDS)).isNull();
    assertThat(mapCache.addAndGet("4", 1L)).isEqualTo(1L);
    assertThat(mapCache.putIfAbsent("4", 0L)).isEqualTo(1L);
    Assert.assertEquals(1L, mapCache.get("4"));
    mapCache.destroy();
    mapCache = redisson.getMapCache("test_put_if_absent_1", LongCodec.INSTANCE);
    mapCache.putIfAbsent("4", 0L);
    mapCache.addAndGet("4", 1L);
    mapCache.putIfAbsent("4", 0L);
    Assert.assertEquals(1L, mapCache.get("4"));
    RMap map = redisson.getMap("test_put_if_absent_2", LongCodec.INSTANCE);
    map.putIfAbsent("4", 0L);
    map.addAndGet("4", 1L);
    map.putIfAbsent("4", 0L);
    Assert.assertEquals(1L, map.get("4"));
    RMapCache<String, Object> mapCache1 = redisson.getMapCache("test_put_if_absent_3", DoubleCodec.INSTANCE);
    mapCache1.putIfAbsent("4", 1.23, 10000L, TimeUnit.SECONDS);
    mapCache1.addAndGet("4", 1D);
    Assert.assertEquals(2.23, mapCache1.get("4"));
    mapCache.destroy();
    mapCache1.destroy();
}
 
Example #11
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test(timeout = 5000)
public void testDeserializationErrorReturnsErrorImmediately() throws Exception {
    RMap<String, SimpleObjectWithoutDefaultConstructor> map = getMap("deserializationFailure", new JsonJacksonCodec());
    Assume.assumeTrue(!(map instanceof RLocalCachedMap));
    SimpleObjectWithoutDefaultConstructor object = new SimpleObjectWithoutDefaultConstructor("test-val");

    Assert.assertEquals("test-val", object.getTestField());
    map.put("test-key", object);

    try {
        map.get("test-key");
        Assert.fail("Expected exception from map.get() call");
    } catch (Exception e) {
        e.printStackTrace();
    }
    destroy(map);
}
 
Example #12
Source File: RedissonBaseTransactionalMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testReplace2() {
    RMap<String, String> m = getMap();
    m.put("1", "2");
    m.put("3", "4");
    
    RTransaction transaction = redisson.createTransaction(TransactionOptions.defaults());
    RMap<String, String> map = getTransactionalMap(transaction);
    assertThat(map.replace("3", "4", "10")).isTrue();
    assertThat(map.replace("1", "1", "3")).isFalse();
    assertThat(map.replace("3", "10", "11")).isTrue();
    
    assertThat(m.get("3")).isEqualTo("4");
    assertThat(m.get("1")).isEqualTo("2");
    assertThat(m.size()).isEqualTo(2);
    
    transaction.commit();
    
    assertThat(m.size()).isEqualTo(2);
    assertThat(m.get("3")).isEqualTo("11");
    assertThat(m.get("1")).isEqualTo("2");
}
 
Example #13
Source File: RedissonLocalCachedMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testReadAllEntrySet() {
    RLocalCachedMap<SimpleKey, SimpleValue> map = redisson.getLocalCachedMap("simple12", LocalCachedMapOptions.defaults());
    Map<SimpleKey, SimpleValue> cache = map.getCachedMap();
    map.put(new SimpleKey("1"), new SimpleValue("2"));
    map.put(new SimpleKey("33"), new SimpleValue("44"));
    map.put(new SimpleKey("5"), new SimpleValue("6"));

    assertThat(map.readAllEntrySet().size()).isEqualTo(3);
    assertThat(cache.size()).isEqualTo(3);
    Map<SimpleKey, SimpleValue> testMap = new HashMap<>(map);
    assertThat(map.readAllEntrySet()).containsOnlyElementsOf(testMap.entrySet());
    
    RMap<SimpleKey, SimpleValue> map2 = redisson.getLocalCachedMap("simple12", LocalCachedMapOptions.defaults());
    assertThat(map2.readAllEntrySet()).containsOnlyElementsOf(testMap.entrySet());
}
 
Example #14
Source File: RedissonBaseTransactionalMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testPutRemove() {
    RMap<String, String> m = getMap();
    m.put("1", "2");
    m.put("3", "4");
    
    RTransaction transaction = redisson.createTransaction(TransactionOptions.defaults());
    RMap<String, String> map = getTransactionalMap(transaction);
    assertThat(map.get("1")).isEqualTo("2");
    assertThat(map.remove("3")).isEqualTo("4");
    assertThat(map.put("3", "5")).isNull();
    assertThat(map.get("3")).isEqualTo("5");
    
    assertThat(m.get("3")).isEqualTo("4");
    
    transaction.commit();
    
    assertThat(m.get("1")).isEqualTo("2");
    assertThat(m.get("3")).isEqualTo("5");
}
 
Example #15
Source File: RedissonKeysTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testDeleteByPatternBatch() {
    RBucket<String> bucket = redisson.getBucket("test0");
    bucket.set("someValue3");
    assertThat(bucket.isExists()).isTrue();

    RBucket<String> bucket2 = redisson.getBucket("test9");
    bucket2.set("someValue4");
    assertThat(bucket.isExists()).isTrue();

    RMap<String, String> map = redisson.getMap("test2");
    map.fastPut("1", "2");
    assertThat(map.isExists()).isTrue();

    RMap<String, String> map2 = redisson.getMap("test3");
    map2.fastPut("1", "5");
    assertThat(map2.isExists()).isTrue();


    RBatch batch = redisson.createBatch();
    batch.getKeys().deleteByPatternAsync("test?");
    BatchResult<?> r = batch.execute();
    Assert.assertEquals(4L, r.getResponses().get(0));
}
 
Example #16
Source File: BaseMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetAll() {
    RMap<Integer, Integer> map = getMap("getAll");
    map.put(1, 100);
    map.put(2, 200);
    map.put(3, 300);
    map.put(4, 400);

    Map<Integer, Integer> filtered = map.getAll(new HashSet<Integer>(Arrays.asList(2, 3, 5)));

    Map<Integer, Integer> expectedMap = new HashMap<Integer, Integer>();
    expectedMap.put(2, 200);
    expectedMap.put(3, 300);
    assertThat(filtered).isEqualTo(expectedMap);
    destroy(map);
}
 
Example #17
Source File: RedissonLocalCachedMapTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testReadAllValues() {
    RLocalCachedMap<SimpleKey, SimpleValue> map = redisson.getLocalCachedMap("simple", LocalCachedMapOptions.defaults());
    Map<SimpleKey, SimpleValue> cache = map.getCachedMap();
    
    map.put(new SimpleKey("1"), new SimpleValue("2"));
    map.put(new SimpleKey("33"), new SimpleValue("44"));
    map.put(new SimpleKey("5"), new SimpleValue("6"));
    assertThat(cache.size()).isEqualTo(3);

    assertThat(map.readAllValues().size()).isEqualTo(3);
    Map<SimpleKey, SimpleValue> testMap = new HashMap<>(map);
    assertThat(map.readAllValues()).containsOnlyElementsOf(testMap.values());
    
    RMap<SimpleKey, SimpleValue> map2 = redisson.getLocalCachedMap("simple", LocalCachedMapOptions.defaults());
    assertThat(map2.readAllValues()).containsOnlyElementsOf(testMap.values());
}
 
Example #18
Source File: RedissonMapReduceTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testCancel() throws InterruptedException, ExecutionException {
    RMap<String, String> map = getMap();
    for (int i = 0; i < 100000; i++) {
        map.put("" + i, "ab cd fjks");
    }
    
    RMapReduce<String, String, String, Integer> mapReduce = map.<String, Integer>mapReduce().mapper(new WordMapper()).reducer(new WordReducer());
    RFuture<Map<String, Integer>> future = mapReduce.executeAsync();
    Thread.sleep(100);
    future.cancel(true);
}
 
Example #19
Source File: MapCacheFastPutOperation.java    From redisson with Apache License 2.0 5 votes vote down vote up
public MapCacheFastPutOperation(RMap<?, ?> map, Object key, Object value, long ttl, TimeUnit ttlUnit, long maxIdleTime, TimeUnit maxIdleUnit, String transactionId, long threadId) {
    super(map, key, value, transactionId, threadId);
    this.ttl = ttl;
    this.ttlUnit = ttlUnit;
    this.maxIdleTime = maxIdleTime;
    this.maxIdleUnit = maxIdleUnit;
}
 
Example #20
Source File: MultiCache.java    From mPaaS with Apache License 2.0 5 votes vote down vote up
/** key是否存在(Hash) */
public boolean hIsExists(String key) {
    Object map = null;
    /**
     * CACHE:key==NULL 表示key不存在<br>
     * CACHE:key==MAP 表示key存在
     */
    // 从线程中读
    Map<String, Object> cache = getThreadLocal();
    if (cache != null) {
        map = cache.get(key);
        if (map != null) {
            return map != NULL;
        }
    }
    // 从redis读并回写线程
    RMap<String, Object> rmap = redisson.getMap(key,
            JsonJacksonCodec.INSTANCE);
    boolean exists = rmap.isExists();
    if (cache != null) {
        if (exists) {
            cache.put(key, new HashMap<>(16));
        } else {
            cache.put(key, NULL);
        }
    }
    return exists;
}
 
Example #21
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testValuesByPattern() {
    RMap<String, String> map = getMap("simple", StringCodec.INSTANCE);
    map.put("10", "100");
    map.put("20", "200");
    map.put("30", "300");

    assertThat(map.values("?0")).containsExactly("100", "200", "300");
    assertThat(map.values("1")).isEmpty();
    assertThat(map.values("10")).containsExactly("100");
    destroy(map);
}
 
Example #22
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testIterator() {
    RMap<Integer, Integer> rMap = getMap("123");

    int size = 1000;
    for (int i = 0; i < size; i++) {
        rMap.put(i, i);
    }
    assertThat(rMap.size()).isEqualTo(1000);

    int counter = 0;
    for (Integer key : rMap.keySet()) {
        counter++;
    }
    assertThat(counter).isEqualTo(size);
    counter = 0;
    for (Integer value : rMap.values()) {
        counter++;
    }
    assertThat(counter).isEqualTo(size);
    counter = 0;
    for (Entry<Integer, Integer> entry : rMap.entrySet()) {
        counter++;
    }
    assertThat(counter).isEqualTo(size);
    destroy(rMap);
}
 
Example #23
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testEmptyRemove() {
    RMap<Integer, Integer> map = getMap("simple");
    Assert.assertFalse(map.remove(1, 3));
    map.put(4, 5);
    Assert.assertTrue(map.remove(4, 5));
    destroy(map);
}
 
Example #24
Source File: RedissonObjectBuilder.java    From redisson with Apache License 2.0 5 votes vote down vote up
public void store(RObject ar, String fieldName, RMap<String, Object> liveMap) {
    Codec codec = ar.getCodec();
    if (codec != null) {
        codecProvider.registerCodec((Class) codec.getClass(), codec);
    }
    liveMap.fastPut(fieldName,
            new RedissonReference(ar.getClass(), ar.getName(), codec));
}
 
Example #25
Source File: MultiCache.java    From mPaaS with Apache License 2.0 5 votes vote down vote up
/** 写,当key不存在时无效,并返回false */
@SuppressWarnings("unchecked")
public boolean hset(String key, String field, Object value) {
    Object map = null;
    /**
     * CACHE:key==NULL 表示key不存在<br>
     * CACHE:key==MAP 表示key存在
     */
    // 从线程中判断key是否存在
    Map<String, Object> cache = getThreadLocal();
    if (cache != null) {
        map = cache.get(key);
        if (map == NULL) {
            // key不存在,写失败
            return false;
        }
    }
    // 从redis读并回写线程
    RMap<String, Object> rmap = redisson.getMap(key,
            JsonJacksonCodec.INSTANCE);
    boolean exists = map != null || rmap.isExists();
    if (!exists) {
        if (cache != null) {
            cache.put(key, NULL);
        }
        return false;
    }
    // 写入数据
    rmap.put(field, value);
    if (cache != null) {
        if (map == null) {
            map = new HashMap<>(16);
            cache.put(key, map);
        }
        ((Map<String, Object>) map).put(field,
                value == null ? NULL : value);
    }
    return true;
}
 
Example #26
Source File: RedissonCodecTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testListOfStrings() {
    Config config = createConfig();
    config.setCodec(new JsonJacksonCodec());
    RedissonClient redisson = Redisson.create(config);

    RMap<String, List<String>> map = redisson.getMap("list of strings", jsonListOfStringCodec);
    map.put("foo", new ArrayList<String>(Arrays.asList("bar")));

    RMap<String, List<String>> map2 = redisson.getMap("list of strings", jsonListOfStringCodec);

    assertThat(map2).isEqualTo(map);
    
    redisson.shutdown();
}
 
Example #27
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadAllKeySet() {
    RMap<SimpleKey, SimpleValue> map = getMap("simple");
    map.put(new SimpleKey("1"), new SimpleValue("2"));
    map.put(new SimpleKey("33"), new SimpleValue("44"));
    map.put(new SimpleKey("5"), new SimpleValue("6"));

    assertThat(map.readAllKeySet().size()).isEqualTo(3);
    Map<SimpleKey, SimpleValue> testMap = new HashMap<>(map);
    assertThat(map.readAllKeySet()).containsOnlyElementsOf(testMap.keySet());
    destroy(map);
}
 
Example #28
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadAllKeySetHighAmount() {
    RMap<SimpleKey, SimpleValue> map = getMap("simple");
    for (int i = 0; i < 1000; i++) {
        map.put(new SimpleKey("" + i), new SimpleValue("" + i));
    }

    assertThat(map.readAllKeySet().size()).isEqualTo(1000);
    Map<SimpleKey, SimpleValue> testMap = new HashMap<>(map);
    assertThat(map.readAllKeySet()).containsOnlyElementsOf(testMap.keySet());
    destroy(map);
}
 
Example #29
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testReplaceOldValueFail() {
    RMap<SimpleKey, SimpleValue> map = getMap("simple");
    map.put(new SimpleKey("1"), new SimpleValue("2"));

    boolean res = map.replace(new SimpleKey("1"), new SimpleValue("43"), new SimpleValue("31"));
    Assert.assertFalse(res);

    SimpleValue val1 = map.get(new SimpleKey("1"));
    Assert.assertEquals("2", val1.getValue());
    destroy(map);
}
 
Example #30
Source File: BaseMapTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testWriterAddAndGet() throws InterruptedException {
    Map<String, Integer> store = new HashMap<>();
    RMap<String, Integer> map = getWriterTestMap("test", store);

    assertThat(map.addAndGet("1", 11)).isEqualTo(11);
    assertThat(map.addAndGet("1", 7)).isEqualTo(18);
    
    Map<String, Integer> expected = new HashMap<>();
    expected.put("1", 18);
    assertThat(store).isEqualTo(expected);
    destroy(map);
}