title: How can I write a JUnit test for a void function with 3 probabilities?
body: <p>Think that I can favorite movies in a website with a twitter-style toggle star button, but I can only have one favorite movie. </p>
  
  <p>Probabilities: </p>
  
  <p>1) When I have a favorite movie and decide to favorite a different movie, it will remove the favorite from the old one and will add a favorite to the new movie (Delete one row, insert one row).</p>
  
  <p>2) I already favorited the movie. So when I clicked it again, it will be removed, the movie would be unfavorited (Delete one row). </p>
  
  <p>T3) I have no favorite movie. When I click favorite for a movie, it will assign the movie as my favorite (Insert one row).</p>
  
  <p>I have a single function in my backend java code for this 3 probabilities:</p>
  
  <pre><code>@PUT
  @Path("/updateFavorite/{newMovieId}")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  public void updateFavorite(@PathParam("newMovieId") int newMovieId) {
      EntityManager entityManager = entityManagerFactory
              .createEntityManager();
  
      try {
          boolean removeFavorite = false;
  
          entityManager.getTransaction().begin();
  
          MovieEntity newMovie = fetchMovieWithId(entityManager, newMovieId);
  
          int movieGenre = newMovie.getMovieGenre();
  
          if (favoriteMovieExists(entityManager, movieGenre)) {
              FavoriteMovieEntity existingFavoriteMovie = fetchFavoriteMovieWithGenre(
                      entityManager, movieGenre);
              // If existing movie and the current movie are the
              // same, than it is a 'remove favorite' click
              if (existingFavoriteMovie.getMovieId() == newMovie.getMovieId()) {
                  removeFavorite = true;
              }
              entityManager.remove(existingFavoriteMovie);
          }
          // it is not already favorited, create a new favorite
          if (!removeFavorite) {
              FavoriteMovieEntity newFavoriteMovie = new FavoriteMovieEntity();
              FavoriteMoviePK newFavoritePK = new FavoriteMoviePK(getUser(),
                      movieGenre);
  
              newFavoriteMovie.setKey(newFavoritePK);
              newFavoriteMovie.setMovieId(newMovieId);
  
              entityManager.persist(newFavoriteMovie);
          }
          entityManager.getTransaction().commit();
      } catch (Exception ex) {
          ex.printStackTrace();
          if (entityManager.getTransaction().isActive()) {
              entityManager.getTransaction().rollback();
          }
      } finally {
          entityManager.close();
      }
  }
  </code></pre>
  
  <p>I decided to write 3 test functions for each probability, but i am not sure how can I do without any value returned. </p>