Search in sources :

Example 46 with KVEntry

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

the class ParserTest method testZAddParser2.

@Test
public void testZAddParser2() {
    // ZADD key [NX|XX] [CH] [INCR] score member [score member ...]
    String command = "ZADD key NX CH INCR 100 m1 80 m2";
    KVEntry builder = new ZAddParser().parse(parseCommand(command));
    Assert.assertEquals("ZADD", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Map<String, String> res = (Map<String, String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("100", res.get("m1"));
    Assert.assertEquals("80", res.get("m2"));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_NX));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_CH));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_INCR));
}
Also used : ZAddParser(org.apache.rocketmq.connect.redis.parser.ZAddParser) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) Map(java.util.Map) Test(org.junit.Test)

Example 47 with KVEntry

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

the class ParserTest method testXTrimParser2.

@Test
public void testXTrimParser2() {
    String command = "XTrim key MAXLEN 100";
    KVEntry builder = new XTrimParser().parse(parseCommand(command));
    Assert.assertEquals("XTrim", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Assert.assertEquals(false, builder.getParam(Options.REDIS_XTRIM));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) XTrimParser(org.apache.rocketmq.connect.redis.parser.XTrimParser) Test(org.junit.Test)

Example 48 with KVEntry

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

the class ParserTest method testZAddParser3.

@Test
public void testZAddParser3() {
    // ZADD key [NX|XX] [CH] [INCR] score member [score member ...]
    String command = "ZADD key XX CH INCR 100 m1 80 m2";
    KVEntry builder = new ZAddParser().parse(parseCommand(command));
    Assert.assertEquals("ZADD", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Map<String, String> res = (Map<String, String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("100", res.get("m1"));
    Assert.assertEquals("80", res.get("m2"));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_XX));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_CH));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_INCR));
}
Also used : ZAddParser(org.apache.rocketmq.connect.redis.parser.ZAddParser) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) Map(java.util.Map) Test(org.junit.Test)

Example 49 with KVEntry

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

the class ParserTest method testEvalParser.

@Test
public void testEvalParser() {
    String command = "EVAL script 2 k1 k2 arg1 arg2";
    KVEntry builder = new EvalParser().parse(parseCommand(command));
    Assert.assertEquals("EVAL", builder.getCommand());
    Assert.assertEquals("script", builder.getKey());
    List<List<String>> res = (List<List<String>>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals(2, res.get(0).size());
    Assert.assertEquals(2, res.get(1).size());
    Assert.assertEquals("k1", res.get(0).get(0));
    Assert.assertEquals("k2", res.get(0).get(1));
    Assert.assertEquals("arg1", res.get(1).get(0));
    Assert.assertEquals("arg2", res.get(1).get(1));
}
Also used : EvalParser(org.apache.rocketmq.connect.redis.parser.EvalParser) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) List(java.util.List) Test(org.junit.Test)

Example 50 with KVEntry

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

the class ParserTest method testEvalShaParser.

@Test
public void testEvalShaParser() {
    String command = "EVAL sha1 2 k1 k2 arg1 arg2";
    KVEntry builder = new EvalShaParser().parse(parseCommand(command));
    Assert.assertEquals("EVAL", builder.getCommand());
    Assert.assertEquals("sha1", builder.getKey());
    List<List<String>> res = (List<List<String>>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals(2, res.get(0).size());
    Assert.assertEquals(2, res.get(1).size());
    Assert.assertEquals("k1", res.get(0).get(0));
    Assert.assertEquals("k2", res.get(0).get(1));
    Assert.assertEquals("arg1", res.get(1).get(0));
    Assert.assertEquals("arg2", res.get(1).get(1));
}
Also used : EvalShaParser(org.apache.rocketmq.connect.redis.parser.EvalShaParser) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) List(java.util.List) 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