Search in sources :

Example 21 with KVEntry

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

the class ParserTest method testMSetNxParser.

@Test
public void testMSetNxParser() {
    String command = "msetnx k1 v1 k2 v2";
    KVEntry builder = new MSetNxParser().parse(parseCommand(command));
    Assert.assertEquals("msetnx", builder.getCommand());
    Assert.assertEquals("k1", builder.getKey());
    Map<String, String> res = (Map<String, String>) builder.getValue();
    Assert.assertEquals("v1", res.get("k1"));
    Assert.assertEquals("v2", res.get("k2"));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) MSetNxParser(org.apache.rocketmq.connect.redis.parser.MSetNxParser) Map(java.util.Map) Test(org.junit.Test)

Example 22 with KVEntry

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

the class ParserTest method testSetParser1.

@Test
public void testSetParser1() {
    String command = "set key value EX 100 NX";
    KVEntry builder = new SetParser().parse(parseCommand(command));
    Assert.assertEquals("set", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    Assert.assertEquals("value", builder.getValue());
    Assert.assertTrue(100 == builder.getParam(Options.REDIS_EX));
    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)

Example 23 with KVEntry

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

the class ParserTest method testLinsertParserBefore.

@Test
public void testLinsertParserBefore() {
    String command = "Linsert key BEFORE pivot value";
    KVEntry builder = new LinsertParser().parse(parseCommand(command));
    Assert.assertEquals("Linsert", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    List<String> res = (List<String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("pivot", res.get(0));
    Assert.assertEquals("value", res.get(1));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_BEFORE));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) LinsertParser(org.apache.rocketmq.connect.redis.parser.LinsertParser) List(java.util.List) Test(org.junit.Test)

Example 24 with KVEntry

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

the class ParserTest method testZIncrByParser.

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

Example 25 with KVEntry

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

the class ParserTest method testLinsertParserAfter.

@Test
public void testLinsertParserAfter() {
    String command = "Linsert key AFTER pivot value";
    KVEntry builder = new LinsertParser().parse(parseCommand(command));
    Assert.assertEquals("Linsert", builder.getCommand());
    Assert.assertEquals("key", builder.getKey());
    List<String> res = (List<String>) builder.getValue();
    Assert.assertEquals(2, res.size());
    Assert.assertEquals("pivot", res.get(0));
    Assert.assertEquals("value", res.get(1));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_AFTER));
}
Also used : KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) LinsertParser(org.apache.rocketmq.connect.redis.parser.LinsertParser) 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