55
66import org .hamcrest .Matchers ;
77import org .junit .jupiter .api .AfterEach ;
8- import org .junit .jupiter .api .BeforeEach ;
98import org .junit .jupiter .api .Test ;
109import org .springframework .beans .factory .annotation .Autowired ;
1110import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
1413import org .springframework .test .web .servlet .MockMvc ;
1514import org .springframework .test .web .servlet .request .MockMvcRequestBuilders ;
1615import org .springframework .test .web .servlet .result .MockMvcResultMatchers ;
17- import org .springframework .web .context .WebApplicationContext ;
1816
1917
2018import java .nio .CharBuffer ;
2119
22- import static org .junit .jupiter .api .Assertions .assertNotNull ;
23- import static org .springframework .test .web .client .match .MockRestRequestMatchers .jsonPath ;
2420import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
2521import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .content ;
2622import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
@@ -32,22 +28,8 @@ public class QuestionControllerTest {
3228 @ Autowired
3329 private QuestionRepository questionRepository ;
3430
35- @ Autowired
36- private WebApplicationContext webApplicationContext ;
37-
3831 @ Autowired
3932 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- }
5133
5234 @ AfterEach
5335 void deleteQuestions () {
@@ -189,4 +171,13 @@ void testDeleteQuestion() throws Exception {
189171 .contentType (MediaType .APPLICATION_JSON ))
190172 .andExpect (status ().isOk ());
191173 }
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+ }
192183}
0 commit comments