use of doitincloud.rdbcache.supports.KvPairs in project rdbcache by rdbcache.
the class KvPairsTest method getPair.
@Test
public void getPair() {
KvPairs pairs;
KvPair pair;
pairs = new KvPairs();
pair = pairs.getPair();
assertNull(pair);
pair = new KvPair("key", "data", "value");
pairs = new KvPairs(pair);
assertTrue(pair == pairs.get(0));
KvPair pair2 = pairs.getPair();
assertNotNull(pair2);
assertTrue(pair == pair2);
}
use of doitincloud.rdbcache.supports.KvPairs in project rdbcache by rdbcache.
the class KvPairsTest method listConstructor1.
@Test
public void listConstructor1() {
List<String> list = new ArrayList<>();
list.add("key0");
list.add("key1");
list.add("key2");
KvPairs pairs = new KvPairs(list);
assertEquals(3, pairs.size());
assertEquals(list, pairs.getKeys());
}
use of doitincloud.rdbcache.supports.KvPairs in project rdbcache by rdbcache.
the class KvPairsTest method listConstructor2.
@Test
public void listConstructor2() {
List<Map<String, Object>> list = new ArrayList<>();
Map<String, Object> map = new LinkedHashMap<>();
map.put("k00", Utils.toMap("{\"kk00\": 0}"));
map.put("k01", Utils.toMap("{\"kk01\": 1}"));
map.put("k02", Utils.toMap("{\"kk02\": 2}"));
list.add(map);
map = new LinkedHashMap<>();
map.put("k10", Utils.toMap("{\"kk10\": 0}"));
map.put("k11", Utils.toMap("{\"kk11\": 1}"));
map.put("k12", Utils.toMap("{\"kk12\": 2}"));
list.add(map);
map = new LinkedHashMap<>();
map.put("k20", Utils.toMap("{\"kk20\": 0}"));
map.put("k21", Utils.toMap("{\"kk21\": 1}"));
map.put("k22", Utils.toMap("{\"kk22\": 2}"));
list.add(map);
KvPairs pairs = new KvPairs(list);
assertEquals(3, pairs.size());
for (int i = 0; i < 3; i++) {
KvPair pair = pairs.get(i);
map = pair.getData();
assertTrue(pair.isNewUuid());
assertEquals(3, map.size());
}
}
use of doitincloud.rdbcache.supports.KvPairs in project rdbcache by rdbcache.
the class KvPairsTest method getKeys.
@Test
public void getKeys() {
KvPairs pairs;
KvPair pair;
pairs = new KvPairs();
for (int i = 0; i < 10; i++) {
pairs.add(new KvPair("key" + i, "data", "value" + i));
}
List<String> keys = pairs.getKeys();
for (int i = 0; i < 10; i++) {
assertEquals("key" + i, keys.get(i));
}
}
Aggregations