Package org.springframework.data.redis.connection

Examples of org.springframework.data.redis.connection.DefaultSortParameters


*/
public abstract class QueryUtils {

  public static <K> SortParameters convertQuery(SortQuery<K> query, RedisSerializer<String> stringSerializer) {

    return new DefaultSortParameters(stringSerializer.serialize(query.getBy()), query.getLimit(), serialize(
        query.getGetPattern(), stringSerializer), query.getOrder(), query.isAlphabetic());
  }
View Full Code Here


  public void testSort() {
    connection.rPush("sortlist", "foo");
    connection.rPush("sortlist", "bar");
    connection.rPush("sortlist", "baz");
    assertEquals(Arrays.asList(new String[] { "bar", "baz", "foo" }),
        connection.sort("sortlist", new DefaultSortParameters(null, Order.ASC, true)));
  }
View Full Code Here

  public void testSortStore() {
    connection.rPush("sortlist", "foo");
    connection.rPush("sortlist", "bar");
    connection.rPush("sortlist", "baz");
    assertEquals(Long.valueOf(3),
        connection.sort("sortlist", new DefaultSortParameters(null, Order.ASC, true), "newlist"));
    assertEquals(Arrays.asList(new String[] { "bar", "baz", "foo" }), connection.lRange("newlist", 0, 9));
  }
View Full Code Here

@SuppressWarnings("deprecation")
public class SrpUtilsTests {

  @Test
  public void testSortParamsWithAllParams() {
    SortParameters sortParams = new DefaultSortParameters().alpha().asc().by("weight_*".getBytes())
        .get("object_*".getBytes()).limit(0, 5);
    Object[] sort = SrpUtils.sortParams(sortParams, "foo".getBytes());
    assertArrayEquals(
        new String[] { "BY", "weight_*", "LIMIT 0 5", "GET", "object_*", "ASC", "ALPHA", "STORE", "foo" },
        convertByteArrays(sort));
View Full Code Here

        convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyBy() {
    SortParameters sortParams = new DefaultSortParameters().numeric().by("weight_*".getBytes());
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "BY", "weight_*" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "BY", "weight_*" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyLimit() {
    SortParameters sortParams = new DefaultSortParameters().numeric().limit(0, 5);
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "LIMIT 0 5" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "LIMIT 0 5" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyGetPatterns() {
    SortParameters sortParams = new DefaultSortParameters().numeric().get("foo".getBytes()).get("bar".getBytes());
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "GET", "foo", "GET", "bar" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "GET", "foo", "GET", "bar" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyOrder() {
    SortParameters sortParams = new DefaultSortParameters().numeric().desc();
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "DESC" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "DESC" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyAlpha() {
    SortParameters sortParams = new DefaultSortParameters().alpha();
    Object[] sort = SrpUtils.sortParams(sortParams);
    assertArrayEquals(new String[] { "ALPHA" }, convertByteArrays(sort));
  }
View Full Code Here

    assertArrayEquals(new String[] { "ALPHA" }, convertByteArrays(sort));
  }

  @Test
  public void testSortParamsOnlyStore() {
    SortParameters sortParams = new DefaultSortParameters().numeric();
    Object[] sort = SrpUtils.sortParams(sortParams, "storelist".getBytes());
    assertArrayEquals(new String[] { "STORE", "storelist" }, convertByteArrays(sort));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.redis.connection.DefaultSortParameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.