@@ -62,8 +62,7 @@ void buildWriteOptions() {
62
62
assertThat (writeOptions .getTracing ()).isTrue ();
63
63
assertThat (writeOptions .getKeyspace ()).isEqualTo (CqlIdentifier .fromCql ("my_keyspace" ));
64
64
assertThat (writeOptions .isIdempotent ()).isEqualTo (true );
65
- assertThat (writeOptions .getRoutingKeyspace ()).isEqualTo (
66
- CqlIdentifier .fromCql ("routing_keyspace" ));
65
+ assertThat (writeOptions .getRoutingKeyspace ()).isEqualTo (CqlIdentifier .fromCql ("routing_keyspace" ));
67
66
assertThat (writeOptions .getRoutingKey ()).isEqualTo (ByteBuffer .allocate (1 ));
68
67
}
69
68
@@ -104,36 +103,20 @@ void buildWriteOptionsMutate() {
104
103
assertThat (mutated .getPageSize ()).isEqualTo (10 );
105
104
assertThat (mutated .getTracing ()).isTrue ();
106
105
assertThat (writeOptions .isIdempotent ()).isEqualTo (true );
107
- assertThat (writeOptions .getRoutingKeyspace ()).isEqualTo (
108
- CqlIdentifier .fromCql ("routing_keyspace" ));
106
+ assertThat (writeOptions .getRoutingKeyspace ()).isEqualTo (CqlIdentifier .fromCql ("routing_keyspace" ));
109
107
assertThat (writeOptions .getRoutingKey ()).isEqualTo (ByteBuffer .allocate (1 ));
110
108
}
111
109
112
110
@ Test // GH-1248
113
111
void buildWriteOptionsWithTtlDurationZero () {
114
- try {
115
- WriteOptions writeOptions = WriteOptions .builder ()
116
- .ttl (Duration .ZERO )
117
- .build ();
118
-
119
- fail ("WiteOptionsBuilder must not allow zero TTL" );
120
- }
121
- catch (Exception e ) {
122
- // expected behavior
123
- }
112
+ assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (0 ));
113
+ assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (Duration .ZERO ));
124
114
}
125
115
126
116
@ Test // GH-1248
127
117
void buildWriteOptionsWithTtlNegativeDuration () {
128
- try {
129
- WriteOptions writeOptions = WriteOptions .builder ()
130
- .ttl (Duration .of (-1 , ChronoUnit .MICROS ))
131
- .build ();
132
-
133
- fail ("WiteOptionsBuilder must not allow negative TTL" );
134
- }
135
- catch (Exception e ) {
136
- // expected behavior
137
- }
118
+ assertThatIllegalArgumentException ().isThrownBy (() -> WriteOptions .builder ().ttl (-1 ));
119
+ assertThatIllegalArgumentException ()
120
+ .isThrownBy (() -> WriteOptions .builder ().ttl (Duration .of (-1 , ChronoUnit .MICROS )));
138
121
}
139
122
}
0 commit comments