package benjamin.groehbiel.ch;

import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertNotNull;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ApplicationTest.class)
public class JedisTest {

    @Autowired
    private JedisConnectionFactory jedisConnectionFactory;

    @Autowired
    private StringRedisTemplate redisTemplate;

    @After
    public void tearDown() {
        redisTemplate.getConnectionFactory().getConnection().flushDb();
    }

    @Test
    public void testJedisConnectionFactory() {
        assertNotNull(jedisConnectionFactory);
    }

    @Test
    public void testRedisTemplate() {
        assertNotNull(redisTemplate);
    }

    @Test
    public void addEntry() {
        Long index = redisTemplate.opsForList().rightPush("ben", "grohbiel");
        assertThat(index, equalTo(1L));
    }

    @Test
    public void getEntry() {
        redisTemplate.opsForList().rightPush("ben", "grohbiel");
        String s = redisTemplate.opsForValue().get("ben");
        Assert.assertThat(s, equalTo("grohbiel"));
    }

}

@@ -1309,39 +1309,36 @@
 .rightPush(%22
-ben
+key
 %22, %22
-grohbiel
+value
 %22);%0A        
@@ -1380,227 +1380,6 @@
  %7D%0A%0A
-    @Test%0A    public void getEntry() %7B%0A        redisTemplate.opsForList().rightPush(%22ben%22, %22grohbiel%22);%0A        String s = redisTemplate.opsForValue().get(%22ben%22);%0A        Assert.assertThat(s, equalTo(%22grohbiel%22));%0A    %7D%0A%0A
 %7D%0A

Add value to key-value store