diff --git a/src/test/java/org/redisson/RedissonHyperLogLogTest.java b/src/test/java/org/redisson/RedissonHyperLogLogTest.java index e0c9dd316..e71d23d93 100644 --- a/src/test/java/org/redisson/RedissonHyperLogLogTest.java +++ b/src/test/java/org/redisson/RedissonHyperLogLogTest.java @@ -16,4 +16,26 @@ public class RedissonHyperLogLogTest extends BaseTest { Assert.assertEquals(3L, log.count()); } + @Test + public void testMerge() { + RHyperLogLog hll1 = redisson.getHyperLogLog("hll1"); + Assert.assertTrue(hll1.add("foo")); + Assert.assertTrue(hll1.add("bar")); + Assert.assertTrue(hll1.add("zap")); + Assert.assertTrue(hll1.add("a")); + + RHyperLogLog hll2 = redisson.getHyperLogLog("hll2"); + Assert.assertTrue(hll2.add("a")); + Assert.assertTrue(hll2.add("b")); + Assert.assertTrue(hll2.add("c")); + Assert.assertTrue(hll2.add("foo")); + Assert.assertFalse(hll2.add("c")); + + RHyperLogLog hll3 = redisson.getHyperLogLog("hll3"); + hll3.mergeWith("hll1", "hll2"); + + Assert.assertEquals(6L, hll3.count()); + } + + } diff --git a/src/test/java/org/redisson/RedissonMapTest.java b/src/test/java/org/redisson/RedissonMapTest.java index d6c90488f..f156651d9 100644 --- a/src/test/java/org/redisson/RedissonMapTest.java +++ b/src/test/java/org/redisson/RedissonMapTest.java @@ -1,9 +1,5 @@ package org.redisson; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.lambdaworks.redis.RedisException; -import io.netty.util.concurrent.Future; - import java.io.Serializable; import java.util.Arrays; import java.util.HashMap; @@ -12,12 +8,16 @@ import java.util.Map; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; import org.junit.Assert; import org.junit.Test; import org.redisson.codec.JsonJacksonCodec; import org.redisson.core.Predicate; import org.redisson.core.RMap; +import io.netty.util.concurrent.Future; + public class RedissonMapTest extends BaseTest { public static class SimpleKey implements Serializable { @@ -121,7 +121,7 @@ public class RedissonMapTest extends BaseTest { } } - + @Test public void testAddAndGet() throws InterruptedException { RMap map = redisson.getMap("getAll"); @@ -231,6 +231,19 @@ public class RedissonMapTest extends BaseTest { Assert.assertEquals("43", val3); } + @Test + public void testEntrySet() { + Map map = redisson.getMap("simple12"); + map.put(1, "12"); + map.put(2, "33"); + map.put(3, "43"); + + Assert.assertEquals(3, map.entrySet().size()); + MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(1), Matchers.equalTo("12"))); + MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(2), Matchers.equalTo("33"))); + MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(3), Matchers.equalTo("43"))); + } + @Test public void testSimpleTypes() { Map map = redisson.getMap("simple12"); @@ -468,6 +481,14 @@ public class RedissonMapTest extends BaseTest { Assert.assertEquals(1, map.size()); } + @Test + public void testFastPut() throws Exception { + RMap map = redisson.getMap("simple"); + Assert.assertTrue(map.fastPut(1, 2)); + Assert.assertFalse(map.fastPut(1, 3)); + Assert.assertEquals(1, map.size()); + } + @Test public void testFastRemoveEmpty() throws Exception { RMap map = redisson.getMap("simple");