Search in sources :

Example 91 with KVEntry

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

the class ParserTest method testHDelParser.

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

Example 92 with KVEntry

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

the class ParserTest method testPExpireParser.

@Test
public void testPExpireParser() {
    String command = "PExpire key 3600";
    KVEntry builder = new PExpireParser().parse(parseCommand(command));
    Assert.assertEquals("PExpire", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Assert.assertTrue(3600L == builder.getParam(Options.REDIS_PX));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) PExpireParser(org.apache.rocketmq.connect.redis.parser.PExpireParser) Test(org.junit.Test)

Example 93 with KVEntry

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

the class ParserTest method testSetBitParser.

@Test
public void testSetBitParser() {
    String command = "SetBit key 100 value";
    KVEntry builder = new SetBitParser().parse(parseCommand(command));
    Assert.assertEquals("SetBit", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Assert.assertEquals("value", builder.getValue());
    Assert.assertTrue(100L == builder.getParam(Options.REDIS_OFFSET));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) SetBitParser(org.apache.rocketmq.connect.redis.parser.SetBitParser) Test(org.junit.Test)

Example 94 with KVEntry

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

the class ParserTest method testXClaimParser2.

@Test
public void testXClaimParser2() {
    // XCLAIM key group consumer min-idle-time ID [ID ...] [IDLE ms] [TIME ms-unix-time] [RETRYCOUNT count] [force]
    String command = "XCLAIM mystream mygroup Alice 3600000 1526569498055-0 1526569498055-1 IDLE 100 TIME 3000 RETRYCOUNT 10 force";
    KVEntry builder = new XClaimParser().parse(parseCommand(command));
    Assert.assertEquals("XCLAIM", builder.getCommand());
    Assert.assertEquals("mystream", builder.getKey());
    Assert.assertEquals("mygroup", builder.getParam(Options.REDIS_GROUP));
    Assert.assertEquals("Alice", builder.getParam(Options.REDIS_CONSUMER));
    Assert.assertTrue(3600000L == builder.getParam(Options.REDIS_MIN_IDLE_TIME));
    Assert.assertTrue(100L == builder.getParam(Options.REDIS_IDLE));
    Assert.assertTrue(3000L == builder.getParam(Options.REDIS_TIME));
    Assert.assertTrue(10 == builder.getParam(Options.REDIS_RETRYCOUNT));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_FORCE));
    List<String> res = (List<String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("1526569498055-0", res.get(0));
    Assert.assertEquals("1526569498055-1", res.get(1));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) List(java.util.List) XClaimParser(org.apache.rocketmq.connect.redis.parser.XClaimParser) Test(org.junit.Test)

Example 95 with KVEntry

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

the class ParserTest method testSetParser3.

@Test
public void testSetParser3() {
    String command = "set key value NX";
    KVEntry builder = new SetParser().parse(parseCommand(command));
    Assert.assertEquals("set", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Assert.assertEquals("value", builder.getValue());
    Assert.assertEquals(true, builder.getParam(Options.REDIS_NX));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) LSetParser(org.apache.rocketmq.connect.redis.parser.LSetParser) SetParser(org.apache.rocketmq.connect.redis.parser.SetParser) HmSetParser(org.apache.rocketmq.connect.redis.parser.HmSetParser) MSetParser(org.apache.rocketmq.connect.redis.parser.MSetParser) HSetParser(org.apache.rocketmq.connect.redis.parser.HSetParser) 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