1
+ package guru .springframework .sfgpetclinic .controllers ;
2
+
3
+ import guru .springframework .sfgpetclinic .fauxspring .Model ;
4
+ import guru .springframework .sfgpetclinic .fauxspring .ModelMapImpl ;
5
+ import guru .springframework .sfgpetclinic .model .Vet ;
6
+ import guru .springframework .sfgpetclinic .services .SpecialtyService ;
7
+ import guru .springframework .sfgpetclinic .services .VetService ;
8
+ import guru .springframework .sfgpetclinic .services .map .SpecialityMapService ;
9
+ import guru .springframework .sfgpetclinic .services .map .VetMapService ;
10
+ import org .junit .jupiter .api .BeforeEach ;
11
+ import org .junit .jupiter .api .Test ;
12
+
13
+ import static org .junit .jupiter .api .Assertions .*;
14
+
15
+ class VetControllerTest {
16
+
17
+ private VetController vetController ;
18
+ private VetService vetService ;
19
+ private SpecialtyService specialtyService ;
20
+ Vet vet1 ;
21
+ Vet vet2 ;
22
+ @ BeforeEach
23
+ void setUp () {
24
+ specialtyService = new SpecialityMapService ();
25
+ vetService = new VetMapService (specialtyService );
26
+ vetController = new VetController (vetService );
27
+ vet1 = new Vet (1l , "joe" , "buck" , null );
28
+ vet2 = new Vet (2l , "joe" , "biden" , null );
29
+
30
+ vetService .save (vet1 );
31
+ vetService .save (vet2 );
32
+ }
33
+
34
+ @ Test
35
+ void listVets () {
36
+ Model model = new ModelMapImpl ();
37
+ assertEquals ("vets/index" , vetController .listVets (model ));
38
+ assertEquals (2 , ((ModelMapImpl ) model ).getMap ().size ());
39
+ }
40
+ }
0 commit comments