From 23c7c7d84455836d3221765174e8386ba3ebeff6 Mon Sep 17 00:00:00 2001 From: Guillermo Casanova Date: Thu, 23 Jun 2016 02:26:55 +0200 Subject: [PATCH 1/5] New redis module We have created this module to work with Redis Java libraries Jedis tested so far --- pom.xml | 1 + redis/pom.xml | 41 ++++ .../src/test/java/com/baeldung/JedisTest.java | 225 ++++++++++++++++++ 3 files changed, 267 insertions(+) create mode 100644 redis/pom.xml create mode 100644 redis/src/test/java/com/baeldung/JedisTest.java diff --git a/pom.xml b/pom.xml index f16861cc68..00967e2c35 100644 --- a/pom.xml +++ b/pom.xml @@ -71,6 +71,7 @@ xml lombok + redis diff --git a/redis/pom.xml b/redis/pom.xml new file mode 100644 index 0000000000..98775b7e13 --- /dev/null +++ b/redis/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + com.baeldung + redis + 0.1-SNAPSHOT + + redis + http://maven.apache.org + + + + redis.clients + jedis + 2.8.1 + + + + com.github.kstyrc + embedded-redis + 0.6 + + + + junit + junit + ${junit.version} + test + + + + + UTF-8 + + + 4.12 + + diff --git a/redis/src/test/java/com/baeldung/JedisTest.java b/redis/src/test/java/com/baeldung/JedisTest.java new file mode 100644 index 0000000000..cba99a1e73 --- /dev/null +++ b/redis/src/test/java/com/baeldung/JedisTest.java @@ -0,0 +1,225 @@ +package com.baeldung; + +import java.io.IOException; +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; +import redis.clients.jedis.Pipeline; +import redis.clients.jedis.Response; +import redis.clients.jedis.Transaction; +import redis.embedded.RedisServer; + +/** + * Unit test for Redis Java library - Jedis. + */ +public class JedisTest { + + private Jedis jedis; + private static RedisServer redisServer; + + public JedisTest() { + jedis = new Jedis(); + } + + @BeforeClass + public static void setUp() throws IOException { + redisServer = new RedisServer(6379); + redisServer.start(); + } + + @AfterClass + public static void destroy() { + redisServer.stop(); + } + + @After + public void flush() { + jedis.flushAll(); + } + + @Test + public void givenAStringThenSaveItAsRedisStrings() { + String key = "key"; + String value = "value"; + + jedis.set(key, value); + String value2 = jedis.get(key); + + Assert.assertEquals(value, value2); + } + + @Test + public void givenListElementsThenSaveThemInRedisList() { + String queue = "queue#tasks"; + + String taskOne = "firstTask"; + String taskTwo = "secondTask"; + String taskThree = "thirdTask"; + + jedis.lpush(queue, taskOne, taskTwo); + + String taskReturnedOne = jedis.rpop(queue); + + jedis.lpush(queue, taskThree); + Assert.assertEquals(taskOne, taskReturnedOne); + + String taskReturnedTwo = jedis.rpop(queue); + String taskReturnedThree = jedis.rpop(queue); + + Assert.assertEquals(taskTwo, taskReturnedTwo); + Assert.assertEquals(taskThree, taskReturnedThree); + + String taskReturnedFour = jedis.rpop(queue); + Assert.assertNull(taskReturnedFour); + } + + @Test + public void givenSetElementsThenSaveThemInRedisSet() { + String countries = "countries"; + + String countryOne = "Spain"; + String countryTwo = "Ireland"; + String countryThree = "Ireland"; + + jedis.sadd(countries, countryOne); + + Set countriesSet = jedis.smembers(countries); + Assert.assertEquals(1, countriesSet.size()); + + jedis.sadd(countries, countryTwo); + countriesSet = jedis.smembers(countries); + Assert.assertEquals(2, countriesSet.size()); + + jedis.sadd(countries, countryThree); + countriesSet = jedis.smembers(countries); + Assert.assertEquals(2, countriesSet.size()); + + boolean exists = jedis.sismember(countries, countryThree); + Assert.assertTrue(exists); + } + + @Test + public void givenObjectFieldsThenSaveThemInRedisHash() { + String key = "user#1"; + + String field = "name"; + String value = "William"; + + String field2 = "job"; + String value2 = "politician"; + + jedis.hset(key, field, value); + jedis.hset(key, field2, value2); + + String value3 = jedis.hget(key, field); + Assert.assertEquals(value, value3); + + Map fields = jedis.hgetAll(key); + String value4 = fields.get(field2); + Assert.assertEquals(value2, value4); + } + + @Test + public void givenARankingThenSaveItInRedisSortedSet() { + String key = "ranking"; + + Map scores = new HashMap<>(); + + scores.put("PlayerOne", 3000.0); + scores.put("PlayerTwo", 1500.0); + scores.put("PlayerThree", 8200.0); + + for (String player : scores.keySet()) { + jedis.zadd(key, scores.get(player), player); + } + + Set players = jedis.zrevrange(key, 0, 1); + Assert.assertEquals("PlayerThree", players.iterator().next()); + + long rank = jedis.zrevrank(key, "PlayerOne"); + Assert.assertEquals(1, rank); + } + + @Test + public void givenMultipleOperationsThatNeedToBeExecutedAtomicallyThenWrapThemInATransaction() { + String friendsPrefix = "friends#"; + + String userOneId = "4352523"; + String userTwoId = "5552321"; + + Transaction t = jedis.multi(); + t.sadd(friendsPrefix + userOneId, userTwoId); + t.sadd(friendsPrefix + userTwoId, userOneId); + t.exec(); + + boolean exists = jedis.sismember(friendsPrefix + userOneId, userTwoId); + Assert.assertTrue(exists); + + exists = jedis.sismember(friendsPrefix + userTwoId, userOneId); + Assert.assertTrue(exists); + } + + @Test + public void givenMultipleIndependentOperationsWhenNetworkOptimizationIsImportantThenWrapThemInAPipeline() { + String userOneId = "4352523"; + String userTwoId = "4849888"; + + Pipeline p = jedis.pipelined(); + p.sadd("searched#" + userOneId, "paris"); + p.zadd("ranking", 126, userOneId); + p.zadd("ranking", 325, userTwoId); + Response pipeExists = p.sismember("searched#" + userOneId, "paris"); + Response> pipeRanking = p.zrange("ranking", 0, -1); + p.sync(); + + Assert.assertTrue(pipeExists.get()); + Assert.assertEquals(2, pipeRanking.get().size()); + } + + @Test + public void givenAPoolConfigurationThenCreateAJedisPool() { + final JedisPoolConfig poolConfig = buildPoolConfig(); + + try (JedisPool jedisPool = new JedisPool(poolConfig, "localhost"); + Jedis jedis = jedisPool.getResource()) { + + // do simple operation to verify that the Jedis resource is working properly + String key = "key"; + String value = "value"; + + jedis.set(key, value); + String value2 = jedis.get(key); + + Assert.assertEquals(value, value2); + + // flush Redis + jedis.flushAll(); + } + } + + private JedisPoolConfig buildPoolConfig() { + final JedisPoolConfig poolConfig = new JedisPoolConfig(); + poolConfig.setMaxTotal(128); + poolConfig.setMaxIdle(128); + poolConfig.setMinIdle(16); + poolConfig.setTestOnBorrow(true); + poolConfig.setTestOnReturn(true); + poolConfig.setTestWhileIdle(true); + poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis()); + poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis()); + poolConfig.setNumTestsPerEvictionRun(3); + poolConfig.setBlockWhenExhausted(true); + return poolConfig; + } +} From 8a8544947924dc9d1bc211ca13b228b11c92c72c Mon Sep 17 00:00:00 2001 From: Guillermo Casanova Date: Thu, 7 Jul 2016 20:33:37 +0200 Subject: [PATCH 2/5] Fix indentation formatting issue --- .../src/test/java/com/baeldung/JedisTest.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/redis/src/test/java/com/baeldung/JedisTest.java b/redis/src/test/java/com/baeldung/JedisTest.java index cba99a1e73..55fee95328 100644 --- a/redis/src/test/java/com/baeldung/JedisTest.java +++ b/redis/src/test/java/com/baeldung/JedisTest.java @@ -31,13 +31,13 @@ public class JedisTest { public JedisTest() { jedis = new Jedis(); } - + @BeforeClass public static void setUp() throws IOException { redisServer = new RedisServer(6379); redisServer.start(); } - + @AfterClass public static void destroy() { redisServer.stop(); @@ -186,15 +186,15 @@ public class JedisTest { Assert.assertTrue(pipeExists.get()); Assert.assertEquals(2, pipeRanking.get().size()); } - + @Test public void givenAPoolConfigurationThenCreateAJedisPool() { final JedisPoolConfig poolConfig = buildPoolConfig(); - - try (JedisPool jedisPool = new JedisPool(poolConfig, "localhost"); - Jedis jedis = jedisPool.getResource()) { - - // do simple operation to verify that the Jedis resource is working properly + + try (JedisPool jedisPool = new JedisPool(poolConfig, "localhost"); Jedis jedis = jedisPool.getResource()) { + + // do simple operation to verify that the Jedis resource is working + // properly String key = "key"; String value = "value"; @@ -202,24 +202,24 @@ public class JedisTest { String value2 = jedis.get(key); Assert.assertEquals(value, value2); - + // flush Redis jedis.flushAll(); } } - + private JedisPoolConfig buildPoolConfig() { - final JedisPoolConfig poolConfig = new JedisPoolConfig(); - poolConfig.setMaxTotal(128); - poolConfig.setMaxIdle(128); - poolConfig.setMinIdle(16); - poolConfig.setTestOnBorrow(true); - poolConfig.setTestOnReturn(true); - poolConfig.setTestWhileIdle(true); - poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis()); - poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis()); - poolConfig.setNumTestsPerEvictionRun(3); - poolConfig.setBlockWhenExhausted(true); - return poolConfig; - } + final JedisPoolConfig poolConfig = new JedisPoolConfig(); + poolConfig.setMaxTotal(128); + poolConfig.setMaxIdle(128); + poolConfig.setMinIdle(16); + poolConfig.setTestOnBorrow(true); + poolConfig.setTestOnReturn(true); + poolConfig.setTestWhileIdle(true); + poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis()); + poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis()); + poolConfig.setNumTestsPerEvictionRun(3); + poolConfig.setBlockWhenExhausted(true); + return poolConfig; + } } From f876a94fc53b0e01f8a98aa54c0ddf184c58cfc6 Mon Sep 17 00:00:00 2001 From: Guillermo Casanova Date: Fri, 8 Jul 2016 07:53:38 +0200 Subject: [PATCH 3/5] Declare java compiler version in pom.xml --- redis/pom.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/redis/pom.xml b/redis/pom.xml index 98775b7e13..ad073a66d0 100644 --- a/redis/pom.xml +++ b/redis/pom.xml @@ -32,6 +32,22 @@ + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + + + + + + UTF-8 From 40cb44a47ab3d00c170255e83b55dab77cc287f9 Mon Sep 17 00:00:00 2001 From: Guillermo Casanova Date: Sun, 10 Jul 2016 11:03:46 +0200 Subject: [PATCH 4/5] Imported and applied formatter --- .../src/test/java/com/baeldung/JedisTest.java | 296 +++++++++--------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/redis/src/test/java/com/baeldung/JedisTest.java b/redis/src/test/java/com/baeldung/JedisTest.java index 55fee95328..b8e29327a1 100644 --- a/redis/src/test/java/com/baeldung/JedisTest.java +++ b/redis/src/test/java/com/baeldung/JedisTest.java @@ -25,201 +25,201 @@ import redis.embedded.RedisServer; */ public class JedisTest { - private Jedis jedis; - private static RedisServer redisServer; + private Jedis jedis; + private static RedisServer redisServer; - public JedisTest() { - jedis = new Jedis(); - } + public JedisTest() { + jedis = new Jedis(); + } - @BeforeClass - public static void setUp() throws IOException { - redisServer = new RedisServer(6379); - redisServer.start(); - } + @BeforeClass + public static void setUp() throws IOException { + redisServer = new RedisServer(6379); + redisServer.start(); + } - @AfterClass - public static void destroy() { - redisServer.stop(); - } + @AfterClass + public static void destroy() { + redisServer.stop(); + } - @After - public void flush() { - jedis.flushAll(); - } + @After + public void flush() { + jedis.flushAll(); + } - @Test - public void givenAStringThenSaveItAsRedisStrings() { - String key = "key"; - String value = "value"; + @Test + public void givenAStringThenSaveItAsRedisStrings() { + String key = "key"; + String value = "value"; - jedis.set(key, value); - String value2 = jedis.get(key); + jedis.set(key, value); + String value2 = jedis.get(key); - Assert.assertEquals(value, value2); - } + Assert.assertEquals(value, value2); + } - @Test - public void givenListElementsThenSaveThemInRedisList() { - String queue = "queue#tasks"; + @Test + public void givenListElementsThenSaveThemInRedisList() { + String queue = "queue#tasks"; - String taskOne = "firstTask"; - String taskTwo = "secondTask"; - String taskThree = "thirdTask"; + String taskOne = "firstTask"; + String taskTwo = "secondTask"; + String taskThree = "thirdTask"; - jedis.lpush(queue, taskOne, taskTwo); + jedis.lpush(queue, taskOne, taskTwo); - String taskReturnedOne = jedis.rpop(queue); + String taskReturnedOne = jedis.rpop(queue); - jedis.lpush(queue, taskThree); - Assert.assertEquals(taskOne, taskReturnedOne); + jedis.lpush(queue, taskThree); + Assert.assertEquals(taskOne, taskReturnedOne); - String taskReturnedTwo = jedis.rpop(queue); - String taskReturnedThree = jedis.rpop(queue); + String taskReturnedTwo = jedis.rpop(queue); + String taskReturnedThree = jedis.rpop(queue); - Assert.assertEquals(taskTwo, taskReturnedTwo); - Assert.assertEquals(taskThree, taskReturnedThree); + Assert.assertEquals(taskTwo, taskReturnedTwo); + Assert.assertEquals(taskThree, taskReturnedThree); - String taskReturnedFour = jedis.rpop(queue); - Assert.assertNull(taskReturnedFour); - } + String taskReturnedFour = jedis.rpop(queue); + Assert.assertNull(taskReturnedFour); + } - @Test - public void givenSetElementsThenSaveThemInRedisSet() { - String countries = "countries"; + @Test + public void givenSetElementsThenSaveThemInRedisSet() { + String countries = "countries"; - String countryOne = "Spain"; - String countryTwo = "Ireland"; - String countryThree = "Ireland"; + String countryOne = "Spain"; + String countryTwo = "Ireland"; + String countryThree = "Ireland"; - jedis.sadd(countries, countryOne); + jedis.sadd(countries, countryOne); - Set countriesSet = jedis.smembers(countries); - Assert.assertEquals(1, countriesSet.size()); + Set countriesSet = jedis.smembers(countries); + Assert.assertEquals(1, countriesSet.size()); - jedis.sadd(countries, countryTwo); - countriesSet = jedis.smembers(countries); - Assert.assertEquals(2, countriesSet.size()); + jedis.sadd(countries, countryTwo); + countriesSet = jedis.smembers(countries); + Assert.assertEquals(2, countriesSet.size()); - jedis.sadd(countries, countryThree); - countriesSet = jedis.smembers(countries); - Assert.assertEquals(2, countriesSet.size()); + jedis.sadd(countries, countryThree); + countriesSet = jedis.smembers(countries); + Assert.assertEquals(2, countriesSet.size()); - boolean exists = jedis.sismember(countries, countryThree); - Assert.assertTrue(exists); - } + boolean exists = jedis.sismember(countries, countryThree); + Assert.assertTrue(exists); + } - @Test - public void givenObjectFieldsThenSaveThemInRedisHash() { - String key = "user#1"; + @Test + public void givenObjectFieldsThenSaveThemInRedisHash() { + String key = "user#1"; - String field = "name"; - String value = "William"; + String field = "name"; + String value = "William"; - String field2 = "job"; - String value2 = "politician"; + String field2 = "job"; + String value2 = "politician"; - jedis.hset(key, field, value); - jedis.hset(key, field2, value2); + jedis.hset(key, field, value); + jedis.hset(key, field2, value2); - String value3 = jedis.hget(key, field); - Assert.assertEquals(value, value3); + String value3 = jedis.hget(key, field); + Assert.assertEquals(value, value3); - Map fields = jedis.hgetAll(key); - String value4 = fields.get(field2); - Assert.assertEquals(value2, value4); - } + Map fields = jedis.hgetAll(key); + String value4 = fields.get(field2); + Assert.assertEquals(value2, value4); + } - @Test - public void givenARankingThenSaveItInRedisSortedSet() { - String key = "ranking"; + @Test + public void givenARankingThenSaveItInRedisSortedSet() { + String key = "ranking"; - Map scores = new HashMap<>(); + Map scores = new HashMap<>(); - scores.put("PlayerOne", 3000.0); - scores.put("PlayerTwo", 1500.0); - scores.put("PlayerThree", 8200.0); + scores.put("PlayerOne", 3000.0); + scores.put("PlayerTwo", 1500.0); + scores.put("PlayerThree", 8200.0); - for (String player : scores.keySet()) { - jedis.zadd(key, scores.get(player), player); - } + for (String player : scores.keySet()) { + jedis.zadd(key, scores.get(player), player); + } - Set players = jedis.zrevrange(key, 0, 1); - Assert.assertEquals("PlayerThree", players.iterator().next()); + Set players = jedis.zrevrange(key, 0, 1); + Assert.assertEquals("PlayerThree", players.iterator().next()); - long rank = jedis.zrevrank(key, "PlayerOne"); - Assert.assertEquals(1, rank); - } + long rank = jedis.zrevrank(key, "PlayerOne"); + Assert.assertEquals(1, rank); + } - @Test - public void givenMultipleOperationsThatNeedToBeExecutedAtomicallyThenWrapThemInATransaction() { - String friendsPrefix = "friends#"; + @Test + public void givenMultipleOperationsThatNeedToBeExecutedAtomicallyThenWrapThemInATransaction() { + String friendsPrefix = "friends#"; - String userOneId = "4352523"; - String userTwoId = "5552321"; + String userOneId = "4352523"; + String userTwoId = "5552321"; - Transaction t = jedis.multi(); - t.sadd(friendsPrefix + userOneId, userTwoId); - t.sadd(friendsPrefix + userTwoId, userOneId); - t.exec(); + Transaction t = jedis.multi(); + t.sadd(friendsPrefix + userOneId, userTwoId); + t.sadd(friendsPrefix + userTwoId, userOneId); + t.exec(); - boolean exists = jedis.sismember(friendsPrefix + userOneId, userTwoId); - Assert.assertTrue(exists); + boolean exists = jedis.sismember(friendsPrefix + userOneId, userTwoId); + Assert.assertTrue(exists); - exists = jedis.sismember(friendsPrefix + userTwoId, userOneId); - Assert.assertTrue(exists); - } + exists = jedis.sismember(friendsPrefix + userTwoId, userOneId); + Assert.assertTrue(exists); + } - @Test - public void givenMultipleIndependentOperationsWhenNetworkOptimizationIsImportantThenWrapThemInAPipeline() { - String userOneId = "4352523"; - String userTwoId = "4849888"; + @Test + public void givenMultipleIndependentOperationsWhenNetworkOptimizationIsImportantThenWrapThemInAPipeline() { + String userOneId = "4352523"; + String userTwoId = "4849888"; - Pipeline p = jedis.pipelined(); - p.sadd("searched#" + userOneId, "paris"); - p.zadd("ranking", 126, userOneId); - p.zadd("ranking", 325, userTwoId); - Response pipeExists = p.sismember("searched#" + userOneId, "paris"); - Response> pipeRanking = p.zrange("ranking", 0, -1); - p.sync(); + Pipeline p = jedis.pipelined(); + p.sadd("searched#" + userOneId, "paris"); + p.zadd("ranking", 126, userOneId); + p.zadd("ranking", 325, userTwoId); + Response pipeExists = p.sismember("searched#" + userOneId, "paris"); + Response> pipeRanking = p.zrange("ranking", 0, -1); + p.sync(); - Assert.assertTrue(pipeExists.get()); - Assert.assertEquals(2, pipeRanking.get().size()); - } + Assert.assertTrue(pipeExists.get()); + Assert.assertEquals(2, pipeRanking.get().size()); + } - @Test - public void givenAPoolConfigurationThenCreateAJedisPool() { - final JedisPoolConfig poolConfig = buildPoolConfig(); + @Test + public void givenAPoolConfigurationThenCreateAJedisPool() { + final JedisPoolConfig poolConfig = buildPoolConfig(); - try (JedisPool jedisPool = new JedisPool(poolConfig, "localhost"); Jedis jedis = jedisPool.getResource()) { + try (JedisPool jedisPool = new JedisPool(poolConfig, "localhost"); Jedis jedis = jedisPool.getResource()) { - // do simple operation to verify that the Jedis resource is working - // properly - String key = "key"; - String value = "value"; + // do simple operation to verify that the Jedis resource is working + // properly + String key = "key"; + String value = "value"; - jedis.set(key, value); - String value2 = jedis.get(key); + jedis.set(key, value); + String value2 = jedis.get(key); - Assert.assertEquals(value, value2); + Assert.assertEquals(value, value2); - // flush Redis - jedis.flushAll(); - } - } + // flush Redis + jedis.flushAll(); + } + } - private JedisPoolConfig buildPoolConfig() { - final JedisPoolConfig poolConfig = new JedisPoolConfig(); - poolConfig.setMaxTotal(128); - poolConfig.setMaxIdle(128); - poolConfig.setMinIdle(16); - poolConfig.setTestOnBorrow(true); - poolConfig.setTestOnReturn(true); - poolConfig.setTestWhileIdle(true); - poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis()); - poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis()); - poolConfig.setNumTestsPerEvictionRun(3); - poolConfig.setBlockWhenExhausted(true); - return poolConfig; - } + private JedisPoolConfig buildPoolConfig() { + final JedisPoolConfig poolConfig = new JedisPoolConfig(); + poolConfig.setMaxTotal(128); + poolConfig.setMaxIdle(128); + poolConfig.setMinIdle(16); + poolConfig.setTestOnBorrow(true); + poolConfig.setTestOnReturn(true); + poolConfig.setTestWhileIdle(true); + poolConfig.setMinEvictableIdleTimeMillis(Duration.ofSeconds(60).toMillis()); + poolConfig.setTimeBetweenEvictionRunsMillis(Duration.ofSeconds(30).toMillis()); + poolConfig.setNumTestsPerEvictionRun(3); + poolConfig.setBlockWhenExhausted(true); + return poolConfig; + } } From d9747e5c6da6772947144419beba993956685aeb Mon Sep 17 00:00:00 2001 From: Guillermo Casanova Date: Tue, 12 Jul 2016 03:18:13 +0200 Subject: [PATCH 5/5] Rename test methods including underscores --- redis/src/test/java/com/baeldung/JedisTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/redis/src/test/java/com/baeldung/JedisTest.java b/redis/src/test/java/com/baeldung/JedisTest.java index b8e29327a1..766fd7b5e9 100644 --- a/redis/src/test/java/com/baeldung/JedisTest.java +++ b/redis/src/test/java/com/baeldung/JedisTest.java @@ -49,7 +49,7 @@ public class JedisTest { } @Test - public void givenAStringThenSaveItAsRedisStrings() { + public void givenAString_thenSaveItAsRedisStrings() { String key = "key"; String value = "value"; @@ -60,7 +60,7 @@ public class JedisTest { } @Test - public void givenListElementsThenSaveThemInRedisList() { + public void givenListElements_thenSaveThemInRedisList() { String queue = "queue#tasks"; String taskOne = "firstTask"; @@ -85,7 +85,7 @@ public class JedisTest { } @Test - public void givenSetElementsThenSaveThemInRedisSet() { + public void givenSetElements_thenSaveThemInRedisSet() { String countries = "countries"; String countryOne = "Spain"; @@ -110,7 +110,7 @@ public class JedisTest { } @Test - public void givenObjectFieldsThenSaveThemInRedisHash() { + public void givenObjectFields_thenSaveThemInRedisHash() { String key = "user#1"; String field = "name"; @@ -131,7 +131,7 @@ public class JedisTest { } @Test - public void givenARankingThenSaveItInRedisSortedSet() { + public void givenARanking_thenSaveItInRedisSortedSet() { String key = "ranking"; Map scores = new HashMap<>(); @@ -152,7 +152,7 @@ public class JedisTest { } @Test - public void givenMultipleOperationsThatNeedToBeExecutedAtomicallyThenWrapThemInATransaction() { + public void givenMultipleOperationsThatNeedToBeExecutedAtomically_thenWrapThemInATransaction() { String friendsPrefix = "friends#"; String userOneId = "4352523"; @@ -171,7 +171,7 @@ public class JedisTest { } @Test - public void givenMultipleIndependentOperationsWhenNetworkOptimizationIsImportantThenWrapThemInAPipeline() { + public void givenMultipleIndependentOperations_whenNetworkOptimizationIsImportant_thenWrapThemInAPipeline() { String userOneId = "4352523"; String userTwoId = "4849888"; @@ -188,7 +188,7 @@ public class JedisTest { } @Test - public void givenAPoolConfigurationThenCreateAJedisPool() { + public void givenAPoolConfiguration_thenCreateAJedisPool() { final JedisPoolConfig poolConfig = buildPoolConfig(); try (JedisPool jedisPool = new JedisPool(poolConfig, "localhost"); Jedis jedis = jedisPool.getResource()) {