Search in sources :

Example 66 with KVEntry

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

the class ParserTest method testZInterStoreParser2.

@Test
public void testZInterStoreParser2() {
    // ZINTERSTORE destination numkeys key [key ...] [weights weight] [aggregate SUM|MIN|MAX]
    String command = "ZINTERSTORE destination 2 k1 k2 weights 100 80 aggregate SUM";
    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"));
    Assert.assertEquals("SUM", builder.getParam(Options.REDIS_AGGREGATE));
}
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 67 with KVEntry

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

the class ParserTest method testPublishParser.

@Test
public void testPublishParser() {
    String command = "Publish channel message";
    KVEntry builder = new PublishParser().parse(parseCommand(command));
    Assert.assertEquals("Publish", builder.getCommand());
    Assert.assertEquals("channel", builder.getKey());
    Assert.assertEquals("message", builder.getValue());
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) PublishParser(org.apache.rocketmq.connect.redis.parser.PublishParser) Test(org.junit.Test)

Example 68 with KVEntry

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

the class ParserTest method testZPopMinParser.

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

Example 69 with KVEntry

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

the class ParserTest method testExpireParser.

@Test
public void testExpireParser() {
    String command = "expire key 500";
    KVEntry builder = new ExpireParser().parse(parseCommand(command));
    Assert.assertEquals("expire", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Assert.assertTrue(500L == builder.getParam(Options.EXPIRED_TIME));
    Assert.assertEquals(ExpiredType.SECOND, builder.getParam(Options.EXPIRED_TYPE));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) ExpireParser(org.apache.rocketmq.connect.redis.parser.ExpireParser) PExpireParser(org.apache.rocketmq.connect.redis.parser.PExpireParser) Test(org.junit.Test)

Example 70 with KVEntry

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

the class ParserTest method testZAddParser1.

@Test
public void testZAddParser1() {
    // ZADD key [NX|XX] [CH] [INCR] score member [score member ...]
    String command = "ZADD key 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"));
}
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)

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