Search in sources :

Example 6 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class RedisEventHandlerTest method testHash.

@Test
public void testHash() {
    KVEntry builder = handlerTest(RDB_TYPE_HASH, () -> {
        Map<byte[], byte[]> values = new HashMap<>();
        values.put("key1".getBytes(), "value1".getBytes());
        values.put("key2".getBytes(), "value2".getBytes());
        return values;
    });
    Map<String, String> va = (Map<String, String>) builder.getValue();
    Assert.assertNotNull(va);
    Assert.assertEquals(2, va.size());
    Assert.assertEquals("value1", va.get("key1"));
    Assert.assertEquals("value2", va.get("key2"));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) HashMap(java.util.HashMap) BatchedKeyStringValueString(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 7 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class RedisEventHandlerTest method testStreamListPacks.

@Test
public void testStreamListPacks() {
    KVEntry builder = handlerTest(RDB_TYPE_STREAM_LISTPACKS, () -> {
        Stream stream = new Stream();
        return stream;
    });
    Stream va = (Stream) builder.getValue();
    Assert.assertNotNull(va);
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) Stream(com.moilioncircle.redis.replicator.rdb.datatype.Stream) Test(org.junit.Test)

Example 8 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class RedisEventHandlerTest method testZSetZipList.

@Test
public void testZSetZipList() {
    KVEntry builder = handlerTest(RDB_TYPE_ZSET_ZIPLIST, () -> {
        Set<ZSetEntry> values = new HashSet<>();
        values.add(new ZSetEntry("v1".getBytes(), 100));
        values.add(new ZSetEntry("v2".getBytes(), 80));
        return values;
    });
    Map<String, Double> va = (Map<String, Double>) builder.getValue();
    Assert.assertNotNull(va);
    Assert.assertEquals(2, va.size());
    Assert.assertTrue(100 == va.get("v1"));
    Assert.assertTrue(80 == va.get("v2"));
}
Also used : ZSetEntry(com.moilioncircle.redis.replicator.rdb.datatype.ZSetEntry) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) BatchedKeyStringValueString(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 9 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class RedisEventHandlerTest method testZSET.

@Test
public void testZSET() {
    KVEntry builder = handlerTest(RDB_TYPE_ZSET, () -> {
        Set<ZSetEntry> values = new HashSet<>();
        values.add(new ZSetEntry("key1".getBytes(), 100));
        values.add(new ZSetEntry("key2".getBytes(), 80));
        return values;
    });
    Map<String, Double> va = (Map<String, Double>) builder.getValue();
    Assert.assertNotNull(va);
    Assert.assertEquals(2, va.size());
    Assert.assertTrue(100 == va.get("key1"));
    Assert.assertTrue(80 == va.get("key2"));
}
Also used : ZSetEntry(com.moilioncircle.redis.replicator.rdb.datatype.ZSetEntry) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) BatchedKeyStringValueString(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with KVEntry

use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.

the class RedisEventHandlerTest method testHashZipMap.

@Test
public void testHashZipMap() {
    KVEntry builder = handlerTest(RDB_TYPE_HASH_ZIPMAP, () -> {
        Map<byte[], byte[]> values = new HashMap<>();
        values.put("key1".getBytes(), "value1".getBytes());
        values.put("key2".getBytes(), "value2".getBytes());
        return values;
    });
    Map<String, String> va = (Map<String, String>) builder.getValue();
    Assert.assertNotNull(va);
    Assert.assertEquals(2, va.size());
    Assert.assertEquals("value1", va.get("key1"));
    Assert.assertEquals("value2", va.get("key2"));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) HashMap(java.util.HashMap) BatchedKeyStringValueString(com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString) KeyStringValueString(com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Aggregations

KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)118 Test (org.junit.Test)114 List (java.util.List)34 Map (java.util.Map)20 BatchedKeyStringValueString (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyStringValueString)13 KeyStringValueString (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueString)12 HashMap (java.util.HashMap)8 KeyStringValueList (com.moilioncircle.redis.replicator.rdb.datatype.KeyStringValueList)6 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 HSetParser (org.apache.rocketmq.connect.redis.parser.HSetParser)5 HmSetParser (org.apache.rocketmq.connect.redis.parser.HmSetParser)5 LSetParser (org.apache.rocketmq.connect.redis.parser.LSetParser)5 MSetParser (org.apache.rocketmq.connect.redis.parser.MSetParser)5 ZSetEntry (com.moilioncircle.redis.replicator.rdb.datatype.ZSetEntry)3 BatchedKeyValuePair (com.moilioncircle.redis.replicator.rdb.iterable.datatype.BatchedKeyValuePair)3 SourceDataEntry (io.openmessaging.connector.api.data.SourceDataEntry)3 IOException (java.io.IOException)3 Config (org.apache.rocketmq.connect.redis.common.Config)3 DefaultRedisEventHandler (org.apache.rocketmq.connect.redis.handler.DefaultRedisEventHandler)3