1616import static org .eclipse .che .api .core .model .workspace .runtime .MachineStatus .RUNNING ;
1717import static org .eclipse .che .api .core .model .workspace .runtime .MachineStatus .STARTING ;
1818import static org .eclipse .che .api .core .model .workspace .runtime .MachineStatus .STOPPED ;
19+ import static org .mockito .ArgumentMatchers .anyList ;
20+ import static org .mockito .ArgumentMatchers .nullable ;
1921import static org .mockito .Matchers .any ;
20- import static org .mockito .Matchers .anyListOf ;
21- import static org .mockito .Matchers .anyString ;
2222import static org .mockito .Mockito .atLeastOnce ;
2323import static org .mockito .Mockito .doAnswer ;
2424import static org .mockito .Mockito .doNothing ;
@@ -101,7 +101,7 @@ public void setup() throws Exception {
101101 when (internalMachineCfg2 .getInstallers ()).thenReturn (singletonList (newInstaller (2 )));
102102 environment .setContainers (ImmutableMap .of (DEV_MACHINE , config1 , DB_MACHINE , config2 ));
103103
104- doNothing ().when (networks ).createNetwork (anyString ( ));
104+ doNothing ().when (networks ).createNetwork (nullable ( String . class ));
105105 when (runtimeContext .getIdentity ()).thenReturn (IDENTITY );
106106 when (runtimeContext .getDockerEnvironment ()).thenReturn (environment );
107107 final LinkedList <String > orderedContainers = new LinkedList <>();
@@ -114,7 +114,7 @@ public void setup() throws Exception {
114114 .thenReturn (
115115 ImmutableMap .of (DEV_MACHINE , internalMachineCfg1 , DB_MACHINE , internalMachineCfg2 ));
116116 ServersCheckerFactory serversCheckerFactory = mock (ServersCheckerFactory .class );
117- when (serversCheckerFactory .create (any (), anyString ( ), any ()))
117+ when (serversCheckerFactory .create (any (), nullable ( String . class ), any ()))
118118 .thenReturn (mock (ServersChecker .class ));
119119 dockerRuntime =
120120 new DockerInternalRuntime (
@@ -136,7 +136,8 @@ public void startsDockerRuntimeAndPropagatesMachineStatusEvents() throws Excepti
136136 mockContainerStart ();
137137 dockerRuntime .start (emptyMap ());
138138
139- verify (starter , times (2 )).startContainer (anyString (), anyString (), any (), any (), any ());
139+ verify (starter , times (2 ))
140+ .startContainer (nullable (String .class ), nullable (String .class ), any (), any (), any ());
140141 verify (eventService , times (4 )).publish (any (MachineStatusEvent .class ));
141142 verifyEventsOrder (
142143 newEvent (DEV_MACHINE , STARTING , null ),
@@ -154,7 +155,8 @@ public void throwsExceptionWhenOneMachineStartFailed() throws Exception {
154155 try {
155156 dockerRuntime .start (emptyMap ());
156157 } catch (InfrastructureException ex ) {
157- verify (starter , times (1 )).startContainer (anyString (), anyString (), any (), any (), any ());
158+ verify (starter , times (1 ))
159+ .startContainer (nullable (String .class ), nullable (String .class ), any (), any (), any ());
158160 verify (eventService , times (2 )).publish (any (MachineStatusEvent .class ));
159161 verifyEventsOrder (newEvent (DEV_MACHINE , STARTING , null ), newEvent (DEV_MACHINE , FAILED , msg ));
160162 throw ex ;
@@ -168,7 +170,8 @@ public void throwsExceptionWhenBootstrappingOfInstallersFailed() throws Exceptio
168170 try {
169171 dockerRuntime .start (emptyMap ());
170172 } catch (InfrastructureException ex ) {
171- verify (starter , times (1 )).startContainer (anyString (), anyString (), any (), any (), any ());
173+ verify (starter , times (1 ))
174+ .startContainer (nullable (String .class ), nullable (String .class ), any (), any (), any ());
172175 verify (bootstrapper , times (1 )).bootstrap ();
173176 verify (eventService , times (3 )).publish (any (MachineStatusEvent .class ));
174177 verifyEventsOrder (
@@ -181,12 +184,15 @@ public void throwsExceptionWhenBootstrappingOfInstallersFailed() throws Exceptio
181184
182185 @ Test (expectedExceptions = RuntimeStartInterruptedException .class )
183186 public void throwsInterruptionExceptionWhenNetworkCreationInterrupted () throws Exception {
184- doThrow (RuntimeStartInterruptedException .class ).when (networks ).createNetwork (anyString ());
187+ doThrow (RuntimeStartInterruptedException .class )
188+ .when (networks )
189+ .createNetwork (nullable (String .class ));
185190
186191 try {
187192 dockerRuntime .start (emptyMap ());
188193 } catch (InfrastructureException ex ) {
189- verify (starter , never ()).startContainer (anyString (), anyString (), any (), any (), any ());
194+ verify (starter , never ())
195+ .startContainer (nullable (String .class ), nullable (String .class ), any (), any (), any ());
190196 throw ex ;
191197 }
192198 }
@@ -199,7 +205,8 @@ public void throwsInterruptionExceptionWhenContainerStartInterrupted() throws Ex
199205 try {
200206 dockerRuntime .start (emptyMap ());
201207 } catch (InfrastructureException ex ) {
202- verify (starter , times (1 )).startContainer (anyString (), anyString (), any (), any (), any ());
208+ verify (starter , times (1 ))
209+ .startContainer (nullable (String .class ), nullable (String .class ), any (), any (), any ());
203210 throw ex ;
204211 }
205212 }
@@ -216,16 +223,17 @@ public void throwsInterruptionExceptionWhenThreadInterruptedOnStarFailedBeforeDe
216223 })
217224 .when (starter )
218225 .startContainer (
219- anyString ( ),
220- anyString ( ),
226+ nullable ( String . class ),
227+ nullable ( String . class ),
221228 any (DockerContainerConfig .class ),
222229 any (RuntimeIdentity .class ),
223230 any (AbnormalMachineStopHandler .class ));
224231
225232 try {
226233 dockerRuntime .start (emptyMap ());
227234 } catch (InfrastructureException ex ) {
228- verify (starter , times (1 )).startContainer (anyString (), anyString (), any (), any (), any ());
235+ verify (starter , times (1 ))
236+ .startContainer (nullable (String .class ), nullable (String .class ), any (), any (), any ());
229237 throw ex ;
230238 }
231239 }
@@ -260,42 +268,42 @@ private static MachineStatusEvent newEvent(
260268
261269 private void mockContainerStart () throws InfrastructureException {
262270 when (starter .startContainer (
263- anyString ( ),
264- anyString ( ),
265- any (DockerContainerConfig .class ),
266- any (RuntimeIdentity .class ),
267- any (AbnormalMachineStopHandler .class )))
271+ nullable ( String . class ),
272+ nullable ( String . class ),
273+ nullable (DockerContainerConfig .class ),
274+ nullable (RuntimeIdentity .class ),
275+ nullable (AbnormalMachineStopHandler .class )))
268276 .thenReturn (mock (DockerMachine .class ));
269277 }
270278
271279 private void mockContainerStartFailed (InfrastructureException exception )
272280 throws InfrastructureException {
273281 when (starter .startContainer (
274- anyString ( ),
275- anyString ( ),
276- any (DockerContainerConfig .class ),
277- any (RuntimeIdentity .class ),
278- any (AbnormalMachineStopHandler .class )))
282+ nullable ( String . class ),
283+ nullable ( String . class ),
284+ nullable (DockerContainerConfig .class ),
285+ nullable (RuntimeIdentity .class ),
286+ nullable (AbnormalMachineStopHandler .class )))
279287 .thenThrow (exception );
280288 }
281289
282290 private void mockInstallersBootstrap () throws Exception {
283291 final DockerBootstrapper bootstrapper = mock (DockerBootstrapper .class );
284292 when (bootstrapperFactory .create (
285- anyString ( ),
286- any (RuntimeIdentity .class ),
287- anyListOf ( InstallerImpl . class ),
288- any (DockerMachine .class )))
293+ nullable ( String . class ),
294+ nullable (RuntimeIdentity .class ),
295+ anyList ( ),
296+ nullable (DockerMachine .class )))
289297 .thenReturn (bootstrapper );
290298 doNothing ().when (bootstrapper ).bootstrap ();
291299 }
292300
293301 private void mockInstallersBootstrapFailed (InfrastructureException exception ) throws Exception {
294302 when (bootstrapperFactory .create (
295- anyString ( ),
296- any (RuntimeIdentity .class ),
297- anyListOf ( InstallerImpl . class ),
298- any (DockerMachine .class )))
303+ nullable ( String . class ),
304+ nullable (RuntimeIdentity .class ),
305+ anyList ( ),
306+ nullable (DockerMachine .class )))
299307 .thenReturn (bootstrapper );
300308 doThrow (exception ).when (bootstrapper ).bootstrap ();
301309 }
0 commit comments