11package fr .ippon .rh .web ;
22
3- import fr .ippon .rh .service .OffreService ;
3+ import static junit .framework .Assert .assertEquals ;
4+ import static junit .framework .Assert .assertNotNull ;
5+ import static org .fest .assertions .Assertions .assertThat ;
6+ import static org .mockito .Mockito .mock ;
7+ import static org .mockito .Mockito .times ;
8+ import static org .mockito .Mockito .verify ;
9+ import static org .mockito .Mockito .when ;
10+
11+ import org .fest .assertions .Assertions ;
412import org .junit .Before ;
513import org .junit .Test ;
6- import org .springframework . test . util . ReflectionTestUtils ;
14+ import org .mockito . Mockito ;
715import org .springframework .ui .ExtendedModelMap ;
816
9- import static junit .framework .Assert .assertEquals ;
10- import static junit .framework .Assert .assertNotNull ;
11- import static org .easymock .EasyMock .*;
17+ import fr .ippon .rh .service .OffreService ;
1218
1319/**
1420 * Test de la classe {@link IpponController}
@@ -19,30 +25,28 @@ public class IpponControllerTest {
1925 private OffreService mockOffreService ;
2026
2127 @ Before
22- public void setUp (){
23- //Init
24- controller = new IpponController ();
25- mockOffreService = createMock (OffreService .class );
26- ReflectionTestUtils .setField (controller , "offreService" , mockOffreService );
28+ public void setUp () {
29+ mockOffreService = mock (OffreService .class );
30+ controller = new IpponController (mockOffreService );
2731 }
2832
2933 @ Test
30- public void testIpponRecruteGet (){
31- //Expect
34+ public void testIpponRecruteGet () {
35+ // Expect
3236 ExtendedModelMap model = new ExtendedModelMap ();
3337 String text = "Offre" ;
34- expect (mockOffreService .getOffre ()).andReturn (text );
38+ when (mockOffreService .getOffre ()).thenReturn (text );
3539
3640 // When
37- replay (mockOffreService );
3841 String returnViewName = controller .ipponRecrute (model );
3942
4043 // Verify
41- verify (mockOffreService );
42- assertNotNull (returnViewName );
43- assertEquals ("ippon" , returnViewName );
44- assertEquals (1 , model .size ());
45- assertNotNull (model .get ("offre" ));
46- assertEquals (text , model .get ("offre" ));
44+ verify (mockOffreService , times (1 )).getOffre ();
45+ assertThat (returnViewName ).isNotNull ();
46+ assertThat (returnViewName ).isEqualTo ("ippon" );
47+ assertThat (model ).isNotNull ();
48+ assertThat (model ).hasSize (1 );
49+ assertThat (model .get ("offre" )).isNotNull ();
50+ assertThat (model .get ("offre" )).isEqualTo (text );
4751 }
4852}
0 commit comments