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

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


        final String key = "foo:bar";
        final Set<String> valueKeys = new LinkedHashSet<String>(Arrays.asList("foo", "bar", "baz"));
        final long size = valueKeys.size();
        final int offset = valueKeys.size() + 1;
        final int count = valueKeys.size();
        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));
        }});
        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("789");
        final long size = valueKeys.size();
        final int offset = valueKeys.size() - 1;
        final int count = valueKeys.size();
        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, "baz"); 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

    @Test
    public void testDoWork_HandleList() 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.LIST.toString()));
            oneOf(jedis).llen(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.LIST, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

        final String key = "foo:bar";
        final List<String> value = 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.LIST.toString()));
            oneOf(jedis).llen(key); will(returnValue(size));
            oneOf(jedis).lrange(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.LIST, keyInfo.getType());
        Assert.assertEquals((Long) size, keyInfo.getSize());
View Full Code Here

    }

    @Test
    public void testDoWork_Unkonwn() throws Exception {
        final String key = "foo:bar";
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue("?"));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNull(keyInfo);
    }
View Full Code Here

    }

    @Test
    public void testDoWork_None() throws Exception {
        final String key = "foo:bar";
        final KeyDAOPoolWork work = new KeyDAOPoolWork(key);
        this.mockCtx.checking(new Expectations(){{
            oneOf(jedis).type(key); will(returnValue(KeyType.NONE.toString()));
        }});
        final KeyInfo keyInfo = work.doWork(this.jedis);
        Assert.assertNull(keyInfo);
    }
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.