-
Notifications
You must be signed in to change notification settings - Fork 676
Expand file tree
/
Copy pathVetControllerTest.java
More file actions
52 lines (40 loc) · 1.73 KB
/
VetControllerTest.java
File metadata and controls
52 lines (40 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package guru.springframework.sfgpetclinic.controllers;
import guru.springframework.sfgpetclinic.ControllerTests;
import guru.springframework.sfgpetclinic.fauxspring.Model;
import guru.springframework.sfgpetclinic.fauxspring.ModelMap;
import guru.springframework.sfgpetclinic.fauxspring.ModelMapImpl;
import guru.springframework.sfgpetclinic.model.Vet;
import guru.springframework.sfgpetclinic.services.SpecialtyService;
import guru.springframework.sfgpetclinic.services.VetService;
import guru.springframework.sfgpetclinic.services.map.SpecialityMapService;
import guru.springframework.sfgpetclinic.services.map.VetMapService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
//@Tag("Controllers") <- now gets the tag from interface
class VetControllerTest implements ControllerTests {
VetService vetService;
SpecialtyService specialtyService;
VetController vetController;
@BeforeEach
void setUp() {
specialtyService = new SpecialityMapService();
vetService = new VetMapService(specialtyService);
vetController = new VetController(vetService);
Vet vet1 = new Vet(1L, "Joe", "Buck", null);
Vet vet2 = new Vet(2L, "Jimmy", "Smith", null);
vetService.save(vet1);
vetService.save(vet2);
}
@Test
void listVets() {
Model model = new ModelMapImpl();
String view = vetController.listVets(model);
assertThat("vets/index").isEqualTo(view);
Set modelAtt = (Set) ((ModelMapImpl)model).getMap().get("vets");
assertThat(modelAtt.size()).isEqualTo(2);
}
}