Implemented by SORT parameter
This commit is contained in:
@@ -45,6 +45,29 @@ public class SortingCommandsTest extends Assert {
|
|||||||
assertEquals(expected, result);
|
assertEquals(expected, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void sortBy() throws JedisException {
|
||||||
|
jedis.lpush("foo", "2");
|
||||||
|
jedis.lpush("foo", "3");
|
||||||
|
jedis.lpush("foo", "1");
|
||||||
|
|
||||||
|
jedis.set("bar1", "3");
|
||||||
|
jedis.set("bar2", "2");
|
||||||
|
jedis.set("bar3", "1");
|
||||||
|
|
||||||
|
SortingParams sp = new SortingParams();
|
||||||
|
sp.by("bar*");
|
||||||
|
|
||||||
|
List<String> result = jedis.sort("foo", sp);
|
||||||
|
|
||||||
|
List<String> expected = new ArrayList<String>();
|
||||||
|
expected.add("3");
|
||||||
|
expected.add("2");
|
||||||
|
expected.add("1");
|
||||||
|
|
||||||
|
assertEquals(expected, result);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sortDesc() throws JedisException {
|
public void sortDesc() throws JedisException {
|
||||||
jedis.lpush("foo", "3");
|
jedis.lpush("foo", "3");
|
||||||
|
|||||||
Reference in New Issue
Block a user