Search in sources :

Example 96 with KVEntry

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

the class ParserTest method testXClaimParser1.

@Test
public void testXClaimParser1() {
    // 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";
    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));
    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 97 with KVEntry

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

the class ParserTest method testSRemParser.

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

Example 98 with KVEntry

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

the class ParserTest method testHmSetParser.

@Test
public void testHmSetParser() {
    String command = "hmset key f1 v1 f2 v2";
    KVEntry builder = new HmSetParser().parse(parseCommand(command));
    Assert.assertEquals("hmset", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Map<String, String> res = (Map<String, String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("v1", res.get("f1"));
    Assert.assertEquals("v2", res.get("f2"));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) HmSetParser(org.apache.rocketmq.connect.redis.parser.HmSetParser) Map(java.util.Map) Test(org.junit.Test)

Example 99 with KVEntry

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

the class ParserTest method testLSetParser.

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

Example 100 with KVEntry

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

the class ParserTest method testSwapDbParser.

@Test
public void testSwapDbParser() {
    String command = "SWAPDB 0 1";
    KVEntry builder = new SwapDbParser().parse(parseCommand(command));
    Assert.assertEquals("SWAPDB", builder.getCommand());
    Assert.assertEquals("0", builder.getKey());
    Assert.assertEquals("1", builder.getValue());
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) SwapDbParser(org.apache.rocketmq.connect.redis.parser.SwapDbParser) 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