use of org.apache.rocketmq.connect.redis.pojo.KVEntry 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.pojo.KVEntry 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.pojo.KVEntry in project rocketmq-externals by apache.
the class RedisEventHandlerTest method testZSet2.
@Test
public void testZSet2() {
KVEntry builder = handlerTest(RDB_TYPE_ZSET_2, () -> {
Set<ZSetEntry> values = new HashSet<>();
values.add(new ZSetEntry("key1".getBytes(), 100));
values.add(new ZSetEntry("key2".getBytes(), 80));
return values;
});
Map<String, Double> va = (Map<String, Double>) builder.getValue();
Assert.assertNotNull(va);
Assert.assertEquals(2, va.size());
Assert.assertTrue(100 == va.get("key1"));
Assert.assertTrue(80 == va.get("key2"));
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class RedisEventHandlerTest method testListQuickList.
@Test
public void testListQuickList() {
KVEntry builder = handlerTest(RDB_TYPE_LIST_QUICKLIST, () -> {
List<byte[]> values = new ArrayList<>();
values.add("v1".getBytes());
values.add("v2".getBytes());
return values;
});
List<String> va = (List<String>) builder.getValue();
Assert.assertNotNull(va);
Assert.assertEquals(2, va.size());
Assert.assertEquals("v1", va.get(0));
Assert.assertEquals("v2", va.get(1));
}
use of org.apache.rocketmq.connect.redis.pojo.KVEntry in project rocketmq-externals by apache.
the class RedisEventHandlerTest method testList.
@Test
public void testList() {
KVEntry builder = handlerTest(RDB_TYPE_LIST, () -> {
List<byte[]> values = new ArrayList<>();
values.add("a".getBytes());
return values;
});
List<String> va = (List) builder.getValue();
Assert.assertNotNull(va);
Assert.assertEquals(1, va.size());
Assert.assertEquals("a", va.get(0));
}
Aggregations