11package org .synyx .hera .core .support ;
22
3- import static org .easymock .EasyMock .*;
43import static org .junit .Assert .*;
4+ import static org .mockito .Mockito .*;
55
66import java .util .HashMap ;
77import java .util .List ;
88import java .util .Map ;
99
1010import org .junit .Before ;
1111import org .junit .Test ;
12+ import org .junit .runner .RunWith ;
13+ import org .mockito .Mock ;
14+ import org .mockito .runners .MockitoJUnitRunner ;
1215import org .springframework .context .ApplicationContext ;
1316import org .springframework .core .Ordered ;
1417
1821 *
1922 * @author Oliver Gierke - gierke@synyx.de
2023 */
24+ @ RunWith (MockitoJUnitRunner .class )
2125public class BeanListFactoryBeanUnitTest {
2226
2327 private BeanListFactoryBean <Ordered > factory ;
28+
29+ @ Mock
2430 private ApplicationContext context ;
2531
2632
2733 @ Before
2834 public void setUp () {
2935
30- context = createNiceMock (ApplicationContext .class );
31-
3236 factory = new BeanListFactoryBean <Ordered >();
3337 factory .setApplicationContext (context );
3438 factory .setType (Ordered .class );
@@ -46,9 +50,7 @@ public void regardsOrderOfBeans() throws Exception {
4650 beans .put ("first" , first );
4751 beans .put ("second" , second );
4852
49- expect (context .getBeansOfType (Ordered .class )).andReturn (beans )
50- .anyTimes ();
51- replay (context );
53+ when (context .getBeansOfType (Ordered .class )).thenReturn (beans );
5254
5355 Object result = factory .getObject ();
5456 assertTrue (result instanceof List <?>);
@@ -63,9 +65,8 @@ public void regardsOrderOfBeans() throws Exception {
6365 @ Test
6466 public void returnsEmptyListIfNoBeansFound () throws Exception {
6567
66- expect (context .getBeansOfType (Ordered .class )).andReturn (
68+ when (context .getBeansOfType (Ordered .class )).thenReturn (
6769 new HashMap <String , Ordered >());
68- replay (context );
6970
7071 Object result = factory .getObject ();
7172 assertTrue (result instanceof List <?>);
0 commit comments