TbCctvCtlrControllerTest.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.its.op;
  2. import com.fasterxml.jackson.databind.ObjectMapper;
  3. import com.its.op.dto.its.cctv.TbCctvCtlrDto;
  4. import org.junit.jupiter.api.BeforeEach;
  5. import org.junit.jupiter.api.DisplayName;
  6. import org.junit.jupiter.api.Test;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.test.web.servlet.MockMvc;
  9. import org.springframework.test.web.servlet.setup.MockMvcBuilders;
  10. import org.springframework.web.context.WebApplicationContext;
  11. //@WebMvcTest(TbCctvCtlrController.class)
  12. public class TbCctvCtlrControllerTest {
  13. @Autowired
  14. private MockMvc mockMvc;
  15. @Autowired
  16. private WebApplicationContext ctx;
  17. @Autowired
  18. private ObjectMapper objectMapper;
  19. @BeforeEach
  20. void setUp() {
  21. //RequestResponseBodyMethodProcessor
  22. mockMvc = MockMvcBuilders.webAppContextSetup(ctx)
  23. // .alwaysDo(print())
  24. .build();
  25. }
  26. @Test
  27. @DisplayName("Post @Valid 테스트")
  28. void test() throws Exception {
  29. final String obj = objectMapper.writeValueAsString(new TbCctvCtlrDto.TbCctvCtlrUpdReq());
  30. // mockMvc.perform(post("/api/cctv/manager/info/1")
  31. // .content(obj)
  32. // .contentType(MediaType.APPLICATION_JSON_VALUE))
  33. // .andExpect(status().isBadRequest());
  34. }
  35. @Test
  36. @DisplayName("Get @Validated 테스트")
  37. void hiTest() throws Exception {
  38. // mockMvc.perform(get("/api/cctv/manager/info/1")
  39. // //.param("value", "0")
  40. // .contentType(MediaType.APPLICATION_JSON_VALUE)
  41. // )
  42. // .andExpect(status().isInternalServerError());
  43. }
  44. }