Search in sources :

Example 41 with KvPairs

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);
}
Also used : KvPair(doitincloud.rdbcache.models.KvPair) KvPairs(doitincloud.rdbcache.supports.KvPairs) Test(org.junit.Test)

Example 42 with KvPairs

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());
}
Also used : ArrayList(java.util.ArrayList) KvPairs(doitincloud.rdbcache.supports.KvPairs) Test(org.junit.Test)

Example 43 with KvPairs

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());
    }
}
Also used : KvPair(doitincloud.rdbcache.models.KvPair) ArrayList(java.util.ArrayList) KvPairs(doitincloud.rdbcache.supports.KvPairs) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 44 with KvPairs

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));
    }
}
Also used : KvPair(doitincloud.rdbcache.models.KvPair) KvPairs(doitincloud.rdbcache.supports.KvPairs) Test(org.junit.Test)

Aggregations

KvPairs (doitincloud.rdbcache.supports.KvPairs)44 AnyKey (doitincloud.rdbcache.supports.AnyKey)32 Context (doitincloud.rdbcache.supports.Context)25 KvPair (doitincloud.rdbcache.models.KvPair)22 KeyInfo (doitincloud.rdbcache.models.KeyInfo)17 BadRequestException (doitincloud.commons.exceptions.BadRequestException)14 Test (org.junit.Test)13 NotFoundException (doitincloud.commons.exceptions.NotFoundException)4 ServerErrorException (doitincloud.commons.exceptions.ServerErrorException)4 StopWatch (doitincloud.rdbcache.models.StopWatch)3 KvIdType (doitincloud.rdbcache.models.KvIdType)2 QueryInfo (doitincloud.rdbcache.queries.QueryInfo)2 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 MockServletContext (org.springframework.mock.web.MockServletContext)2 Query (doitincloud.rdbcache.queries.Query)1 ExpireDbOps (doitincloud.rdbcache.supports.ExpireDbOps)1 Connection (java.sql.Connection)1