10
10
import org .junit .jupiter .api .BeforeEach ;
11
11
import org .junit .jupiter .api .Test ;
12
12
13
- import static org .junit .Assert .assertEquals ;
13
+ import static org .junit .jupiter . api . Assertions .assertEquals ;
14
14
import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
15
15
import static org .mockito .Mockito .*;
16
16
@@ -78,6 +78,7 @@ void resubscribeChannelSubscription() {
78
78
when (mockedEndpoint .hasChannelSubscriptions ()).thenReturn (true );
79
79
when (mockedEndpoint .getChannels ()).thenReturn (new HashSet <>(Arrays .asList (new String [] { "channel1" , "channel2" })));
80
80
when (mockedEndpoint .hasPatternSubscriptions ()).thenReturn (false );
81
+ when (mockedEndpoint .hasShardChannelSubscriptions ()).thenReturn (false );
81
82
82
83
List <RedisFuture <Void >> subscriptions = connection .resubscribe ();
83
84
RedisFuture <Void > commandFuture = subscriptions .get (0 );
@@ -87,17 +88,35 @@ void resubscribeChannelSubscription() {
87
88
}
88
89
89
90
@ Test
90
- void resubscribeChannelAndPatternSubscription () {
91
+ void resubscribeShardChannelSubscription () {
92
+ when (mockedEndpoint .hasShardChannelSubscriptions ()).thenReturn (true );
93
+ when (mockedEndpoint .getShardChannels ())
94
+ .thenReturn (new HashSet <>(Arrays .asList (new String [] { "shard_channel1" , "shard_channel2" })));
95
+ when (mockedEndpoint .hasChannelSubscriptions ()).thenReturn (false );
96
+ when (mockedEndpoint .hasPatternSubscriptions ()).thenReturn (false );
97
+
98
+ List <RedisFuture <Void >> subscriptions = connection .resubscribe ();
99
+ RedisFuture <Void > commandFuture = subscriptions .get (0 );
100
+
101
+ assertEquals (1 , subscriptions .size ());
102
+ assertInstanceOf (AsyncCommand .class , commandFuture );
103
+ }
104
+
105
+ @ Test
106
+ void resubscribeChannelAndPatternAndShardChanelSubscription () {
91
107
when (mockedEndpoint .hasChannelSubscriptions ()).thenReturn (true );
92
- when (mockedEndpoint .getChannels ()).thenReturn (new HashSet <>(Arrays .asList (new String [] { "channel1" , "channel2" })));
93
108
when (mockedEndpoint .hasPatternSubscriptions ()).thenReturn (true );
109
+ when (mockedEndpoint .hasShardChannelSubscriptions ()).thenReturn (true );
110
+ when (mockedEndpoint .getChannels ()).thenReturn (new HashSet <>(Arrays .asList (new String [] { "channel1" , "channel2" })));
94
111
when (mockedEndpoint .getPatterns ()).thenReturn (new HashSet <>(Arrays .asList (new String [] { "bcast*" , "echo" })));
95
-
112
+ when (mockedEndpoint .getShardChannels ())
113
+ .thenReturn (new HashSet <>(Arrays .asList (new String [] { "shard_channel1" , "shard_channel2" })));
96
114
List <RedisFuture <Void >> subscriptions = connection .resubscribe ();
97
115
98
- assertEquals (2 , subscriptions .size ());
116
+ assertEquals (3 , subscriptions .size ());
99
117
assertInstanceOf (AsyncCommand .class , subscriptions .get (0 ));
100
118
assertInstanceOf (AsyncCommand .class , subscriptions .get (1 ));
119
+ assertInstanceOf (AsyncCommand .class , subscriptions .get (1 ));
101
120
}
102
121
103
122
}
0 commit comments