Search in sources :

Example 81 with KVEntry

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

the class ParserTest method testHSetNxParser.

@Test
public void testHSetNxParser() {
    String command = "hsetnx key field value";
    KVEntry builder = new HSetNxParser().parse(parseCommand(command));
    Assert.assertEquals("hsetnx", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Map<String, String> res = (Map<String, String>) builder.getValue();
    Assert.assertEquals(1, res.size());
    Assert.assertEquals("value", res.get("field"));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) HSetNxParser(org.apache.rocketmq.connect.redis.parser.HSetNxParser) Map(java.util.Map) Test(org.junit.Test)

Example 82 with KVEntry

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

the class ParserTest method testPSetExParser.

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

Example 83 with KVEntry

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

the class ParserTest method testFlushAllParser.

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

Example 84 with KVEntry

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

the class ParserTest method testPfMergeParser.

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

Example 85 with KVEntry

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

the class ParserTest method testExpireAtParser.

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