5
5
6
6
import org .hamcrest .Matchers ;
7
7
import org .junit .jupiter .api .AfterEach ;
8
- import org .junit .jupiter .api .BeforeEach ;
9
8
import org .junit .jupiter .api .Test ;
10
9
import org .springframework .beans .factory .annotation .Autowired ;
11
10
import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
14
13
import org .springframework .test .web .servlet .MockMvc ;
15
14
import org .springframework .test .web .servlet .request .MockMvcRequestBuilders ;
16
15
import org .springframework .test .web .servlet .result .MockMvcResultMatchers ;
17
- import org .springframework .web .context .WebApplicationContext ;
18
16
19
17
20
18
import java .nio .CharBuffer ;
21
19
22
- import static org .junit .jupiter .api .Assertions .assertNotNull ;
23
- import static org .springframework .test .web .client .match .MockRestRequestMatchers .jsonPath ;
24
20
import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
25
21
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .content ;
26
22
import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
@@ -32,22 +28,8 @@ public class QuestionControllerTest {
32
28
@ Autowired
33
29
private QuestionRepository questionRepository ;
34
30
35
- @ Autowired
36
- private WebApplicationContext webApplicationContext ;
37
-
38
31
@ Autowired
39
32
private MockMvc mockMvc ;
40
- @ Autowired
41
- private QuestionController questionController ;
42
-
43
- private void fillQuestions (Integer number ) {
44
- for (int i = 0 ; i < number ; i ++) {
45
- Question question = new Question ();
46
- question .setTitle ("Question " + i );
47
- question .setDescription ("Description " + i );
48
- questionRepository .save (question );
49
- }
50
- }
51
33
52
34
@ AfterEach
53
35
void deleteQuestions () {
@@ -189,4 +171,13 @@ void testDeleteQuestion() throws Exception {
189
171
.contentType (MediaType .APPLICATION_JSON ))
190
172
.andExpect (status ().isOk ());
191
173
}
174
+
175
+ private void fillQuestions (Integer number ) {
176
+ for (int i = 0 ; i < number ; i ++) {
177
+ Question question = new Question ();
178
+ question .setTitle ("Question " + i );
179
+ question .setDescription ("Description " + i );
180
+ questionRepository .save (question );
181
+ }
182
+ }
192
183
}
0 commit comments