Move Tuple, Limit, and Weights to top-level types.
See: #2273 Original Pull Request: #2276
This commit is contained in:
committed by
Christoph Strobl
parent
91cfbf5470
commit
b45d358abf
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014-2022 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.redis;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
class VersionParserUnitTests {
|
||||
|
||||
@Test
|
||||
void shouldParseNullToUnknown() {
|
||||
assertThat(VersionParser.parseVersion(null)).isEqualTo(Version.UNKNOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldParseEmptyVersionStringToUnknown() {
|
||||
assertThat(VersionParser.parseVersion("")).isEqualTo(Version.UNKNOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldParseInvalidVersionStringToUnknown() {
|
||||
assertThat(VersionParser.parseVersion("ThisIsNoValidVersion")).isEqualTo(Version.UNKNOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldParseMajorMinorWithoutPatchCorrectly() {
|
||||
assertThat(VersionParser.parseVersion("1.2")).isEqualTo(new Version(1, 2, 0));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldParseMajorMinorPatchCorrectly() {
|
||||
assertThat(VersionParser.parseVersion("1.2.3")).isEqualTo(new Version(1, 2, 3));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldParseMajorWithoutMinorPatchCorrectly() {
|
||||
assertThat(VersionParser.parseVersion("1.2.3.a")).isEqualTo(new Version(1, 2, 3));
|
||||
}
|
||||
}
|
||||
@@ -59,9 +59,7 @@ import org.springframework.data.redis.connection.RedisStreamCommands.XClaimOptio
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.BitOperation;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Range;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.ZAddArgs;
|
||||
import org.springframework.data.redis.connection.SortParameters.Order;
|
||||
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
|
||||
@@ -77,6 +75,8 @@ import org.springframework.data.redis.connection.stream.StreamInfo.XInfoGroups;
|
||||
import org.springframework.data.redis.connection.stream.StreamInfo.XInfoStream;
|
||||
import org.springframework.data.redis.connection.stream.StreamOffset;
|
||||
import org.springframework.data.redis.connection.stream.StringRecord;
|
||||
import org.springframework.data.redis.connection.zset.DefaultTuple;
|
||||
import org.springframework.data.redis.connection.zset.Tuple;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.KeyScanOptions;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
|
||||
@@ -50,9 +50,6 @@ import org.springframework.data.redis.connection.RedisServerCommands.ShutdownOpt
|
||||
import org.springframework.data.redis.connection.RedisStreamCommands.XAddOptions;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.BitOperation;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Weights;
|
||||
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
|
||||
import org.springframework.data.redis.connection.convert.Converters;
|
||||
import org.springframework.data.redis.connection.stream.Consumer;
|
||||
@@ -61,6 +58,9 @@ import org.springframework.data.redis.connection.stream.RecordId;
|
||||
import org.springframework.data.redis.connection.stream.StreamOffset;
|
||||
import org.springframework.data.redis.connection.stream.StreamReadOptions;
|
||||
import org.springframework.data.redis.connection.stream.StreamRecords;
|
||||
import org.springframework.data.redis.connection.zset.DefaultTuple;
|
||||
import org.springframework.data.redis.connection.zset.Tuple;
|
||||
import org.springframework.data.redis.connection.zset.Weights;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,8 @@ import org.springframework.data.geo.GeoResults;
|
||||
import org.springframework.data.geo.Metric;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.redis.connection.RedisNode.RedisNodeBuilder;
|
||||
import org.springframework.data.redis.connection.zset.Tuple;
|
||||
import org.springframework.data.redis.connection.zset.Weights;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
@@ -947,12 +949,13 @@ class RedisConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByLex(byte[] key, Range range, Limit limit) {
|
||||
public Set<byte[]> zRangeByLex(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
|
||||
return delegate.zRangeByLex(key, range, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range, Limit limit) {
|
||||
public Set<Tuple> zRangeByScoreWithScores(byte[] key, Range range,
|
||||
org.springframework.data.redis.connection.Limit limit) {
|
||||
return delegate.zRangeByScoreWithScores(key, range, limit);
|
||||
}
|
||||
|
||||
@@ -962,12 +965,14 @@ class RedisConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRevRangeByScore(byte[] key, Range range, Limit limit) {
|
||||
public Set<byte[]> zRevRangeByScore(byte[] key, Range range,
|
||||
org.springframework.data.redis.connection.Limit limit) {
|
||||
return delegate.zRevRangeByScore(key, range, limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range, Limit limit) {
|
||||
public Set<Tuple> zRevRangeByScoreWithScores(byte[] key, Range range,
|
||||
org.springframework.data.redis.connection.Limit limit) {
|
||||
return delegate.zRevRangeByScoreWithScores(key, range, limit);
|
||||
}
|
||||
|
||||
@@ -992,7 +997,7 @@ class RedisConnectionUnitTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> zRangeByScore(byte[] key, Range range, Limit limit) {
|
||||
public Set<byte[]> zRangeByScore(byte[] key, Range range, org.springframework.data.redis.connection.Limit limit) {
|
||||
return delegate.zRangeByScore(key, range, limit);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
package org.springframework.data.redis.connection;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Weights;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.redis.connection.zset.Weights;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link org.springframework.data.redis.connection.RedisZSetCommands.Weights}.
|
||||
* Unit tests for {@link Weights}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
|
||||
@@ -56,7 +56,7 @@ import org.springframework.data.redis.connection.ClusterConnectionTests;
|
||||
import org.springframework.data.redis.connection.ClusterSlotHashUtil;
|
||||
import org.springframework.data.redis.connection.DataType;
|
||||
import org.springframework.data.redis.connection.DefaultSortParameters;
|
||||
import org.springframework.data.redis.connection.DefaultTuple;
|
||||
import org.springframework.data.redis.connection.Limit;
|
||||
import org.springframework.data.redis.connection.RedisClusterNode;
|
||||
import org.springframework.data.redis.connection.RedisClusterNode.SlotRange;
|
||||
import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation;
|
||||
@@ -66,6 +66,8 @@ import org.springframework.data.redis.connection.RedisStringCommands.BitOperatio
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.connection.ReturnType;
|
||||
import org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding;
|
||||
import org.springframework.data.redis.connection.zset.DefaultTuple;
|
||||
import org.springframework.data.redis.connection.zset.Tuple;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.core.script.DigestUtils;
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
import org.springframework.dao.InvalidDataAccessResourceUsageException;
|
||||
import org.springframework.data.redis.connection.AbstractConnectionUnitTestBase;
|
||||
import org.springframework.data.redis.connection.RedisServerCommands.ShutdownOption;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Tuple;
|
||||
import org.springframework.data.redis.connection.zset.Tuple;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.GeoResults;
|
||||
import org.springframework.data.geo.Point;
|
||||
import org.springframework.data.redis.connection.*;
|
||||
import org.springframework.data.redis.connection.Limit;
|
||||
import org.springframework.data.redis.connection.RedisClusterNode.SlotRange;
|
||||
import org.springframework.data.redis.connection.RedisGeoCommands.GeoLocation;
|
||||
import org.springframework.data.redis.connection.RedisListCommands.Position;
|
||||
@@ -56,6 +57,8 @@ import org.springframework.data.redis.connection.RedisServerCommands.FlushOption
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.BitOperation;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding;
|
||||
import org.springframework.data.redis.connection.zset.DefaultTuple;
|
||||
import org.springframework.data.redis.connection.zset.Tuple;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
|
||||
@@ -40,7 +40,6 @@ import org.springframework.data.redis.connection.RedisClusterNode.LinkState;
|
||||
import org.springframework.data.redis.connection.RedisPassword;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands;
|
||||
import org.springframework.data.redis.core.types.Expiration;
|
||||
import org.springframework.data.redis.core.types.RedisClientInfo;
|
||||
|
||||
@@ -204,15 +203,15 @@ class LettuceConvertersUnitTests {
|
||||
@Test // DATAREDIS-981
|
||||
void toLimit() {
|
||||
|
||||
Limit limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.unlimited());
|
||||
Limit limit = LettuceConverters.toLimit(org.springframework.data.redis.connection.Limit.unlimited());
|
||||
assertThat(limit.isLimited()).isFalse();
|
||||
assertThat(limit.getCount()).isEqualTo(-1L);
|
||||
|
||||
limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.limit().count(-1));
|
||||
limit = LettuceConverters.toLimit(org.springframework.data.redis.connection.Limit.limit().count(-1));
|
||||
assertThat(limit.isLimited()).isTrue();
|
||||
assertThat(limit.getCount()).isEqualTo(-1L);
|
||||
|
||||
limit = LettuceConverters.toLimit(RedisZSetCommands.Limit.limit().count(5));
|
||||
limit = LettuceConverters.toLimit(org.springframework.data.redis.connection.Limit.limit().count(5));
|
||||
assertThat(limit.isLimited()).isTrue();
|
||||
assertThat(limit.getCount()).isEqualTo(5L);
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.junit.Ignore;
|
||||
|
||||
import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.redis.RedisSystemException;
|
||||
import org.springframework.data.redis.connection.Limit;
|
||||
import org.springframework.data.redis.connection.RedisStreamCommands.XClaimOptions;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.data.redis.connection.stream.Consumer;
|
||||
import org.springframework.data.redis.connection.stream.ReadOffset;
|
||||
import org.springframework.data.redis.connection.stream.RecordId;
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.redis.connection.DefaultTuple;
|
||||
import org.springframework.data.redis.connection.zset.DefaultTuple;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
import org.springframework.data.redis.test.condition.EnabledOnCommand;
|
||||
import org.springframework.data.redis.test.extension.parametrized.ParameterizedRedisTest;
|
||||
|
||||
@@ -30,9 +30,9 @@ import org.springframework.data.domain.Range.Bound;
|
||||
import org.springframework.data.redis.ObjectFactory;
|
||||
import org.springframework.data.redis.Person;
|
||||
import org.springframework.data.redis.PersonObjectFactory;
|
||||
import org.springframework.data.redis.connection.Limit;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.data.redis.connection.stream.Consumer;
|
||||
import org.springframework.data.redis.connection.stream.MapRecord;
|
||||
import org.springframework.data.redis.connection.stream.ReadOffset;
|
||||
|
||||
@@ -32,11 +32,11 @@ import org.junit.jupiter.api.Disabled;
|
||||
import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.redis.ByteBufferObjectFactory;
|
||||
import org.springframework.data.redis.ObjectFactory;
|
||||
import org.springframework.data.redis.connection.Limit;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Aggregate;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Weights;
|
||||
import org.springframework.data.redis.connection.zset.Weights;
|
||||
import org.springframework.data.redis.core.ReactiveOperationsTestParams.Fixture;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@@ -29,8 +29,8 @@ import org.springframework.data.domain.Range;
|
||||
import org.springframework.data.domain.Range.Bound;
|
||||
import org.springframework.data.redis.ObjectFactory;
|
||||
import org.springframework.data.redis.Person;
|
||||
import org.springframework.data.redis.connection.Limit;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Limit;
|
||||
import org.springframework.data.redis.connection.jedis.extension.JedisConnectionFactoryExtension;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension;
|
||||
|
||||
@@ -35,8 +35,9 @@ import org.springframework.data.redis.LongAsStringObjectFactory;
|
||||
import org.springframework.data.redis.LongObjectFactory;
|
||||
import org.springframework.data.redis.ObjectFactory;
|
||||
import org.springframework.data.redis.RawObjectFactory;
|
||||
import org.springframework.data.redis.connection.Limit;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands.Weights;
|
||||
import org.springframework.data.redis.connection.zset.Weights;
|
||||
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
|
||||
import org.springframework.data.redis.test.condition.EnabledOnCommand;
|
||||
import org.springframework.data.redis.test.extension.parametrized.MethodSource;
|
||||
@@ -348,7 +349,7 @@ public class DefaultZSetOperationsIntegrationTests<K, V> {
|
||||
zSetOps.add(key, value2, 3.7);
|
||||
zSetOps.add(key, value3, 5.8);
|
||||
Set<V> tuples = zSetOps.rangeByLex(key, RedisZSetCommands.Range.unbounded(),
|
||||
RedisZSetCommands.Limit.limit().count(2).offset(1));
|
||||
Limit.limit().count(2).offset(1));
|
||||
|
||||
assertThat(tuples).hasSize(2).containsSequence(value2, value3);
|
||||
}
|
||||
@@ -368,7 +369,7 @@ public class DefaultZSetOperationsIntegrationTests<K, V> {
|
||||
zSetOps.add(key, value2, 3.7);
|
||||
zSetOps.add(key, value3, 5.8);
|
||||
Set<V> tuples = zSetOps.reverseRangeByLex(key, RedisZSetCommands.Range.unbounded(),
|
||||
RedisZSetCommands.Limit.limit().count(2).offset(1));
|
||||
Limit.limit().count(2).offset(1));
|
||||
|
||||
assertThat(tuples).hasSize(2).containsSequence(value2, value1);
|
||||
}
|
||||
@@ -388,7 +389,7 @@ public class DefaultZSetOperationsIntegrationTests<K, V> {
|
||||
zSetOps.add(key, value2, 3.7);
|
||||
zSetOps.add(key, value3, 5.8);
|
||||
Set<V> tuples = zSetOps.rangeByLex(key, RedisZSetCommands.Range.range().gte(value1),
|
||||
RedisZSetCommands.Limit.limit().count(1).offset(1));
|
||||
Limit.limit().count(1).offset(1));
|
||||
|
||||
assertThat(tuples).hasSize(1).startsWith(value2);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.data.redis.DoubleObjectFactory;
|
||||
import org.springframework.data.redis.LongAsStringObjectFactory;
|
||||
import org.springframework.data.redis.LongObjectFactory;
|
||||
import org.springframework.data.redis.ObjectFactory;
|
||||
import org.springframework.data.redis.connection.Limit;
|
||||
import org.springframework.data.redis.connection.RedisZSetCommands;
|
||||
import org.springframework.data.redis.core.BoundZSetOperations;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
@@ -441,7 +442,7 @@ public abstract class AbstractRedisZSetTestIntegration<T> extends AbstractRedisC
|
||||
zSet.add(t2, 2);
|
||||
zSet.add(t3, 3);
|
||||
Set<T> tuples = zSet.rangeByLex(RedisZSetCommands.Range.unbounded(),
|
||||
RedisZSetCommands.Limit.limit().count(1).offset(1));
|
||||
Limit.limit().count(1).offset(1));
|
||||
|
||||
assertThat(tuples).hasSize(1);
|
||||
T tuple = tuples.iterator().next();
|
||||
@@ -462,7 +463,7 @@ public abstract class AbstractRedisZSetTestIntegration<T> extends AbstractRedisC
|
||||
zSet.add(t2, 2);
|
||||
zSet.add(t3, 3);
|
||||
Set<T> tuples = zSet.rangeByLex(RedisZSetCommands.Range.range().gte(t1),
|
||||
RedisZSetCommands.Limit.limit().count(2).offset(1));
|
||||
Limit.limit().count(2).offset(1));
|
||||
|
||||
assertThat(tuples).hasSize(2).containsSequence(t2, t3);
|
||||
}
|
||||
@@ -481,7 +482,7 @@ public abstract class AbstractRedisZSetTestIntegration<T> extends AbstractRedisC
|
||||
zSet.add(t2, 2);
|
||||
zSet.add(t3, 3);
|
||||
Set<T> tuples = zSet.reverseRangeByLex(RedisZSetCommands.Range.range().gte(t1),
|
||||
RedisZSetCommands.Limit.limit().count(2).offset(1));
|
||||
Limit.limit().count(2).offset(1));
|
||||
|
||||
assertThat(tuples).hasSize(2).containsSequence(t2, t1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user