Skip to content

Commit 2832f33

Browse files
committed
Polishing.
Delegate calls from deprecated methods to their replacement methods. Simplify tests. See #1494 Original pull request: #1495
1 parent eae72b1 commit 2832f33

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/QueryOptions.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,10 @@ public boolean equals(@Nullable Object o) {
219219
return true;
220220
}
221221

222-
if (!(o instanceof QueryOptions)) {
222+
if (!(o instanceof QueryOptions options)) {
223223
return false;
224224
}
225225

226-
QueryOptions options = (QueryOptions) o;
227-
228226
if (!ObjectUtils.nullSafeEquals(consistencyLevel, options.consistencyLevel)) {
229227
return false;
230228
}
@@ -482,12 +480,7 @@ public QueryOptionsBuilder readTimeout(long readTimeout, TimeUnit timeUnit) {
482480
*/
483481
@Deprecated
484482
public QueryOptionsBuilder readTimeout(Duration readTimeout) {
485-
486-
Assert.isTrue(!readTimeout.isNegative(), "ReadTimeout must be greater than equal to zero");
487-
488-
this.timeout = readTimeout;
489-
490-
return this;
483+
return timeout(readTimeout);
491484
}
492485

493486
/**

spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/cql/QueryOptionsUnitTests.java

+2-17
Original file line numberDiff line numberDiff line change
@@ -99,22 +99,7 @@ void buildZeroDurationTimeoutQueryOptions() {
9999
@Test // GH-1494
100100
void shouldRejectNegativeDurationTimeoutQueryOptions() {
101101

102-
assertThatIllegalArgumentException().isThrownBy(
103-
() -> QueryOptions.builder().timeout(Duration.ofSeconds(-1)).build());
104-
}
105-
106-
@Test // GH-1494
107-
void buildZeroDurationReadTimeoutQueryOptions() {
108-
109-
QueryOptions queryOptions = QueryOptions.builder().readTimeout(Duration.ofSeconds(0)).build();
110-
111-
assertThat(queryOptions.getReadTimeout()).isEqualTo(Duration.ZERO);
112-
}
113-
114-
@Test // GH-1494
115-
void shouldRejectNegativeDurationReadTimeoutQueryOptions() {
116-
117-
assertThatIllegalArgumentException().isThrownBy(
118-
() -> QueryOptions.builder().readTimeout(Duration.ofSeconds(-1)).build());
102+
assertThatIllegalArgumentException()
103+
.isThrownBy(() -> QueryOptions.builder().timeout(Duration.ofSeconds(-1)).build());
119104
}
120105
}

0 commit comments

Comments
 (0)