2
2
3
3
import static com .devonfw .cobigen .api .assertj .CobiGenAsserts .assertThat ;
4
4
import static com .devonfw .cobigen .test .matchers .CustomHamcrestMatchers .hasItemsInList ;
5
+ import static org .hamcrest .CoreMatchers .any ;
5
6
import static org .hamcrest .CoreMatchers .equalTo ;
6
7
import static org .hamcrest .CoreMatchers .sameInstance ;
7
8
import static org .junit .Assert .assertEquals ;
8
9
import static org .junit .Assert .assertNotNull ;
9
- import static org .mockito .Matchers .any ;
10
- import static org .mockito .Matchers .anyList ;
11
- import static org .mockito .Matchers .argThat ;
10
+ import static org .mockito .ArgumentMatchers .anyList ;
12
11
import static org .mockito .Mockito .mock ;
13
12
import static org .mockito .Mockito .when ;
14
- import static org .mockito .internal . matchers . Any . ANY ;
13
+ import static org .mockito .hamcrest . MockitoHamcrest . argThat ;
15
14
16
15
import java .io .File ;
17
16
import java .nio .charset .Charset ;
20
19
21
20
import org .junit .Assert ;
22
21
import org .junit .Test ;
22
+ import org .mockito .Mockito ;
23
23
24
24
import com .devonfw .cobigen .api .CobiGen ;
25
25
import com .devonfw .cobigen .api .extension .GeneratorPluginActivator ;
@@ -251,26 +251,34 @@ public String toString() {
251
251
when (triggerInterpreter .getMatcher ()).thenReturn (matcher );
252
252
when (triggerInterpreter .getInputReader ()).thenReturn (inputReader );
253
253
254
- when (inputReader .isValidInput (any ())).thenReturn (true );
254
+ when (inputReader .isValidInput (Mockito . any ())).thenReturn (true );
255
255
256
256
// Simulate container children resolution of any plug-in
257
- when (matcher .resolveVariables (argThat (new MatcherToMatcher (equalTo ("or" ), ANY , sameInstance (child1 ))), anyList (),
258
- any ())).thenReturn (ImmutableMap .<String , String > builder ().put ("variable" , "child1" ).build ());
259
- when (matcher .resolveVariables (argThat (new MatcherToMatcher (equalTo ("or" ), ANY , sameInstance (child2 ))), anyList (),
260
- any ())).thenReturn (ImmutableMap .<String , String > builder ().put ("variable" , "child2" ).build ());
261
- when (inputReader .getInputObjects (any (), any (Charset .class ))).thenReturn (Lists .newArrayList (child1 , child2 ));
257
+ when (matcher .resolveVariables (argThat (new MatcherToMatcher (equalTo ("or" ), any (String .class ), sameInstance (child1 ))),
258
+ anyList (), Mockito .any ()))
259
+ .thenReturn (ImmutableMap .<String , String > builder ().put ("variable" , "child1" ).build ());
260
+ when (matcher .resolveVariables (argThat (new MatcherToMatcher (equalTo ("or" ), any (String .class ), sameInstance (child2 ))),
261
+ anyList (), Mockito .any ()))
262
+ .thenReturn (ImmutableMap .<String , String > builder ().put ("variable" , "child2" ).build ());
263
+ when (inputReader .getInputObjects (Mockito .any (), Mockito .any (Charset .class )))
264
+ .thenReturn (Lists .newArrayList (child1 , child2 ));
262
265
263
266
// match container
264
- when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("container" ), ANY , sameInstance (container )))))
265
- .thenReturn (true );
267
+ when (matcher
268
+ .matches (argThat (new MatcherToMatcher (equalTo ("container" ), any (String .class ), sameInstance (container )))))
269
+ .thenReturn (true );
266
270
267
271
// do not match first child
268
- when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("or" ), ANY , sameInstance (child1 ))))).thenReturn (true );
269
- when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("not" ), ANY , sameInstance (child1 ))))).thenReturn (true );
272
+ when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("or" ), any (String .class ), sameInstance (child1 )))))
273
+ .thenReturn (true );
274
+ when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("not" ), any (String .class ), sameInstance (child1 )))))
275
+ .thenReturn (true );
270
276
271
277
// match second child
272
- when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("or" ), ANY , sameInstance (child2 ))))).thenReturn (true );
273
- when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("not" ), ANY , sameInstance (child2 ))))).thenReturn (false );
278
+ when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("or" ), any (String .class ), sameInstance (child2 )))))
279
+ .thenReturn (true );
280
+ when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("not" ), any (String .class ), sameInstance (child2 )))))
281
+ .thenReturn (false );
274
282
275
283
PluginRegistry .registerTriggerInterpreter (triggerInterpreter , activator );
276
284
@@ -346,10 +354,10 @@ public String toString() {
346
354
when (triggerInterpreter .getMatcher ()).thenReturn (matcher );
347
355
when (triggerInterpreter .getInputReader ()).thenReturn (inputReader );
348
356
349
- when (inputReader .isValidInput (any ())).thenReturn (true );
350
- when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("fqn" ), ANY , sameInstance (container )))))
357
+ when (inputReader .isValidInput (Mockito . any ())).thenReturn (true );
358
+ when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("fqn" ), any ( String . class ) , sameInstance (container )))))
351
359
.thenReturn (false );
352
- when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("package" ), ANY , sameInstance (container )))))
360
+ when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("package" ), any ( String . class ) , sameInstance (container )))))
353
361
.thenReturn (true );
354
362
355
363
// Simulate container children resolution of any plug-in
@@ -361,22 +369,25 @@ public String toString() {
361
369
return "child2" ;
362
370
}
363
371
};
364
- when (inputReader .getInputObjects (any (), any (Charset .class )))
372
+ when (inputReader .getInputObjects (Mockito . any (), Mockito . any (Charset .class )))
365
373
.thenReturn (Lists .newArrayList (firstChildResource , secondChildResource ));
366
374
} else {
367
- when (inputReader .getInputObjects (any (), any (Charset .class ))).thenReturn (Lists .newArrayList (firstChildResource ));
375
+ when (inputReader .getInputObjects (Mockito .any (), Mockito .any (Charset .class )))
376
+ .thenReturn (Lists .newArrayList (firstChildResource ));
368
377
}
369
378
370
- when (matcher .matches (argThat (new MatcherToMatcher (equalTo ("fqn" ), ANY , sameInstance (firstChildResource )))))
371
- .thenReturn (containerChildMatchesTrigger );
379
+ when (matcher
380
+ .matches (argThat (new MatcherToMatcher (equalTo ("fqn" ), any (String .class ), sameInstance (firstChildResource )))))
381
+ .thenReturn (containerChildMatchesTrigger );
372
382
373
383
// Simulate variable resolving of any plug-in
374
- when (matcher .resolveVariables (argThat (new MatcherToMatcher (equalTo ("fqn" ), ANY , sameInstance (firstChildResource ))),
384
+ when (matcher .resolveVariables (
385
+ argThat (new MatcherToMatcher (equalTo ("fqn" ), any (String .class ), sameInstance (firstChildResource ))),
375
386
argThat (hasItemsInList (
376
387
//
377
388
new VariableAssignmentToMatcher (equalTo ("regex" ), equalTo ("rootPackage" ), equalTo ("1" ), equalTo (false )),
378
389
new VariableAssignmentToMatcher (equalTo ("regex" ), equalTo ("entityName" ), equalTo ("3" ), equalTo (false )))),
379
- any ()))
390
+ Mockito . any ()))
380
391
.thenReturn (ImmutableMap .<String , String > builder ().put ("rootPackage" , "com.devonfw" )
381
392
.put ("entityName" , "Test" ).build ());
382
393
0 commit comments