Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package jdbc;
- import static org.junit.Assert.assertEquals;
- import static org.junit.Assert.assertNotEquals;
- import static org.junit.Assert.assertNotNull;
- import static org.junit.Assert.assertNull;
- import static org.junit.Assert.assertTrue;
- import org.junit.Ignore;
- import org.junit.Test;
- import com.itstep.mvn.app.jdbc.dao.EmployeeDAO;
- import com.itstep.mvn.app.jdbc.dao.EmployeeDAOImpl;
- import com.itstep.mvn.app.jdbc.dao.OfficeDAO;
- import com.itstep.mvn.app.jdbc.dao.OfficeDAOImpl;
- import com.itstep.mvn.app.jdbc.dao.ProductsDAOImpl;
- import com.itstep.mvn.app.jdbc.dao.ProductsDao;
- import com.itstep.mvn.app.jdbc.dao.UniverDao;
- import com.itstep.mvn.app.jdbc.dao.UniverDaoImpl;
- import com.itstep.mvn.app.model.jdbc.Employee;
- import com.itstep.mvn.app.model.jdbc.Office;
- import com.itstep.mvn.app.model.jdbc.Product;
- import com.itstep.mvn.app.model.jdbc.Univer;
- public class JDBCTests {
- @Test
- @Ignore
- public void t1() {
- UniverDao dao = new UniverDaoImpl();
- assertNull(dao.getUniverById(-2));
- Univer u = dao.getUniverById(2);
- assertNotNull(u);
- System.out.println(u);
- }
- @Test
- @Ignore
- public void t2() {
- UniverDao dao = new UniverDaoImpl();
- Univer u = new Univer();
- u.setName("BGU");
- u.setLocation("Minsk");
- u.setRate(5);
- // assertTrue
- }
- @Test
- @Ignore
- public void t3() {
- UniverDao dao = new UniverDaoImpl();
- assertTrue(dao.removeUniverById(3));
- }
- @Test
- @Ignore
- public void t44() {
- ProductsDao prDao = new ProductsDAOImpl();
- // System.out.println(prDao.getProduct("S10_1678"));
- Product product = new Product();
- product.setBuyPrice(60);
- assertTrue(prDao.addProduct(product));
- }
- @Test
- @Ignore
- public void t4() {
- EmployeeDAO dao = new EmployeeDAOImpl();
- Employee empl = dao.getEmployee(1056);
- System.out.println(empl);
- assertNotNull(empl.getReportsTo());
- }
- @Test
- @Ignore
- public void t5() {
- EmployeeDAO dao = new EmployeeDAOImpl();
- Employee empl = dao.getEmployee(1088);
- System.out.println(empl);
- assertNotNull(empl.getReportsTo());
- }
- @Test
- @Ignore
- public void t6() {
- OfficeDAO dao = new OfficeDAOImpl();
- Office office = dao.getOffice("7");
- System.out.println(office);
- assertNotNull(office);
- //assertNotNull(office.getEmployees());
- //assertTrue(office.getEmployees().size() > 0);
- }
- @Test
- public void officeTest() {
- Office o = new Office("10", "Minsk", "+375333142890", "K. Marksa 32", "", "MINSK", "BRL", "220052", "EMEA");
- OfficeDAO dao = new OfficeDAOImpl();
- assertTrue(dao.createOffice(o));
- Office dbOffice = dao.getOffice("10");
- assertEquals(o, dbOffice);
- Office officeToUpdate = new Office("10", "Minsk", "+375777777777", "K. Marksa 32", "", "MINSK", "BRL", "220052", "NA");
- assertTrue(dao.updateOffice(officeToUpdate));
- assertNotEquals(o, dao.getOffice("10"));
- assertTrue(dao.removeOffice("10"));
- assertNull(dao.getOffice("10"));
- }
- @Test
- public void emplTest() {
- EmployeeDAO edao = new EmployeeDAOImpl();
- OfficeDAO odao = new OfficeDAOImpl();
- Employee eRep = edao.getEmployee(1056); // Patterson Mary
- Office office = odao.getOffice("5");
- Employee e = new Employee(2000, "Ivanov", "Ivan", "X", "gmail", office, eRep, "TESTER");
- assertTrue(edao.createEmployee(e));
- Employee dbEmpl = edao.getEmployee(2000);
- assertEquals(e, dbEmpl);
- Employee emplToUpdate = new Employee(2000, "NeIvanov", "NeIvan", "X", "gmail", office, eRep, "TESTER");
- assertTrue(edao.updateEmployee(emplToUpdate));
- assertNotEquals(e, edao.getEmployee(2000));
- assertTrue(edao.removeEmployee(2000));
- assertNull(edao.getEmployee(2000));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement