I have a service layer with methods to insert data into db, update data and delete data from db, which invoke DAO layer for the definitions of these methods. In the client package, I have a test class, where I get user input for the operations invoking the service layer.
My service class looks as follows:
public class Service extends AbstractService {
public void createEmp(Emp emp) {
EmpDAO empDao = new EmpDAO();
empDao.insertEmp(emp);
}
public int updateEmp(int empId, Emp emp) {
EmpDAO empDao = new EmpDAO();
int rows_affected = empDao.updateEmp(empId, emp);
return rows_affected;
}
public int deleteEmp(int empId) {
EmpDAO empDao = new EmpDAO();
int rows_affected = empDao.deleteEmp(empId);
return rows_affected;
}
}
and test class looks as follows:
public class Application {
public void insertData(){
Emp em = new Emp();
Service service = new Service();
//insert data into Employee table
em.setEmpName("aaaaaa");
em.setDeptId(2);
service.createEmp(em);
}
public void updateData(){
// update employee
em.setDeptId(2);
.....
service.updateEmp(2,em);
.....
}
public void deleteData()
//Delete data from Employee table
service.deleteEmp(2);
}
}
Now I want to write a test class to test my method using TestNG. I don't know how to use @DataProvider
to give input for the insert operation to invoke it once with more inputs.