Advertisement
Amakesh

Untitled

Mar 24th, 2022 (edited)
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. @SpringBootTest
  2. @AutoConfigureMockMvc
  3. //@WebMvcTest(Controller.class)
  4. public class ControllerTest {
  5.  
  6.     @Autowired
  7.     Pesel pesel;
  8.  
  9.     @Autowired
  10.     MockMvc mockMvc;
  11.  
  12.     @Autowired
  13.     ObjectMapper objectMapper;
  14.  
  15.  
  16.     @Test
  17.     public void postPeselNumbersTest() throws Exception {
  18.  
  19.         List <Integer> numberslist = (Lists.newArrayList(2,2,2,2,2,2,2,2,2,2,2));
  20.         pesel.setNumbersList(numberslist);
  21.      
  22.  
  23.         mockMvc.perform(post("/validate")
  24.                         .contentType(MediaType.APPLICATION_JSON)
  25.                         .content(new Gson().toJson(pesel)))
  26.                 .andExpect(model().attribute("numbersist", pesel));
  27.              //   .andExpect(model().hasNoErrors())
  28.               //  .andExpect(view().name("pesel_validate"))
  29.              //   .andExpect(status().isOk());
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement