title: Mockito and EasyMock
body: <p>In EasyMock when we want to record an expectation for a method that doesn't have a return type like <code>bookService.save();</code>, we just call the method before the replay.</p>
  
  <p>How can we perform this with Mockito and what is the equivalent of <code>replay()</code> for Mockito?</p>
  
  <p>My Test controller is </p>
  
  <pre><code> @RequestMapping(value = "/add", method = RequestMethod.POST)
      public String addBookPost(@ModelAttribute("book") Book book, HttpServletRequest request, Model model) {
  
          bookService.save(book);
          MultipartFile bookImage = book.getBookImage();
          try {
              byte[] bytes = bookImage.getBytes();
              String name = book.getId() + ".png";
              BufferedOutputStream stream = new BufferedOutputStream(
                      new FileOutputStream(new File("src/main/resources/static/image/book/" + name)));
              stream.write(bytes);
              stream.close();
          } catch (Exception e) {
              e.printStackTrace();
          }
          return "redirect:bookList";
      }
  </code></pre>
  
  <p>This is my test</p>
  
  <pre><code> @Test
       public void addBookClicked() throws Exception {
  
          Mockito.verify(bookService).save(book);
  
          mockMvc.perform(get("/book/add").with(user("admin").password("admin").roles("USER","ADMIN"))
  
                  .accept(MediaType.TEXT_HTML)
                  .contentType(MediaType.TEXT_HTML))
                  .andExpect(status().isOk())
  
                  .andExpect(model().attributeExists("book"))
                  .andExpect(view().name("addBook"))
                  .andReturn();
      }
  </code></pre>
  
  <p>But it's wrong. How should I verify the call?</p>