Search in sources :

Example 1 with ZInterStoreParser

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

the class ParserTest method testZInterStoreParser1.

@Test
public void testZInterStoreParser1() {
    // ZINTERSTORE destination numkeys key [key ...] [weights weight] [aggregate SUM|MIN|MAX]
    String command = "ZINTERSTORE destination 2 k1 k2 weights 100 80";
    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"));
}
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 2 with ZInterStoreParser

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

Aggregations

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