File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed
spring-data-cassandra/src
main/java/org/springframework/data/cassandra/core/cql
test/java/org/springframework/data/cassandra/core/cql Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,7 @@ public int hashCode() {
148148 * @author Mark Paluch
149149 * @author Lukasz Antoniak
150150 * @author Thomas Strauß
151+ * @author Tudor Marc
151152 * @since 1.5
152153 */
153154 public static class WriteOptionsBuilder extends QueryOptionsBuilder {
@@ -306,7 +307,7 @@ public WriteOptionsBuilder ttl(int ttl) {
306307 public WriteOptionsBuilder ttl (Duration ttl ) {
307308
308309 Assert .notNull (ttl , "TTL must not be null" );
309- Assert .isTrue (!ttl .isNegative () && ! ttl . isZero () , "TTL must be greater than equal to zero" );
310+ Assert .isTrue (!ttl .isNegative (), "TTL must be greater than equal to zero" );
310311
311312 this .ttl = ttl ;
312313
Original file line number Diff line number Diff line change 3333 *
3434 * @author Mark Paluch
3535 * @author Thomas Strauß
36+ * @author Tudor Marc
3637 */
3738class WriteOptionsUnitTests {
3839
@@ -92,16 +93,18 @@ void buildWriteOptionsMutate() {
9293 assertThat (mutated .getTracing ()).isTrue ();
9394 }
9495
95- @ Test // GH-1248
96- void buildWriteOptionsWithTtlDurationZero () {
97- assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (0 ));
98- assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (Duration .ZERO ));
99- }
100-
10196 @ Test // GH-1248
10297 void buildWriteOptionsWithTtlNegativeDuration () {
10398 assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (-1 ));
10499 assertThatIllegalArgumentException ()
105100 .isThrownBy (() -> WriteOptions .builder ().ttl (Duration .of (-1 , ChronoUnit .MICROS )));
106101 }
102+
103+ @ Test // GH-1262
104+ void buildZeroDurationTtlWriterOptions () {
105+
106+ WriteOptions writeOptions = WriteOptions .builder ().ttl (0 ).build ();
107+
108+ assertThat (writeOptions .getTtl ()).isEqualTo (Duration .ZERO );
109+ }
107110}
You can’t perform that action at this time.
0 commit comments