|
1 | 1 | package com.baeldung; |
2 | 2 |
|
| 3 | +import org.junit.*; |
| 4 | +import redis.clients.jedis.*; |
| 5 | +import redis.embedded.RedisServer; |
| 6 | + |
3 | 7 | import java.io.IOException; |
4 | 8 | import java.time.Duration; |
5 | 9 | import java.util.HashMap; |
6 | 10 | import java.util.Map; |
7 | 11 | import java.util.Set; |
8 | 12 |
|
9 | | -import org.junit.After; |
10 | | -import org.junit.AfterClass; |
11 | | -import org.junit.Assert; |
12 | | -import org.junit.BeforeClass; |
13 | | -import org.junit.Test; |
14 | | - |
15 | | -import redis.clients.jedis.Jedis; |
16 | | -import redis.clients.jedis.JedisPool; |
17 | | -import redis.clients.jedis.JedisPoolConfig; |
18 | | -import redis.clients.jedis.Pipeline; |
19 | | -import redis.clients.jedis.Response; |
20 | | -import redis.clients.jedis.Transaction; |
21 | | -import redis.embedded.RedisServer; |
22 | | - |
23 | | -/** |
24 | | - * Unit test for Redis Java library - Jedis. |
25 | | - */ |
26 | 13 | public class JedisTest { |
27 | 14 |
|
28 | 15 | private Jedis jedis; |
@@ -140,9 +127,9 @@ public void givenARanking_thenSaveItInRedisSortedSet() { |
140 | 127 | scores.put("PlayerTwo", 1500.0); |
141 | 128 | scores.put("PlayerThree", 8200.0); |
142 | 129 |
|
143 | | - for (String player : scores.keySet()) { |
| 130 | + scores.keySet().forEach(player -> { |
144 | 131 | jedis.zadd(key, scores.get(player), player); |
145 | | - } |
| 132 | + }); |
146 | 133 |
|
147 | 134 | Set<String> players = jedis.zrevrange(key, 0, 1); |
148 | 135 | Assert.assertEquals("PlayerThree", players.iterator().next()); |
|
0 commit comments