@@ -32,12 +32,14 @@ import org.apache.toree.kernel.protocol.v5.client.execution.{DeferredExecution,
32
32
import org .apache .toree .kernel .protocol .v5 .client .{ActorLoader , Utilities }
33
33
import org .apache .toree .kernel .protocol .v5 .content .{CommClose , CommMsg , CommOpen , StreamContent }
34
34
import com .typesafe .config .ConfigFactory
35
- import org .mockito .Matchers .{eq => mockEq , _ }
35
+ import org .mockito .ArgumentMatchers .{eq => mockEq , _ }
36
36
import org .mockito .Mockito ._
37
37
import org .scalatest .concurrent .{Eventually , ScalaFutures }
38
38
import org .scalatestplus .mockito .MockitoSugar
39
39
import org .scalatest .time .{Milliseconds , Span }
40
- import org .scalatest .{BeforeAndAfter , FunSpecLike , Matchers }
40
+ import org .scalatest .funspec .AnyFunSpecLike
41
+ import org .scalatest .matchers .should .Matchers
42
+ import org .scalatest .BeforeAndAfterEach
41
43
import play .api .libs .json .Json
42
44
43
45
import scala .concurrent .duration ._
@@ -53,8 +55,8 @@ object IOPubClientSpec {
53
55
54
56
class IOPubClientSpec extends TestKit (ActorSystem (
55
57
" IOPubClientSpecSystem" , ConfigFactory .parseString(IOPubClientSpec .config)
56
- )) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar
57
- with ScalaFutures with BeforeAndAfter with Eventually
58
+ )) with ImplicitSender with AnyFunSpecLike with Matchers with MockitoSugar
59
+ with ScalaFutures with BeforeAndAfterEach with Eventually
58
60
{
59
61
private val TestTimeout = Timeout (10 .seconds)
60
62
implicit override val patienceConfig = PatienceConfig (
@@ -77,19 +79,19 @@ class IOPubClientSpec extends TestKit(ActorSystem(
77
79
private val TestTargetName = " some target"
78
80
private val TestCommId = UUID .randomUUID().toString
79
81
80
- before {
82
+ override def beforeEach () : Unit = {
81
83
kmBuilder = KMBuilder ()
82
84
mockCommCallbacks = mock[CommCallbacks ]
83
85
mockCommRegistrar = mock[CommRegistrar ]
84
86
85
- spyCommStorage = spy(new CommStorage ())
87
+ spyCommStorage = spy[ CommStorage ] (new CommStorage ())
86
88
87
89
clientSocketProbe = TestProbe ()
88
90
mockActorLoader = mock[ActorLoader ]
89
91
mockClientSocketFactory = mock[SocketFactory ]
90
92
91
93
// Stub the return value for the socket factory
92
- when(mockClientSocketFactory.IOPubClient (anyObject (), any[ActorRef ]))
94
+ when(mockClientSocketFactory.IOPubClient (any[ ActorSystem ] (), any[ActorRef ]))
93
95
.thenReturn(clientSocketProbe.ref)
94
96
95
97
// Construct the object we will test against
@@ -108,7 +110,7 @@ class IOPubClientSpec extends TestKit(ActorSystem(
108
110
.build
109
111
110
112
// Mark as target being provided
111
- doReturn(Some (mockCommCallbacks)).when(spyCommStorage)
113
+ doReturn(Some (mockCommCallbacks), Nil : _* ).when(spyCommStorage)
112
114
.getTargetCallbacks(anyString())
113
115
114
116
// Simulate receiving a message from the kernel
@@ -129,7 +131,7 @@ class IOPubClientSpec extends TestKit(ActorSystem(
129
131
.build
130
132
131
133
// Mark as target NOT being provided
132
- doReturn(None ).when(spyCommStorage).getTargetCallbacks(anyString())
134
+ doReturn(None , Nil : _* ).when(spyCommStorage).getTargetCallbacks(anyString())
133
135
134
136
// Simulate receiving a message from the kernel
135
137
ioPubClient ! message
@@ -153,7 +155,7 @@ class IOPubClientSpec extends TestKit(ActorSystem(
153
155
.build
154
156
155
157
// Mark as target being provided
156
- doReturn(Some (mockCommCallbacks)).when(spyCommStorage)
158
+ doReturn(Some (mockCommCallbacks), Nil : _* ).when(spyCommStorage)
157
159
.getCommIdCallbacks(any[v5.UUID ])
158
160
159
161
// Simulate receiving a message from the kernel
@@ -173,7 +175,7 @@ class IOPubClientSpec extends TestKit(ActorSystem(
173
175
.build
174
176
175
177
// Mark as target NOT being provided
176
- doReturn(None ).when(spyCommStorage).getCommIdCallbacks(any[v5.UUID ])
178
+ doReturn(None , Nil : _* ).when(spyCommStorage).getCommIdCallbacks(any[v5.UUID ])
177
179
178
180
// Simulate receiving a message from the kernel
179
181
ioPubClient ! message
@@ -195,7 +197,7 @@ class IOPubClientSpec extends TestKit(ActorSystem(
195
197
.build
196
198
197
199
// Mark as target being provided
198
- doReturn(Some (mockCommCallbacks)).when(spyCommStorage)
200
+ doReturn(Some (mockCommCallbacks), Nil : _* ).when(spyCommStorage)
199
201
.getCommIdCallbacks(any[v5.UUID ])
200
202
201
203
// Simulate receiving a message from the kernel
@@ -215,7 +217,7 @@ class IOPubClientSpec extends TestKit(ActorSystem(
215
217
.build
216
218
217
219
// Mark as target NOT being provided
218
- doReturn(None ).when(spyCommStorage).getCommIdCallbacks(any[v5.UUID ])
220
+ doReturn(None , Nil : _* ).when(spyCommStorage).getCommIdCallbacks(any[v5.UUID ])
219
221
220
222
// Simulate receiving a message from the kernel
221
223
ioPubClient ! message
0 commit comments