Search in sources :

Example 1 with ZAddParser

use of org.apache.rocketmq.connect.redis.parser.ZAddParser in project rocketmq-externals by apache.

the class ParserTest method testZAddParser2.

@Test
public void testZAddParser2() {
    // ZADD key [NX|XX] [CH] [INCR] score member [score member ...]
    String command = "ZADD key NX CH INCR 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"));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_NX));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_CH));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_INCR));
}
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)

Example 2 with ZAddParser

use of org.apache.rocketmq.connect.redis.parser.ZAddParser in project rocketmq-externals by apache.

the class ParserTest method testZAddParser3.

@Test
public void testZAddParser3() {
    // ZADD key [NX|XX] [CH] [INCR] score member [score member ...]
    String command = "ZADD key XX CH INCR 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"));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_XX));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_CH));
    Assert.assertEquals(true, builder.getParam(Options.REDIS_INCR));
}
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)

Example 3 with ZAddParser

use of org.apache.rocketmq.connect.redis.parser.ZAddParser 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

Map (java.util.Map)3 ZAddParser (org.apache.rocketmq.connect.redis.parser.ZAddParser)3 KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)3 Test (org.junit.Test)3