@@ -184,9 +184,10 @@ public void bitCountWithRangeShouldWorkCorrectly() {
184184assertThat (clusterConnection .bitCount (KEY_1_BYTES , 0 , 3 )).isEqualTo (3L );
185185}
186186
187- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
187+ @ Test // DATAREDIS-315
188188public void bitOpShouldThrowExceptionWhenKeysDoNotMapToSameSlot () {
189- clusterConnection .bitOp (BitOperation .AND , KEY_1_BYTES , KEY_2_BYTES , KEY_3_BYTES );
189+ assertThatExceptionOfType (DataAccessException .class )
190+ .isThrownBy (() -> clusterConnection .bitOp (BitOperation .AND , KEY_1_BYTES , KEY_2_BYTES , KEY_3_BYTES ));
190191}
191192
192193@ Test // DATAREDIS-315
@@ -344,9 +345,9 @@ public void delShouldRemoveSingleKeyCorrectly() {
344345assertThat (nativeConnection .get (KEY_1 )).isNull ();
345346}
346347
347- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
348+ @ Test // DATAREDIS-315
348349public void discardShouldThrowException () {
349- clusterConnection .discard ();
350+ assertThatExceptionOfType ( DataAccessException . class ). isThrownBy (() -> clusterConnection .discard () );
350351}
351352
352353@ Test // DATAREDIS-315
@@ -379,9 +380,9 @@ public void echoShouldReturnInputCorrectly() {
379380assertThat (clusterConnection .echo (VALUE_1_BYTES )).isEqualTo (VALUE_1_BYTES );
380381}
381382
382- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
383+ @ Test // DATAREDIS-315
383384public void execShouldThrowException () {
384- clusterConnection .exec ();
385+ assertThatExceptionOfType ( DataAccessException . class ). isThrownBy (() -> clusterConnection .exec () );
385386}
386387
387388@ Test // DATAREDIS-689
@@ -401,9 +402,10 @@ public void executeWithKeyAndArgs() {
401402assertThat (nativeConnection .get (KEY_1 )).isEqualTo (VALUE_1 );
402403}
403404
404- @ Test ( expected = IllegalArgumentException . class ) // DATAREDIS-689
405+ @ Test // DATAREDIS-689
405406public void executeWithNoKeyAndArgsThrowsException () {
406- clusterConnection .execute ("KEYS" , (byte []) null , Collections .singletonList ("*" .getBytes ()));
407+ assertThatIllegalArgumentException ()
408+ .isThrownBy (() -> clusterConnection .execute ("KEYS" , (byte []) null , Collections .singletonList ("*" .getBytes ())));
407409}
408410
409411@ Test // DATAREDIS-529
@@ -1209,14 +1211,15 @@ public void mSetShouldWorkWhenKeysMapToSameSlot() {
12091211assertThat (nativeConnection .get (SAME_SLOT_KEY_2 )).isEqualTo (VALUE_2 );
12101212}
12111213
1212- @ Test ( expected = UnsupportedOperationException . class ) // DATAREDIS-315
1214+ @ Test // DATAREDIS-315
12131215public void moveShouldNotBeSupported () {
1214- clusterConnection .move (KEY_1_BYTES , 3 );
1216+ assertThatExceptionOfType (UnsupportedOperationException .class )
1217+ .isThrownBy (() -> clusterConnection .move (KEY_1_BYTES , 3 ));
12151218}
12161219
1217- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
1220+ @ Test // DATAREDIS-315
12181221public void multiShouldThrowException () {
1219- clusterConnection .multi ();
1222+ assertThatExceptionOfType ( DataAccessException . class ). isThrownBy (() -> clusterConnection .multi () );
12201223}
12211224
12221225@ Test // DATAREDIS-315
@@ -1318,9 +1321,10 @@ public void pfCountShouldThrowErrorCountingOnDifferentSlotKeys() {
13181321clusterConnection .pfCount (KEY_1_BYTES , KEY_2_BYTES );
13191322}
13201323
1321- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
1324+ @ Test // DATAREDIS-315
13221325public void pfMergeShouldThrowErrorOnDifferentSlotKeys () {
1323- clusterConnection .pfMerge (KEY_3_BYTES , KEY_1_BYTES , KEY_2_BYTES );
1326+ assertThatExceptionOfType (DataAccessException .class )
1327+ .isThrownBy (() -> clusterConnection .pfMerge (KEY_3_BYTES , KEY_1_BYTES , KEY_2_BYTES ));
13241328}
13251329
13261330@ Test // DATAREDIS-315
@@ -1344,9 +1348,10 @@ public void pingShouldRetrunPongForExistingNode() {
13441348assertThat (clusterConnection .ping (new RedisClusterNode ("127.0.0.1" , 7379 , SlotRange .empty ()))).isEqualTo ("PONG" );
13451349}
13461350
1347- @ Test ( expected = IllegalArgumentException . class ) // DATAREDIS-315
1351+ @ Test // DATAREDIS-315
13481352public void pingShouldThrowExceptionWhenNodeNotKnownToCluster () {
1349- clusterConnection .ping (new RedisClusterNode ("127.0.0.1" , 1234 , null ));
1353+ assertThatIllegalArgumentException ()
1354+ .isThrownBy (() -> clusterConnection .ping (new RedisClusterNode ("127.0.0.1" , 1234 , null )));
13501355}
13511356
13521357@ Test // DATAREDIS-315
@@ -1697,9 +1702,9 @@ public void selectShouldAllowSelectionOfDBIndexZero() {
16971702clusterConnection .select (0 );
16981703}
16991704
1700- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
1705+ @ Test // DATAREDIS-315
17011706public void selectShouldThrowExceptionWhenSelectingNonZeroDbIndex () {
1702- clusterConnection .select (1 );
1707+ assertThatExceptionOfType ( DataAccessException . class ). isThrownBy (() -> clusterConnection .select (1 ) );
17031708}
17041709
17051710@ Test // DATAREDIS-315
@@ -1926,14 +1931,14 @@ public void typeShouldReadKeyTypeCorrectly() {
19261931assertThat (clusterConnection .type (KEY_3_BYTES )).isEqualTo (DataType .HASH );
19271932}
19281933
1929- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
1934+ @ Test // DATAREDIS-315
19301935public void unwatchShouldThrowException () {
1931- clusterConnection .unwatch ();
1936+ assertThatExceptionOfType ( DataAccessException . class ). isThrownBy (() -> clusterConnection .unwatch () );
19321937}
19331938
1934- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
1939+ @ Test // DATAREDIS-315
19351940public void watchShouldThrowException () {
1936- clusterConnection .watch ();
1941+ assertThatExceptionOfType ( DataAccessException . class ). isThrownBy (() -> clusterConnection .watch () );
19371942}
19381943
19391944@ Test // DATAREDIS-674
@@ -1988,9 +1993,10 @@ public void zIncrByShouldIncScoreForValueCorrectly() {
19881993assertThat (nativeConnection .zrank (KEY_1_BYTES , VALUE_1_BYTES )).isEqualTo (1L );
19891994}
19901995
1991- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
1996+ @ Test // DATAREDIS-315
19921997public void zInterStoreShouldThrowExceptionWhenKeysDoNotMapToSameSlots () {
1993- clusterConnection .zInterStore (KEY_3_BYTES , KEY_1_BYTES , KEY_2_BYTES );
1998+ assertThatExceptionOfType (DataAccessException .class )
1999+ .isThrownBy (() -> clusterConnection .zInterStore (KEY_3_BYTES , KEY_1_BYTES , KEY_2_BYTES ));
19942000}
19952001
19962002@ Test // DATAREDIS-315
@@ -2251,9 +2257,10 @@ public void zScoreShouldRetrieveScoreForValue() {
22512257assertThat (clusterConnection .zScore (KEY_1_BYTES , VALUE_2_BYTES )).isEqualTo (20D );
22522258}
22532259
2254- @ Test ( expected = DataAccessException . class ) // DATAREDIS-315
2260+ @ Test // DATAREDIS-315
22552261public void zUnionStoreShouldThrowExceptionWhenKeysDoNotMapToSameSlots () {
2256- clusterConnection .zUnionStore (KEY_3_BYTES , KEY_1_BYTES , KEY_2_BYTES );
2262+ assertThatExceptionOfType (DataAccessException .class )
2263+ .isThrownBy (() -> clusterConnection .zUnionStore (KEY_3_BYTES , KEY_1_BYTES , KEY_2_BYTES ));
22572264}
22582265
22592266@ Test // DATAREDIS-315
@@ -2395,9 +2402,10 @@ public void bitFieldIncrByWithOverflowShouldWorkCorrectly() {
23952402assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
23962403create ().incr (unsigned (2 )).valueAt (BitFieldSubCommands .Offset .offset (102L )).overflow (FAIL ).by (1L )))
23972404.containsExactly (3L );
2398- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2399- create ().incr (unsigned (2 )).valueAt (BitFieldSubCommands .Offset .offset (102L )).overflow (FAIL ).by (1L )).get (0 ))
2400- .isNull ();
2405+ assertThat (clusterConnection .stringCommands ()
2406+ .bitField (JedisConverters .toBytes (KEY_1 ),
2407+ create ().incr (unsigned (2 )).valueAt (BitFieldSubCommands .Offset .offset (102L )).overflow (FAIL ).by (1L ))
2408+ .get (0 )).isNull ();
24012409}
24022410
24032411@ Test // DATAREDIS-562
@@ -2413,9 +2421,11 @@ public void bitfieldShouldAllowMultipleSubcommands() {
24132421@ IfProfileValue (name = "redisVersion" , value = "3.2+" )
24142422public void bitfieldShouldWorkUsingNonZeroBasedOffset () {
24152423
2416- assertThat (clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2417- create ().set (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (0L ).multipliedByTypeLength ()).to (100L ).set (INT_8 )
2418- .valueAt (BitFieldSubCommands .Offset .offset (1L ).multipliedByTypeLength ()).to (200L ))).containsExactly (0L , 0L );
2424+ assertThat (
2425+ clusterConnection .stringCommands ().bitField (JedisConverters .toBytes (KEY_1 ),
2426+ create ().set (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (0L ).multipliedByTypeLength ()).to (100L )
2427+ .set (INT_8 ).valueAt (BitFieldSubCommands .Offset .offset (1L ).multipliedByTypeLength ()).to (200L )))
2428+ .containsExactly (0L , 0L );
24192429assertThat (
24202430clusterConnection .stringCommands ()
24212431.bitField (JedisConverters .toBytes (KEY_1 ),
0 commit comments