title: how can I test a void method that insert a record in database using Junit?
body: <p>I have a method that calls another method to retrieve data and insert it into the database, how can I test this method in Junit since this method retrieve nothing? Can anyone provide me some example of this situation? </p>
  
  <pre><code>public static void method(){ 
      User user = getUser();  
      try {
          String Query = "INSERT INTO users (USER_ID , Name) VALUES ("
           +user.getID()+","+user.getName()+")";
  
          Statement statement = conn.createStatement();
          statement.executeUpdate(Query);
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>I was thinking to use mock object for user, but I'm not sure how can I check if the user is inserted to the database. please help.</p>