Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Delegate calls from deprecated methods to their replacement methods. Simplify tests.

See #1494
Original pull request: #1495
  • Loading branch information
mp911de committed Jun 12, 2024
1 parent 74189c7 commit acbdd87
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,10 @@ public boolean equals(@Nullable Object o) {
return true;
}

if (!(o instanceof QueryOptions)) {
if (!(o instanceof QueryOptions options)) {
return false;
}

QueryOptions options = (QueryOptions) o;

if (!ObjectUtils.nullSafeEquals(consistencyLevel, options.consistencyLevel)) {
return false;
}
Expand Down Expand Up @@ -482,12 +480,7 @@ public QueryOptionsBuilder readTimeout(long readTimeout, TimeUnit timeUnit) {
*/
@Deprecated
public QueryOptionsBuilder readTimeout(Duration readTimeout) {

Assert.isTrue(!readTimeout.isNegative(), "ReadTimeout must be greater than equal to zero");

this.timeout = readTimeout;

return this;
return timeout(readTimeout);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,7 @@ void buildZeroDurationTimeoutQueryOptions() {
@Test // GH-1494
void shouldRejectNegativeDurationTimeoutQueryOptions() {

assertThatIllegalArgumentException().isThrownBy(
() -> QueryOptions.builder().timeout(Duration.ofSeconds(-1)).build());
}

@Test // GH-1494
void buildZeroDurationReadTimeoutQueryOptions() {

QueryOptions queryOptions = QueryOptions.builder().readTimeout(Duration.ofSeconds(0)).build();

assertThat(queryOptions.getReadTimeout()).isEqualTo(Duration.ZERO);
}

@Test // GH-1494
void shouldRejectNegativeDurationReadTimeoutQueryOptions() {

assertThatIllegalArgumentException().isThrownBy(
() -> QueryOptions.builder().readTimeout(Duration.ofSeconds(-1)).build());
assertThatIllegalArgumentException()
.isThrownBy(() -> QueryOptions.builder().timeout(Duration.ofSeconds(-1)).build());
}
}

0 comments on commit acbdd87

Please sign in to comment.