use of org.apache.rocketmq.connect.redis.converter.KVEntryConverter in project rocketmq-externals by apache.
the class RedisEntryConverterTest method testListSplit.
@Test
public void testListSplit() {
KVEntryConverter converter = new RedisEntryConverter();
KVEntry entry = getArrayKVEntry(999);
Collection res = converter.kVEntryToDataEntries(entry);
Assert.assertEquals(2, res.size());
KVEntry entry1 = getArrayKVEntry(1001);
Collection res1 = converter.kVEntryToDataEntries(entry1);
Assert.assertEquals(3, res1.size());
KVEntry entry2 = getArrayKVEntry(1000);
Collection res2 = converter.kVEntryToDataEntries(entry2);
Assert.assertEquals(2, res2.size());
}
use of org.apache.rocketmq.connect.redis.converter.KVEntryConverter in project rocketmq-externals by apache.
the class RedisEntryConverterTest method test.
@Test
public void test() {
KVEntry entry = getKVEntry();
KVEntryConverter converter = new RedisEntryConverter();
Collection<SourceDataEntry> res = converter.kVEntryToDataEntries(entry);
Assert.assertNotNull(res);
Assert.assertEquals(1, res.size());
Assert.assertEquals("key", ((List<SourceDataEntry>) res).get(0).getPayload()[1]);
Assert.assertEquals("value", ((List<SourceDataEntry>) res).get(0).getPayload()[2]);
Assert.assertEquals("set", ((List<SourceDataEntry>) res).get(0).getPayload()[0]);
Map<String, Object> params = (Map<String, Object>) ((List<SourceDataEntry>) res).get(0).getPayload()[3];
Assert.assertEquals("replId", params.get(Options.REDIS_REPLID.name()));
}
use of org.apache.rocketmq.connect.redis.converter.KVEntryConverter in project rocketmq-externals by apache.
the class RedisEntryConverterTest method testMapSplit.
@Test
public void testMapSplit() {
KVEntryConverter converter = new RedisEntryConverter();
RedisEntry entry = RedisEntry.newEntry(FieldType.MAP);
entry.queueName("queue1");
entry.key("key");
entry.entryType(EntryType.UPDATE);
entry.offset(65535L);
entry.param(Options.REDIS_INCREMENT, 15L);
entry.sourceId("123");
entry.command("set");
Map<String, String> values = new HashMap<>();
int num = 10001;
for (int i = 0; i < num; i++) {
values.put("a" + i, Integer.toString(i));
}
entry.value(values);
List<SourceDataEntry> entryList = converter.kVEntryToDataEntries(entry);
Assert.assertNotNull(entryList);
Assert.assertEquals(21, entryList.size());
Assert.assertEquals("set", entryList.get(0).getPayload()[0]);
}
Aggregations