File tree Expand file tree Collapse file tree
test/java/hexlet/code/controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,12 +78,13 @@ dependencies {
7878 testImplementation(platform(" org.junit:junit-bom:6.0.0-M1" ))
7979 testImplementation(" org.junit.jupiter:junit-jupiter:6.0.0-M1" )
8080
81- // для стартёра
81+ // стартёр тестов
8282 testImplementation(" org.springframework.boot:spring-boot-starter-test" )
8383
8484 // для аутентификации
8585 testImplementation(" org.springframework.security:spring-security-test" )
8686 // ****
87+ // testImplementation("org.springframework:spring-test:6.2.10")
8788
8889 // test JSON struct
8990 testImplementation(" net.javacrumbs.json-unit:json-unit-assertj:4.1.1" )
Original file line number Diff line number Diff line change 11package hexlet .code .model ;
22
3+
34public class BaseEntity {
45}
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ public class User extends BaseEntity implements UserDetails {
3737 @ NotBlank
3838 private String lastName ;
3939
40+
4041 @ Email
4142 @ Column (unique = true )
4243 private String email ;
Original file line number Diff line number Diff line change 11---
22logging :
33 level :
4- # root: WARN
5- root : DEBUG
4+ root : WARN
5+ # root: DEBUG
66 org :
77 springframework :
88 # web: DEBUG
99 security : DEBUG
1010 org.hibernate : " error"
1111
1212spring :
13- main :
14- banner-mode : " off"
13+ # main:
14+ # banner-mode: "off"
1515 output :
1616 ansi :
1717 enabled : always
Original file line number Diff line number Diff line change 11package hexlet .code .controller ;
22
3+ import com .fasterxml .jackson .databind .ObjectMapper ;
4+ import hexlet .code .mapper .UserMapper ;
5+ import hexlet .code .repository .UserRepository ;
36import org .junit .jupiter .api .Test ;
7+ import org .springframework .beans .factory .annotation .Autowired ;
8+ import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
49import org .springframework .boot .test .context .SpringBootTest ;
10+ import org .springframework .test .web .servlet .MockMvc ;
11+ import org .springframework .web .context .WebApplicationContext ;
512
613import static org .assertj .core .api .Assertions .assertThat ;
714
815@ SpringBootTest
16+ @ AutoConfigureMockMvc
917public class TestUserController {
1018
19+ @ Autowired
20+ private MockMvc mockMvc ;
21+
22+ @ Autowired
23+ private ObjectMapper om ;
24+
25+ @ Autowired
26+ private UserRepository userRepository ;
27+
28+ @ Autowired
29+ private UserMapper userMapper ;
30+
31+ @ Autowired
32+ private WebApplicationContext wac ;
33+
34+
1135 @ Test
1236 public void testWelcome () {
1337 assertThat (true ).isTrue ();
You can’t perform that action at this time.
0 commit comments