use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class ParserTest method testSetParser4.
@Test
public void testSetParser4() {
String command = "set key value PX 100 XX";
KVEntry builder = new SetParser().parse(parseCommand(command));
Assert.assertEquals("set", builder.getCommand());
Assert.assertEquals("key", builder.getKey());
Assert.assertEquals("value", builder.getValue());
Assert.assertTrue(100L == builder.getParam(Options.REDIS_PX));
Assert.assertEquals(true, builder.getParam(Options.REDIS_XX));
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class ParserTest method testXGroupParser.
@Test
public void testXGroupParser() {
String command = "XGroup [CREATE key groupname id-or-$] [SETID key id-or-$] [DESTROY key groupname] [DELCONSUMER key groupname consumername]";
KVEntry builder = new XGroupParser().parse(parseCommand(command));
Assert.assertEquals("XGroup", builder.getCommand());
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class KVEntryTest method testConstruct.
@Test
public void testConstruct() {
KVEntry entry = new RedisEntry(FieldType.STRING);
entry.value("value");
Assert.assertEquals(String.class, entry.getValue().getClass());
entry = new RedisEntry("partition", FieldType.ARRAY);
entry.value(new ArrayList<>());
Assert.assertEquals(ArrayList.class, entry.getValue().getClass());
Assert.assertEquals("partition", entry.getPartition());
entry = RedisEntry.newEntry(FieldType.MAP);
entry.value(new HashMap());
Assert.assertEquals(HashMap.class, entry.getValue().getClass());
entry = RedisEntry.newEntry("partition", FieldType.INT64);
entry.value(123L);
Assert.assertEquals(Long.class, entry.getValue().getClass());
Assert.assertTrue(123L == (long) entry.getValue());
Assert.assertEquals("partition", entry.getPartition());
Assert.assertNotNull(entry.toString());
List<SourceDataEntry> entries = getConverter().kVEntryToDataEntries(entry);
Assert.assertNotNull(entries);
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class ProcessorTest method testHandler.
@Test
public void testHandler() throws Exception {
processor = getProcessor();
DefaultRedisEventProcessor defaultRedisEventProcessor = (DefaultRedisEventProcessor) processor;
RedisEvent event = new RedisEvent();
event.setEvent(getKeyValuePair());
event.setReplOffset(123L);
event.setStreamDB(0);
event.setReplId("asdfsdfa");
defaultRedisEventProcessor.commit(event);
KVEntry res = null;
try {
res = defaultRedisEventProcessor.poll();
} catch (Exception e) {
e.printStackTrace();
}
Assert.assertNotNull(res);
event.setEvent(getKVCommandPair());
defaultRedisEventProcessor.commit(event);
try {
res = defaultRedisEventProcessor.poll();
} catch (Exception e) {
e.printStackTrace();
}
Assert.assertNotNull(res);
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class RedisEntryConverterTest method getArrayKVEntry.
private KVEntry getArrayKVEntry(int size) {
KVEntry entry = new RedisEntry(FieldType.ARRAY);
List<String> values = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
values.add(Integer.toString(i));
}
return entry.key("key").value(values).command("set").sourceId("replId").offset(6000L);
}
Aggregations