Skip to content

Commit 0067cab

Browse files
committed
Adopt to Mockito 5.1 changes.
Closes #2504
1 parent b5fda56 commit 0067cab

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionUnitTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.mockito.junit.jupiter.MockitoExtension;
4747
import org.mockito.junit.jupiter.MockitoSettings;
4848
import org.mockito.quality.Strictness;
49-
5049
import org.springframework.data.redis.connection.ClusterCommandExecutor;
5150
import org.springframework.data.redis.connection.ClusterNodeResourceProvider;
5251
import org.springframework.data.redis.connection.ClusterTopologyProvider;
@@ -307,7 +306,7 @@ void clusterDeleteSlotsShouldBeExecutedCorrectly() {
307306
int[] slots = new int[] { 9000, 10000 };
308307
connection.clusterDeleteSlots(CLUSTER_NODE_2, slots);
309308

310-
verify(clusterConnection2Mock, times(1)).clusterDelSlots((int[]) any());
309+
verify(clusterConnection2Mock, times(1)).clusterDelSlots(any(int[].class));
311310
}
312311

313312
@Test // DATAREDIS-315

src/test/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSubscriptionUnitTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void before() {
6868
@Test // DATAREDIS-612
6969
void shouldSubscribeChannels() {
7070

71-
when(pubSubMock.subscribe(any())).thenReturn(Mono.empty());
71+
when(pubSubMock.subscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
7272

7373
Mono<Void> subscribe = subscription.subscribe(getByteBuffer("foo"), getByteBuffer("bar"));
7474

@@ -83,7 +83,7 @@ void shouldSubscribeChannels() {
8383
@Test // DATAREDIS-612
8484
void shouldSubscribeChannelsShouldFail() {
8585

86-
when(pubSubMock.subscribe(any())).thenReturn(Mono.error(new RedisConnectionException("Foo")));
86+
when(pubSubMock.subscribe(any(ByteBuffer[].class))).thenReturn(Mono.error(new RedisConnectionException("Foo")));
8787

8888
Mono<Void> subscribe = subscription.subscribe(getByteBuffer("foo"), getByteBuffer("bar"));
8989

@@ -93,7 +93,7 @@ void shouldSubscribeChannelsShouldFail() {
9393
@Test // DATAREDIS-612
9494
void shouldSubscribePatterns() {
9595

96-
when(pubSubMock.pSubscribe(any())).thenReturn(Mono.empty());
96+
when(pubSubMock.pSubscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
9797

9898
Mono<Void> subscribe = subscription.pSubscribe(getByteBuffer("foo"), getByteBuffer("bar"));
9999

@@ -108,33 +108,33 @@ void shouldSubscribePatterns() {
108108
@Test // DATAREDIS-612
109109
void shouldUnsubscribeChannels() {
110110

111-
when(pubSubMock.subscribe(any())).thenReturn(Mono.empty());
112-
when(pubSubMock.unsubscribe(any())).thenReturn(Mono.empty());
111+
when(pubSubMock.subscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
112+
when(pubSubMock.unsubscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
113113
subscription.subscribe(getByteBuffer("foo"), getByteBuffer("bar")).as(StepVerifier::create).verifyComplete();
114114

115115
subscription.unsubscribe().as(StepVerifier::create).verifyComplete();
116116

117117
assertThat(subscription.getChannels()).isEmpty();
118-
verify(pubSubMock).unsubscribe(any());
118+
verify(pubSubMock).unsubscribe(any(ByteBuffer[].class));
119119
}
120120

121121
@Test // DATAREDIS-612
122122
void shouldUnsubscribePatterns() {
123123

124-
when(pubSubMock.pSubscribe(any())).thenReturn(Mono.empty());
125-
when(pubSubMock.pUnsubscribe(any())).thenReturn(Mono.empty());
124+
when(pubSubMock.pSubscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
125+
when(pubSubMock.pUnsubscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
126126
subscription.pSubscribe(getByteBuffer("foo"), getByteBuffer("bar")).as(StepVerifier::create).verifyComplete();
127127

128128
subscription.pUnsubscribe().as(StepVerifier::create).verifyComplete();
129129

130130
assertThat(subscription.getPatterns()).isEmpty();
131-
verify(pubSubMock).pUnsubscribe(any());
131+
verify(pubSubMock).pUnsubscribe(any(ByteBuffer[].class));
132132
}
133133

134134
@Test // DATAREDIS-612
135135
void shouldEmitChannelMessage() {
136136

137-
when(pubSubMock.subscribe(any())).thenReturn(Mono.empty());
137+
when(pubSubMock.subscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
138138
subscription.subscribe(getByteBuffer("foo"), getByteBuffer("bar")).as(StepVerifier::create).verifyComplete();
139139

140140
Sinks.Many<io.lettuce.core.pubsub.api.reactive.ChannelMessage<ByteBuffer, ByteBuffer>> sink = Sinks.many().unicast()
@@ -154,7 +154,7 @@ void shouldEmitChannelMessage() {
154154
@Test // DATAREDIS-612
155155
void shouldEmitPatternMessage() {
156156

157-
when(pubSubMock.pSubscribe(any())).thenReturn(Mono.empty());
157+
when(pubSubMock.pSubscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
158158
subscription.pSubscribe(getByteBuffer("foo*"), getByteBuffer("bar*")).as(StepVerifier::create).verifyComplete();
159159

160160
Sinks.Many<io.lettuce.core.pubsub.api.reactive.PatternMessage<ByteBuffer, ByteBuffer>> sink = Sinks.many().unicast()
@@ -176,7 +176,7 @@ void shouldEmitPatternMessage() {
176176
@Test // DATAREDIS-612
177177
void shouldEmitError() {
178178

179-
when(pubSubMock.subscribe(any())).thenReturn(Mono.empty());
179+
when(pubSubMock.subscribe(any(ByteBuffer[].class))).thenReturn(Mono.empty());
180180
subscription.subscribe(getByteBuffer("foo"), getByteBuffer("bar")).as(StepVerifier::create).verifyComplete();
181181

182182
Sinks.Many<io.lettuce.core.pubsub.api.reactive.ChannelMessage<ByteBuffer, ByteBuffer>> sink = Sinks.many().unicast()

src/test/java/org/springframework/data/redis/core/DefaultClusterOperationsUnitTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@
2727
import org.junit.jupiter.api.Test;
2828
import org.junit.jupiter.api.extension.ExtendWith;
2929
import org.mockito.Mock;
30-
import org.mockito.Mockito;
3130
import org.mockito.junit.jupiter.MockitoExtension;
3231
import org.mockito.junit.jupiter.MockitoSettings;
3332
import org.mockito.quality.Strictness;
34-
3533
import org.springframework.data.redis.connection.RedisClusterCommands.AddSlots;
3634
import org.springframework.data.redis.connection.RedisClusterConnection;
3735
import org.springframework.data.redis.connection.RedisClusterNode;
@@ -142,7 +140,7 @@ void addSlotsShouldDelegateToConnection() {
142140

143141
clusterOps.addSlots(NODE_1, 1, 2, 3);
144142

145-
verify(connection, times(1)).clusterAddSlots(eq(NODE_1), Mockito.<int[]> any());
143+
verify(connection, times(1)).clusterAddSlots(eq(NODE_1), any(int[].class));
146144
}
147145

148146
@Test // DATAREDIS-315
@@ -155,7 +153,7 @@ void addSlotsWithRangeShouldDelegateToConnection() {
155153

156154
clusterOps.addSlots(NODE_1, new SlotRange(1, 3));
157155

158-
verify(connection, times(1)).clusterAddSlots(eq(NODE_1), Mockito.<int[]> any());
156+
verify(connection, times(1)).clusterAddSlots(eq(NODE_1), any(int[].class));
159157
}
160158

161159
@Test // DATAREDIS-315

src/test/java/org/springframework/data/redis/core/IndexWriterUnitTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.mockito.junit.jupiter.MockitoExtension;
3232
import org.mockito.junit.jupiter.MockitoSettings;
3333
import org.mockito.quality.Strictness;
34-
3534
import org.springframework.core.convert.converter.Converter;
3635
import org.springframework.core.convert.support.GenericConversionService;
3736
import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -127,10 +126,10 @@ void removeAllIndexesShouldDeleteAllIndexKeys() {
127126

128127
writer.removeAllIndexes(KEYSPACE);
129128

130-
ArgumentCaptor<byte[]> captor = ArgumentCaptor.forClass(byte[].class);
129+
ArgumentCaptor<byte[][]> captor = ArgumentCaptor.forClass(byte[][].class);
131130

132131
verify(connectionMock, times(1)).del(captor.capture());
133-
assertThat(captor.getAllValues()).contains(indexKey1, indexKey2);
132+
assertThat(captor.getAllValues()).contains(new byte[][] { indexKey1, indexKey2 });
134133
}
135134

136135
@Test // DATAREDIS-425

0 commit comments

Comments
 (0)