Search in sources :

Example 26 with KVEntry

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

the class ParserTest method testLPopParser.

@Test
public void testLPopParser() {
    String command = "LPOP key";
    KVEntry builder = new LPopParser().parse(parseCommand(command));
    Assert.assertEquals("LPOP", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) LPopParser(org.apache.rocketmq.connect.redis.parser.LPopParser) Test(org.junit.Test)

Example 27 with KVEntry

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

the class ParserTest method testRPopLPushParser.

@Test
public void testRPopLPushParser() {
    String command = "RPOPLPUSH source destination";
    KVEntry builder = new RPopLPushParser().parse(parseCommand(command));
    Assert.assertEquals("RPOPLPUSH", builder.getCommand());
    Assert.assertEquals("source", builder.getKey());
    Assert.assertEquals("destination", builder.getValue());
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) RPopLPushParser(org.apache.rocketmq.connect.redis.parser.RPopLPushParser) Test(org.junit.Test)

Example 28 with KVEntry

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

the class ParserTest method testZRemRangeByRankParser.

@Test
public void testZRemRangeByRankParser() {
    String command = "ZREMRANGEBYRANK key 0 10";
    KVEntry builder = new ZRemRangeByRankParser().parse(parseCommand(command));
    Assert.assertEquals("ZREMRANGEBYRANK", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    List<String> res = (List<String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("0", res.get(0));
    Assert.assertEquals("10", res.get(1));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) ZRemRangeByRankParser(org.apache.rocketmq.connect.redis.parser.ZRemRangeByRankParser) List(java.util.List) Test(org.junit.Test)

Example 29 with KVEntry

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

the class ParserTest method testZInterStoreParser1.

@Test
public void testZInterStoreParser1() {
    // ZINTERSTORE destination numkeys key [key ...] [weights weight] [aggregate SUM|MIN|MAX]
    String command = "ZINTERSTORE destination 2 k1 k2 weights 100 80";
    KVEntry builder = new ZInterStoreParser().parse(parseCommand(command));
    Assert.assertEquals("ZINTERSTORE", builder.getCommand());
    Assert.assertEquals("destination", builder.getKey());
    Map<String, String> res = (Map<String, String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("100", res.get("k1"));
    Assert.assertEquals("80", res.get("k2"));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) ZInterStoreParser(org.apache.rocketmq.connect.redis.parser.ZInterStoreParser) Map(java.util.Map) Test(org.junit.Test)

Example 30 with KVEntry

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

the class ParserTest method testSelectParser.

@Test
public void testSelectParser() {
    String command = "Select 1";
    KVEntry builder = new SelectParser().parse(parseCommand(command));
    Assert.assertEquals("Select", builder.getCommand());
    Assert.assertEquals("1", builder.getKey());
    Assert.assertTrue(1 == builder.getParam(Options.REDIS_DB_INDEX));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) SelectParser(org.apache.rocketmq.connect.redis.parser.SelectParser) 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