### Question:
BatchProcessing { public void useStatement(){ try { String insertEmployeeSQL = "INSERT INTO EMPLOYEE(ID, NAME, DESIGNATION) VALUES ('%s','%s','%s');"; String insertEmployeeAddrSQL = "INSERT INTO EMP_ADDRESS(ID, EMP_ID, ADDRESS) VALUES ('%s','%s','%s');"; Statement statement = connection.createStatement(); for(int i = 0; i < EMPLOYEES.length; i++){ String employeeId = UUID.randomUUID().toString(); statement.addBatch(String.format(insertEmployeeSQL, employeeId, EMPLOYEES[i],DESIGNATIONS[i])); statement.addBatch(String.format(insertEmployeeAddrSQL, UUID.randomUUID().toString(),employeeId,ADDRESSES[i])); } statement.executeBatch(); connection.commit(); } catch (Exception e) { try { connection.rollback(); } catch (SQLException ex) { System.out.println("Error during rollback"); System.out.println(ex.getMessage()); } e.printStackTrace(System.out); } }  void getConnection(); void createTables(); void useStatement(); void usePreparedStatement(); static void main(String[] args);  }### Answer:
@Test public void when_useStatement_thenInsertData_success() throws Exception { Mockito.when(connection.createStatement()).thenReturn(statement); target.useStatement(); }
@Test public void when_useStatement_ifThrowException_thenCatchException() throws Exception { Mockito.when(connection.createStatement()).thenThrow(new RuntimeException()); target.useStatement(); }