Polishing.
Refine assertions usage. Original pull request: #2985 Closes #2982
This commit is contained in:
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2024 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.connection;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
@@ -24,7 +39,7 @@ class ReactiveStreamCommandsUnitTests {
|
||||
|
||||
PendingRecordsCommand command = PendingRecordsCommand.pending(key, groupName);
|
||||
|
||||
assertThatThrownBy(() -> command.range(null, 10L)).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> command.range(null, 10L));
|
||||
}
|
||||
|
||||
@Test // GH-2982
|
||||
@@ -36,6 +51,6 @@ class ReactiveStreamCommandsUnitTests {
|
||||
PendingRecordsCommand command = PendingRecordsCommand.pending(key, groupName);
|
||||
Range<?> range = Range.closed("0", "10");
|
||||
|
||||
assertThatThrownBy(() -> command.range(range, -1L)).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> command.range(range, -1L));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2024 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.connection;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
@@ -16,14 +31,12 @@ class RedisStreamCommandsUnitTests {
|
||||
|
||||
@Test // GH-2982
|
||||
void xPendingOptionsUnboundedShouldThrowExceptionWhenCountIsNegative() {
|
||||
|
||||
assertThatThrownBy(() -> XPendingOptions.unbounded(-1L)).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> XPendingOptions.unbounded(-1L));
|
||||
}
|
||||
|
||||
@Test // GH-2982
|
||||
void xPendingOptionsRangeShouldThrowExceptionWhenRangeIsNull() {
|
||||
|
||||
assertThatThrownBy(() -> XPendingOptions.range(null, 10L)).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> XPendingOptions.range(null, 10L));
|
||||
}
|
||||
|
||||
@Test // GH-2982
|
||||
@@ -31,6 +44,6 @@ class RedisStreamCommandsUnitTests {
|
||||
|
||||
Range<?> range = Range.closed("0", "10");
|
||||
|
||||
assertThatThrownBy(() -> XPendingOptions.range(range, -1L)).isInstanceOf(IllegalArgumentException.class);
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> XPendingOptions.range(range, -1L));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,12 +80,6 @@ public class DefaultReactiveStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
return ReactiveOperationsTestParams.testParams();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param redisTemplate
|
||||
* @param keyFactory
|
||||
* @param valueFactory
|
||||
* @param label parameterized test label, no further use besides that.
|
||||
*/
|
||||
public DefaultReactiveStreamOperationsIntegrationTests(Fixture<K, HV> fixture) {
|
||||
|
||||
this.serializer = fixture.getSerializer();
|
||||
@@ -359,7 +353,6 @@ public class DefaultReactiveStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
assertThat(pending.get(0).getConsumerName()).isEqualTo("my-consumer");
|
||||
assertThat(pending.get(0).getTotalDeliveryCount()).isOne();
|
||||
}).verifyComplete();
|
||||
|
||||
}
|
||||
|
||||
@ParameterizedRedisTest // GH-2465
|
||||
@@ -384,6 +377,5 @@ public class DefaultReactiveStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
assertThat(claimed.getValue()).isEqualTo(content);
|
||||
assertThat(claimed.getId()).isEqualTo(messageId);
|
||||
}).verifyComplete();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,16 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
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;
|
||||
import org.springframework.data.redis.connection.stream.*;
|
||||
import org.springframework.data.redis.connection.stream.Consumer;
|
||||
import org.springframework.data.redis.connection.stream.MapRecord;
|
||||
import org.springframework.data.redis.connection.stream.ObjectRecord;
|
||||
import org.springframework.data.redis.connection.stream.PendingMessages;
|
||||
import org.springframework.data.redis.connection.stream.PendingMessagesSummary;
|
||||
import org.springframework.data.redis.connection.stream.ReadOffset;
|
||||
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.test.condition.EnabledOnCommand;
|
||||
import org.springframework.data.redis.test.condition.EnabledOnRedisDriver;
|
||||
import org.springframework.data.redis.test.condition.EnabledOnRedisVersion;
|
||||
@@ -65,7 +74,7 @@ public class DefaultStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
private final StreamOperations<K, HK, HV> streamOps;
|
||||
|
||||
public DefaultStreamOperationsIntegrationTests(RedisTemplate<K, ?> redisTemplate, ObjectFactory<K> keyFactory,
|
||||
ObjectFactory<?> objectFactory) {
|
||||
ObjectFactory<?> objectFactory) {
|
||||
|
||||
this.redisTemplate = redisTemplate;
|
||||
this.connectionFactory = redisTemplate.getRequiredConnectionFactory();
|
||||
@@ -81,7 +90,7 @@ public class DefaultStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
params.addAll(AbstractOperationsTestParams
|
||||
.testParams(JedisConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class)));
|
||||
|
||||
if(RedisDetector.isClusterAvailable()) {
|
||||
if (RedisDetector.isClusterAvailable()) {
|
||||
params.addAll(AbstractOperationsTestParams
|
||||
.testParams(JedisConnectionFactoryExtension.getConnectionFactory(RedisCluster.class)));
|
||||
}
|
||||
@@ -89,7 +98,7 @@ public class DefaultStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
params.addAll(AbstractOperationsTestParams
|
||||
.testParams(LettuceConnectionFactoryExtension.getConnectionFactory(RedisStanalone.class)));
|
||||
|
||||
if(RedisDetector.isClusterAvailable()) {
|
||||
if (RedisDetector.isClusterAvailable()) {
|
||||
params.addAll(AbstractOperationsTestParams
|
||||
.testParams(LettuceConnectionFactoryExtension.getConnectionFactory(RedisCluster.class)));
|
||||
}
|
||||
@@ -305,7 +314,8 @@ public class DefaultStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
RecordId messageId1 = streamOps.add(StreamRecords.objectBacked(value).withStreamKey(key));
|
||||
streamOps.add(StreamRecords.objectBacked(value).withStreamKey(key));
|
||||
|
||||
List<ObjectRecord<K, HV>> messages = streamOps.read((Class<HV>) value.getClass(), StreamOffset.create(key, ReadOffset.from("0-0")));
|
||||
List<ObjectRecord<K, HV>> messages = streamOps.read((Class<HV>) value.getClass(),
|
||||
StreamOffset.create(key, ReadOffset.from("0-0")));
|
||||
|
||||
assertThat(messages).hasSize(2);
|
||||
|
||||
@@ -384,8 +394,7 @@ public class DefaultStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
RecordId messageId = streamOps.add(key, Collections.singletonMap(hashKey, value));
|
||||
streamOps.createGroup(key, ReadOffset.from("0-0"), "my-group");
|
||||
|
||||
streamOps.read(Consumer.from("my-group", "my-consumer"),
|
||||
StreamOffset.create(key, ReadOffset.lastConsumed()));
|
||||
streamOps.read(Consumer.from("my-group", "my-consumer"), StreamOffset.create(key, ReadOffset.lastConsumed()));
|
||||
|
||||
PendingMessagesSummary pending = streamOps.pending(key, "my-group");
|
||||
|
||||
@@ -403,8 +412,7 @@ public class DefaultStreamOperationsIntegrationTests<K, HK, HV> {
|
||||
RecordId messageId = streamOps.add(key, Collections.singletonMap(hashKey, value));
|
||||
streamOps.createGroup(key, ReadOffset.from("0-0"), "my-group");
|
||||
|
||||
streamOps.read(Consumer.from("my-group", "my-consumer"),
|
||||
StreamOffset.create(key, ReadOffset.lastConsumed()));
|
||||
streamOps.read(Consumer.from("my-group", "my-consumer"), StreamOffset.create(key, ReadOffset.lastConsumed()));
|
||||
|
||||
PendingMessages pending = streamOps.pending(key, "my-group", Range.unbounded(), 10L);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user