Search in sources :

Example 1 with KVEntryConverter

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());
}
Also used : RedisEntryConverter(org.apache.rocketmq.connect.redis.converter.RedisEntryConverter) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) KVEntryConverter(org.apache.rocketmq.connect.redis.converter.KVEntryConverter) Collection(java.util.Collection) Test(org.junit.Test)

Example 2 with KVEntryConverter

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()));
}
Also used : RedisEntryConverter(org.apache.rocketmq.connect.redis.converter.RedisEntryConverter) KVEntry(org.apache.rocketmq.connect.redis.pojo.KVEntry) SourceDataEntry(io.openmessaging.connector.api.data.SourceDataEntry) KVEntryConverter(org.apache.rocketmq.connect.redis.converter.KVEntryConverter) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 3 with KVEntryConverter

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]);
}
Also used : RedisEntry(org.apache.rocketmq.connect.redis.pojo.RedisEntry) RedisEntryConverter(org.apache.rocketmq.connect.redis.converter.RedisEntryConverter) SourceDataEntry(io.openmessaging.connector.api.data.SourceDataEntry) KVEntryConverter(org.apache.rocketmq.connect.redis.converter.KVEntryConverter) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

KVEntryConverter (org.apache.rocketmq.connect.redis.converter.KVEntryConverter)3 RedisEntryConverter (org.apache.rocketmq.connect.redis.converter.RedisEntryConverter)3 Test (org.junit.Test)3 SourceDataEntry (io.openmessaging.connector.api.data.SourceDataEntry)2 HashMap (java.util.HashMap)2 KVEntry (org.apache.rocketmq.connect.redis.pojo.KVEntry)2 Collection (java.util.Collection)1 Map (java.util.Map)1 RedisEntry (org.apache.rocketmq.connect.redis.pojo.RedisEntry)1