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
2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,7 @@ public int hashCode() {
148
148
* @author Mark Paluch
149
149
* @author Lukasz Antoniak
150
150
* @author Thomas Strauß
151
+ * @author Tudor Marc
151
152
* @since 1.5
152
153
*/
153
154
public static class WriteOptionsBuilder extends QueryOptionsBuilder {
@@ -306,7 +307,7 @@ public WriteOptionsBuilder ttl(int ttl) {
306
307
public WriteOptionsBuilder ttl (Duration ttl ) {
307
308
308
309
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" );
310
311
311
312
this .ttl = ttl ;
312
313
Original file line number Diff line number Diff line change 33
33
*
34
34
* @author Mark Paluch
35
35
* @author Thomas Strauß
36
+ * @author Tudor Marc
36
37
*/
37
38
class WriteOptionsUnitTests {
38
39
@@ -92,16 +93,18 @@ void buildWriteOptionsMutate() {
92
93
assertThat (mutated .getTracing ()).isTrue ();
93
94
}
94
95
95
- @ Test // GH-1248
96
- void buildWriteOptionsWithTtlDurationZero () {
97
- assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (0 ));
98
- assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (Duration .ZERO ));
99
- }
100
-
101
96
@ Test // GH-1248
102
97
void buildWriteOptionsWithTtlNegativeDuration () {
103
98
assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (-1 ));
104
99
assertThatIllegalArgumentException ()
105
100
.isThrownBy (() -> WriteOptions .builder ().ttl (Duration .of (-1 , ChronoUnit .MICROS )));
106
101
}
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
+ }
107
110
}
You can’t perform that action at this time.
0 commit comments