Package net.greghaines.jesque.meta.dao.impl.KeysDAORedisImpl

Examples of net.greghaines.jesque.meta.dao.impl.KeysDAORedisImpl.KeyDAOPoolWork


    @Test
    public void testDoWork_HandleString() throws Exception {
        final String key = "foo:bar";
        final String value = "bazqux";
        final long size = value.length();
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.STRING.toString()));
            oneOf(jedis).strlen(key); will(returnValue(size));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.STRING, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here


    @Test
    public void testDoWork_HandleString_ArrayValue() throws Exception {
        final String key = "foo:bar";
        final String value = "bazqux";
        final long size = value.length();
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key, 0, 1);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.STRING.toString()));
            oneOf(jedis).strlen(key); will(returnValue(size));
            oneOf(jedis).get(key); will(returnValue(value));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.STRING, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

    @Test
    public void testDoWork_HandleZSet() throws Exception {
        final String key = "foo:bar";
        final long size = 8;
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.ZSET.toString()));
            oneOf(jedis).zcard(key); will(returnValue(size));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.ZSET, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

        final String key = "foo:bar";
        final Set<String> value = new LinkedHashSet<String>(Arrays.asList("foo", "bar", "baz"));
        final long size = 8;
        final int offset = 1;
        final int count = value.size();
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key, offset, count);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.ZSET.toString()));
            oneOf(jedis).zcard(key); will(returnValue(size));
            oneOf(jedis).zrange(key, offset, offset + count); will(returnValue(value));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.ZSET, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

    @Test
    public void testDoWork_HandleSet() throws Exception {
        final String key = "foo:bar";
        final long size = 8;
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.SET.toString()));
            oneOf(jedis).scard(key); will(returnValue(size));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.SET, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

        final String key = "foo:bar";
        final Set<String> value = new LinkedHashSet<String>(Arrays.asList("foo", "bar", "baz"));
        final long size = value.size();
        final int offset = 0;
        final int count = 1;
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key, offset, count);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.SET.toString()));
            oneOf(jedis).scard(key); will(returnValue(size));
            oneOf(jedis).smembers(key); will(returnValue(value));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.SET, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

        final String key = "foo:bar";
        final Set<String> value = new LinkedHashSet<String>(Arrays.asList("foo", "bar", "baz"));
        final long size = value.size();
        final int offset = value.size() + 1;
        final int count = value.size();
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key, offset, count);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.SET.toString()));
            oneOf(jedis).scard(key); will(returnValue(size));
            oneOf(jedis).smembers(key); will(returnValue(value));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.SET, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

        final String key = "foo:bar";
        final Set<String> value = new LinkedHashSet<String>(Arrays.asList("foo", "bar", "baz"));
        final long size = value.size();
        final int offset = value.size() - 1;
        final int count = value.size();
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key, offset, count);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.SET.toString()));
            oneOf(jedis).scard(key); will(returnValue(size));
            oneOf(jedis).smembers(key); will(returnValue(value));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.SET, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

    @Test
    public void testDoWork_HandleHash() throws Exception {
        final String key = "foo:bar";
        final long size = 8;
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.HASH.toString()));
            oneOf(jedis).hlen(key); will(returnValue(size));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.HASH, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

        final Set<String> valueKeys = new LinkedHashSet<String>(Arrays.asList("foo", "bar", "baz"));
        final List<String> valueValues = Arrays.asList("123");
        final long size = valueKeys.size();
        final int offset = 0;
        final int count = 1;
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key, offset, count);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.HASH.toString()));
            oneOf(jedis).hlen(key); will(returnValue(size));
            oneOf(jedis).hkeys(key); will(returnValue(valueKeys));
            oneOf(jedis).hmget(key, "foo"); will(returnValue(valueValues));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNotNull(keyInfo);
        Assert.assertEquals("foo", keyInfo.getNamespace());
        Assert.assertEquals("bar", keyInfo.getName());
        Assert.assertEquals(KeyType.HASH, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

TOP

Related Classes of net.greghaines.jesque.meta.dao.impl.KeysDAORedisImpl.KeyDAOPoolWork

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.