title: Testing JdbcTemplete.BatchUpdate method in Springboot
body: <p>I am writing a JUnit test for testing the below method save in the <code>ExampleRepository</code> class,</p>
  
  <pre><code>@Repository
  public class ExampleRepsoitory {
  
      @Autowired
      private JdbcTemplate jdbcTemplate;
  
  
      String sql = "Select * from Hello";
  
      public void save(List&lt;Course&gt; listOfCourses) {
  
          jdbcTemplate.batchUpdate(sql, new BatchPreparedStatementSetter() {
  
              @Override
              public void setValues(PreparedStatement arg0, int arg1) throws SQLException {
  
                  System.out.println("In Set Values Method");
              }
  
              @Override
              public int getBatchSize() {
  
                  System.out.println("In side getB");
                  return 0;
              }
          });
      }
  
  }
  </code></pre>
  
  <p>Below is the JUnit method,  </p>
  
  <pre><code>@Test
  public void testSave() throws Exception {
  
      List&lt;Course&gt; listofCourses = new ArrayList&lt;Course&gt;();
  
      Course course1 = new Course("Course1", "Spring", "10 Steps", Arrays
              .asList("Learn Maven", "Import Project", "First Example",
                      "Second Example"));
      Course course2 = new Course("Course2", "Spring MVC", "10 Examples",
              Arrays.asList("Learn Maven", "Import Project", "First Example",
                      "Second Example"));
  
      listofCourses.add(course1);
      listofCourses.add(course2);
  
      int[]  returnValue = {1,2,3};
  
      when(batchPreparedStatementSetter.getBatchSize()).thenReturn(5);
  
      when(jdbcTemplate.batchUpdate(sql, batchPreparedStatementSetter)).thenReturn(returnValue);
  
      exampleRepo.save(listofCourses);
  
  }
  </code></pre>
  
  <p>I want to test the code in <code>setValue()</code> and <code>getBatchSize()</code>methods so that it will include my test coverage.</p>
  
  <p>Please help, I tried with the above JUnit method but it's not working out.</p>