Guest User

Untitled

a guest
Dec 11th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. @RunWith(SpringRunner.class)
  2. @WebMvcTest(BookCRUDOperationsController.class)
  3. public class BookCRUDOperationsControllerTest {
  4.  
  5. @Autowired
  6. MockMvc mockMvc;
  7.  
  8. @MockBean
  9. BookCRUDOperationsService bookCRUDOperationsService;
  10.  
  11. @Test
  12. public void createBook() throws Exception {
  13.  
  14. Book newBook = new Book("W pustyni i w puszczy", "Henryk Sienkiewicz", "dramat", true);
  15.  
  16. //Mockito.when(bookCRUDOperationsService.createBook(newBook)).thenReturn(newBook); ??
  17.  
  18. mockMvc.perform(post("/books"))
  19. .andExpect(status().isOk()).andDo(print())
  20. .andExpect((ResultMatcher) content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();
  21. }
Add Comment
Please, Sign In to add comment