Search in sources :

Example 36 with AnyKey

use of doitincloud.rdbcache.supports.AnyKey in project rdbcache by rdbcache.

the class RequestTest method process1.

@Test
public void process1() {
    try {
        String key = "*";
        Optional<String> tableOpt = Optional.of("tb1");
        Optional<String> expireOpt = Optional.of("30");
        String queryString = "id=1";
        HttpServletRequest request = getRequest("get", key, null, tableOpt, expireOpt, queryString);
        Context context = new Context();
        AnyKey anyKey = Request.process(context, request, new KvPairs(key), tableOpt, expireOpt);
        assertEquals(1, anyKey.size());
        KeyInfo keyInfo = anyKey.getKeyInfo();
        assertTrue(keyInfo.getIsNew());
        assertEquals("KeyInfo(true, tb1, 30, {id: {=: [1]}})", keyInfo.toString());
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getCause().getMessage());
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Context(doitincloud.rdbcache.supports.Context) MockServletContext(org.springframework.mock.web.MockServletContext) AnyKey(doitincloud.rdbcache.supports.AnyKey) KeyInfo(doitincloud.rdbcache.models.KeyInfo) KvPairs(doitincloud.rdbcache.supports.KvPairs) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

AnyKey (doitincloud.rdbcache.supports.AnyKey)36 KvPairs (doitincloud.rdbcache.supports.KvPairs)32 Context (doitincloud.rdbcache.supports.Context)23 KeyInfo (doitincloud.rdbcache.models.KeyInfo)21 KvPair (doitincloud.rdbcache.models.KvPair)14 BadRequestException (doitincloud.commons.exceptions.BadRequestException)12 Test (org.junit.Test)9 NotFoundException (doitincloud.commons.exceptions.NotFoundException)4 ServerErrorException (doitincloud.commons.exceptions.ServerErrorException)4 StopWatch (doitincloud.rdbcache.models.StopWatch)2 QueryInfo (doitincloud.rdbcache.queries.QueryInfo)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 CacheOps (doitincloud.rdbcache.services.CacheOps)1 ExpireDbOps (doitincloud.rdbcache.supports.ExpireDbOps)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 SQLException (java.sql.SQLException)1