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("key", "value");
        assertThat(index, equalTo(1L));
    }

}

@@ -1244,16 +1244,22 @@
 void add
+AndGet
 Entry() 
@@ -1271,21 +1271,8 @@
     
- Long index =
  red
@@ -1292,24 +1292,19 @@
 sFor
-List().rightPush
+Value().set
 (%22ke
@@ -1321,24 +1321,94 @@
 %22);%0A        
+String value = redisTemplate.opsForValue().get(%22key%22);%0A        Assert.
 assertThat(i
@@ -1410,13 +1410,13 @@
 hat(
-index
+value
 , eq
@@ -1425,10 +1425,15 @@
 lTo(
-1L
+%22value%22
 ));%0A
@@ -1438,11 +1438,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

add and get value