DATAREDIS-288 - Improved support for collection parameters in ListOperations.
Added additional leftPushAll and rightPushAll method overloads that accept a Collection parameter. Previously we only accepted varargs which required users to convert collections to arrays. Based on David Liu's pull request: #100. Original pull request: #114.
This commit is contained in:
committed by
Christoph Strobl
parent
cf46d6e766
commit
d89773387a
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,11 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.redis.core;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.springframework.data.redis.matcher.RedisTestMatchers.isEqual;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.springframework.data.redis.matcher.RedisTestMatchers.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -39,6 +37,7 @@ import org.springframework.data.redis.connection.RedisConnection;
|
||||
* Integration test of {@link DefaultListOperations}
|
||||
*
|
||||
* @author Jennifer Hickey
|
||||
* @author Thomas Darimont
|
||||
* @param <K> Key test
|
||||
* @param <V> Value test
|
||||
*/
|
||||
@@ -174,4 +173,40 @@ public class DefaultListOperationsTests<K, V> {
|
||||
assertEquals(Long.valueOf(3), listOps.rightPush(key, v3));
|
||||
assertThat(listOps.range(key, 0, -1), isEqual(Arrays.asList(new Object[] { v1, v2, v3 })));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-288
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("all")
|
||||
// get rid of varargs warning
|
||||
public void testRightPushAllCollection() {
|
||||
|
||||
K key = keyFactory.instance();
|
||||
|
||||
V v1 = valueFactory.instance();
|
||||
V v2 = valueFactory.instance();
|
||||
V v3 = valueFactory.instance();
|
||||
|
||||
assertEquals(Long.valueOf(3), listOps.rightPushAll(key, Arrays.<V> asList(v1, v2, v3)));
|
||||
assertThat(listOps.range(key, 0, -1), isEqual(Arrays.asList(new Object[] { v1, v2, v3 })));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-288
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("all")
|
||||
// get rid of varargs warning
|
||||
public void testLeftPushAllCollection() {
|
||||
|
||||
K key = keyFactory.instance();
|
||||
|
||||
V v1 = valueFactory.instance();
|
||||
V v2 = valueFactory.instance();
|
||||
V v3 = valueFactory.instance();
|
||||
|
||||
assertEquals(Long.valueOf(3), listOps.leftPushAll(key, Arrays.<V> asList(v1, v2, v3)));
|
||||
assertThat(listOps.range(key, 0, -1), isEqual(Arrays.asList(new Object[] { v3, v2, v1 })));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user