Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RunWith(SpringRunner.class)
- @WebMvcTest(BookCRUDOperationsController.class)
- public class BookCRUDOperationsControllerTest {
- @Autowired
- MockMvc mockMvc;
- @MockBean
- BookCRUDOperationsService bookCRUDOperationsService;
- @Test
- public void createBook() throws Exception {
- Book newBook = new Book("W pustyni i w puszczy", "Henryk Sienkiewicz", "dramat", true);
- //Mockito.when(bookCRUDOperationsService.createBook(newBook)).thenReturn(newBook); ??
- mockMvc.perform(post("/books"))
- .andExpect(status().isOk()).andDo(print())
- .andExpect((ResultMatcher) content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();
- }
Add Comment
Please, Sign In to add comment